DSPRelated.com
Forums

spectral analysis between wav and mp3 decoded wav

Started by jeff...@hotmail.com September 4, 2009
Hello everyone,

Can anyone tell me where have i gone wrong with the following code? It was understood that when u encode a wav file to mp3 and decode it back, there will be more trough(zero spectral coeff) present when we plot dB vs frequency.

I converted a wav to mp3 and back to wav using audacity.

[x,fs,n] = wavread('test.wav');
Y = fft(x.*hamming(length(x)));
m = 0:ceil(length(Y)/2);
plot(m*fs/length(Y), 20*log10(abs(Y(m+1))));
ylabel('Magnitude (dB)');
xlabel('Frequency (Hz)');

But the waveform was the same as the original non encoded one. Can anyone tell me did i got something wrong along the way?
Jeff-

> Can anyone tell me where have i gone wrong with the following
> code? It was understood that when u encode a wav file to
> mp3 and decode it back, there will be more trough (zero
> spectral coeff) present when we plot dB vs frequency.
>
> I converted a wav to mp3 and back to wav using audacity.
>
> [x,fs,n] = wavread('test.wav');
> Y = fft(x.*hamming(length(x)));
> m = 0:ceil(length(Y)/2);
> plot(m*fs/length(Y), 20*log10(abs(Y(m+1))));
> ylabel('Magnitude (dB)');
> xlabel('Frequency (Hz)');
>
> But the waveform was the same as the original non encoded
> one. Can anyone tell me did i got something wrong along the
> way?

How long is the .wav file and what is its sampling rate? MP3 uses approx 1150 sample frame size. For example, if the
.wav file sampling rate is 44.1 kHz, then MP3 encode decisions are made every 26 msec or so. If your .wav file is,
say, 1 sec long, and you FFT the whole thing (as is the case in your code above), then you've looking at an "average"
of MP3 encoding effects over about 38 frames -- is that really what you want?

Here is a page with some explanation:

http://www.mp3-converter.com/mp3codec/frames.htm

-Jeff
Hello everyone,
>
>Can anyone tell me where have i gone wrong with the following code? It was understood that when u encode a wav file to mp3 and decode it back, there will be more trough(zero spectral coeff) present when we plot dB vs frequency.
>
>I converted a wav to mp3 and back to wav using audacity.
>
>[x,fs,n] = wavread('test.wav');
>Y = fft(x.*hamming(length(x)));
>m = 0:ceil(length(Y)/2);
>plot(m*fs/length(Y), 20*log10(abs(Y(m+1))));
>ylabel('Magnitude (dB)');
>xlabel('Frequency (Hz)');
>
>But the waveform was the same as the original non encoded one. Can anyone tell me did i got something wrong along the way?
Hi Jeff,

My wav file is 1.45mb.. What im trying to do is actually reconstructing the mp3 co-efficients from the decoded wav.. Thanks for your reply. =)