audio-rms icon indicating copy to clipboard operation
audio-rms copied to clipboard

Is there a away to avoid using the ScriptProcessor

Open zya opened this issue 9 years ago • 2 comments

I was wondering if it would be possible to achieve the same result using the AnalyserNode as opposed to ScriptProcessor and give the user a method that returns the rms value. This would give users more control in their applications, specially when it comes to performance issues in more complex applications.

zya avatar Jan 04 '16 12:01 zya

As far as I know, no. But pull requests accepted :)

I have not found the script processor in this case to be a performance issue, however this might be because I'm only using a single rms analyser in my app. If I was doing it on every channel, instead of just master, things might be more ... interesting.

mmckegg avatar Jan 05 '16 03:01 mmckegg

You can use the AnalyserNode which is far more efficient, but you sacrifice accuracy. Use AnalyserNode.getByteTimeDomainData() or getFloatTimeDomainData(). https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatTimeDomainData Take the resulting data and do what you're already doing in this module. The AnalyserNode time domain data is approximated from the actual sampled waveform. Probably good enough for RMS, but not for peak, unfortunately.

bradisbell avatar Feb 22 '16 17:02 bradisbell