This project has moved and is read-only. For the latest updates, please go here.

Create WAV from G.726 (IMA-?)ADPCM byte stream

Sep 26, 2012 at 9:43 PM

Hi,

I have a g.726-32 audio stream (from RTP) which I would like to save out as a WAV file. I am pretty new to working with Audio and could do with a few pointers (and I suppose being told if nAudio supports what I am trying to do).

Am i right in thinking the audio (speech from asterisk in g.726 format from an RTP stream) is IMA-ADPMC?

Can nAudio handle this format of data?

And lastly, can i use nAudio to write out a wav file that windows can play?

Any help is greatly apreciated, and thank you in advance!

Ben

Sep 27, 2012 at 1:00 PM

OK, just to show I am looking into this myself also :)

I've installed the Sharp g.726 Codec, however I am not seeing it listed in the ACM Codec list in the nAudio demo application. I see the Microsoft PCM/ADPCM/IMA-ADPCM codecs, but not the Sharp g.726. Any reason anyone could think this might be?

Cheers,

Ben

Sep 27, 2012 at 1:41 PM

you may need to run as a 32 bit process if you are on 64 bit windows, as most ACM codecs are 32 bit and won't show up to a 64 bit process

Sep 27, 2012 at 2:59 PM

Cheers Mark,

I can see the Sharp g.726 codec now. So here's the main question, can anyone give me some pointers on where to start on converting a g.726 stream to (this may sound like i have poor understanding) "a simple" wav file? Or even an MP3!

Which general pattern do i follow? I had a quick look at the MP3 to wave example, and understand it takes a stream (from the Mp3FileReader)  and writes out a stream in a given format using the WaveFileWriter.

How do I apply this to a realtime process, i.e. I get bytes([]) from an RTP stream and want to write them out to the disk in a format that's more universal.

Thansk again for any help!

Cheers,

Ben

Sep 27, 2012 at 3:05 PM

You need to access your codec with the WaveFormatConversion stream. You'll probably have to create your own class that derives from WaveFormat that matches the parameters expected by your codec (you can look at these using the NAudioDemo tool. You can use the WaveFileWriter to write the converted audio to a WAV file.