NAME
SYNOPSIS
DESCRIPTION
A user can write a subroutine with an arbitrary name which will be invoked by a data statement with an arbitrary (i.e., up- to- the- user) character string starting in the first column of a data card. When this routine is then called in this way in Minc the p array will contain, in floating-point form, all the arguments written on the data card, and the number of such arguments will be contained in n_args. As long as the function is declared as type double, it can return a value to Minc. For example, you can write a routine called double whamo(p,n_args) and have it invoked by the Minc command:


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.

SEE ALSO
profile(2),setnote(2),ADDOUT(2),endnote(2)
DIAGNOSTICS
The C compiler is your best friend here.
BUGS
Theoretically unlimited, depending on your programming skill and care.