DirectSound for QuickBasic 2.0 with CD Support
Programmed by AetherSoft

Welcome.  Many of you have used DS4QB 1.0.  I'd therefore like to start off by saying that DS4QB was one of the coolest programs available!  Since this version of DS4QB uses the same general technique as DS4QB, I would like to give a huge credit to Nekrophidius, who started this whole thing off.  At the same time, I did NOT use any of Nekro's code.  This program is completely original in coding, and indeed uses a method of QB-->VB data transfer that I thought up.  So this is an original program - it was not plagiarised.  I do, however, credit Nekrophidius greatly, as he was the one who had the original idea of doing this.

A brief introduction to DS4QB:
DS4QB is a VisualBasic slave that allows a DOS program to communicate with Windows sound  resources - specifically DirectSound.  It does this through the excellent bass.dll sound library, which should also be heavily credited here.  The result of this is that QBasic programmers, or anyone programming in a DOS language, now has a fast, easy, and efficient way to play MODs, MP3s, and WAVs, and to access the capabilities of 3D Audio and Sound Blaster Live Environmental Audio Extensions.  This special version of DS4QB is able to access CD Audio

DS4QB2 differs from DS4QB in that it no longer uses the clipboard for data transfer.  This means that you no longer need to insert clipboard code into your program (which makes it much easier on those people who have other functions using interrupts and QB inline ASM.  What this also means is that DS4QB now uses a single OUT command to play a sound effect, with no polling of the clipboard in between.  This results in almost instantaneous sound-effects playing, while DS4QB's sound effects were so slow that it wasn't practical to use them.  DS4QB2 transfers text (such as the filename of a MOD to play) via a file called DS4QB2.DAT.  While you may think that using a file is definitely slower than using the clipboard, it turns out that it really isn't much slower at all.  Besides this, the command to play music is not very time-critical, while sound effects commands are.  So while there may be a slightly longer delay between the time you call a function to play music and when the music actually starts playing, it is negligible, and the huge increase in sound-effects speeds more than makes up for it.

Finally, DS4QB2 version 2.0 supports all the functions that DS4QB supports.  DS4QB2 also supports volume control, which is something that DS4QB did not support.  DS4QB2 additionally supports SB Live Environmental Audio, which will definitely boost the overall sound quality of many games.

USING DS4QB2
Take a look at DSDEMO.BAS for how to use the functions in DS4QB2.  Most functions are used and called in almost the same way, so not much in the way of modification must be done.

HOW TO MAKE DS4QB2 BETTER
If you have any comments or suggestions, please email them to aethersoft@hotmail.com.  I'm accepting any realistic suggestions about what to add to DS4QB to make it better!

IMPORTANT NOTE --> DS4QB popped up a window when it ran.  In order to decrease EXE size, and allow the slave to load faster, I've removed this.  Now running DS4QB will apparently do nothing.  In fact, the program is running, but is just not visible.  You should therefore always use ShutDownDS4QB before quitting your program, or else DS4QB will remain loaded.  The only other way to unload it is to press CONTROL-ALT-DELETE, select the program, and click "End Task"


DS4QB2 is Copyright (C) 2000 by AetherSoft.  You may edit, modify, and change this program's code to fit your needs provided that credit is given to AetherSoft and to Nekrophidius, who had the original concept.  This program may be distributed freely provided that this text file and all other files are included in the package.


                               - DS4QB2 FUNCTIONS - 

InitDS4QB2 () - Starts the sound engine.  DS4QB2.EXE is assumed to be in the same directory as the program, so if it is not, you should edit the SHELL line in this sub.

LoadMusic (Musicname As String, Musictype As Integer, MusicChannel As Integer, Repeat As Integer, Enable3D As Integer) - Automatically stops other modules or streams playing in the same channel, and loads the new module or stream contained in Filename into memory.  Setting repeat to 1 will make the music loop, and setting Enable3D to 1 will allow the music to use 3D effects.  Music type should be 1 for a MOD or MO3, and 2 for an MP3 or WAV.  Musicchannel is from 1 to 5.  You may therefore have up to 5 musics playing at once.  To play CD audio, set MusicType to 3, set Channel to the CD track that you would like to play (Track 1 is often the equivalent of Track 0 (non-audio track) on some CDs, and so Track 2 is the first track that actually has audio).  Set repeat to 1 if you want the track to loop, and set Enable3D to 1 in order to wait drive to wait until the track has started playing before continuing.

LoadSample () - Loads samples into memory.  These samples MUST first be written to the file DS4QB2.dat in the same directory as DS4QB2.exe.  Samples should be written sequentially, one after another.  For example:

Test1.wav
Test2.wav

Eventually there will be functions that will load/overwrite specific sample slots, allowing you to load more samples as necessary, or remove ones that are no longer needed.  Maximum number of sound effects is 200

PlaySample (SampleNum As Integer) - plays a previously loaded sound effect.  Maximum is 200.

RemoveMusic (Channel As Integer) - Removes the currently loaded Module or Stream from the channel that was passed to the function.  Channels 1-5 are valid.

ResumeCD () - Resumes a CD that has been paused

SetEAX(EaxCode As Integer) - sets the current EAX (Environmental Audio) environment preset.  Following is a full list of presets:

0 - Off
1 - Generic
2 - Padded Cell
3 - Room
4 - Bathroom
5 - Living Room
6 - Stone Room
7 - Auditorium
8 - Concert Hall
9 - Cave
10 - Arena
11 - Hangar
12 - Carpeted Hallway
13 - Hallway
14 - Stone Corridor
15 - Alley
16 - Forest
17 - City
18 - Mountains
19 - Quarry
20 - Plain
21 - Parking Lot
22 - Sewer Pipe
23 - Underwater
24 - Drugged
25 - Dizzy
26 - Psychotic

SetVolume (MusicVolume As Integer, SampleVolume As Integer, StreamVolume As Integer, CDVolume AS INTEGER) - Sets the current volumes.  Volumes must be from 0 to 100, with -1 leaving the volume as it is.

ShutDownDS4QB - Unloads DS4QB2

StopCD - Stops/Pauses a CD that is currently playing