Previous Section: Extensions and Variations
Compiling CMIX Instruments
CMIX instruments are easily compiled using the UNIX *makefile* utility. The *makefile* for the *snazzypan* instrument, residing in the same directory as *snazzypan*, looks like this:
CFLAGS = -O
SNAZZYPAN = profile.o snazzypan.o
LDFLAGS = /musr/bin/cmix.o /musr/lib/genlib.a -lm
snazzypan: /musr/H/ugens.h /musr/bin/cmix.o $(SNAZZYPAN)
cc -o snazzypan $(SNAZZYPAN) $(LDFLAGS)
"CFLAGS -O" is simply telling the compiler to optimize the code whenever possible (other C compiler options may be added here). The "SNAZZYPAN = ..." line is used to tell the compiler to create the object files *snazzypan.o* (from the *snazzypan.c* source file) and *profile.o*. *profile.o* is created from a source file called *profile.c*. This file contains the *profile* function mentioned earlier along with a definition for the symbol "NBYTES":
#include "/musr/H/ugens.h"
int NBYTES = 32768;
profile()
{
UG_INTRO("snazzypan",snazzypan);
}
"NBYTES" sets the size of the internal CMIX i/o buffers. The *UG_INTRO* macro is the piece of code responsible for registering the symbol "snazzypan" in the MINC symbol table. This causes MINC to call the *snazzypan* function whenever the "snazzypan" symbol is seen.
The "LDFLAGS" in the *makefile* informs the C compiler to link the *profile.o* and *snazzypan.o* objects together with the main CMIX program (*/musr/bin/cmix.o*), the CMIX library of unit generator functions (*/musr/lib/genlib.a*) and the standard UNIX math library ("-lm").
The final two lines in the *makefile* are instructions to the C compiler for building the executable instrument *snazzypan*. The command "make snazzypan", executed in the directory containing the *makefile* and the *snazzypan.c* and *profile.c* C code files, should create the *snazzypan* CMIX instrument.
Next Section: Final Words
What is CMIX? - Index -
Cmix Home Page