So I think I understand getFloatFrequencyData
pretty well. If getFloatFrequencyData
returns an array of 1024 values, each value represents the volume of a frequency bin/range. In the case of 1024 values at a sample rate of 44.1, each value would represent the volume of a frequency range of about 20 hertz.
Now what about getFloatTimeDomainData
? Let's say I have 2048 values, what does each value represent?
Not the same as understanding getByteTimeDomainData and getByteFrequencyData in web audio. Or at least, this question's answer doesn't answer mine.
The Float32Array obtained using getFloatTimeDomainData
will contain an array of sample values, each value defining the amplitude at the sampled location, usually in the domain of [-1, 1]
. Sample locations are uniquely distributed, the obtained data is essentially the equivalent of raw PCM.
For a sine wave, it would yield gradually changing continuous values among the following approximation curve:
0 ... 0.7 ... 1.0 ... 0.7 ... 0 ... -0.7 ... -1.0 ... -0.7 ... 0 ...
Think of it as a series of subsequent values that together define the shape of the audio wave; if you were to visualize the obtained values on, say, a canvas, using the sample values as y
coordinates (amplitude) and a subsequently increasing value for x
coordinates (time), you would get an oscilloscope, such as:
Note how this sine waveform correlates with the example values above. Here are some example operations you can do on this data to get a better understanding:
If you were to multiply each value by 2, you would amplify the volume by 100% (double volume)
If you were to replace every value with 0, you would get silence
If you were to skip every second value, you would get a 100% pitched up audio (double playback speed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With