Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
Makefiles
that compile project-specific class objects from common src
and include
directories. And still others like to compile and link to a common library of object files. STK was not designed with one particular style of use in mind.
Without the "realtime" classes, it is still possible to read SKINI scorefiles for control input and to read and write to/from a variety of audio file formats (WAV, SND, AIFF, MAT-file, and RAW). If compiling for a "little-endian" host processor, the __LITTLE_ENDIAN__
preprocessor definition should be provided.
OS: | Realtime Audio/MIDI API: | Preprocessor Definition: | Library or Framework: |
Linux | ALSA | __LINUX_ALSA__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ | asound, pthread |
Linux | OSS (version 4.0 only, use ALSA for MIDI support) | __LINUX_OSS__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ | asound, pthread |
Linux and Macintosh OS-X | Jack (audio only, use ALSA for MIDI support) | __UNIX_JACK__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ | asound, pthread, jack |
Macintosh OS X | CoreAudio | __MACOSX_CORE__ | pthread, CoreAudio, CoreMIDI, CoreFoundation |
The available C++ compilers on any of these systems can vary.
One approach in using STK is to simply copy the class files needed for a particular program into a project directory. Taking the sineosc.cpp
example from the previous tutorial chapter, it would be necessary to set up a directory that includes the files sineosc.cpp
, the rawwave file sinewave.raw
in a subdirectory called rawwaves
, and the header and source files for the classes Stk, FileRead, FileWrite, WvIn, FileWvIn, WaveLoop, WvOut, and FileWvOut. The program could then be compiled on a little-endian system, such as a PC running Linux, using the GNU g++ compiler as follows:
g++ -Wall -D__LITTLE_ENDIAN__ -o sineosc Stk.cpp FileRead.cpp FileWrite.cpp WvIn.cpp FileWvIn.cpp WaveLoop.cpp WvOut.cpp FileWvOut.cpp sineosc.cpp
Note that the sineosc.cpp
example does not make use of realtime audio or MIDI input/output classes. For programs using any of the STK realtime classes mentioned above, it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks.
When working with a number of different projects that make use of ToolKit classes, the above approach can become cumbersome (especially when trying to synchronize with new STK releases). Most of the STK projects (e.g., demo, effects, ...) contain Makefiles
(built by the configure script) that compile project-specific class objects from the distribution src
and include
directories. This approach makes it relatively easy when upgrading to a new STK release (by making path substitutions in the Makefile
or by moving the projects to a similar relative path within the new STK source tree). A Makefile
is provided in the projects/examples
directory for compiling all the tutorial programs, as well as other example programs. To compile the sineosc.cpp
program, for example, one need only type make sineosc
from within the projects/examples
directory.
Makefile
that can be used on Unix systems to build a static library. After unpacking the distribution (tar -xzf stk-4.x.x.tar.gz
), run the configure script by typing ./configure
from the top level distribution directory (see the INSTALL file in the same directory for more information). Then from within the src
directory, type make
. After a successful build, you may wish to move the library (libstk.a
) and the contents of the include
directory to standard library and include search paths on your system. For example, the linux RPM distribution of STK puts the library in /usr/lib/
and the STK header files in /usr/include/stk/
.
Assuming the library is located in a standard search path and the header files are located in /usr/include/stk/
, the sineosc.cpp
example from the previous tutorial chapter can be compiled on a little-endian system using the GNU g++ compiler as follows:
g++ -Wall -D__LITTLE_ENDIAN__ -I/usr/include/stk -o sineosc sineosc.cpp -lstk
With the header files in a standard search path, it is possible to modify the #include
statements in the sineosc.cpp
program as follows:
#include "stk/WaveLoop.h" #include "stk/FileWvOut.h"
and then compile without an explicit include path argument to the compiler:
g++ -Wall -D__LITTLE_ENDIAN__ -o sineosc sineosc.cpp -lstk
The approach when using Visual C++ is to build a project that includes the necessary ToolKit files from the distribution src
and include
directories. For the example program from the previous tutorial chapter, create a VC++ console application project, add the Stk, FileRead, FileWrite, WvIn, FileWvIn, WaveLoop, WvOut, and FileWvOut class files, as well as sineosc.cpp
, and make sure the sinewave.raw
file is in the subdirectory rawwaves
.
For programs using any of the STK realtime classes mentioned above, it is necessary to link with the DirectSound (dsound.lib
), winmm.lib
, and Wsock32.lib
libraries, select the multithreaded library, and provide the __LITTLE_ENDIAN__
, __WINDOWS_DS__
, and __WINDOWS_MM__
preprocessor definitions.
For Steinberg ASIO support, use the __WINDOWS_ASIO__
preprocessor definition (and the __WINDOWS_MM__
definition for RtMidi support), include all the files in the src/asio/
directory (i.e., asio.h,cpp
, asiodrivers.h,cpp
, ...), and link with the winmm.lib
, and Wsock32.lib
libraries.
[Main tutorial page] [Next tutorial]
The Synthesis ToolKit in C++ (STK) |
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |