#io-stream #stream #io #dsp #music

sound_stream

Provides a simple interface to the default audio input and output device streams on a user's system

14 releases (4 breaking)

Uses old Rust 2015

0.6.0 Oct 31, 2015
0.5.0 Oct 17, 2015
0.4.4 Sep 18, 2015
0.4.3 Jun 11, 2015
0.2.0 Mar 3, 2015

#44 in #io-stream

45 downloads per month

MIT license

53KB
1K SLoC

SoundStream Build Status

A simple-as-possible, fast audio I/O stream wrapping PortAudio for Rust! It looks like this:

// The callback we'll use to pass to the Stream. It will write the input directly to the output.
let f = Box::new(move |input: &[f32], _: Settings,
                       output: &mut[f32], _: Settings,
                       dt: f64, _: CallbackFlags| {
    for (output_sample, input_sample) in o.iter_mut().zip(i.iter()) {
        *output_sample = *input_sample;
    }
    CallbackResult::Continue
});

// Run our callback on the default, duplex, non-blocking stream.
let stream = SoundStream::new()
    .duplex(StreamParams::new(), StreamParams::new())
    .run_callback(f)
    .unwrap();

Usage

Add sound_stream to your Cargo.toml dependencies like so:

[dependencies]
sound_stream = "*"

For more details, see the example.

PortAudio

SoundStream uses PortAudio as a cross-platform audio backend. The rust-portaudio dependency will first try to find an already installed version on your system before trying to download it and build PortAudio itself.

License

MIT - Same license as PortAudio.

Dependencies

~2.5MB
~29K SLoC