home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
dos
/
prg
/
dsik205
/
dsik.dat
/
EXAMPLES
/
EXAMP08.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-10
|
3KB
|
99 lines
/****************************************************************************
*
* Digital Sound Interface Kit (DSIK)
* Version 2.00
*
* by Carlos Hasan
*
* Filename: example8.c
* Version: Revision 1.0
*
* Language: WATCOM C
* Environment: IBM PC (DOS/4GW)
*
* Description: Play a module file using dynamic link audio drivers
* loaded from disk (EXPERIMENTAL).
*
* IMPORTANT: To build all the dynamic link audio drivers required
* type at the DOS prompt: MKDRV SB PAS WSS GUS.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "audio.h"
#include "import.h"
#include "pe.h"
#define MODPATH "SONG.DSM"
#define MODFORM FORM_DSM
int main(void)
{
SoundCard SC;
Driver *Drv;
DSM *M;
/* The sound system supports static and dynamic link audio drivers.
If you want to use static-link drivers you must register the
drivers using dRegisterDrivers. For example,
dRegisterDrivers();
dLoadSetup(&SC,"SETUP.CFG");
dInit(&SC);
If you want to use dynamic-link audio drivers you must use the
dLoadDriver and dRegisterDriver to load and register the driver
you will use. Also, you should NOT referece the static-link
audio driver variables (ie. SBDriver, GUSDriver, etc). If you
reference any of these driver variables, the static-link drivers
will be automatically linked to your code.
Here is an example about how to use dynamic-link drivers:
dLoadSetup(&SC,"SETUP.CFG");
dRegisterDriver(dLoadDriver(&SC));
dInit(&SC);
The dynamic-link audio drivers can be created running MKDRV.BAT
at the DOS prompt. For example,
C:>MKDRV SB PAS WSS GUS
The above line will build SB.DRV, PAS.DRV, WSS.DRV and GUS.DRV
dynamic-link audio driver files. The file format used for the
audio drivers is the Portable Executable (PE) file format.
However, the current implementation of the PE DLL loader does
not support all the features availables for this format, so do
not try to load PE files others than the DSIK audio drivers.
*/
if (dLoadSetup(&SC,"SETUP.CFG")) {
printf("Please run SETUP.EXE to configure.\n");
exit(EXIT_FAILURE);
}
if (!(Drv = dLoadDriver(&SC))) {
printf("Error loading %s audio driver.\n", SC.DriverName);
exit(EXIT_FAILURE);
}
dRegisterDriver(Drv);
if (dInit(&SC)) {
printf("Error initializing the sound system.\n");
exit(EXIT_FAILURE);
}
atexit((void(*)(void))dDone);
if (!(M = dImportModule(MODPATH,MODFORM))) {
printf("Error (%03d) loading %s module file: %s.\n",
dError, MODPATH, dErrorMsg[dError]);
exit(EXIT_FAILURE);
}
dSetupVoices(M->Header.NumTracks,M->Header.MasterVolume);
dPlayMusic(M);
printf("Playing module. Press any key to continue.\n");
while (!kbhit()) dPoll();
dStopMusic();
dFreeModule(M);
return 0;
}