Help - Search - Members - Calendar
Full Version: Frame offset
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - General
jeffcech
Hello everyone,

I need to apply frame offset to a mp3 file.. Shifting the signal 1 to the left or right.

Can anyone tell me if there is any software that allows me to do it?
pdq
Sorry, but I don't understand what you are asking. Could you clarify?
jeffcech
QUOTE (pdq @ Sep 2 2009, 16:40) *
Sorry, but I don't understand what you are asking. Could you clarify?


Hello,

Oh erm what i meant was like, shifting the samples within the mp3 file.

I'm trying to do a analysis of mp3 files now.. So im converting a wav file into a mp3 file. After which i would like to shift the samples within the mp3 file by an offset of 1 or -1. By default, offset is 0.

Sorry if im still unclear..
lvqcl
Decode mp3 file back to WAV and perform any analysis you want.
pdq
You can only offset by a small number of samples if you decode. The least you can offset by without decoding is one frame, and even that can be tricky.

Within the mp3 itself the data do not exist as samples, only as frequencies over a period of time.

jeffcech
QUOTE (lvqcl @ Sep 2 2009, 16:58) *
Decode mp3 file back to WAV and perform any analysis you want.



Hello Ivqcl!

Hmm so there is no way i can do the sample shift under mp3 format? I will need to decode it back to WAV format first?
pdq
Maybe it will help if you tell us what it is that you really want to do.
jeffcech
QUOTE (pdq @ Sep 2 2009, 17:04) *
You can only offset by a small number of samples if you decode. The least you can offset by without decoding is one frame, and even that can be tricky.

Within the mp3 itself the data do not exist as samples, only as frequencies over a period of time.


Hi pdq,

Actually i just need to do a offset by a +1 and -1..

And i do not know how to do it even when i decode it back to WAV.. So i was thinking if there are softwares or does anyone know how i can perform the sample offset..

Thanks!
jeffcech
QUOTE (pdq @ Sep 2 2009, 17:06) *
Maybe it will help if you tell us what it is that you really want to do.


I'm actually performing an analysis between wav and mp3. In wav format, without any encoding, there will be very few zero spectral coefficients when we plot dB vs frequency. After the wav file went through a mp3 encoding, by right there will be more zero spectral coefficients, ie more troughs in the graph of dB vs frequency.

However, when a offset of +1 or -1 is applied, the troughs disappear.

So actually i wish to perform this and plot it out myself.. However as i am new to this, im having a lot of problems now..
DVDdoug
Sorry, but I'm still not clear...

QUOTE
However, when a offset of +1 or -1 is applied, the troughs disappear.
How do you know that? What does the file sound like? Noise? Of course, you can't improve quality by shifting bytes or frames... If so, the MP3 developers (who are smarter than most of us) would have that built in already. wink.gif

QUOTE
So actually i wish to perform this and plot it out myself.. However as i am new to this, im having a lot of problems now..
Do you know any programming? This looks like programming to me... You can shift samples in an audio editor... You can open an MP3 (decode it) shift the samples and re-save it (re-encode it). But, that wont affect the spectrum, and I don't think that's what you're trying to do.

I think I understand what you're doing with WAV files... If you've got a 16-bit stereo file, each sample is 4 bytes. For a +1 sample shift, you "right shift" all of the audio data by 4 bytes, and presumably fill the first 4 bytes (of audio data) with zero? Is that what you're doing?

That will work fine with WAV files, and you have simply added one sample of silence at the beginning and time-shifted the audio. (Of course, you should either adjust the header for the new length or throw away the last sample.)

If you try that with MP3 files, I don't know what will happen... My guess is that you will simply corrupt the 1st frame. As pdq said, the "raw samples" don't exist in the MP3 file. The samples don't exist until the file is decoded... Think about this: There are more samples than there are bytes in the file.


You could shift by a whole frame, and thereby create a time-shift (bigger than one sample), but this will not affect the spectrum.

Mike Giacomelli
QUOTE (jeffcech @ Sep 2 2009, 12:11) *
QUOTE (pdq @ Sep 2 2009, 17:06) *
Maybe it will help if you tell us what it is that you really want to do.


I'm actually performing an analysis between wav and mp3. In wav format, without any encoding, there will be very few zero spectral coefficients when we plot dB vs frequency. After the wav file went through a mp3 encoding, by right there will be more zero spectral coefficients, ie more troughs in the graph of dB vs frequency.

However, when a offset of +1 or -1 is applied, the troughs disappear.


Why do you think this exactly? I think you are greatly mistaken about a few different things.

QUOTE (jeffcech @ Sep 2 2009, 12:11) *
So actually i wish to perform this and plot it out myself.. However as i am new to this, im having a lot of problems now..


You can't do analysis on an MP3 file. Can't be done. Decode it to wav first, and then perform the analysis in your program of choice (which incidentally you should have mentioned by now if you really expect help).
jeffcech
Hi all,

Thanks for your replies.. But im doing this based on a research paper that proves the more zero spectral coefficients phenomenon.. Probably i have read thing wrongly in between..

And i am using matlab for the analysis.=)
kdo
QUOTE (jeffcech @ Sep 4 2009, 09:42) *
But im doing this based on a research paper that proves the more zero spectral coefficients phenomenon..


Is there any chance that the paper is about how to reconstruct mp3 coefficients from the decoded wav?
In that case, yes, there is a "zero spectral coefficients phenomenon", and it appears not only for the "+1" or "-1" sample shifts, but for any shift not aligned with the mp3 framing.
But still you always have to work with the wav/PCM stream, never with mp3 data directly.

In matlab, one could use the function wavread to load the wav file, and then once could manipulate with the data array to cut or add a few samples before sending the array as input to a filter function.
jeffcech
QUOTE (kdo @ Sep 4 2009, 18:07) *
QUOTE (jeffcech @ Sep 4 2009, 09:42) *
But im doing this based on a research paper that proves the more zero spectral coefficients phenomenon..


Is there any chance that the paper is about how to reconstruct mp3 coefficients from the decoded wav?
In that case, yes, there is a "zero spectral coefficients phenomenon", and it appears not only for the "+1" or "-1" sample shifts, but for any shift not aligned with the mp3 framing.
But still you always have to work with the wav/PCM stream, never with mp3 data directly.

In matlab, one could use the function wavread to load the wav file, and then once could manipulate with the data array to cut or add a few samples before sending the array as input to a filter function.


Hi kdo,

Thanks for your reply. Part of the implementation of that paper is to first reconstruct the spectral coefficients so you got it right. I guess i have been too unclear in my description previousy.

I have been using wavread then doing a 20*log10(abs(fft(x)) as it was mentioned it will be shown in the dB vs freq plot. However can you elaborate more on the the cutting and adding of samples before input to a filter function? I did not do the filtering part..
kdo
QUOTE (jeffcech @ Sep 5 2009, 06:47) *
I have been using wavread then doing a 20*log10(abs(fft(x)) as it was mentioned it will be shown in the dB vs freq plot. However can you elaborate more on the the cutting and adding of samples before input to a filter function? I did not do the filtering part..


By "cutting/adding samples" I meant simply that when you have the WAV PCM data loaded into an array in matlab, then you can use very basic matlab operations, like deleting a few elements from the array or concatenating a few additional elements. It goes something like this:
a = [ 2; 5; 6; 3] %make array
b = a(2:4) % now b is [5 6 3]
c = [0; a] % now c is [0 2 5 6 3]

As for the filtering, using simply fft(x) is not good enough. To see the "zero coefficients" effect, one need to use a filter which is either identical or very close to the actual mp3 filterbank. Simple Fourier transform (fft) won't do the trick.
Perhaps you could find more information about mp3 filterbank on mp3-tech.org, or perhaps someone else here will guide you.
jeffcech
QUOTE (kdo @ Sep 5 2009, 15:40) *
QUOTE (jeffcech @ Sep 5 2009, 06:47) *
I have been using wavread then doing a 20*log10(abs(fft(x)) as it was mentioned it will be shown in the dB vs freq plot. However can you elaborate more on the the cutting and adding of samples before input to a filter function? I did not do the filtering part..


By "cutting/adding samples" I meant simply that when you have the WAV PCM data loaded into an array in matlab, then you can use very basic matlab operations, like deleting a few elements from the array or concatenating a few additional elements. It goes something like this:
a = [ 2; 5; 6; 3] %make array
b = a(2:4) % now b is [5 6 3]
c = [0; a] % now c is [0 2 5 6 3]

As for the filtering, using simply fft(x) is not good enough. To see the "zero coefficients" effect, one need to use a filter which is either identical or very close to the actual mp3 filterbank. Simple Fourier transform (fft) won't do the trick.
Perhaps you could find more information about mp3 filterbank on mp3-tech.org, or perhaps someone else here will guide you.


Thanks for the advice kdo. So i guess i need to pass the decoded wav file into a filterbank before i do a fft on it. However as i read the more about the mp3 encoding process, is there a need to pass it into a mdct after i pass it into a filterbank?
kdo
QUOTE (jeffcech @ Sep 6 2009, 06:59) *
So i guess i need to pass the decoded wav file into a filterbank before i do a fft on it. However as i read the more about the mp3 encoding process, is there a need to pass it into a mdct after i pass it into a filterbank?


But why fft ? Does the paper suggest using fft ? That would be quite strange. The only thing fft can show is the typical mp3 lowpass, and then any sample offset won't make any difference at all.

To see the effect of the sample offset, you need to use mp3 filterbank (including mdct) instead of fft.

By the way, just looked at the mp3 wiki page on this very site. The schematics of the mp3 filterbank is layed out there quite nicely. So, yes the "mp3 filterbank" does include mdct (instead of fft). First polyphase subband filter, then mdct.

The key is that the input wav samples must be processed frame by frame and mdct is applied over overlapping windows, just like an mp3 encoder would do it. That's the point of the "sample offset effect": when you send your decoded wav samples through the mp3 filterbank aligned exactly with the previously encoded frames you get more "zero troughs" as compared to when you shift the samples by an offset.
jeffcech
Hello kdo,

Nope the paper didn't mention the use of fft. But i because all the plots are in dB vs freq or db vs coefficient number form, so i did a 20*log10 fft to the waveform..

I have looked at the wiki page for mp3 already. Going to try and build it up now...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.