view frontend/mikmodux.c @ 18:db40f957950f

Replaced the shell scripts with a Makefile
author darius
date Thu, 23 Apr 1998 22:58:04 +0000
parents e5529b6e3b1c
children
line wrap: on
line source

/*
 * Basic mod player. Just takes the name of the mod to play
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fnmatch.h>
#include <signal.h>
#include "mikmod.h"
#include "mikmodux.h"
#include "mmio.h"


int 
main(int argc, char *argv[])
{
    static          BOOL
                    cfg_extspd = 1,		/* Extended Speed enable */
                    cfg_panning = 1,	/* DMP panning enable (8xx effects) */
                    cfg_loop = 0;		/* auto song-looping disable */
    int
                    cfg_maxchn = 64, c;

    UNIMOD         *mf = NULL;

    if (argc != 2) {
		printf("Usage is mikmod <mod name>\n");
		exit(1);
    }

	init_mikmod();

    if ((mf = MikMod_LoadSong(argv[1], cfg_maxchn)) != NULL) {
		mf->extspd = cfg_extspd;
		mf->panflag = cfg_panning;
		mf->loop = cfg_loop;

		Player_Start(mf);

		/*
		 * set the number of voices to use.. you could add extra channels
		 * here (e.g. md_numchn=mf->numchn+4; ) to use for your own
		 * soundeffects:
		 */

		while (Player_Active()) {	/* if we have a quit signal, exit
									 * loop */
			MikMod_Update();

			usleep(500);
		}

		Player_Stop();		/* stop playing */
		MikMod_FreeSong(mf);	/* and free the module */
    } else {
		/* didn't work -> exit with errormsg. */
		printf("MikMod Error\n");
    }

    MikMod_Exit();
}

void
init_mikmod(void)
{
    /*
     * 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 = 32768;	/* standard dma buf size (max 32000) */
    md_device = 0;			/* standard device: autodetect */
    md_volume = 96;			/* driver volume (max 128) */
    md_musicvolume = 128;	/* music volume (max 128) */
    md_sndfxvolume = 128;	/* sound effects volume (max 128) */
    md_pansep = 128;		/* panning separation (0 = mono, 128 = full
							 * stereo) */
    /* md_stereodelay  = 10;               /* Stereo Delay (max 15) */
    md_reverb = 0;			/* Reverb (max 15) */
    md_mode =
	DMODE_16BITS |
	DMODE_STEREO |
	DMODE_SOFT_MUSIC;		/* default mixing mode */

    /* Register the loaders we want to use..  */
    MikMod_RegisterAllLoaders();

    /* Register the drivers we want to use: */
    MikMod_RegisterAllDrivers();

    MikMod_RegisterDriver(drv_wav);
    MikMod_RegisterDriver(drv_raw);
    MikMod_RegisterDriver(drv_nos);

    MikMod_Init();

}