home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
dos
/
prg
/
dsik205
/
dsik.dat
/
EXAMPLES
/
EXAMP09.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-10
|
2KB
|
88 lines
/****************************************************************************
*
* Digital Sound Interface Kit (DSIK)
* Version 2.00
*
* by Carlos Hasan
*
* Filename: example9.c
* Version: Revision 1.0
*
* Language: WATCOM C
* Environment: IBM PC (DOS/4GW)
*
* Description: Play a music module file. This example show how to load
* a module file from a big resource file.
*
****************************************************************************/
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "audio.h"
#include "import.h"
#define MODPATH "SONG.DSM"
#define MODFORM FORM_DSM
#define MODSEEK 0L
#define MODSIZE 50697L
DSM *XLoadModule(char *Filename, long SeekPos, long Length, int Form)
{
int Handle;
DSM *Module;
/* For your programs you should search the filename in the resource
* file directory and get the file offset and length from there.
* Also, you can use directly dLoadModuleFile to load RIFF/DSMF files
* instead of using the dImportModuleFile import routines (see below).
*/
/* open the resource file */
if ((Handle = open(Filename,O_BINARY|O_RDONLY)) < 0) {
dError = ERR_NOFILE;
return NULL;
}
/* seek the module file */
if (lseek(Handle,SeekPos,SEEK_SET) < 0) {
dError = ERR_FILEIO;
close(Handle);
return NULL;
}
/* load module file */
Module = dImportModuleFile(Handle,Length,Form);
close(Handle);
return Module;
}
int main(void)
{
SoundCard SC;
DSM *M;
dRegisterDrivers();
if (dLoadSetup(&SC,"SETUP.CFG")) {
printf("Please run SETUP.EXE to configure.\n");
exit(EXIT_FAILURE);
}
if (dInit(&SC)) {
printf("Error initializing the sound system.\n");
exit(EXIT_FAILURE);
}
atexit((void(*)(void))dDone);
if (!(M = XLoadModule(MODPATH,MODSEEK,MODSIZE,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;
}