Re: MP3 to PCM and playback with wave

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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



.



Relevant Pages

  • Re: java audio capability
    ... I haven't touched Java audio in years. ... I have not found any information on support in Java 6, although I presume it is about the same as in Java 1.5. ... Actually there is a Sun MP3 plugin that supports some MP3 formats. ...
    (comp.lang.java.help)
  • Re: Questions about ghosting and unghosting
    ... "Microsoft does not support modifying the default set of site ... "Microsoft does not support modifying a custom site definition or a ... area definition after you create a new site or a new portal area by ... The big performance hit from unghosting is that the page layout is ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Questions about ghosting and unghosting
    ... "Microsoft does not support modifying the default set of site ... "Microsoft does not support modifying a custom site definition or a ... area definition after you create a new site or a new portal area by ... The big performance hit from unghosting is that the page layout is ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: DIME WSE 2.0 in .NET 2.0
    ... \par Thanks - Rich F. ... it is pity that WSE 3.0 no longer support DIME. ... \par> DIME is removed is because WSE is an .NET based implementation of the WS-* ... If we need only to maintain the custom security dlls in .NET ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: LP record to CD transfer DSP questions
    ... I took another look at the piles of source audio material to ... does not support the on-board Solaris audio setup with its driver. ... Windows 2000 Pro installs with service packs available. ...
    (rec.audio.pro)