Below is an example program that you might want to write. It generates a sound file called "noise.wav" containing whitenoise with a duration of one second. The hyperlinks in the example code point to documentation for those classes defined in the sig++ library.
#include "sig.h" int main(void) { int numSamples = 44100; float amplitude = 0.5; SoundHeader header; header.setHighMono(); // Elements: WhiteNoise noise(amplitude); SoundFileOut outsound("noise.wav", header); // Connections: outsound.connect(noise); Action action; action.tick(outsound, numSamples); return 0; } |
|
To compile this program, you need to tell the compiler where the header files and library file are located. Suppose that the header files are in directory XXX (usually include/sig from the base sig++ directory), and the library file is in directory YYY (usually lib), and suppose that the library file is called libsig.a and the program above is called noise.cc. Thus, you would type the following command on Unix-based computers to compile your program:
g++ -O3 -o noise noise.cc -IXXX -LYYY -lsig && strip noise
If you are going to use an architecture-specific feature in the sig++ library, then you may have to tell the compiler. This is mostly the case with only the sig control classes, where you would need to add the -DLINUX option to the compiler's command line when compiling in linux, e.g.:
g++ -DLINUX -O3 -o noise noise.cc -IXXX -LYYY -lsig && strip noiseThe file sigConfiguration.h lists all of the OS-specific configurations that are possible.
Including sig.h into the program above is the lazy way to include all necessary header files for the sig library. You could also include just the header files which are needed for the program, e.g.:
#include "WhiteNoise.h" #include "SoundFileOut.h" #include "SoundHeader.h" #include "Action.h"
See the examples page for more program code examples, particularly the sigFile examples for creating/modifying soundfiles.