javascript - Firefox getByteTimeDomainData assumes maximum wave amplitude when processing oscillatorNode output -


below simple snippet demonstrate problem.

in google chrome, setting gainnode.gain.value extremely low value 0.01 cause getbytetimedomaindata data stay relatively close 128, expected.

in firefox, however, setting gainnode.gain.value higher 0 cause values vary between 0 , 255, though signal loud possible.

var ctx = (new audiocontext() || new webkitaudiocontext()); var oscillator = ctx.createoscillator(); var gainnode = ctx.creategain(); var analyser = ctx.createanalyser(); var processor = ctx.createscriptprocessor(2048,1,1); window.wavedata = new uint8array(analyser.frequencybincount);  oscillator.type = 'sine'; oscillator.frequency.value = 440; oscillator.start();  gainnode.gain.value = 0.01;  processor.onaudioprocess = function(){     analyser.getbytetimedomaindata(wavedata);     console.log(wavedata[0]); };  oscillator.connect(gainnode); gainnode.connect(analyser); analyser.connect(processor); processor.connect(ctx.destination); 

is there work-around in firefox 'emulate' chrome's implementation , expected data?

my first thought populate audio source oscillator output, i'm not sure how feasible is, , seems unreasonably ugly.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -