0
votes

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 Rate - 750kbps
Audio Sample Size - 16 bit
Channels - 1 (mono)
Audio Sample Rate - 44kHz
Audio Format - PCM

Snippet:

System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(Captcha.Properties.Resources.sound1);
myPlayer.Play();

Is this because of the way I am playing the file or the file itself? Thank you.

4
Have you tried playing different files?timoxley
I just tried another WAV file and there's no distortion. Here are the properties: Bit Rate - 88kbps Audio Sample Size - 8 bit Channels - 1 (mono) Audio Sample Rate - 11kHz Audio Format - PCM I'm not so audio savy, so would somebody be able to tell me what exactly might be the cause of this?user
Something is off with the Wav Properties: 16 (sample size) * 44000 (sample rate) != 750000 (kbps) (704000)Shay Erlichmen
does the file play fine from media player?Matthew Whited
Yes, it just seems to be when I'm playing it back from within my application. It only happens occasionally but it's a very irritating sound that comes out.user

4 Answers

1
votes

Seems to be a audio problem. Try another WAV file.

0
votes

Do you get this noise on vista?

I've encounter this problem using the WaveOut WIN32 API. PlaySound uses the same library (Winmm) internally to play the sound.

This noise appears only on certain wave files, and on windows vista (and I think windows 7 too). It works fine on XP. I believe it's a bug in the new implementation of those APIs. If you use windows media player to play those WAV files they play fine (on vista) because I think it uses DirectSound APIs.

I've got no solution for this right now and I am thinking of changing my implementation to use DirectSound in the future.

0
votes

So the reason for this either seems to be a problem with the WAV file itself or a bug in .NET. Most likely it is a problem with the file and I'll either try working with the file to see if that helps or just use another file altogether. Thank you for your help everyone.

0
votes

I had similar problems in the past and I solved it by replacing the audio drivers of the offending machine.

Try reproducing the problem in identical conditions but in a different machine.