This project has moved. For the latest updates, please go here.

Problem with MP3 to A-Law conversion

Jan 26, 2011 at 2:12 PM

HI,

I'm trying to convert an mp3 file to A-Law format (8bit, 8khz, mono). I'm making this in three steps:

Fisrt convert mp3 to pcm format, next convert pcm to 8khz, 8bit mono pcm format, and now I'm trying to convert to a-law using this:

WaveStream law = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(tmp.WaveFormat.SampleRate, tmp.WaveFormat.Channels), tmp);

When program execute this line I get this exception: AcmNotPossible calling acmStreamOpen

Please help me.

My conversion stages code:

using (Mp3FileReader reader = new Mp3FileReader(SelectedFile.Text))
            {
                using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
                {
                    WaveFormat f = new WaveFormat(8000, 8, 1);
                    WaveStream tmp = new WaveFormatConversionStream(f, pcmStream);
                    WaveStream law = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(tmp.WaveFormat.SampleRate, tmp.WaveFormat.Channels), tmp);
                }
            }

Regrds,

Maciek

Coordinator
Jan 26, 2011 at 2:15 PM

the first conversion should be to 16 bit PCM.

Mark