How To Convert MP3 to Wav 8Bit A-Law

Oct 17, 2011 at 5:02 AM

I have an exception on convert MP3 file to 8 bit A-Law
Here is my code to convert

            Mp3FileReader mp3reader = new Mp3FileReader(originalSound);
            WaveFormatConversionStream convertStream = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), mp3reader);
            WaveFileWriter.CreateWaveFile(@"TempWav.wav", pcmStream);

When I convert MP3
           SampleRate : 8000
           Channel       : 1
It's will complete.

But when I convert MP3
           SampleRate : 48000
           Channel       : 2

I will get an MmException -> AcmNotPossible calling acmStreamOpen
           at WaveFormatConversionStream convertStream = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), mp3reader);

Thanks for any help.

Coordinator
Oct 17, 2011 at 9:02 AM

You need to do the conversion in two (and maybe 3) stages (use WaveFormatConversionStream). First go to 8kHz PCM, then go to A-Law.