Rust Audio

Any example that record sound and play it to default device at the same time by using cpal?

I want an example code that shows how to record and play it at the same time.
I can found and but not able to figure out how to chain them.

I think this is not really supported by cpal at this time, see this issue. If you don’t worry about the synchronisation between recording and playback, you can try to record in one thread and play back in another thread and communicate between these threads. Communicating between two real-time threads is another unsolved problem since we’re still waiting for this PR to be merged. You can use normal channels from crossbeam and that will work most of the times, but may cause some delay/stuttering/??? sometimes.

If you’re targeting Linux, my best advice is to use the jack crate instead.