Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion DirectX mp3 decoding
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Apr 12 2005, 1:57 pm
Newsgroups: microsoft.public.win32.programmer.directx.audio
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 12 Apr 2005 19:57:32 +0200
Local: Tues, Apr 12 2005 1:57 pm
Subject: Re: DirectX mp3 decoding
[I forgot something.]

S Matos wrote:
> Thanks for the reply
> I would actually prefer to decode the file using an acm
> decoder... but still don't know how to do it. Can you
> refer me to information on how to use a codec for
> decoding (or give me the direct answer...)?
> I need to be able to select the bit of the file that I
> want and convert that to a WAV that I can then read.

- MP3 frame header info:

http://www.google.it/groups?selm=O3T9AVDdBHA.2416%40tkmsftngp05

- my sample MP3 parser (the full tables are listed in the
docs referenced above):

http://www.google.it/groups?selm=eJti8FKxDHA.2448%40TK2MSFTNGP12.phx.gbl

- my ACM instructions:

http://groups-beta.google.com/group/microsoft.public.win32.programmer...

- WAV format info:

http://www.wotsit.org/download.asp?f=wave

(Notice that a WAV is just a raw stream with a prefixed
header and that the format chunk in this header is just a
WAVEFORMATEX structure.)

Since you need to perform MP3->PCM, you need to reverse the
input and output WAVEFORMATEX structures.

For the input, populate an MPEGLAYER3WAVEFORMAT with info
from the first MP3 frame header.

MPEGLAYER3WAVEFORMAT.wfx.wForm­atTag
    = WAVE_FORMAT_MPEGLAYER3;
MPEGLAYER3WAVEFORMAT.wfx.nChan­nels
    = mode == 3 ? 1 : 2;
MPEGLAYER3WAVEFORMAT.wfx.nSamp­lesPerSec
    = ...;  /// from sampling_freq and version
MPEGLAYER3WAVEFORMAT.wfx.nAvgB­ytesPerSec
    = ...;  /// from bitrate_index, version and layer, then
divide by 8
MPEGLAYER3WAVEFORMAT.wfx.nBloc­kAlign
    = 1;
MPEGLAYER3WAVEFORMAT.wfx.wBits­PerSample
    = 0;
MPEGLAYER3WAVEFORMAT.wfx.cbSiz­e
    = MPEGLAYER3_WFX_EXTRA_BYTES;
MPEGLAYER3WAVEFORMAT.wID
    = MPEGLAYER3_ID_MPEG;
MPEGLAYER3WAVEFORMAT.fdwFlags
    = MPEGLAYER3_FLAG_PADDING_OFF;
MPEGLAYER3WAVEFORMAT.nBlockSiz­e
    = ...; /// the frame size
MPEGLAYER3WAVEFORMAT.nFramesPe­rBlock
    = 1;
MPEGLAYER3WAVEFORMAT.nCodecDel­ay
    = 1393;

For the output, populate a WAVEFORMATEX that uses the same
nChannels and nSamplesPerSec of the MPEGLAYER3WAVEFORMAT and
16 wBitsPerSample; you can calculate the rest.

WAVEFORMATEX.wForm­atTag
    = WAVE_FORMAT_PCM;
WAVEFORMATEX.nChan­nels
    = mp3.wfx.nChannels;
WAVEFORMATEX.nSamp­lesPerSec
    = mp3.wfx.nSamplesPerSec;
WAVEFORMATEX.nAvgB­ytesPerSec
    = nSamp­lesPerSec * nChannels * wBits­PerSample / 8;
WAVEFORMATEX.nBloc­kAlign
    =nAvgB­ytesPerSec / nSamp­lesPerSec;
WAVEFORMATEX.wBits­PerSample
    = 16;
WAVEFORMATEX.cbSiz­e
    = 0;

My ACM instructions use the FhG MP3 codec that ships in
Windows. If you use the LAME codec,
MPEGLAYER3WAVEFORMAT.nCodecDel­ay should be 0. If you use
the LAME codec and the MP3 streams use LAME's ABR mode, I
think you should sum 2 to MPEGLAYER3WAVEFORMAT.fdwFlags; I
don't know about VBR mode.

You need to cut the MP3 on frame boundaries, so you need to
read it using a parser (see my sample parser) and not as a
flat byte stream.

--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google