home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 3
/
FREEWARE.BIN
/
towns_os
/
pon_tool
/
play.c
< prev
next >
Wrap
Text File
|
1980-01-02
|
3KB
|
139 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fmc.h>
#include <snd.h>
extern void dsp_msg();
static char swork[16384];
int kbhit(void)
{
unsigned ec;
if ( KYB_read(1,&ec) != 0xFFFF )
return 1;
else
return 0;
}
char *getins(env,file)
char *env,*file;
{
static char tmp[128];
char *p;
if ( (p = getenv(env)) == NULL )
return NULL;
sprintf(tmp,"%s\\%s",p,file);
return tmp;
}
void play_misc(buf)
char *buf;
{
int i,n;
int err,size,signa,tempo;
char *p;
char tmp[16];
char dmy[16];
dsp_msg("Euphony Music Play Start\n");
SND_init(swork);
SND_eup_init(swork);
SND_elevol_mute(0x03);
p = &buf[852]; /* trk mute */
for( i = 0 ; i < 32 ; i++ )
err = SND_eup_mute_set(i,*(p++));
p = &buf[884]; /* trk port */
for( i = 0 ; i < 32 ; i++ )
err = SND_eup_port_set(i,*(p++));
p = &buf[916]; /* trk midi ch */
for( i = 0 ; i < 32 ; i++ )
err = SND_eup_midi_ch_set(i,*(p++));
p = &buf[948]; /* trk key bias */
for( i = 0 ; i < 32 ; i++ )
err = SND_eup_bias_set(i,*(p++));
p = &buf[980]; /* trk transpose */
for( i = 0 ; i < 32 ; i++ )
err = SND_eup_transpose_set(i,*(p++));
/********************
channel assign
*********************/
p = &buf[1748]; /* fm midi ch */
for( i = 0 ; i < 6 ; i++ )
err = SND_midi_ch_assign(i,*(p++));
p = &buf[1754]; /* pcm midi ch */
for( i = 0 ; i < 8 ; i++ )
err = SND_midi_ch_assign(i+64,*(p++));
/****************
bank load
*****************/
SND_pcm_mode_set(0);
tmp[8] = '\0';
strncpy(tmp,&buf[1762],8); /* fm file name */
if ( tmp[0] != '\0' ) {
strcat(tmp,".FMB");
if ( SND_fm_bank_load(tmp,dmy) != 0 ) {
if ( (p = getins("FMINST",tmp)) == NULL ||
SND_fm_bank_load(p,dmy) != 0 )
fprintf(stderr,"can't open '%s'\n",tmp);
}
}
tmp[8] = '\0';
strncpy(tmp,&buf[1770],8); /* pcm file name */
if ( tmp[0] != '\0' ) {
strcat(tmp,".PMB");
if ( SND_pcm_bank_load(tmp,dmy) != 0 ) {
if ( (p = getins("PCMINST",tmp)) == NULL ||
SND_pcm_bank_load(p,dmy) != 0 )
fprintf(stderr,"can't open '%s'\n",tmp);
}
}
/*******************
play eup file
********************/
p = &buf[2048]; /* data top */
size = *((int *)p); p += 4;
signa = *(p++);
tempo = *(p++);
SND_eup_loop_set(0);
SND_eup_tempo_set(tempo);
SND_eup_play_start(p,size,signa);
i = (-1);
while ( SND_eup_stat_flag() ) {
if ( (n = SND_eup_stat_meas()) != i ) {
dsp_msg("\rNow Play %d meas",n);
i = n;
}
if ( kbhit() ) {
dsp_msg(" Abort");
break;
}
}
SND_eup_play_stop();
SND_eup_end();
SND_end();
dsp_msg(" End of Play\n");
}