🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools
Article #186

Re: VB and sound

#186
From: Galen Raben
Date: Tue, 28 Jul 1992 15:28
65 lines
2514 bytes
In comp.os.ms-windows.programmer.tools, sp@cs.brown.edu (Seth Padowitz) writes:

>If you have Windows 3.1, then you can use the sndPlaySound() API
>from VB to play sounds through your soundblaster.
>Alternatively, you can use the Media Control Interface (MCI)
>Custom Control included in the VB Professional Toolkit to play
>sounds.
[... stuff deleted ...]
>You'll need to create a VB prototype for sndPlaySound().  My VB
>is a bit rusty, so I'll simply recommend that you look at your
>manual.

>Hope this helps.

>Seth

Hi Seth, good to see you again!  I've had some requests for the VB
prototypes as well, so I'll post them here for anyone to use!!!
Note - these are NOT official MS prototypes!  Use them, but at your
own risk... :-)

In the global declare....

Declare Function sndPlaySound Lib "MMsystem" (ByVal lpSound As String, ByVal Flags As Integer) As Integer

Global Const SND_SYNC = 0
Global Const SND_ASYNC = 1

In your program simply put...

Ret% = SndPlaySound("TADA.WAV", SND_ASYNC)


You can also access the MCI without the VB Pro Toolkit!!  Much more flexible
but more difficult to use.  You communicate with MCI via messages.  The
alias is arbitrary, the ones I used below are for readability...  A few 
examples should get you going...

The VB prototypes are...

Declare Function mciSendString Lib "MMsystem" (ByVal lpCoMMand As String, ByVal lpReturnString As String, ByVal WReturnLength As Integer, ByVal hCallback As Integer) As Long

Declare Function mciGetErrorString Lib "MMsystem" (ByVa dwError As Long, ByVal lpBuffer As String, ByVal WReturnLength As Integer) As Integer

In your program to play TADA.WAV...

Ret% = mciSendString("Open TADA.WAV alias TALK");
Ret% = mciSendString("Play TALK");
Ret% = mciSendString("Close TALK");

to play "CANYON.MID":

Ret% = mciSendString("Open CANYON.MID alias MUSIC");
Ret% = mciSendString("Play MUSIC");
Ret% = micSendString("Close MUSIC");

to pause it

Ret% = mciSendString("Pause MUSIC");

simply "Play MUSIC" to continue.

I think you get the idea...
Anyway, enjoy!!!!!
- Galen -
Technical Details
Message-ID: <36720005@hpgrla.gr.hp.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!mips!sdd.hp.com!hplabs!hplextra!hpfcso!hpgrla!galenr
References: <1992Jul21.223156.21625@cs.brown.edu>

Show Full Headers
Complete Article Headers
From: galenr@hpgrla.gr.hp.com (Galen Raben)
Date: Tue, 28 Jul 1992 15:28:08 GMT
Subject: Re: VB and sound
Message-ID: <36720005@hpgrla.gr.hp.com>
Organization: Hewlett-Packard, Greeley, CO
Path: arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!mips!sdd.hp.com!hplabs!hplextra!hpfcso!hpgrla!galenr
Newsgroups: comp.os.ms-windows.programmer.tools
References: <1992Jul21.223156.21625@cs.brown.edu>
Lines: 66