简体   繁体   English

可以通过setInterval或requestAnimationFrame影响ScriptProcessor的onaudioprocess事件速度

[英]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. 我正在使用Web Audio API的ScriptProcessor并且它是onaudioprocess事件,用于重复节拍器(例如节拍器)。

I tried using requestAnimationFrame and analyser node for audio visualisation in the same app. 我尝试在同一应用程序中使用requestAnimationFrameanalyser节点进行音频可视化。

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 . 尝试使用requestAnimationFramesetInterval绘制到canvas时,似乎onaudioprocess事件发生的速度降低了一半。

The question is, is it normal that other stuff can interrupt onaudioprocess speed? 问题是,其他东西可以中断onaudioprocess速度正常吗? or am i doing something hugely wrong? 还是我做错了什么?

Or it is being effected by canvas drawing stuff? 还是受canvas绘画效果影响? Because i tried using RAF and set Interval to log stuff to console and it did not effect anything. 因为我尝试使用RAF并将Interval设置为将内容记录到控制台,但它没有任何效果。

ScriptProcessor really shouldn't be used as an event source like that. 真的不应该将ScriptProcessor用作这样的事件源。 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/ . 如果你只是想建立一个节拍器,我想请您看看的HTML5Rocks文章中,我在今年年初写的- http://www.html5rocks.com/en/tutorials/audio/scheduling/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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