Search code examples
c#naudio

Convert pcm data to wav file with NAudio


Is it possible to use the NAudio API to convert a raw pcm file to Wav format. I can see there is an Mp3FileReader that allows mp3 to wav but we need to convert raw audio data files.

Thanks


Solution

  • The naudio page on github has an example about this This Page

    var path = "example.pcm";
    var s = new RawSourceWaveStream(File.OpenRead(path), new WaveFormat(8000,1));
    var outpath = "example.wav";
    WaveFileWriter.CreateWaveFile(outpath, s);