WINPLAY.DLL
DLL to provide the PLAY function, found in QB to VB programmers.
by Jonathan Zuck
Published in the Windows Tech Journal, June '92.

	Those of your familiar with the PLAY statment, already know how to use it. However, it is missing from VB. WINPLAY.DLL provides this function in a DLL that can be called easily from VB.

Function Declaration:
Declare Sub Play Lib "WINPLAY.DLL" (ByVal Song$)

For those of you who are not familiar with the syntax of the PLAY statment, here is a table of the things you can use when constructing this string:

Table 2 PLAY Commands
Command	Action
A-Gnn	Play that note for that length
#,+	Sharp the immediately previous note.
-	Flat the immediately previous note.
.	Dot the immediately previous note. (3/2 length)
 >	Up one octave
 < 	Down one octave
Lnn	Set default length for notes that follow.Default is L4.
MB	Music in background
MF	Music in foreground (default)
ML	Music Legato (full length)
MN	Music Normal (7/8 length)
MS	Music Staccato (3/4 length)
Nnn	Play this numeric note (1-84)
On	Set Octave. (0 - 6).Default is O4, where C is an
	octave above middle C.  Pitches in an octave begin at
	C and work upwards to B.
Pnn	Pause for that duration
Tnnn	Set tempo (32-255). The number of quarter notes in
	one minute.  Default is T120.


Details:
	This function is not entirely self-contained as it is in QuickPak and VBTOOLS. The reason was to provide complete flexibility, in terms of the buffer used by Windows to hold the notes. When playing notes in the background, a bigger buffer allows more notes to be stored and the function returns to the calling program *much* faster.
	Therefore, you need to call a couple Windows API function to actually make this DLL work. Of course, you could make your own PLAY function in VB which encapsulated all of this.
	Here is a summary of the Windows API functions that you will need to use:

Table 1. Sound  Functions in the Windows API
OpenSound	Opens the sound driver for exclusive use
CloseSound	Closes the sound driver, making it available
SetVoiceQueue	Sets the size of the voice queue


Hopefully the PLAYDEMO.MAK sample will be sufficient to explain the use of each of these function. One caveat that you should keep in mind, however, is that once you have opened the sound queue with OpenSound it is not available to other programs until you issue a closesound. For this reason, it is a good idea to call CloseSound as soon as possible after you are done making a particular sound.

Source Code:
	The TPW source for WINPLAY.DLL can be found in Lib 9 of CLMFORUM. Both source and explanation can be found in the June '92 issue of the Windows Tech Journal.


        For more information or subscriptions to the Windows Tech Journal,
call (800) 234 - 0386 or outside of the US, (503) 747 - 0800. The fax number
is (503) 747 - 0071. Alternatively, you may reach the editor, J.D. Hildebrand
 (until he becomes too popular) here on CIS at id: 76701,32. The journal
 can be reached by mail at:

        Windows Tech Journal
        P.O. Box 70167
        Eugene, OR 97401-0110

Thanks a lot for your interest! -=- Jonathan
