am developing an android app that needs to take any audio track and calculate the BPM and duration of the song.
I am having trouble understanding the byte arrays of
public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate)
{
}
I've tested with the same ogg file where I panned all the audio to the left, right, and amplified the audio track using Audacity.
The magnitude of sound energy is tracked by the mag[], but im not sure if
mag[i] = bytes[2*i]*bytes[2*i] + bytes[2*i+1]*bytes[2*i+1]; is correct
Basically, how can we get from having a streaming byte[] to calculating a songs BPM?
Updates:
the sampling rate for onWaveFormDataCapture and onFftDataCapture come out to be 44100000, so does that mean for each index in the bytes[], we take 44100000 / 2 to find the highest frequency we can capture, which is 22050000. Then divide 22050000 into 1024 to get the frequency data as a number between -128 and 127?
I have a feeling I am suppose to convert the values in the byte[] into a short[], but Im unsure of how to get this data also into the time domain.
Suppose your FFT of N PCM samples returns N/2 complex values representing positive frequencies. Then the distance between 2 complex samples is F/2N Hz.
With F=44100Hz and N=1024 samples, this would be 21.5Hz.
This is my frequency resolution