whamo(4,x,23/2*z,b) /* assuming that x,z and b have been
defined*/
There are two steps that have to be taken in oder to write a
routine and have it called by Cmix. First, it must be introduced to Cmix along with any other routines which are to be
invoked in this way in a profile.c file (see profile).
Then it must be linked with /musr/bin/cmix.o, and
/musr/bin/genlib.a must be searched for any referenced
unit-generators. Let us say that you have a subroutine
called whamo.
#include "../H/ugens.h"
double whamo(p,n_args)
float *p;
int n_args;
{
int nsamps,i;
float out[4];
nsamps = setnote(p[0],p[1],0); /* for example */
for(i=0; i<nsamps; i++) {
...whatever your heart desires...
ADDOUT(out,0);
}
endnote(0);
return(some_value_to_Minc);
}
You must then have a profile.c such as:
#include "../H/ugens.h"
int NBYTES = 32768; /* size of i/o buffers, this is a good size */
profile()
{
UG_INTRO("whamo",whamo);
}
UG_INTRO must be called once for each routine which is to be
invoked in this way. The profile() is called just once and
can be used for any one time initializations.And the following Makefile will create an executable imbed- ding whamo in a Cmix context.
CFLAGS = -O
WHAM = whamo.o profile.o
LDFLAGS = ../sys/cmix.o ../lib/genlib.a -lm
whamo: ../H/ugens.h $(WHAM) ../sys/cmix.o
cc -o whamo $(WHAM) $(LDFLAGS)
The include file, ugens.h contains the type casting for all
the unit generators; the sampling rate, stored as SR; com-
mand line information in variables aargc and *aargv[]; (the
form aargv[1], e.g., must be used instead of *aargv, to
access the strings); and a few other convenient definitions
such as FLOAT, INT, PI, PI2.