diwic / alsa-rs

Thin but safe ALSA wrappers for Rust
Apache License 2.0
139 stars 66 forks source link

Please, Need example #62

Closed pvitaliy84 closed 3 years ago

pvitaliy84 commented 3 years ago

Please, I very need example "Capture and Playback" (Stereo Microphone) in infinity loop.

diwic commented 3 years ago

If you mean "capture what comes in through the microphone and play it back through the speaker", I'm afraid it isn't that easy. Chances are that capture and playback might have different master clocks, leading to clock drift eventually. Compensating for clock drift is beyond what simple ALSA bindings do, you probably want a higher level library to do this. Maybe gstreamer or pulseaudio can do this?

bburdette commented 3 years ago

For what its worth, a while back I made a program called fraust-echo. There's a branch for alsa-rs, rust-portaudio, portaudio-rs, and I think one other toolkit. Alas its 5 years old now.

Anyway, code is here and it basically copies samples from input, runs them through some DSP, and the samples go to output.

https://github.com/bburdette/fraust-echo/tree/alsa

pvitaliy84 commented 3 years ago

Thanks. Maybe gstreamer or pulseaudio