예제 #1
0
void init_sound_system()
{
	char lod_buf[30000];
	WORD ltatten, rtatten, ltgain, rtgain;

	/* Lock Sound System */
	locksnd();

	/* Save old settings */
	ltatten = soundcmd(LTATTEN, -1);
	rtatten = soundcmd(RTATTEN, -1);
	ltgain = soundcmd(LTGAIN, -1);
	rtgain = soundcmd(RTGAIN, -1);
	/* Reset sound system */
	sndstatus(1);
	/* Restore old settings */
	soundcmd(LTATTEN, ltatten);
	soundcmd(RTATTEN, rtatten);
	soundcmd(LTGAIN, ltgain);
	soundcmd(RTGAIN, rtgain);

	/* Set some necessary parameters */
	settracks(0,0);
	setmontracks(0);
	setmode(STEREO16);
	setbuffer(0,sound,sound+sizeof(sound));

	soundcmd(ADDERIN, 0x2);
	soundcmd(ADCINPUT, 0x0);

	/* DSP side */
	dsptristate(ENABLE, ENABLE);
	dsp_abil = Dsp_RequestUniqueAbility();
/*	Dsp_LoadProg(DSP_LOD, dsp_abil, lod_buf);	*/
	Dsp_ExecProg(dsp_bin, sizeof(dsp_bin)/3, dsp_abil);

	/* Connect DMA playback with DSP and then to DAC */
	switch (options.function) {
		case replay:
			devconnect(DMAPLAY, DSPRECV, CLK25M, options.prescale, NO_SHAKE);
			devconnect(DSPXMIT, DAC, CLK25M, options.prescale, NO_SHAKE);
			break;
		case record:
			break;
		case thru:
			devconnect(ADC, DSPRECV, CLK25M, options.prescale, NO_SHAKE);
			devconnect(DSPXMIT, DAC, CLK25M, options.prescale, NO_SHAKE);
			break;
	}

	Dsp_BlkUnpacked(&options.dsp.mono, 1L, 0L, 0L);
	Dsp_BlkUnpacked(&options.dsp.karaoke, 1L, 0L, 0L);
	Dsp_BlkUnpacked(&options.dsp.flange, 1L, 0L, 0L);
}
예제 #2
0
int main(void)
{
DSP_WORD *dsp_prog;
FILE * fp;
long prog_size;
int abil;
MATRIX c;
long c1[N][N*2];
int i,j;

	if (Dsp_Lock())
		{
			printf("DSP already in use\n");
			return 10;
		}
	
	if (Dsp_Reserve(0x40+N*N,0x1000+N*N*3))
		{
			printf("Can't reserve enough DSP RAM\n");
			Dsp_Unlock();
			return 10;
		}

/* Now open the DSP file */
	fp=fopen(DSP_CODE_FILE,"rb");
	if (fp==NULL)
		{
			printf("Can't open file " DSP_CODE_FILE "\n");
			Dsp_Unlock();
			return 10;
		}
	
/* Now read the DSP file into dsp_prog with the size in dsp words in prog_size */	
	fseek(fp,0,SEEK_END);
	prog_size=ftell(fp)/sizeof(DSP_WORD);
	fseek(fp,0,SEEK_SET);
	dsp_prog=malloc(prog_size*sizeof(DSP_WORD));
	fread(dsp_prog,sizeof(DSP_WORD),prog_size,fp);
	fclose(fp);

	abil=Dsp_RequestUniqueAbility();
	Dsp_ExecProg(dsp_prog,prog_size,abil);
	Dsp_BlkUnpacked(0,0,&(c1[0][0]),N*N*2);

	for	(i=0;i<N;i++)
		for	(j=0;j<N;j++)
			c[i][j]=c1[i][j*2]+(float)(c1[i][j*2+1])/0x800000;
	
	showmat(c);
	Dsp_Unlock();
	return	0;
}
예제 #3
0
void bootdsp()
{
	char *dsp_binptr;
	long dsp_binsize,dsp_datsize;
	
	if((mp2info.sample_frequency==44100L) && !ext)
	{
		dsp_binptr=dsp_binint; /* use internal clock */
		dsp_binsize = get_bin_len(0)/3;
/*		dsp_binsize=((long)sizeof(dsp_binint))/3; */
	}
	else
	{
		dsp_binptr=dsp_binext; /* use external clock */
		dsp_binsize = get_bin_len(1)/3;
/*		dsp_binsize=((long)sizeof(dsp_binext))/3; */
	}

/*
	dsp_codebin=(long)dsp_binptr;
	dsp_codelen=(int)dsp_binsize;
	dsp_bootbin=(long)dsp_bootstrap;
	dsp_bootlen=((int)sizeof(dsp_bootstrap))/3;
	Supexec(dsp_load);
*/

	Dsp_ExecProg(dsp_binptr, dsp_binsize, 0x42);


#ifdef DEBUG
	printf("DSP bootstrapped\n");
#endif
	
	dsp_datsize=get_dat_len()/4;
	Dsp_BlkUnpacked((long *)dsp_dat, dsp_datsize, 0, 0);
#ifdef DEBUG
	printf("DSP data uploaded\n");
#endif
}
예제 #4
0
/* multiply a by b giving c - returns non-zero if error */
int mult(MATRIX a,MATRIX b,MATRIX c)
{
DSP_WORD *dsp_prog;
FILE * fp;
long prog_size;
int abil;
long a1[N][N],b1[N][N],c1[N][N*2];
int i,j;

/* First we need to convert the values to fixed point */
for	(i=0;i<N;i++)
		for	(j=0;j<N;j++)
			{
				a1[i][j]= 0x800000*a[i][j];
				b1[i][j]= 0x800000*b[i][j];
			}


	if (Dsp_Lock())
		{
			printf("DSP already in use\n");
			return 10; 
		}
	
	if (Dsp_Reserve(0x40+N*N,0x1000+N*N*3))
		{
			printf("Can't reserve enough DSP RAM\n");
			Dsp_Unlock();
			return 10;
		}

/* Now open the DSP file */
	fp=fopen(DSP_CODE_FILE,"rb");
	if (fp==NULL)
		{
			printf("Can't open file " DSP_CODE_FILE "\n");
			Dsp_Unlock();
			return 10;
		}
	
/* Now read the DSP file into dsp_prog with the size in dsp words in prog_size */	
	fseek(fp,0,SEEK_END);
	prog_size=ftell(fp)/sizeof(DSP_WORD);
	fseek(fp,0,SEEK_SET);
	dsp_prog=malloc(prog_size*sizeof(DSP_WORD));
	fread(dsp_prog,sizeof(DSP_WORD),prog_size,fp);
	fclose(fp);

	abil=Dsp_RequestUniqueAbility();
	Dsp_ExecProg(dsp_prog,prog_size,abil);
/* send the data */
	Dsp_BlkUnpacked(&a1[0][0],N*N,0,0);
	Dsp_BlkUnpacked(&b1[0][0],N*N,0,0);

	Dsp_BlkUnpacked(0,0,&c1[0][0],N*N*2);

	for	(i=0;i<N;i++)
		for	(j=0;j<N;j++)
			{
			c[i][j]=c1[i][j*2]*2 +(float)(c1[i][j*2+1])/0x800000;
			}
	
	Dsp_Unlock();
	return 0;
}