Search code examples
c#winformsaudiowavpcm

Is there a way to play a CCITT u-Law .wav file in C#?


Having failed to find a way to programmatically convert a CCITT u-Law wave file to a PCM file (which Soundplayer demands) in accord with this question: How to play non-PCM file or convert it to PCM on the fly ?

(SOX looks like it might work, but I can't find any examples for converting from CCITT u-Law .wav file to a "regular" (PCM) .wav file using it from C#),

I wonder if I'm going about it the wrong way: maybe I should find a way to play CCITT u-Law .wav files, rather than trying to convert such to a PCM .wav file.

Does anybody know how this is possible? SoundPlayer always says, "Sound API only supports playing PCM wave files" so maybe there's another API I can use?

Note: Alvas.Audio is also "not an option" due to it not being free or open source.


Solution

  • The way to do it is to use newkie's code at: http://www.codeproject.com/Articles/175030/PlaySound-A-Better-Way-to-Play-Wav-Files-in-C?msg=4366037#xx4366037xx

    In my case, at least, I had to change all of the lowercase x's to uppercase x's, though, to get it to work.