Beispiel #1
0
/* Open a module via its filename.  The loader will initialize the specified
   song-player 'player'. */
MIKMODAPI MODULE* Player_Load(CHAR* filename,int maxchan,BOOL curious)
{
	FILE *fp;
	MODULE *mf=NULL;

	if((fp=_mm_fopen(filename,"rb"))) {
		mf=Player_LoadFP(fp,maxchan,curious);
		_mm_fclose(fp);
	}
	return mf;
}
Beispiel #2
0
static int pat_readpat_attr(int pat, WaveHeader *hw, int layer)
{
	char fname[128];
	MMSTREAM *mmpat;
	pat_build_path(fname, pat);
	mmpat = _mm_fopen(fname, "r");
	if( !mmpat )
		return 0;
	pat_read_waveheader(mmpat, hw, layer);
	_mm_fclose(mmpat);
	return 1;
}
Beispiel #3
0
static int pat_readpat_attr(int pat, WaveHeader *hw, int layer)
{
	char fname[128];
	unsigned long fsize;
	MMSTREAM *mmpat;
	pat_build_path(fname, pat);
	mmpat = _mm_fopen(fname, "rb");
	if( !mmpat )
		return 0;
	fsize = _mm_getfsize(mmpat);
	pat_read_waveheader(mmpat, hw, layer);
	_mm_fclose(mmpat);
	if (hw->wave_size > fsize)
		return 0;
	return 1;
}
Beispiel #4
0
MIKMODAPI CHAR* Player_LoadTitle(CHAR* filename)
{
	CHAR* result=NULL;
	FILE* fp;
	MREADER* reader;

	if((fp=_mm_fopen(filename,"rb"))) {
		if((reader=_mm_new_file_reader(fp))) {
			MUTEX_LOCK(lists);
			result=Player_LoadTitle_internal(reader);
			MUTEX_UNLOCK(lists);
			_mm_delete_file_reader(reader);
		}
		_mm_fclose(fp);
	}
	return result;
}
Beispiel #5
0
void pat_init_patnames(void)
{
	int z, i, nsources, isdrumset, nskip, pfnlen;
	char *p, *q;
	char line[PATH_MAX];
	char cfgsources[5][PATH_MAX] = {{0}, {0}, {0}, {0}, {0}};
	MMSTREAM *mmcfg;
	strncpy(pathforpat, PATHFORPAT, PATH_MAX);
	strncpy(timiditycfg, TIMIDITYCFG, PATH_MAX);
	p = getenv(PAT_ENV_PATH2CFG);
	if( p ) {
		strncpy(timiditycfg, p, PATH_MAX - 14);
		strncpy(pathforpat, p, PATH_MAX - 13);
		strcat(timiditycfg, "/timidity.cfg");
		strcat(pathforpat, "/instruments");
	}
	strncpy(cfgsources[0], timiditycfg, PATH_MAX - 1);
	nsources = 1;

	for( i=0; i<MAXSMP; i++ )	midipat[i][0] = '\0';

	for ( z=0; z<5; z++ ) {
		if (cfgsources[z][0] == 0) continue;
		mmcfg = _mm_fopen(cfgsources[z],"r");
		if( !mmcfg ) {
			pat_message("can not open %s, use environment variable " PAT_ENV_PATH2CFG " for the directory", cfgsources[z]);
		}
		else {
			// read in bank 0 and drum patches
			isdrumset = 0;
			_mm_fgets(mmcfg, line, PATH_MAX);
			while( !_mm_feof(mmcfg) ) {
			if( isdigit(line[0]) || (isblank(line[0]) && isdigit(line[1])) ) {
				p = line;
				// get pat number
				while ( isspace(*p) ) p ++;
				i = atoi(p);
				while ( isdigit(*p) ) p ++;
				while ( isspace(*p) ) p ++;
				// get pat file name
				if( *p && i < MAXSMP && i >= 0 && *p != '#' ) {
					q = isdrumset ? midipat[pat_gm_drumnr(i)-1] : midipat[i];
					pfnlen = 0;
					while( *p && !isspace(*p) && *p != '#' && pfnlen < 128 ) {
						pfnlen ++;
						*q++ = *p++;
					}
					if( isblank(*p) && *(p+1) != '#' && pfnlen < 128 ) {
						*q++ = ':'; pfnlen ++;
						while( isspace(*p) ) {
							while( isspace(*p) ) p++;
							if ( *p == '#' ) { // comment

							} else while( *p && !isspace(*p) && pfnlen < 128 ) {
								pfnlen ++;
								*q++ = *p++;
							}
							if( isspace(*p) ) { *q++ = ' '; pfnlen++; }
						}
					}
					*q++ = '\0';
				}
			}
			if( !strncmp(line,"drumset",7) ) isdrumset = 1;
			if( !strncmp(line,"source",6) && nsources < 5 ) {
				q = cfgsources[nsources];
				p = &line[7];
				while ( isspace(*p) ) p ++;
				pfnlen = 0;
				while ( *p && *p != '#' && !isspace(*p) && pfnlen < 128 ) {
					pfnlen ++;
					*q++ = *p++;
				}
				*q = 0; // null termination
				nsources++;
			}
			_mm_fgets(mmcfg, line, PATH_MAX);

			} /* end file parsing */
			_mm_fclose(mmcfg);
		}
	}
	q = midipat[0];
	nskip = 0;
	// make all empty patches duplicates the previous valid one.
	for( i=0; i<MAXSMP; i++ )	{
		if( midipat[i][0] ) q = midipat[i];
		else {
			if( midipat[i] != q)
				strcpy(midipat[i], q);
			if( midipat[i][0] == '\0' ) nskip++;
		}
	}
	if( nskip ) {
		for( i=MAXSMP; i-- > 0; )	{
			if( midipat[i][0] ) q = midipat[i];
			else if( midipat[i] != q )
				strcpy(midipat[i], q);
		}
	}
}
Beispiel #6
0
void pat_init_patnames(void)
{
	int i,j;
	char *p, *q;
	char line[80];
	MMSTREAM *mmcfg;
	strcpy(pathforpat, PATHFORPAT);
	strcpy(timiditycfg, TIMIDITYCFG);
	p = getenv(PAT_ENV_PATH2CFG);
	if( p ) {
		strcpy(timiditycfg,p);
		strcpy(pathforpat,p);
		strcat(timiditycfg,"/timidity.cfg");
		strcat(pathforpat,"/instruments");
	}
	mmcfg = _mm_fopen(timiditycfg,"r");
	for( i=0; i<MAXSMP; i++ )	midipat[i][0] = '\0';
	if( !mmcfg ) {
		pat_message("can not open %s, use environment variable " PAT_ENV_PATH2CFG " for the directory", timiditycfg);
	}
	else {
		// read in bank 0 and drum patches
		j = 0;
		_mm_fgets(mmcfg, line, 80);
		while( !_mm_feof(mmcfg) ) {
			if( isdigit(line[0]) ) {
				i = atoi(line);
				if( i < MAXSMP && i >= 0 ) {
					p = strchr(line,'/')+1;
					if(j) 
						q = midipat[pat_gm_drumnr(i)-1];
					else
						q = midipat[i];
					while( *p && !isspace(*p) )	*q++ = *p++;
					if( isspace(*p) ) {
						*q++ = ':';
						while( isspace(*p) ) {
							while( isspace(*p) ) p++;
							while( *p && !isspace(*p) ) *q++ = *p++;
							if( isspace(*p) ) *q++ = ' ';
						}
					}
					*q++ = '\0';
				}
			}
			if( !strncmp(line,"drumset",7) ) j = 1;
			_mm_fgets(mmcfg, line, 80);
		}
		_mm_fclose(mmcfg);
	}
	q = midipat[0];
	j = 0;
	for( i=0; i<MAXSMP; i++ )	{
		if( midipat[i][0] ) q = midipat[i];
		else {
			strcpy(midipat[i],q);
			if( midipat[i][0] == '\0' ) j++;
		}
	}
	if( j ) {
		for( i=MAXSMP; i-- > 0; )	{
			if( midipat[i][0] ) q = midipat[i];
			else strcpy(midipat[i],q);
		}
	}
}