audio-rms
audio-rms copied to clipboard
Is there a away to avoid using the ScriptProcessor
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.
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.
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.