IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Help With Side Information, Finding it hard to find any technical details
jimmmeh
post May 1 2007, 20:55
Post #1





Group: Members
Posts: 3
Joined: 1-May 07
Member No.: 43101



Hey guys, I know I am going to sound like a bit of a newbie with these questions but I am struggling a bit with a piece of work that requires me to grab and possibly adjust the global gain value of each frame of an MP3 file and I would be very appreciative if someone could help me with a couple of points.

I am finding it hard to find any solid information on the side information header structure on the internet - I know that it is 32 bytes long for stereo data but I am confused by talk of granules and such like. What I really need to know is there a really quick way that I can find the global gain value for an MP3 track without worrying about any other fields. For example, if I can find the start of the main frame header, is there a quick and easy way from that position to grab the global gain value from there? I basically want to create a piece of C code that can as efficiently as possible loop through the frames and then process this value without worrying about any of the other technical details of the MP3 file.

Also, out of interest, what is the maximum and minimum value for this gain as well and would changing this value by one create an audible difference in an MP3 track? Part of the work I am doing might involve taking an MP3 file and generating a sample file by taking, say, the first 380 frames of a file and creating a fade in by adjusting the global gain slowly over the first 60-100 frames - would this work?

I know I have asked quite a few questions in this post but from a brief look over the forum there seems to be a lot of technical know-how floating around and I am hoping someone will be kind enough to help me out. I appreciate any help that can be offered.

Cheers guys,

Jim.
Go to the top of the page
+Quote Post
[JAZ]
post May 1 2007, 21:02
Post #2





Group: Members
Posts: 1711
Joined: 24-June 02
From: Catalunya(Spain)
Member No.: 2383



http://mp3gain.sourceforge.net/


(as the site implies, it is opensource)
Go to the top of the page
+Quote Post
jimmmeh
post May 1 2007, 23:09
Post #3





Group: Members
Posts: 3
Joined: 1-May 07
Member No.: 43101



Thanks for the link, I have looked at MP3 Gain but it seems overly complicated, the truth is, i'm used to programming on Win32 platforms with C# and Java and I am finding moving back to C quite a complex task. MP3 Gain takes a lot of functions from an open source full blown encoder/decoder and had a lot of overly complicated structures and such related to fully processing each part of the various headers that I don't need.

I'm really looking for just a very simple thing: if I can find the start of the header, I know I can find the start of the side information by checking either straight after the main frame header or after the 16bit CRC value if present but I am not fully understanding of the layout of the side information header, how uniform it is across different bitrates or stereo/joint stereo so I can universally and easily, through a couple of functions, grab that global gain value as quickly and efficiently as possible without having to parse the rest of the frame information into various C structures to get to it.

If anyone can help me understand this task or answer any of the questions from my first post then I would be very appreciative.

Cheers again,

Jim.

This post has been edited by jimmmeh: May 1 2007, 23:09
Go to the top of the page
+Quote Post
smack
post May 2 2007, 15:12
Post #4





Group: Members
Posts: 182
Joined: 16-January 02
Member No.: 1046



The global_gain value you're looking for is part of the "granule side info" structure inside of each MP3 frame.

The number of "granule side info" structures per frame depends on the MPEG-version (MPEG-1 or MPEG-2 LSF) and the number of channels (one or two) of your particular mp3 file. MPEG-1 Layer III frames consist of two granules (you may call them "sub-frames" if that helps you wink.gif ). MPEG-2 LSF Layer III frames consist of only one granule. Btw, a granule decodes to 576 audio samples. Each granule contains one or two channels, for mono or (joint-)stereo/dual-mono frames, respectively.

So, how many global_gain values are there per mp3 frame?
MPEG-1 mono: 2
MPEG-1 stereo: 4
MPEG-2 mono: 1
MPEG-2 stereo: 2

The most reliable sources of information about any mp3 details are the source codes of existing and working mp3 decoders. I would suggest that you look at MAD. Get the libmad sources and start reading in frame.c and layer3.c (III_sideinfo function). Good luck. wink.gif
Go to the top of the page
+Quote Post
jimmmeh
post May 2 2007, 15:25
Post #5





Group: Members
Posts: 3
Joined: 1-May 07
Member No.: 43101



Thanks for that detailed response, it's very much appreciated - one last thing - if I am only ever dealing with MP3s and no other format will I ever come across MPEG-2 LSF files?

Cheers,

Jim.
Go to the top of the page
+Quote Post
smack
post May 2 2007, 20:44
Post #6





Group: Members
Posts: 182
Joined: 16-January 02
Member No.: 1046



MPEG-2 LSF (Low Sampling Frequency extension) is used for low-bitrate applications, such as mp3 streaming for internet radios.

MPEG-1: bitrate 32-320 kbps, sampling frequency 32/44.1/48 kHz
MPEG-2: bitrate 8-160 kbps, sampling frequency 16/22.05/24 kHz

See also the Programmer's corner at MP3 tech for more infos.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 24th April 2014 - 03:28