Question

Does anyone know how to convert GSM audio into PCM WAV via C#? I have tried to find a viable solution on the Internet to no avail.

Was it helpful?

Solution

Here is a link to a C library that encodes and decodes GSM files:

http://user.cs.tu-berlin.de/~jutta/gsm/gsm-1.0.13.tar.gz

and a link to more information on the subject:

http://user.cs.tu-berlin.de/~jutta/toast.html

It should be possible to either compile the C code as a DLL and call it from a C# application using PInvoke, or else incorporate the methods directly into your C# app.

Once you have the GSM data decoded into sample data, writing it out to a WAV file is very simple.

OTHER TIPS

Another alternative is SoX (Command line/library)

This is for java, but it should be adaptable to C#:

http://www.jsresources.org/faq_audio.html

See code below from http://alvas.net/alvas.audio,articles.aspx#mp3-to-wav-without-desktop-experience

void AnyToWav(string fileName)
{
    DsReader dr1 = new DsReader(fileName);
    if (dr1.HasAudio)
    {
        WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), 
           AudioCompressionManager.FormatBytes(dr1.ReadFormat()));
        ww.WriteData(dr1.ReadData());
        ww.Close();
        Console.WriteLine("Done!");
    }
    else
    {
        Console.WriteLine("Has no audio");
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top