PortAudio bindings and wrappers for Rust.

Overview

rust-portaudio

Crates.io docs.rs

License Build Status

PortAudio bindings and wrappers for Rust.

PortAudio is a free, cross-platform, open-source, audio I/O library.

rust-portaudio is still under development, so there may be bugs - please feel free to add an issue or even better, submit a PR!

To use rust-portaudio in your own project, add it to your Cargo.toml dependencies like so:

[dependencies]
portaudio = "X.Y.Z"

Installation

rust-portaudio will try to detect portaudio on your system and, failing that (or if given the PORTAUDIO_ONLY_STATIC environment variable on the build process), will download and build portaudio statically. If this fails please let us know! In the mean-time, you can manually download and install PortAudio yourself.

On Mac OS X, you may need to install manually portaudio and pkg-config (using brew, run brew install portaudio and brew install pkg-config)

rust-portaudio is built using cargo, so just type cargo build at the root of the rust-portaudio repository.

You can build the tests and examples with cargo test, and the documentation with cargo doc.

Comments
  • Implement / bind non-blocking API (portaudio callback)

    Implement / bind non-blocking API (portaudio callback)

    Portaudio provide a non-blocking API using callback function which is called each time some new data are coming. For now this functionality is not implemented in rust-portaudio as a user can do the same thing using a rust task and calling the blocking api inside of it. Maybe we can bind this functionality too as the native implementation is probably more effective.

    opened by jeremyletang 16
  • Callback function never called - arm

    Callback function never called - arm

    I'm working on getting rust-portaudio to work on my bananapi. On the bananapi I want to ignore the builtin audio devices and use a USB soundblaster instead. I'm able to specify that device using a device index, but I get a lot of error messages concerning the builtin audio device. The results is I don't hear any audio. I'm not sure what the cause might be, though the error messages look suspicious. PortAudio doesn't seem to be too happy.

    FWIW, I am able to play audio through the soundblaster using other sound sources on that computer. aplay works, as does supercollider running through jack1.

    Output from my test program is below. (portaudio startup is at line 89 in my test program).

    initting with sample rate: 44100
    add_elem(ui_elem_type_t type, char *label) 0x00
    add_elem(ui_elem_type_t type, char *label) Volume
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.front.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround40.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround40
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround41
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround50
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround51
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround71.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround71
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM iec958
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    --------------------------------------- DeviceIndex(1)
    DeviceInfo {
        struct_version: 2,
        name: "Sound Blaster X-Fi Go! Pro: USB Audio (hw:1,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.008684807256235827,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        44100hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        44100hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        44100hz
    

    And here's output from the 'devices.rs' example:

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.front.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround40.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround40
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround41
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround50
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround51
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround71.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround71
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM iec958
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    Number of devices = 7
    --------------------------------------- DeviceIndex(0)
    DeviceInfo {
        struct_version: 2,
        name: "sunxi-CODEC: PCM (hw:0,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(1)
    DeviceInfo {
        struct_version: 2,
        name: "Sound Blaster X-Fi Go! Pro: USB Audio (hw:1,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.008684807256235827,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        44100hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        44100hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        44100hz
    --------------------------------------- DeviceIndex(2)
    DeviceInfo {
        struct_version: 2,
        name: "sysdefault",
        host_api: 0,
        max_input_channels: 128,
        max_output_channels: 128,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 128 channel input:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 128 channel input, 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(3)
    DeviceInfo {
        struct_version: 2,
        name: "default",
        host_api: 0,
        max_input_channels: 128,
        max_output_channels: 128,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 128 channel input:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 128 channel input, 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(4)
    DeviceInfo {
        struct_version: 2,
        name: "dmix",
        host_api: 0,
        max_input_channels: 0,
        max_output_channels: 2,
        default_low_input_latency: -1,
        default_low_output_latency: 0.021333333333333333,
        default_high_input_latency: -1,
        default_high_output_latency: 0.021333333333333333,
        default_sample_rate: 48000
    }
    Supported standard sample rates for half-duplex 16-bit 0 channel input:
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        48000hz
    Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:
    --------------------------------------- DeviceIndex(5)
    DeviceInfo {
        struct_version: 2,
        name: "/dev/dsp",
        host_api: 1,
        max_input_channels: 16,
        max_output_channels: 16,
        default_low_input_latency: 0.008707482993197279,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 16 channel input:
    Supported standard sample rates for half-duplex 16-bit 16 channel output:
    Supported standard sample rates for full-duplex 16-bit 16 channel input, 16 channel output:
    --------------------------------------- DeviceIndex(6)
    DeviceInfo {
        struct_version: 2,
        name: "/dev/dsp1",
        host_api: 1,
        max_input_channels: 16,
        max_output_channels: 16,
        default_low_input_latency: 0.008707482993197279,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 16 channel input:
    Supported standard sample rates for half-duplex 16-bit 16 channel output:
    Supported standard sample rates for full-duplex 16-bit 16 channel input, 16 channel output:
    
    bug 
    opened by bburdette 15
  • Occasional Runtime SIGSEGV, Segmentation fault when using a non-blocking Stream

    Occasional Runtime SIGSEGV, Segmentation fault when using a non-blocking Stream

    This issue hasn't shown itself in any of the tests in the rust-portaudio, sound_stream, dsp-chain or synth crates, however it has appeared when trying to instantiate a non-blocking stream while following it immediately with a gl window event loop (using piston_window to be precise).

    The problem disappears if the event polling is removed (i.e. for event in window {}).

    @bvssvni mentioned the possibility of alignment issues - it could be worth looking into this.

    Here is the backtrace provided by gdb when the segfault is hit:

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x170b of process 12317]
    0x0000000100035cef in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$for$LT$$u27$r$C$$u27$r$C$$u27$r$GT$$u20$core..ops..FnMut$LP$$RF$$u27$r$u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$r$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20
    $$RF$$u27$r$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult$C$$u20$$LP$$RF$$u27$static$u20$
    $u5b$f32$u5d$$C$$u20$$RF$$u27$static$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20$$RF$$u27$static$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$RP$
    $u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult::object_shim.7671::h696b92cd3d5f10da ()                                                                                                                                
    
    (gdb) backtrace                                                                                                                                                                                                                  
    
    #0  0x0000000100035cef in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$for$LT$$u27$r$C$$u27$r$C$$u27$r$GT$$u20$core..ops..FnMut$LP$$RF$$u27$r$u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$r$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$
    $u20$$RF$$u27$r$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult$C$$u20$$LP$$RF$$u27$static$
    u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$static$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20$$RF$$u27$static$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$
    $RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult::object_shim.7671::h696b92cd3d5f10da ()                                                                                                                            
    #1  0x0000000100035a22 in fnfn (input=0x0, output=0x102c608d0, frame_count=64, time_info=0x10b7936d0, flags=0) at /Users/Mitch/Programming/Rust/rust-portaudio/src/pa/mod.rs:360                                                 
    #2  0x000000010020d292 in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$core..ops..FnMut$LP$$BP$const$u20$libc..types..common..c95..c_void$C$$u20$$BP$mut$u20$libc..types..common..c95..c_void$C$$u20$u64$C$$u20$$BP$const
    $u20$pa..types..StreamCallbackTimeInfo$C$$u20$u64$RP$$u20$.$GT$$u20$pa..types..StreamCallbackResult$C$$u20$$LP$$BP$const$u20$libc..types..common..c95..c_void$C$$u20$$BP$mut$u20$libc..types..common..c95..c_void$C$$u20$u64$C$$u
    20$$BP$const$u20$pa..types..StreamCallbackTimeInfo$C$$u20$u64$RP$$RP$$u20$.$GT$$u20$pa..types..StreamCallbackResult::object_shim.7462::h90ce1a85a735cc1d ()                                                                      
    #3  0x000000010020d248 in portaudio::pa::stream_callback_proc (input=0x0, output=0x102c608d0, frame_count=64, time_info=0x10b7936d0, flags=0, user_callback=0x101830120)                                                         
        at /Users/Mitch/Programming/Rust/rust-portaudio/src/pa/mod.rs:765                                                                                                                                                            
    #4  0x000000010020d1b2 in pa::stream_callback_proc::hadfcdc53593a76e60hd ()                                                                                                                                                      
    #5  0x0000000100660f6b in ?? ()                                                                                                                                                                                                  
    #6  0x000000010b7936cc in ?? ()                                                                                                                                                                                                  
    #7  0x0000000000000000 in ?? ()                                                                                                                                                                                                  
    Warning: the current language does not match this frame.                                                                                                                                                                         
    
    opened by mitchmindtree 10
  • Issues with running Linux ALSA stream

    Issues with running Linux ALSA stream

    @niclashoyer has been running into issues with rust-portaudio on Linux. The blocking stream immediately underruns and breaks from the loop, while the non-blocking stream shows some warning messages however seems to run fine. Perhaps we are missing some platform specific ALSA implementation? @jeremyletang any ideas? Do you test on linux?

    blocking.rs output

    PortAudio version : 1899
    PortAudio version text : PortAudio V19-devel (built Aug 18 2014 05:50:44)
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    Successfully initialized PortAudio
    PortAudio host count : 2
    PortAudio default host : 0
    PortAudio host name : ALSA
    PortAudio type id : -9979
    Default input device info :
        version : 2
        name : default
        max input channels : 32
        max output channels : 32
        default sample rate : 44100
    Default output device name : default
    Successfully opened the stream.
    Successfully started the stream.
    Read stream available with 96 frames.
    Write stream available with 768 frames.
    Read stream available with 120 frames.
    ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
    Write stream available with 768 frames.
    An error occurred while writing to the output stream: The output stream has overflowed
    Successfully closed the stream.
    
    Successfully terminated PortAudio.
    

    non_blocking.rs output

    PortAudio version : 1899
    PortAudio version text : PortAudio V19-devel (built Aug 18 2014 05:50:44)
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    Successfully initialized PortAudio
    PortAudio host count : 2
    PortAudio default host : 0
    PortAudio host name : ALSA
    PortAudio type id : -9979
    Default input device info :
        version : 2
        name : default
        max input channels : 32
        max output channels : 32
        default sample rate : 44100
    Default output device name : default
    Successfully opened the stream.
    Successfully started the stream.
    

    Original issue was raised here.

    opened by mitchmindtree 9
  • Rust-portaudio crashes (doesn't panic) with

    Rust-portaudio crashes (doesn't panic) with "signal 11"

    I started a project that uses rust-portaudio. The example provided in this repo seems to work, but when I try to generate and play a generated sound wave by myself, I run all kinds of strange phenomena.

    My code is in https://github.com/golddranks/ongen

    First of all, trying to pass it just a buffer of zeros, it emits loud buzzing noise. (With buffer of 0.00s, it should be just silent, right?) I thought this was maybe problem in latency and the output stream was starving, and thus producing clicks whenever the buffer was consumed and a new buffer was provided. I set the latency looser, default_high_output_latency, with no audible difference.

    Then I tried to set the frames_per_buffer value higher. Originally I had it in 256 like in the example. Changing the buffer size to 512 produced audible difference, but still just noise, all together. When I set it to 1024, Portaudio started crashing, not panicking in Rust-style but like this: Process didn't exit successfully:target/ongen(signal: 11)

    Do you have any idea how to fix these issues? It is surely the C library side that crashes with "signal 11"? Is buffer of 1024 outrageous in size? Any idea how to fix the buzzing?

    Running on OS X, rustc 1.0.0-nightly (3b3bb0e68 2015-03-04) (built 2015-03-04),

    PortAudio host name : Core Audio
    Default output device name : Built-in Output
    
    opened by golddranks 8
  • Both blocking and non-blocking examples use 100% CPU

    Both blocking and non-blocking examples use 100% CPU

    When I run the two streaming programs from the examples directory, they take 100% of the CPU. When I limit it to just reading the input, the same happens, and it seems the main loop just gets 0 bytes and keeps looping like mad until finally a full buffer arrives. Is that a problem in rust-portaudio or in the lower portaudio library?

    opened by theovosse 6
  • Change Stream to hold a generic reference to PortAudio

    Change Stream to hold a generic reference to PortAudio

    Currently Stream requires a &'a PortAudio. This prevents placing both into the same structure. Perhaps this relationship could be changed such that Stream requires a T where T: Deref<PortAudio> such that you could use an Rc<PortAudio> instead, allowing greater flexibility when structuring code.

    opened by JustAPerson 6
  • Relicense under dual MIT/Apache-2.0

    Relicense under dual MIT/Apache-2.0

    Why?

    The MIT license requires reproducing countless copies of the same copyright header with different names in the copyright field, for every MIT library in use. The Apache license does not have this drawback, and has protections from patent trolls and an explicit contribution licensing clause. However, the Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and doing so would be wise for this project. This also makes this crate suitable for inclusion in the Rust standard distribution and other project using dual MIT/Apache.

    How?

    To do this, get explicit approval from each contributor of copyrightable work (as not all contributions qualify for copyright) and then add the following to your README:

    ## License
    
    Licensed under either of
     * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
     * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
    at your option.
    
    ### Contribution
    
    Unless you explicitly state otherwise, any contribution intentionally submitted
    for inclusion in the work by you shall be dual licensed as above, without any
    additional terms or conditions.
    

    and in your license headers, use the following boilerplate (based on that used in Rust):

    // Copyright (c) 2015 t developers
    // Licensed under the Apache License, Version 2.0
    // <LICENSE-APACHE or
    // http://www.apache.org/licenses/LICENSE-2.0> or the MIT
    // license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
    // at your option. All files in the project carrying such
    // notice may not be copied, modified, or distributed except
    // according to those terms.
    

    And don't forget to update the license metadata in your Cargo.toml!

    Contributor checkoff

    • [x] @mitchmindtree
    • [ ] @jeremyletang
    • [x] @thenyeguy
    • [ ] @renato-zannon
    • [ ] @ebfe
    • [ ] @bvssvni
    • [ ] @kellydunn
    • [ ] @cyndis
    • [ ] @victor-shepardson
    • [ ] @hughrawlinson
    • [ ] @filmor
    • [ ] @niclashoyer
    • [x] @rryan
    • [ ] @tafia
    opened by emberian 5
  • Use Cargo's

    Use Cargo's "Build Script Support" and include PortAudio with the repo as a static lib.

    I'm unsure how tricky this would be, but it would be awesome if we could have Cargo automatically handle the downloading and installation of the PortAudio lib - would make it much easier for other Rusty users to pick our libs :)

    The info on Cargo's build script support is here.

    opened by mitchmindtree 5
  • I am looking for an audio crate I can import to get various information about an audio file?

    I am looking for an audio crate I can import to get various information about an audio file?

    I am looking for a high level audio crate library that allows me to easily get various information about an audio such as its loudness, tempo, current key/pitch etc? Can rust-portaudio do this?

    opened by Joe23232 4
  • Looking for Maintainers

    Looking for Maintainers

    Hi all!

    I no longer have the time or motivation to manage the rust-portaudio crate. These days, most of my efforts have been going into CPAL - a pure-Rust alternative. As a result, I find it difficult to prioritise issues and PRs here.

    If anyone would like to step in as the maintainer for the crate they would be more than welcome. I'd be happy to add them as an administrator to the RustAudio organisation if they are not already so.

    opened by mitchmindtree 4
  • Stream API is unsound

    Stream API is unsound

    The callback is passed a 'static reference to the audio buffer (here and here; also see Output and Duplex), which allows the reference to outlive the duration of the callback. The lifetime of the buffer should be appropriately constrained to the duration of the callback.

    opened by glowcoil 1
  • Switch to GitHub Actions or travis-ci.com

    Switch to GitHub Actions or travis-ci.com

    Per the banner at the top of https://travis-ci.org, travis-ci.org is shutting down in a few weeks. CI should be migrated to travis-ci.com or maybe GitHub Actions. For both of these choices, I believe one of the repo owners will need to enable it.

    opened by kevinji 0
  • mscv configuration

    mscv configuration

    Installation portaudio on windows-msvc. Users must put Git, devenv, and msbuild through the system path. As for msbuild and devenv, maybe there's a way to get rid of the path, but I didn't see it. The standard Windows commands are used to get ASIOSDK and extract the zip, so no new tools are needed.

    opened by ytanimura 1
  • Huge output gaps in duplex mode

    Huge output gaps in duplex mode

    When using duplex mode, I'm getting serious gaps in the audio output. This is in release mode, and even if I increase the frames per buffer to buffers sizes corresponding to multiple seconds, there are gaps between the buffers. The gaps are approximate 1 sec long. A minimal example to reproduce looks like this:

    use std::io;
    use portaudio as pa;
    
    const CHANNELS: i32 = 2;
    const SAMPLE_RATE: f64 = 44_100.0;
    const FRAMES_PER_BUFFER: u32 = 1024;
    
    fn main() {
        run().unwrap()
    }
    
    fn run() -> Result<(), pa::Error> {
        let pa = pa::PortAudio::new()?;
    
        let mut settings = pa.default_duplex_stream_settings(
            CHANNELS,
            CHANNELS,
            SAMPLE_RATE,
            FRAMES_PER_BUFFER,
        )?;
        settings.flags = pa::stream_flags::CLIP_OFF;
    
        let callback = move |pa::DuplexStreamCallbackArgs { in_buffer, out_buffer, frames, time, .. }: pa::DuplexStreamCallbackArgs<f32, f32>| {
            for i in 0 .. out_buffer.len() {
                out_buffer[i] = ((i * 2 % 1000) - 500) as f32 / 1000.0;
            }
            pa::Continue
        };
    
        // Start stream
        let mut stream = pa.open_non_blocking_stream(settings, callback)?;
        stream.start()?;
    
        // Wait for user input to quit
        println!("Press enter/return to quit...");
        let mut user_input = String::new();
        io::stdin().read_line(&mut user_input).ok();
    
        stream.stop()?;
        stream.close()?;
    
        Ok(())
    }
    

    I can run the same example in other languages just fine, which indicates it is a problem in the Rust binding themselves.

    The non-duplex variant using default_output_stream_settings also runs fine.

    opened by bluenote10 0
  • Callback does not time correctly

    Callback does not time correctly

    As found in RustAudio/synth -> https://github.com/RustAudio/synth/issues/50

    At this line of the example whenever a synth is started sounds never stop playing as the time and the counter do not flow:

    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    
    opened by Mec-iS 1
Owner
Free and useful Audio, DSP and music libraries written in Rust. Discourse https://rust-audio.discourse.group/ Discord https://discord.gg/b3hjnGw
null
High-level PortMidi bindings and wrappers for Rust

portmidi-rs High-level PortMidi bindings for Rust. PortMidi website: http://portmedia.sourceforge.net/portmidi/ Installation Add this to your Cargo.to

Philippe Delrieu 69 Dec 1, 2022
Thin but safe ALSA wrappers for Rust

ALSA bindings for Rust Thin but safe wrappers for ALSA, the most common API for accessing audio devices on Linux. The ALSA API is rather big, so every

null 91 Dec 26, 2022
A library for constructing Groth-Sahai proofs using pre-built wrappers

Groth-Sahai Wrappers A Rust library containing wrappers that facilitate the construction of non-interactive witness-indistinguishable and zero-knowled

Jacob White 1 Mar 7, 2022
Idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX).

alto alto provides idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX). WARNING Because Alto interacts with global C state via dynam

null 80 Aug 7, 2022
Rust bindings for the soloud audio engine library

soloud-rs A crossplatform Rust bindings for the soloud audio engine library. Supported formats: wav, mp3, ogg, flac. The library also comes with a spe

Mohammed Alyousef 38 Dec 8, 2022
minimp3 rust bindings + wrapper

minimp3 Rust bindings Usage example # Cargo.toml [dependencies] minimp3 = "0.5" use minimp3::{Decoder, Frame, Error}; use std::fs::File; fn main()

german gömez 52 Dec 2, 2022
Symphonia is a pure Rust audio decoding and media demuxing library supporting AAC, FLAC, MP3, MP4, OGG, Vorbis, and WAV.

Pure Rust multimedia format demuxing, tag reading, and audio decoding library

Philip Deljanov 1k Jan 2, 2023
A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.

OptiVorbis A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without alter

OptiVorbis 27 Jan 3, 2023
A CLI and library to convert data to sound, and vice versa (dependency-free)

Data to sound A simple crate to convert data to sound, and sound to data. The sound file format is wave (.wav). You can use it as a library or as a co

Awiteb 8 Feb 28, 2023
A Rust environment for sound synthesis and algorithmic composition.

Sorceress A Rust environment for sound synthesis and algorithmic composition, powered by SuperCollider. Overview Sorceress is a Rust crate that provid

Wesley Merkel 82 Dec 26, 2022
Implements the free and open audio codec Opus in Rust.

opus-native Overview Implements the free and open audio codec Opus in Rust. Status This crate is under heavy development. Most functionality is not wo

Nils Hasenbanck 9 Nov 28, 2022
Auritia is a DAW coded in Rust and Vue in hopes of having cross platform compatability, while also providing enough features for anyone to use professionally

Steps Install WebView if you're not on Windows 11 Install Node deps npm i To run the dev server do npm run tauri dev Compiling Linux You will need to

Auritia 20 Aug 27, 2022
Loopers is graphical live looper, written in Rust, designed for ease of use and rock-solid stability

Loopers Loopers is a graphical live looper, written in Rust, designed for ease of use and rock-solid stability. It can be used as a practice tool, com

Micah Wylde 81 Dec 29, 2022
Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio

iced baseplug examples Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio WIP (The GUI knobs do nothing curr

Billy Messenger 10 Sep 12, 2022
A wav encoding and decoding library in Rust

Hound A wav encoding and decoding library in Rust. Hound can read and write the WAVE audio format, an ubiquitous format for raw, uncompressed audio. T

Ruud van Asseldonk 345 Dec 27, 2022
Rust task runner and build tool.

cargo-make Rust task runner and build tool. Overview Installation Binary Release Usage Simple Example Tasks, Dependencies and Aliases Commands, Script

Sagie Gur-Ari 1.8k Jan 7, 2023
ears is a simple library to play Sounds and Musics in Rust

ears ears is a simple library to play Sounds and Musics in Rust. ears is build on the top of OpenAL and libsndfile. Provides an access to the OpenAL s

Jeremy Letang 56 Dec 1, 2022
DSP real time audio synthesis, effect algorithms and utilities for Rust

synfx-dsp synfx-dsp DSP real time audio synthesis, effect algorithms and utilities for Rust Most of the algorithms and implementations in this library

Weird Constructor 8 Nov 23, 2022
A low-overhead and adaptable audio playback library for Rust

Awedio   A low-overhead and adaptable audio playback library for Rust. Examples Play a single sound file: let (mut manager, backend) = awedio::start()

10 Buttons 20 May 25, 2023