Get The Decibel Level From A Mic In Rust
This is what I'm using for ASCII_BEAR to move the mouth when I speak into the mic with enough volume:
Code
#!/usr/bin/env cargo +nightly -Zscript
//! ```cargo
//! [dependencies]
//! anyhow = "1.0.75"
//! clap = "4.4.7"
//! cpal = "0.15.2"
//! ```
use ;
Notes
This outputs the dB level to the terminal
The samples happen non-stop. I put a check in place so the values only output if they are greater than 0.006
I've seen negative numbers coming from the float values as well. I'm not sure what's happening with those (I've only got a single channel in my setup so I don't think it's a stereo thing)
There's a very slight delay on my setup from the time I speak until the output shows up. I got through a DAC which might have something to do with it, or that might just be how it works. I'm not super worried about it for now
References
-
My virtual avatar for streaming on Twitch. I set it up when I moved computers and didn't have a wire to connect the camera to the new machine and have just kina been running with it