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

Conversion Problems

Sep 12, 2010 at 8:16 PM

Hi Mark,

I've been using NAudio for the past few days playing with converting some old audio files, to newer formats that are still supported on newer machines, ipods and ipads.  The file that I'm originally working with is in the below format:

Original Encoding: WAVE_FORMAT_MSG723
Original SampleRate: 8000
Original BitsPerSample: 0
Original Channels: 1
Original Block Align Channels: 24
Original Bits per Second: 8


I can succesfully convert it to a basic uncompressed wav file, and convert it to a new format, but the new format is approximately 10x larger in terms of disk space then the original file.
New Encoding: ALaw
New SampleRate: 8000
New BitsPerSample: 8
New Channels: 1
New Block Align Channels: 1
New Bits per Second: 8000

I've been playing with format settings, and I continue to receive errors even when trying to convert the uncompressed basic PCM file back to the original format described above.  The error that I'm receiving is: NAudio.MmException: AcmNotPossible calling acmStreamOpen.  Ultimately my objective is to get a wav file in a newer format with a similar bitspersecond rate of the original file.  The original file shows (in windows explorer) with a bitrate of 6kbps. The ALaw format used above, has a BitPerSecond rate of 64kbps. I thought just dividing the SampleRate by 10 would result in the smaller kbps that I wanted, however i receive the above error.

What am I doing wrong?  Sample test code below.

 private static void ConvertAudio(string inputFileName)
        {
            WaveFileReader wr = new WaveFileReader(inputFileName);
            WaveStream ns = WaveFormatConversionStream.CreatePcmStream(wr);
            //WaveFormat wf = WaveFormat.CreateALawFormat(800, 1); // This doesn't work
            //WaveFormat wf = WaveFormat.CreateALawFormat(8000, 1);  // This works
            WaveFormat wf = WaveFormat.CreateCustomFormat(WaveFormatEncoding.WAVE_FORMAT_MSG723,8000,1,8,24,0);
            WaveFormatConversionStream fs = new WaveFormatConversionStream(wf, ns);
            WaveFileWriter.CreateWaveFile(@"C:\Recompressed.wav", fs);
         }

Thanks for your assistance,

Mike

 

Coordinator
Sep 13, 2010 at 11:46 AM

ACM codecs can only typically convert to one of a set of allowed output formats. A-law simply isn't very efficient, so it will use more disk space than GSM. An 800Hz sample rate would be pretty useless in any case, as almost all the interesting frequencies (i.e. everything above 400Hz) would be filtered out.

Mark