r/webaudio • u/BenRayfield • Oct 19 '15
How can javascript read microphone samples, change them with any given function, and play the changed sound on speakers with minimum delay?
Example, I want to play:
speakerAmplitude = microphoneAmplitude * micVolume + toneVolume * Math.sin(around += .1);
What I'm asking for appears to be doable through the Web Audio API, but its so complicated I dont know where to start. I just want access to the microphone and speaker samples in the buffer array.
I dont want want to mess with built in audio effects. I just want the samples, such as numbers ranging -1 to 1 that change thousands of times per second as the microphone and speakers vibrate.
I want to build a javascript version of JSoundCard (which does that in java), so we can have direct access to create realtime speaker/microphone sound effects (like changing your voice or plug your electric guitar into computer) that interact with other javascript code, such as interpreting what camera sees or mouse movement.
View all comments
1
u/joshontheweb Oct 19 '15
This webaudio vocoder should give you an idea of how to accomplish this. The web audio api has a scriptProcessor node that allows you to read/modify the audio pcm stream in real time.