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

Using AcmMp3FrameDecompressor on a mp3 stream.

Dec 10, 2012 at 11:40 AM
Edited Dec 10, 2012 at 11:41 AM

Hi,

First of all I just want to say that I've been researching this for a couple of days without any luck. I've browsed and search through the discussion board without finding an answer.

I was wondering if someone could explain the function "AcmMp3FrameDecompressor.DecompressFrame" for me, what does it actually do?

I have a mp3 stream coming in and I do as follow:

 

using(var ms = new MemoryStream(streamBuffer)
{
      var frame = Mp3Frame.LoadFromStream(ms);
      var f = new WaveFormat();
      var format = new Mp3WaveFormat(frame.SampleRate,
                        frame.ChannelMode == ChannelMode.Mono ? 1 : 2,          frame.FrameLength, frame.BitRate);

      if (decompress == null)
          decompress = new AcmMp3FrameDecompressor(f);

      decompressed = decompress.DecompressFrame(frame, buffer, 0);
}

What does the "DecompressFrame" actually give me? I'm after a way to convert the incoming mp3 stream into for example A-law format. Is this the correct way? I understand that in order to actually get A-law I have to later convert it to A-law format using "WaveFormat.CreateALawFormat", but first I need to understand what I get from that function mentioned above.

Coordinator
Dec 10, 2012 at 2:15 PM

DecompressFrame turns MP3 into PCM. You cannot go directly from MP3 to A-law. You must go to PCM first. Also, a-law is almost always 8kHz mono, so you would need to resample as well. And really sure you want to convert it to A-law? Unless you are integrating with some antiquated telephony hardware, I can think of no reason to want to do this. Any music you use this on will sound horrible.

I have written a detailed article on CodeProject about how to convert between any audio formats which you can access here.

Dec 10, 2012 at 2:52 PM
markheath wrote:

DecompressFrame turns MP3 into PCM. You cannot go directly from MP3 to A-law. You must go to PCM first. Also, a-law is almost always 8kHz mono, so you would need to resample as well. And really sure you want to convert it to A-law? Unless you are integrating with some antiquated telephony hardware, I can think of no reason to want to do this. Any music you use this on will sound horrible.

I have written a detailed article on CodeProject about how to convert between any audio formats which you can access here.

Thank you got the explanation. There's no music, only speech, so PCM is used by default in the software. I was hoping it was PCM coming from the DecompressFrame function, so that makes life alot easier for me :).

Again, thank you for the response! I'll check out your article as well.