home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio Version 4.94
/
audioversion4.94knowledgemediaresourcelibraryoctober1994.iso
/
amiga
/
utils
/
wavemkr
/
addwaves.c
next >
Wrap
C/C++ Source or Header
|
1991-08-15
|
1KB
|
48 lines
#include <exec/types.h>
extern SHORT sinewave[8][513];
extern UBYTE bitval[16];
/****************************************************************/
LONG AddWaves(LONG ampl[],SHORT control,BYTE wf[],UBYTE *ws)
/* Create the compound waveform by adding the harmonics. This */
/* routine is a likely candidate for future conversion to assembler */
/* to speed things up. */
{
SHORT i,j;
LONG wavebuff[513];
LONG maxval,minval;
for (j=0; j<513; j++) wavebuff[j]=0;
for (i=0;i<8;i++)
{
if ((ampl[i]!=0)&&(control&bitval[i]))
{
for (j=0;j<513;j++)
{
wavebuff[j]=wavebuff[j]+ampl[i]*sinewave[i][j];
}
}
}
maxval=minval=0;
for (j=0;j<513;j++)
{
wf[j]=wavebuff[j]>>15;
if (wavebuff[j]>maxval) maxval=wavebuff[j];
if (wavebuff[j]<minval) minval=wavebuff[j];
}
if (ws != NULL)
{
i=0;
for (j=0;j<129;j++)
{
ws[j]=wf[i];
i += 4;
}
}
if (abs(minval)>maxval) maxval=abs(minval);
return(maxval);
}