chore: clicks

ptr.pet 2965f40c

verified
+1
.gitignore
···
+
/target
+140
Cargo.lock
···
+
# This file is automatically @generated by Cargo.
+
# It is not intended for manual editing.
+
version = 4
+
+
[[package]]
+
name = "audir-sles"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ea47348666a8edb7ad80cbee3940eb2bccf70df0e6ce09009abe1a836cb779f5"
+
+
[[package]]
+
name = "audrey"
+
version = "0.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "58b92a84e89497e3cd25d3672cd5d1c288abaac02c18ff21283f17d118b889b8"
+
dependencies = [
+
"dasp_frame",
+
"dasp_sample",
+
"hound",
+
"lewton",
+
]
+
+
[[package]]
+
name = "byteorder"
+
version = "1.5.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+
[[package]]
+
name = "clickee"
+
version = "0.1.0"
+
dependencies = [
+
"quad-snd",
+
]
+
+
[[package]]
+
name = "dasp_frame"
+
version = "0.11.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6"
+
dependencies = [
+
"dasp_sample",
+
]
+
+
[[package]]
+
name = "dasp_sample"
+
version = "0.11.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
+
+
[[package]]
+
name = "hound"
+
version = "3.5.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f"
+
+
[[package]]
+
name = "lewton"
+
version = "0.9.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8d542c1a317036c45c2aa1cf10cc9d403ca91eb2d333ef1a4917e5cb10628bd0"
+
dependencies = [
+
"byteorder",
+
"ogg",
+
"smallvec",
+
]
+
+
[[package]]
+
name = "libc"
+
version = "0.2.175"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
+
+
[[package]]
+
name = "maybe-uninit"
+
version = "2.0.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
+
+
[[package]]
+
name = "ogg"
+
version = "0.7.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "13e571c3517af9e1729d4c63571a27edd660ade0667973bfc74a67c660c2b651"
+
dependencies = [
+
"byteorder",
+
]
+
+
[[package]]
+
name = "quad-alsa-sys"
+
version = "0.3.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "c66c2f04a6946293477973d85adc251d502da51c57b08cd9c997f0cfd8dcd4b5"
+
dependencies = [
+
"libc",
+
]
+
+
[[package]]
+
name = "quad-snd"
+
version = "0.2.8"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cba0c4943fc67147fbe9d1eb731fb9e678bfc9d926507eebbbfe0103e154e5b0"
+
dependencies = [
+
"audir-sles",
+
"audrey",
+
"libc",
+
"quad-alsa-sys",
+
"winapi",
+
]
+
+
[[package]]
+
name = "smallvec"
+
version = "0.6.14"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0"
+
dependencies = [
+
"maybe-uninit",
+
]
+
+
[[package]]
+
name = "winapi"
+
version = "0.3.9"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+
dependencies = [
+
"winapi-i686-pc-windows-gnu",
+
"winapi-x86_64-pc-windows-gnu",
+
]
+
+
[[package]]
+
name = "winapi-i686-pc-windows-gnu"
+
version = "0.4.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+
[[package]]
+
name = "winapi-x86_64-pc-windows-gnu"
+
version = "0.4.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+7
Cargo.toml
···
+
[package]
+
name = "clickee"
+
version = "0.1.0"
+
edition = "2024"
+
+
[dependencies]
+
quad-snd = "0.2.8"
+3
README.md
···
+
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).
+
+
the click sound is taken from https://github.com/enjarai/clickrtraining.
+24
UNLICENSE
···
+
This is free and unencumbered software released into the public domain.
+
+
Anyone is free to copy, modify, publish, use, compile, sell, or
+
distribute this software, either in source code form or as a compiled
+
binary, for any purpose, commercial or non-commercial, and by any
+
means.
+
+
In jurisdictions that recognize copyright laws, the author or authors
+
of this software dedicate any and all copyright interest in the
+
software to the public domain. We make this dedication for the benefit
+
of the public at large and to the detriment of our heirs and
+
successors. We intend this dedication to be an overt act of
+
relinquishment in perpetuity of all present and future rights to this
+
software under copyright law.
+
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+
OTHER DEALINGS IN THE SOFTWARE.
+
+
For more information, please refer to <https://unlicense.org/>
+35
src/main.rs
···
+
use std::{
+
io::{BufRead, BufReader, Write},
+
net::TcpListener,
+
};
+
+
use quad_snd::*;
+
+
const CLICK: &[u8] = include_bytes!("./sound.ogg");
+
+
fn main() {
+
let ctx = AudioContext::new();
+
let click = Sound::load(&ctx, CLICK);
+
+
let port = std::env::var("PORT")
+
.ok()
+
.and_then(|p| p.parse::<u16>().ok())
+
.unwrap_or(8668);
+
let listener = TcpListener::bind(("0.0.0.0", port)).expect("cant bind");
+
+
for stream in listener.incoming() {
+
let Ok(mut stream) = stream else {
+
continue;
+
};
+
click.play(&ctx, PlaySoundParams::default());
+
// exhaust connection to not get "connection reset by peer"
+
BufReader::new(&stream)
+
.lines()
+
.flatten()
+
.take_while(|line| !line.is_empty())
+
.for_each(drop);
+
// this never "fails"
+
let response = "HTTP/1.1 200 OK\r\n\r\n";
+
let _ = stream.write_all(response.as_bytes());
+
}
+
}
src/sound.ogg

This is a binary file and will not be displayed.