1 unstable release

Uses old Rust 2015

0.1.1 Mar 6, 2017

#863 in Audio

Download history 170/week @ 2023-11-30 174/week @ 2023-12-07 233/week @ 2023-12-14 179/week @ 2023-12-21 137/week @ 2023-12-28 203/week @ 2024-01-04 162/week @ 2024-01-11 217/week @ 2024-01-18 140/week @ 2024-01-25 344/week @ 2024-02-01 175/week @ 2024-02-08 215/week @ 2024-02-15 191/week @ 2024-02-22 350/week @ 2024-02-29 270/week @ 2024-03-07 210/week @ 2024-03-14

1,054 downloads per month
Used in 10 crates (via portaudio-rs)

MIT license

11KB
209 lines

portaudio-rs

Build Status

Documentation

PortAudio bindings for Rust

See http://portaudio.com/

Example

extern crate portaudio_rs as portaudio;

fn demo() -> portaudio::PaResult
{
    let stream = portaudio::stream::Stream::open_default(
                          0, // input channels
                          1, // output channels
                          44100.0, // sample rate
                          portaudio::stream::FRAMES_PER_BUFFER_UNSPECIFIED,
                          None // no callback
                 )?;

    stream.start()?;

    let mut phase = 0.0f32;
    let mut buffer = Vec::with_capacity(44100);
    for _i in 0..44100
    {
        // Small amplitude such that the test does not produce sound
        buffer.push(phase * 0.001);

        phase += 0.03;
        if phase > 1.0 { phase -= 2.0; }
    }

    stream.write(&buffer)?;

    Ok(())
}

fn main()
{
    portaudio::initialize().unwrap();
    println!("{:?}", demo());
    portaudio::terminate().unwrap();
}

Dependencies

~46KB