Ejemplo n.º 1
0
/* If either parameter is -1, the current set value will be retained. */
BOOL MikMod_SetNumVoices_internal(int music, int sfx)
{
	BOOL resume = 0;
	int t, oldchn = 0;

	if((!music)&&(!sfx)) return 1;
	_mm_critical = 1;
	if(isplaying) {
		MikMod_DisableOutput_internal();
		oldchn = md_numchn;
		resume = 1;
	}

	if(sfxinfo) free(sfxinfo);
	if(md_sample) free(md_sample);
	md_sample  = NULL;
	sfxinfo    = NULL;

	if(music!=-1) md_sngchn = music;
	if(sfx!=-1)   md_sfxchn = sfx;
	md_numchn = md_sngchn + md_sfxchn;

	LimitHardVoices(md_driver->HardVoiceLimit);
	LimitSoftVoices(md_driver->SoftVoiceLimit);

	if(md_driver->SetNumVoices()) {
		MikMod_Exit_internal();
		if(_mm_errno)
			if(_mm_errorhandler!=NULL) _mm_errorhandler();
		md_numchn = md_softchn = md_hardchn = md_sfxchn = md_sngchn = 0;
		return 1;
	}

	if(md_sngchn+md_sfxchn)
		md_sample=(SAMPLE**)_mm_calloc(md_sngchn+md_sfxchn,sizeof(SAMPLE*));
	if(md_sfxchn)
		sfxinfo = (UBYTE *)_mm_calloc(md_sfxchn,sizeof(UBYTE));

	/* make sure the player doesn't start with garbage */
	for(t=oldchn;t<md_numchn;t++)  Voice_Stop_internal(t);

	sfxpool = 0;
	if(resume) MikMod_EnableOutput_internal();
	_mm_critical = 0;

	return 0;
}
Ejemplo n.º 2
0
BOOL MikMod_SetNumVoices(int music, int sfx)

/* If either parameter is -1, the current set value will be retained. */

{
    BOOL resume = 0;
    int  t, oldchn = 0;

    if((music==0) && (sfx==0)) return 0;

    _mm_critical = 1;

    if(isplaying)
    {   MikMod_DisableOutput();
        oldchn = md_numchn;
        resume = 1;
    }

    if(sfxinfo!=NULL)   free(sfxinfo);
    if(md_sample!=NULL) free(md_sample);
    md_sample  = NULL;
    sfxinfo    = NULL;

    /*md_softchn = md_hardchn = 0;

    if(md_mode & DMODE_SOFT_SNDFX)
       md_softchn = sfx; else md_hardchn = sfx;

    if(md_mode & DMODE_SOFT_MUSIC)
       md_softchn += music; else md_hardchn += music;
    */

    if(music != -1) md_sngchn = music;
    if(sfx != -1)   md_sfxchn = sfx;

    md_numchn = md_sngchn + md_sfxchn;

    LimitHardVoices(md_driver->HardVoiceLimit);
    LimitSoftVoices(md_driver->SoftVoiceLimit);

    if(md_driver->SetNumVoices())
    {   MikMod_Exit();
        md_numchn = md_softchn = md_hardchn = md_sfxchn = md_sngchn = 0;
        if(_mm_errorhandler!=NULL) _mm_errorhandler();
        return 1;
    }

    if(md_sngchn || md_sfxchn)
        md_sample = (SAMPLE **)_mm_calloc(md_sngchn+md_sfxchn, sizeof(SAMPLE *));
    if(md_sfxchn)
        sfxinfo = (UBYTE *)_mm_calloc(md_sfxchn, sizeof(UBYTE));

    /* make sure the player doesn't start with garbage */
    for(t=oldchn; t<md_numchn; t++)  Voice_Stop(t);

    sfxpool = 0;

    if(resume) MikMod_EnableOutput();
    _mm_critical = 0;

    return 0;
}