NibbleRealm / twang

Library for pure Rust advanced audio synthesis.
https://nibblerealm.com/twang/
Apache License 2.0
125 stars 8 forks source link

Directly running a Signal #8

Closed bobbbay closed 2 years ago

bobbbay commented 2 years ago

Hi there. Great crate! I'm new to sound synthesis, and want to find a way to actually "play" my audio directly after creating it in Rust. I think crates like rodio will help, but I don't know how to link Twang with it. Furthermore, none of the examples play the created audio - they just save it.

Thanks!

AldaronLau commented 2 years ago

@Bobbbay Thanks for opening this issue, I should add a playback example to this repo. If you are ok with targeting only Linux or WebAssembly (wasm), you can try this example from the wavy crate: https://github.com/libcala/wavy/blob/main/examples/play.rs or the wasm-compatible project: https://github.com/libcala/wavy/tree/main/examples/play (they will work on MacOS and Windows eventually), otherwise you can use an API like fon::Audio::as_f32_slice to get the generated samples as f32s and pass them on to another crate for playback.

bobbbay commented 2 years ago

Strangely, I get a successful build but no audio when I use wavy, but I imagine that's a problem for that crate, not this one. Thank you for the help!