AudioEngineV2 : getByteFrequencyData what is the difference bewteen V1 and V2?

Hi (again)

I’m trying to upgrade my project from Babylon 6 to 9, so the major breaking change is AudioEngineV2.

I’m succeed to have something that works, but not has expected.“getByteFrequencyData()” doesn’t return same data between v1 and V2

V2 implementation from documentation : https://playground.babylonjs.com/#JY5TDF#1

Quick rewriting of this playground with V1 (need to set babylon version to 6.49 to work): https://playground.babylonjs.com/#JY5TDF#7

And, I don’t see any implementation of the GetByteTimeDomainData which is usefull for waveform/oscilo visualizer AnalyserNode: getByteTimeDomainData() method - Web APIs | MDN

So why there is difference between V1 and V2 ? And how to reproduce Waveform Visualizer with V2 ?

Thank you !

cc @RaananW

ok! Let’s first start with the missing parts :slight_smile:

This PR will add waveform data. You are right, it wasn’t implemented.

Now, to your initial question:

The difference is mostly analyzer configuration, not a different FFT algorithm. Both v1 and v2 ultimately use Web Audio’s AnalyserNode.getByteFrequencyData(), but the defaults changed:

V1:

minDecibels = -140
maxDecibels = 0
FFT_SIZE = 512
SMOOTHING = 0.75

V2:

fftSize = 2048
minDecibels = -100
maxDecibels = -30
smoothing = 0.8

Since getByteFrequencyData() maps decibel values into the 0..255 byte range using minDecibels / maxDecibels, different min/max values can produce very different-looking data.

If you want I can provide you with a code to use v2 with “legacy” preconfiguration

Oh I wasn’t aware of the min/max decibel things on the web audio API, I guess i just need to set min/maxDecibels values on the Analyzer. Thank you for the clarification, and thank you for the PR, it’s very helpful !