0

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
user
  • 16,429
  • 28
  • 80
  • 97
  • Have you tried playing different files? – timoxley Oct 19 '09 at 05:41
  • 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 Oct 19 '09 at 05:59
  • Something is off with the Wav Properties: 16 (sample size) * 44000 (sample rate) != 750000 (kbps) (704000) – Shay Erlichmen Oct 19 '09 at 07:49
  • does the file play fine from media player? – Matthew Whited Oct 19 '09 at 18:56
  • 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 Oct 19 '09 at 19:28
  • The WAV file format does not include a "Bit Rate" property - you are probably looking at a different property (like "average bytes per second") that has been mislabeled. The WAV file format is extremely old, and includes calculated values in the header (like Block Align etc.) that are usually ignored by modern playback engines. – MusiGenesis May 02 '11 at 20:22

4 Answers4

1

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

0

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.

dtroy
  • 1,187
  • 3
  • 14
  • 21
0

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.

user
  • 16,429
  • 28
  • 80
  • 97
  • yeah. try to play it with external players to see if you still get the noise – dtroy Oct 19 '09 at 22:35
  • I just played it for about 8 minutes straight in Windows Media Player 11 and in Songbird and there were no problems. – user Oct 19 '09 at 23:04
  • You can check out this project: http://naudio.codeplex.com/ the sample let's you play the audio with different APIs. it might help you pin point the API you're having a problem with. A work around might be using DirectSound for example. – dtroy Oct 19 '09 at 23:11
0

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.

Padu Merloti
  • 3,219
  • 3
  • 33
  • 44