soundplayer

C# - .WAV Playback Randomly High Pitch

For some reason, when a WAV file is played back using the snippet below, it randomly plays back screwy, like a high pitch noise. It doesn't happen all the time, just randomly. It seems to happen more often when it is played back more frequently. The WAV properties are below along with the code snippet I am using. WAV Properties: Bit...

Playing embedded wav files using SoundPlayer

I have a Compact Framework 3.5 application that is responsible for scanning barcodes. There are 3 different sounds it should play depending on the situation, so I created a wrapper class around the SoundPlayer object and call the Play method on that. public static class SoundEffectsPlayer { private static readonly SoundEffect _alert...

SoundPlayer and Windows 7 wav file

When I try to play the sound file "Windows Critical Stop.wav" I get the following exception: exec {"Sound API only supports playing PCM wave files."} System.Exception {System.InvalidOperationException} I understand what PCM is, I just do not know how to either: 1) play the sound file, 2) determine apiori that it is not PCM and will no...

get length of wav file ? (playing wav with soundplayer class)

I'm playing wav sound files using the .NET SoundPlayer class in my program, is it somehow possible to get the length of the wav file (in milli sec) ? thanks for answers ...

Stopping a SoundPlayer loop at the local level

I'm working on setting up an alarm that pops up as a dialog with multiple sound file options the user can choose from. The problem I'm having is creating a sound player at the local level that I can close with a button. The problem I'm having is that the sound keeps looping when I close the form because the SoundPlayer doesn't exist wi...

How to play a pure PCM raw stream with C#?

I was looking into System.Media.SoundPlayer and NAudio, and AFAIK they only play WAVE streams. The WAVE file is composed of the pure PCM data plus a format header. I don't want to provide this header in the WAVE format. I want to pass the parameters (bitrate, etc) programatically ...

System.Media.SoundPlayer.Play() freezes GUI

Hi! I am trying to implement a simple game in .NET with C#. There is a ball bouncing against objects, and when it bounces I play a sound asynchronously using System.Media:SoundPlayer. The problem is that most of the time (not always) the ball freezes at the time of impact, for as long as the sound plays. This happens on Windows XP, b...