.net and beep(freq, duration)

ford2go

New member
Joined
Sep 8, 2006
Messages
1
Programming Experience
Beginner
If I understand things correctly, this is a .net question.

I am doing a simple VBexpress app, and I want to generate my own sounds.

Console.Beep(freq, Duration) does work, but I have a sound card, and it doesn't use that. It uses the 'system speaker' which is not used by anything else -- except my modem. System sounds, and even a QB4
DOS app works through the sound card -- just as you'd expect.

Any suggestions will be greatly appreciated.

Thanks,

ford2go
 
Windows programming is geared towards playing WAV, MIDI, etc. sounds. If that's what you want then you can use the My.Computer.Audio.Play method or the SoundPlayer class to play sound files or resources. Those will wrap the PlaySound API. Console.Beep wraps the Beep API, which allows you to specify a frequency and duration and plays a sound on the system speaker. If you want to create a sound dynamically and play it through your sound card then it's going to be considerably more complex. You're going to have to create a Byte array that represents your sound in WAV format and then play it in one of the aforementioned ways. You may also be able to use MCI but that means using the Windows API to call the mciSendString function and working out the format of the command to send.
 
Back
Top