rodio_tap
rodio_tap taps rodio::Source audio while still passing the source through to playback.
Use it when you want to analyze, visualize, meter, or record playback data in real time.
https://github.com/user-attachments/assets/54d66615-4ef3-4876-af7b-6dc5886b64ff
What it provides
TapReader+TapAdapter: low-level packet ring-buffer access.FrameReader: synchronous high-level reader that yields frame batches.AsyncFrameReader(featureasync): async high-level reader for Tokio runtimes.Visualizer(featurevisualizer): callback-driven FFT bins + peak/rms per channel.
Installation
In your Cargo.toml:
[]
= "0.1.0"
Enable the visualizer module:
[]
= { = "0.1.0", = ["visualizer"] }
Enable async support if tokio support is needed:
[]
= { = "0.1.0", = ["async"] }
Quick start
use Arc;
use thread;
use Decoder;
use ;
Multiple tracks:
use Arc;
use queue;
use TapReader;
// One queue source for all tracks.
let = queue;
// One persistent tap around the queue output.
let = new;
let _ = ;
// Append each decoder to queue_in.append(decoder).
Async reader
With the async feature enabled:
use Arc;
use AsyncFrameReader;
async
Visualizer
Visualizer (feature visualizer) provides an abstract for building music visualizers.
use SineWave;
use ;
use Arc;
use thread;
use Duration;
use ;
Real-Time Use
rodio_tap is suitable for real-time monitoring and low-latency audio
pipeline paths when configured for low latency. In release mode, typical
overhead is very small (often around ~100 ns).
Suggested low-latency FrameReaderConfig starting point:
frames_per_batch: Some(64)(equivalent to 128 sample buffer size in stereo)time_per_batch: None(use fixed frame batches)sleep_bias: 0.5(wake earlier to avoid late batch delivery)min_sleep: Duration::from_micros(5)(tiny cooperative sleep)- Run in
--releasemode for realistic performance numbers
This profile is generally appropriate for real-time use cases such as ASIO, CoreAudio, WASAPI, and JACK style pipelines.
Examples
wav_visualizer_full
Terminal FFT visualizer with explicit pipeline wiring and rendering logic.
wav_visualizer_simple (feature: visualizer)
Higher-level visualizer API example with less boilerplate.
wav_recorder
Queues one or more WAV files, captures frames with FrameReader, and writes a
single output WAV file.
wav_low_latency
Low-latency timing monitor for callback interval and overhead measurement.