From: "laine" Newsgroups: comp.os.msdos.djgpp Subject: Mods and Wavs with MikAllegro (MikMod) Date: 30 Jan 1998 18:37:52 GMT Organization: Clinet, Espoo, Finland. Lines: 130 Message-ID: <01bd2d62$738ff0e0$453e64c2@default> NNTP-Posting-Host: dialup204.iwn.fi To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! I'vedone this program wich should (at least I think so ;) play a mod (.xm) and when space is pressed it should make a sound. It uses MikMod and Allegro (MikAllegro 3.0). It plays the music ok but the sounds don't work. MikMod only gives the following message: predict stopped it. current 1, end -1 What's wrong. The code is below. Thanks. Jarkko Laine www: http://www.ks.iwn.fi/~laine/line_a.html ---------------------------------------------------------------------------- -- The code: #include #include #include UNIMOD *fn; void tickhandler(void) { MP_HandleTick(); /* play 1 tick of the module */ MD_SetBPM(mp_bpm); } void aseta_mikmod (void) { setvbuf(stdout, NULL, _IONBF, 0); srandom(_farpeekw(_dos_ds, 0x0046C)); // Initialize soundcard parameters.. you _have_ to do this // before calling MD_Init(), and it's illegal to change them // after you've called MD_Init() md_mixfreq =44100; /* standard mixing freq */ md_dmabufsize =2000; /* standard dma buf size */ md_mode =7; /* standard mixing mode */ md_device =0; /* standard device: autodetect */ ML_RegisterLoader(&load_xm); // Register the loaders we want to use.. MD_RegisterDriver(&drv_nos); // Register the drivers we want to use: MD_RegisterDriver(&drv_ss); MD_RegisterDriver(&drv_sb); MD_RegisterDriver(&drv_gus); MD_RegisterPlayer(tickhoituri); allegro_init(); install_keyboard(); install_timer(); if(!MD_Init()) // initialize soundcard { printf("Driver error: %s.\n",myerr); exit (1); } printf("\nUsing %s for %d bit %s sound at %u Hz\n\n", md_driver->Name, (md_mode&DMODE_16BITS) ? 16:8, (md_mode&DMODE_STEREO) ? "stereo":"mono", md_mixfreq); } void play_mikalg_sample (MSAMPLE *sample) { static int channel_no = 24; MD_VoiceSetVolume(channel_no, 61); MD_VoiceSetPanning(channel_no, 127); MD_VoiceSetFrequency(channel_no, sample->c2spd); MD_VoicePlay(channel_no ,sample->handle, 0, sample->length,0,0, sample->flags); channel_no++; if (channel_no >= 32) channel_no=24; } int main (void) { MSAMPLE *aani; aseta_mikmod(); allegro_init(); install_timer(); install_keyboard(); fn=ML_LoadFN("sc/autstp.xm"); // load the the music. If it didn't work, if(fn==NULL) // exit with errormsg { printf("MikMod Error: %s\n",myerr); exit (1); } mp_loop=TRUE; md_numchn=32; MP_Init(fn); MD_PlayStart(); // Aletaan soittaa install_int (MD_Update, 10); // update the buffer every 10 msec aani=MW_LoadWavFN("kops.wav"); while(!key[KEY_ESC]){ if(key[KEY_SPACE]){ play_mikalg_sample(aani); clear_keybuf(); } } MD_PlayStop(); // stop playing*/ ML_Free(fn); // and free the module*/ MD_Exit(); allegro_exit(); }