chore: clicks

ptr.pet 2965f40c

+1
.gitignore
··· 1 + /target
+140
Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "audir-sles" 7 + version = "0.1.0" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "ea47348666a8edb7ad80cbee3940eb2bccf70df0e6ce09009abe1a836cb779f5" 10 + 11 + [[package]] 12 + name = "audrey" 13 + version = "0.3.0" 14 + source = "registry+https://github.com/rust-lang/crates.io-index" 15 + checksum = "58b92a84e89497e3cd25d3672cd5d1c288abaac02c18ff21283f17d118b889b8" 16 + dependencies = [ 17 + "dasp_frame", 18 + "dasp_sample", 19 + "hound", 20 + "lewton", 21 + ] 22 + 23 + [[package]] 24 + name = "byteorder" 25 + version = "1.5.0" 26 + source = "registry+https://github.com/rust-lang/crates.io-index" 27 + checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 28 + 29 + [[package]] 30 + name = "clickee" 31 + version = "0.1.0" 32 + dependencies = [ 33 + "quad-snd", 34 + ] 35 + 36 + [[package]] 37 + name = "dasp_frame" 38 + version = "0.11.0" 39 + source = "registry+https://github.com/rust-lang/crates.io-index" 40 + checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6" 41 + dependencies = [ 42 + "dasp_sample", 43 + ] 44 + 45 + [[package]] 46 + name = "dasp_sample" 47 + version = "0.11.0" 48 + source = "registry+https://github.com/rust-lang/crates.io-index" 49 + checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" 50 + 51 + [[package]] 52 + name = "hound" 53 + version = "3.5.1" 54 + source = "registry+https://github.com/rust-lang/crates.io-index" 55 + checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" 56 + 57 + [[package]] 58 + name = "lewton" 59 + version = "0.9.4" 60 + source = "registry+https://github.com/rust-lang/crates.io-index" 61 + checksum = "8d542c1a317036c45c2aa1cf10cc9d403ca91eb2d333ef1a4917e5cb10628bd0" 62 + dependencies = [ 63 + "byteorder", 64 + "ogg", 65 + "smallvec", 66 + ] 67 + 68 + [[package]] 69 + name = "libc" 70 + version = "0.2.175" 71 + source = "registry+https://github.com/rust-lang/crates.io-index" 72 + checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" 73 + 74 + [[package]] 75 + name = "maybe-uninit" 76 + version = "2.0.0" 77 + source = "registry+https://github.com/rust-lang/crates.io-index" 78 + checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" 79 + 80 + [[package]] 81 + name = "ogg" 82 + version = "0.7.1" 83 + source = "registry+https://github.com/rust-lang/crates.io-index" 84 + checksum = "13e571c3517af9e1729d4c63571a27edd660ade0667973bfc74a67c660c2b651" 85 + dependencies = [ 86 + "byteorder", 87 + ] 88 + 89 + [[package]] 90 + name = "quad-alsa-sys" 91 + version = "0.3.2" 92 + source = "registry+https://github.com/rust-lang/crates.io-index" 93 + checksum = "c66c2f04a6946293477973d85adc251d502da51c57b08cd9c997f0cfd8dcd4b5" 94 + dependencies = [ 95 + "libc", 96 + ] 97 + 98 + [[package]] 99 + name = "quad-snd" 100 + version = "0.2.8" 101 + source = "registry+https://github.com/rust-lang/crates.io-index" 102 + checksum = "cba0c4943fc67147fbe9d1eb731fb9e678bfc9d926507eebbbfe0103e154e5b0" 103 + dependencies = [ 104 + "audir-sles", 105 + "audrey", 106 + "libc", 107 + "quad-alsa-sys", 108 + "winapi", 109 + ] 110 + 111 + [[package]] 112 + name = "smallvec" 113 + version = "0.6.14" 114 + source = "registry+https://github.com/rust-lang/crates.io-index" 115 + checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" 116 + dependencies = [ 117 + "maybe-uninit", 118 + ] 119 + 120 + [[package]] 121 + name = "winapi" 122 + version = "0.3.9" 123 + source = "registry+https://github.com/rust-lang/crates.io-index" 124 + checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 125 + dependencies = [ 126 + "winapi-i686-pc-windows-gnu", 127 + "winapi-x86_64-pc-windows-gnu", 128 + ] 129 + 130 + [[package]] 131 + name = "winapi-i686-pc-windows-gnu" 132 + version = "0.4.0" 133 + source = "registry+https://github.com/rust-lang/crates.io-index" 134 + checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 135 + 136 + [[package]] 137 + name = "winapi-x86_64-pc-windows-gnu" 138 + version = "0.4.0" 139 + source = "registry+https://github.com/rust-lang/crates.io-index" 140 + checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+7
Cargo.toml
··· 1 + [package] 2 + name = "clickee" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [dependencies] 7 + quad-snd = "0.2.8"
+3
README.md
··· 1 + tiny program that listens on a port for *any* tcp connection (but assuming its http so curl / webhooks etc. work fine) and plays a click sound using [`quad-snd`](https://github.com/not-fl3/quad-snd). 2 + 3 + the click sound is taken from https://github.com/enjarai/clickrtraining.
+24
UNLICENSE
··· 1 + This is free and unencumbered software released into the public domain. 2 + 3 + Anyone is free to copy, modify, publish, use, compile, sell, or 4 + distribute this software, either in source code form or as a compiled 5 + binary, for any purpose, commercial or non-commercial, and by any 6 + means. 7 + 8 + In jurisdictions that recognize copyright laws, the author or authors 9 + of this software dedicate any and all copyright interest in the 10 + software to the public domain. We make this dedication for the benefit 11 + of the public at large and to the detriment of our heirs and 12 + successors. We intend this dedication to be an overt act of 13 + relinquishment in perpetuity of all present and future rights to this 14 + software under copyright law. 15 + 16 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 + OTHER DEALINGS IN THE SOFTWARE. 23 + 24 + For more information, please refer to <https://unlicense.org/>
+35
src/main.rs
··· 1 + use std::{ 2 + io::{BufRead, BufReader, Write}, 3 + net::TcpListener, 4 + }; 5 + 6 + use quad_snd::*; 7 + 8 + const CLICK: &[u8] = include_bytes!("./sound.ogg"); 9 + 10 + fn main() { 11 + let ctx = AudioContext::new(); 12 + let click = Sound::load(&ctx, CLICK); 13 + 14 + let port = std::env::var("PORT") 15 + .ok() 16 + .and_then(|p| p.parse::<u16>().ok()) 17 + .unwrap_or(8668); 18 + let listener = TcpListener::bind(("0.0.0.0", port)).expect("cant bind"); 19 + 20 + for stream in listener.incoming() { 21 + let Ok(mut stream) = stream else { 22 + continue; 23 + }; 24 + click.play(&ctx, PlaySoundParams::default()); 25 + // exhaust connection to not get "connection reset by peer" 26 + BufReader::new(&stream) 27 + .lines() 28 + .flatten() 29 + .take_while(|line| !line.is_empty()) 30 + .for_each(drop); 31 + // this never "fails" 32 + let response = "HTTP/1.1 200 OK\r\n\r\n"; 33 + let _ = stream.write_all(response.as_bytes()); 34 + } 35 + }
src/sound.ogg

This is a binary file and will not be displayed.