I want to control the audio volume of an incoming webRTC audio stream. The code looks like this:
...
audioContext=new AudioContext;
gainFilter=audioContext.createGain(),
jsnode=audioContext.createScriptProcessor(512,1,1); // used for VU-Meter
source=audioContext.createMediaStreamSource(stream);
source.connect(gainFilter);
gainFilter.connect(jsnode);
jsnode.connect(audioContext.destination);
...
// when volume slider is moved
gainFilter.gain.value=volume;
...
The basic idea is working: I hear the audio, I can see in my VU meter that the signal's volume is affected by the fader that determines the gainFilters's setting. But the output I hear through the speakers never changes in volume.
I do not understand what is wrong: The audio data seen by the script processor is affected. When I move the fader to lowest volume, the vu meter correctly shows no peak. Still, I can hear the audio.