Open austintheriot opened 12 months ago
Also waiting for audio input :)
Waiting for audio input :/
This is a code I created for my own use as a trial. I have confirmed that it works with egui, and I can retrieve data using try_recv
for Vec<f32>
. I don't have time to implement it with cpal, but please use it as a reference. I haven't refined the details.
Hello! First off, thanks for your work on this library!
cpal
has been incredibly useful to me as a web/Rust dev.Currently, there are
// TODO
s in place of all input-related coded for the WebAudio host: https://github.com/RustAudio/cpal/blob/76b04065cf189c1e04a15816657d1108759c3665/src/host/webaudio/mod.rs#L449I'm wondering, what would it take to make input available on the web? Fundamentally, there appears to be an API mismatch in that cpal requires synchronous configuration, whereas the web requires async setup via
getUserMedia()
. Would it be possible to force a synchronous API here, where the input is basically just a plain buffer that you can write into via a media stream that is set up after the fact?I'm interested, because I'm working on a cross-platform audio node library, and I'd like to support web compilation as a high-priority compilation target:
Code: https://github.com/austintheriot/resonix Demo: https://austintheriot.github.io/resonix/
So far, I've been working with pre-recorded audio primarily, but I'd love to support microphone access directly.
Would it make more sense to create this type of API user-side rather than library-side? I suppose I could potentially write microphone data to a plain buffer and surface that as if it were an audio node, but I'm not sure if the web audio API gives raw audio data like that or not.