none
The error occured, when I tried to play WAV file, WinForms RRS feed

  • Question

  • Hello!

    I have the next error:

    I have listened to the lesson:

    http://msdn.microsoft.com/ru-ru/vcsharp/bb798024%28en-us%29.aspx

    I decide to try this lesson in IDE immediately. I have followed all the inctructions.
    When I tried to play WAV file from Resources by using System.Media.SoundPlayer class.
    I have got the next error:

    System.InvalidOperationException was unhandled
      Message="Sound API only supports playing PCM wave files."

    As, I understand  correctly, WAV sound may have different formats? If it shows me the error, that it can run only PCM WAV.
    It's difficult, how can I recognize the diffrent formats of WAV? How can I know, is PCM WAV or not?
    Is in Visual Studio the special instrument for WAV files, may there is a converter from other WAV formats to PCM WAV?

    Best Regards,
    Oleg
    Thursday, September 24, 2009 5:38 PM

Answers

  • WAV files can have multiple compression methods, including MP3.  PCM (Pulse Code Modulation) is the only one supported by the System.Media.SoundPlayer class. Fortunately, it's the most common WAV format, so most .WAV files just work.

    There are quite a few tools that can convert audio files.  For example, Switch Audio can convert between formats (even in the free version).  You'll need need to get your file into a standard, PCM encoded WAV file.

    Reed Copsey, Jr. - http://reedcopsey.com
    • Marked as answer by magesi Thursday, September 24, 2009 6:10 PM
    Thursday, September 24, 2009 5:44 PM
    Moderator

All replies

  • WAV files can have multiple compression methods, including MP3.  PCM (Pulse Code Modulation) is the only one supported by the System.Media.SoundPlayer class. Fortunately, it's the most common WAV format, so most .WAV files just work.

    There are quite a few tools that can convert audio files.  For example, Switch Audio can convert between formats (even in the free version).  You'll need need to get your file into a standard, PCM encoded WAV file.

    Reed Copsey, Jr. - http://reedcopsey.com
    • Marked as answer by magesi Thursday, September 24, 2009 6:10 PM
    Thursday, September 24, 2009 5:44 PM
    Moderator
  • Oh, Dear Reed, thanks a lot! I have download Switch Audio, and convert it to PCM.

    My WAV file was under MPEG-1 Layer 3 Codec ( MP-3 ), allthough the extension of the file was *.WAV !

    I have converted to PCM, and the program began to work.

    Thanks a lot!

    And Switch Audio is really a good program! I didn't know about it until you told about it.

    Thanks again!

    Oleg
    Thursday, September 24, 2009 6:10 PM