I'm trying to extract fft data from an mp3 without playing it. I'm using AS3 and CS5. I found a great real-time Spectrum Analyzer here, but it only works with the microphone. I also found a great mp3 looper here, which I'm using for sound extraction. I'm essentially trying to combine the source found in both of those links. I'm getting a RangeError while reading the byteArray data from the mp3 sample into the Vector used to make the fft. The mp3 data is in stereo so I divide by 8 (4 bytes for the left channel, 4 for the right). It reads through the loop just fine and traces the correct data but when it gets to the end I get the error, even if the loop is set to go through just one time. Any and all help would be much appreciated. Here is my code used to move the data into the Vector.
public function readMp3(): void {
for (var i:int = 0; i < byteArray.length/8; i++) {
byteArray.position = i;
/*
m_buf is fed into the updateSpectrum function in
the Sound Analyzer
*/
m_buf[i] = byteArray.readFloat();
trace (m_buf[i]);
}
}
Thanks!!
I'm trying to extract fft data from an mp3 without playing it. I'm using AS3 and CS5. I found a great real-time Spectrum Analyzer here, but it only works with the microphone. I also found a great mp3 looper here, which I'm using for sound extraction. I'm essentially trying to combine the source found in both of those links. I'm getting a RangeError while reading the byteArray data from the mp3 sample into the Vector used to make the fft. The mp3 data is in stereo so I divide by 8 (4 bytes for the left channel, 4 for the right). It reads through the loop just fine and traces the correct data but when it gets to the end I get the error, even if the loop is set to go through just one time. Any and all help would be much appreciated. Here is my code used to move the data into the Vector.
public function readMp3(): void {
for (var i:int = 0; i < byteArray.length/8; i++) {
byteArray.position = i;
/*
m_buf is fed into the updateSpectrum function in
the Sound Analyzer
*/
m_buf[i] = byteArray.readFloat();
trace (m_buf[i]);
}
}
Thanks!!
0 commentaires:
Enregistrer un commentaire