Hi
I am programming a toolset for analysing wav-files with FFT. The
programm works fine, except that the results are crap. I made some
testfiles (4khz and 440Hz) but in the end i see just crap (it does not
show me a peak 440Hz). I believe that my decoding and splitting is
wrong, so i'd like you to tell me whether it is right.
I want to do 2 FT-analyzes per channel (fftlyzer[analyze][channel]).
fftlyzer is a class I made for analyzing the sound. (It is doing the
FT-analyse when it's internal buffer is full, stores the result and
resets the buffer afterwards.)
Here is a snippet of my code.
long signed int audio_buf[ (AVCODEC_MAX_AUDIO_FRAME_SIZE*3) /2];
int len = 0 , data_size = 0 , i2;
while(av_read_frame(FormatCtx, &packet)>=0)
{
if(packet.stream_index==audioStream)
{
uint8_t *packetData = packet.data;
int packetSize = packet.size;
int numBytesUsed = 0;
while (packetSize > 0)
{
data_size= AVCODEC_MAX_AUDIO_FRAME_SIZE ;
numBytesUsed = avcodec_decode_audio2(CodecCtx,
(int16_t*)audio_buf, &data_size, packetData, packetSize);
if (numBytesUsed > 0) {
for( i2 = 0 ; i2 < data_size ; i2++ ) {
fftlyzer[0][ i2 % infostruct.channels ]->add(
audio_buf[i2] ) ;
fftlyzer[1][ i2 % infostruct.channels ]->add(
audio_buf[i2] ) ;
}
// Update data pointer and size for next frame
packetData += numBytesUsed;
packetSize -= numBytesUsed;
}
}
}
av_free_packet(&packet);
}
Thank you for your help :)
Ps: this is actually my third try sending this message .. silly me :)
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user