Re: MP3 to PCM and playback with wave
- From: "Alessandro Angeli" <nobody@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 12 May 2008 12:38:45 -0400
From: "dim.raft@xxxxxxxxx"
I need to change this program to support MP3 files.[...]
Preferably it should support any compressed audio for
which there is a codec installed on the system. So I need
The least effort option is preferable. I don't want to
have to re- write the whole program.
Chris told you how to adapt your program. However, as he
pointed out, supporting arbitrary file formats requires
custom code for each one. Even MP3 alone, which is nothing
more than a raw stream, requires custom support to strip non
audio frames like ID3 tags and to correctly read and seek
the files (especially VBR ones).
An alternative would be to use DirectShow, which will do the
file parsing, audio decoding and audio rendering for you in
an automated fashion, supporting whatever format for which
there is a parser and decoder installed in the system (by
default, compressed and uncompressed WAV, AVI, WMA, MP3,
MP1/MP2/MPA, AIFF and AU and live/capture/network sources).
However, that requires a full rewrite of your program.
This is how you play any kind of file in DirectShow:
http://msdn.microsoft.com/en-us/library/ms783787(VS.85).aspx
To perform your processing, you need to insert a filter in
between decoder and renderer. Depending on the kind of
processing, it can be a custom DMO, a custom full transform
filter, a custom trans-in-place filter or even the stock
SampleGrabber (used in sample callbak mode:
http://msdn.microsoft.com/en-us/library/ms787867(VS.85).aspx).
The whole code will be much simpler but there will be a big
difference in the processing part: instead of you
synchronously fetching the data in the amount you need, the
data will be asynchronously feed to you in arbitrary
amounts.
As a note, MP3s in DirectShow will require a little hack: if
you let DS decice, it will default to parsing the files
using the generic MPEG-1 parser, which does not handle ID3
tags very well, so it is better to manually insert the
WMASFReader instead, which also handles MP3s.
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
.
- References:
- MP3 to PCM and playback with wave
- From: dim . raft
- MP3 to PCM and playback with wave
- Prev by Date: Re: MP3 to PCM and playback with wave
- Next by Date: Re: MP3 to PCM and playback with wave
- Previous by thread: Re: MP3 to PCM and playback with wave
- Next by thread: Image\Video Compression for Video Streaming
- Index(es):
Relevant Pages
|