home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
dos
/
prg
/
dsik205
/
dsik.dat
/
EXAMPLES
/
EXAMP03.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-10
|
3KB
|
90 lines
/****************************************************************************
*
* Digital Sound Interface Kit (DSIK)
* Version 2.00
*
* by Carlos Hasan
*
* Filename: example3.c
* Version: Revision 1.0
*
* Language: WATCOM C
* Environment: IBM PC (DOS/4GW)
*
* Description: Play a module and a sample file simultaneously.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include "audio.h"
#include "import.h"
#define MODPATH "SONG.DSM"
#define MODFORM FORM_DSM
#define SMPPATH "SAMPLE.WAV"
#define SMPFORM FORM_WAV
int main(void)
{
SoundCard SC;
DSM *M;
Sample *S;
int key,chan;
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 = dImportModule(MODPATH,MODFORM))) {
printf("Error (%03d) loading %s module file: %s.\n",
dError, MODPATH, dErrorMsg[dError]);
exit(EXIT_FAILURE);
}
if (!(S = dImportSample(SMPPATH,SMPFORM))) {
printf("Error (%03d) loading %s sample file: %s.\n",
dError, SMPPATH, dErrorMsg[dError]);
exit(EXIT_FAILURE);
}
/* The sound system needs M->Header.NumTracks voices to
playback the music module, and I need an extra voice to
play the WAVE sample file.
*/
dSetupVoices(M->Header.NumTracks+1,M->Header.MasterVolume);
/* Get the unused voice number to play the WAVE sample file */
chan = M->Header.NumTracks;
dPlayMusic(M);
dSetMusicVolume(160);
printf("Press keys 0-9 to play the module instruments,\n");
printf("SPACE to play the sample file or ESC to quit.\n");
do {
while (!kbhit()) dPoll();
if ((key = getch()) != 27) {
if (isdigit(key)) {
key -= '0';
if (key < M->Header.NumSamples) {
dPlayVoice(chan,M->Samples[key]);
}
}
else if (isspace(key)) {
dPlayVoice(chan,S);
}
}
} while (key != 27);
dStopVoice(chan);
dStopMusic();
dFreeModule(M);
return 0;
}