tags:

views:

59

answers:

3

I need to be able to raise different types of audio notifications to the user. I need an "ok" and an "error" type sounds, I was hoping to be able to raise a simple beep and a critical stop type sound but I can only find the Beep() command which doesn't allow for differing sounds. Is there a library that does what I need or will I need to roll my own using the system wavs.

+2  A: 

See Beep(int frequency, int duration);

Beep( 750, 300 );

dwFreq [in] The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration [in] The duration of the sound, in milliseconds.

This article is in C#, but see if it helps.

KMan
A: 

Since you're in VB.Net, you've got the My namespace to play with, and if you look under My.Computer.Audio you'll find the PlaySystemSound command. This allows you to play whatever sound the user has setup for:

  • the default Beep
  • asterisk
  • question mark
  • exclamation mark

There's Intellisense and an enumeration that allows you to select the one you want, then it's just one line of code: My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)

PhilPursglove
+1  A: 

You can use the managed SystemSounds class to play most of the default sounds. Use it like this:

' Plays the sound associated with the Exclamation system event.
SystemSounds.Exclamation.Play()

This API simply encapsualtes the Windows API function MessageBeep, that you could also use. Take a look here to see its pinvoke signature.

Frank Bollack