简体   繁体   中英

Can ScriptProcessor's onaudioprocess event speed be effected by setInterval or requestAnimationFrame

i am using Web Audio API's ScriptProcessor and it's onaudioprocess event for repetitive callbacks such as a metronome.

I tried using requestAnimationFrame and analyser node for audio visualisation in the same app.

It seems like the speed of which onaudioprocess event happens is being slowed down by half when trying to draw to a canvas using requestAnimationFrame or setInterval .

The question is, is it normal that other stuff can interrupt onaudioprocess speed? or am i doing something hugely wrong?

Or it is being effected by canvas drawing stuff? Because i tried using RAF and set Interval to log stuff to console and it did not effect anything.

ScriptProcessor really shouldn't be used as an event source like that. If you just want to build a metronome, I'd refer you to the HTML5Rocks article I wrote early this year - http://www.html5rocks.com/en/tutorials/audio/scheduling/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM