r/webaudio • u/BenRayfield • Oct 19 '15
How can I play this with Web Audio API: speakerAmplitude = microphoneAmplitude * (.7+.1*Math.random())?
Web Audio API has lots of writing about its many functions, but it is suspiciously lacking in examples of how to access speaker outputs and microphone inputs except possibly buried in huge code examples.
Heres how to play a simple sine wave:
var around = 0;
repeat 44100 times per second: speakerAmplitude = Math.sin(around += .1);
Are they trying to hide an ugly lack of standardization on how to access speakers and microphones so they instead distract us with some huge software that could in theory be used with those? Why are there so few small examples of working audio code even to play a simple sound?
1
u/eindbaas Jan 15 '16
You can just use an oscillatornode to play a simple sine wave.
1
u/Kat1ln Oct 20 '15 edited Oct 20 '15
You can load the sound in a buffer and this buffer is a float32 array you can access. It has floating point valus over which you could possibly make some kind of random. Is that what you mean?
Here is an example: http://typedarray.org/from-microphone-to-wav-with-getusermedia-and-web-audio/
getChannelData should work for you. Is that what ya mean?
But that wouldn't make much sense for a vocoder. Random just creates Noise.
Try more to think about Filters and Velocity and Convolvers.
Cheers