rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.88k stars 160 forks source link

Access Microphone Output #115

Closed saransha closed 4 years ago

saransha commented 4 years ago

Hey, is there any way to access the raw microphone output from a Wad. I would like to do so to possibly add an analyzer from the audio context.

I tried getting the decodedBuffer but i don't think it is the correct endpoint. Basically need access to "mediaStreamSource" but i don't think it is exposed? I could definitely be missing something.

Or, is there a way to get access to the stream after all the wad effects are applied to the microphone input?

Thank you for the help.

Tyutyesz commented 4 years ago

Same here. I can't stop the browser to listening to the microphone. Once I initialised a voice like here. Then calling the voice.stop() and the browser is still connected to the microphone. Can we access the microphone media stream?

Thank you for your reply!

rserota commented 4 years ago

@saransha You should be able to access the mediaStreamSource directly on the mic wad, after you give your browser permission to use your mic.

var voice = new Wad({source : 'mic' })
// give your browser permission to use the microphone
console.log(voice.mediaStreamSource)

If you want access to the audio after effects are applied, wrap the mic wad in a polywad, and then access the output on the polywad, which is just a regular WebAudio analyser node.

var voice = new Wad({source : 'mic' })
var tuner = new Wad.Poly()
tuner.add(voice)
console.log(tuner.output) // this is just a regular analyser node

@Tyutyesz Your problem sounds like a different issue, but I'll answer it here anyway, I guess. I'm not exactly sure what you mean by 'the browser is still connected to the microphone'. When you call voice.stop(), you should no longer hear your microphone input, although this won't revoke permission to use your microphone. Is it possible that you've accidentally created multiple microphone wads, but you only stopped one of them?

saransha commented 4 years ago

Alright, thank you for your quick reply. I will definitely try it out.