//This one is for wavs! int Mix_Playing(int channel) { if (Voice_Stopped(v1) == 0) return 1; else return 0; }
//0-256 int Mix_Volume(int channel, int v) { voicevolume = v; if (Voice_Stopped(v1) == 0) Voice_SetVolume(v1, v); return v; }
//0-256 int Mix_VolumeChunk(Mix_Chunk *chunk, int volume) { voicevolume = volume; if (Voice_Stopped(v1) == 0) Voice_SetVolume(v1, volume); return volume; }
int main(void) { /* sound effects */ SAMPLE *sfx1, *sfx2; /* voices */ int v1, v2; int i; /* register all the drivers */ MikMod_RegisterAllDrivers(); /* initialize the library */ md_mode |= DMODE_SOFT_SNDFX; if (MikMod_Init("")) { fprintf(stderr, "Could not initialize sound, reason: %s\n", MikMod_strerror(MikMod_errno)); return 1; } /* load samples */ sfx1 = Load("first.wav"); if (!sfx1) { MikMod_Exit(); fprintf(stderr, "Could not load the first sound, reason: %s\n", MikMod_strerror(MikMod_errno)); return 1; } sfx2 = Load("second.wav"); if (!sfx2) { Sample_Free(sfx1); MikMod_Exit(); fprintf(stderr, "Could not load the second sound, reason: %s\n", MikMod_strerror(MikMod_errno)); return 1; } /* reserve 2 voices for sound effects */ MikMod_SetNumVoices(-1, 2); /* get ready to play */ MikMod_EnableOutput(); /* play first sample */ v1 = Sample_Play(sfx1, 0, 0); do { MikMod_Update(); MikMod_Sleep(100000); } while (!Voice_Stopped(v1)); for (i = 0; i < 10; i++) { MikMod_Update(); MikMod_Sleep(100000); } /* half a second later, play second sample */ v2 = Sample_Play(sfx2, 0, 0); do { MikMod_Update(); MikMod_Sleep(100000); } while (!Voice_Stopped(v2)); for (i = 0; i < 10; i++) { MikMod_Update(); MikMod_Sleep(100000); } MikMod_DisableOutput(); Sample_Free(sfx2); Sample_Free(sfx1); MikMod_Exit(); return 0; }