Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
The previous tutorial chapters were concerned only with monophonic ToolKit instrument playback and control. At this point, it should be relatively clear that one can instantiate multiple instruments and perhaps sum together their outputs or even direct their outputs to separate channels. It is less clear how one might go about controlling a group of instruments. The stk::Voicer class is designed to serve just this purpose.
The stk::Voicer class is a relatively simple voice manager. The user can dynamically add and delete instruments to/from its "control", with the option of controlling specific instruments via unique note tags and/or grouping sets of instruments via a "group" number. All sounding instrument outputs are summed and returned via the tick()
function. The stk::Voicer class responds to noteOn, noteOff, setFrequency, pitchBend, and controlChange messages, automatically assigning incoming messages to the voices in its control. When all voices are sounding and a new noteOn is encountered, the stk::Voicer interrupts the oldest sounding voice. The user is responsible for creating and deleting all instrument instances.
In the following example, we modify the controlbee.cpp
program to make use of three stk::BeeThree instruments, all controlled using a stk::Voicer.
We have written this program to accept control messages from STDIN
. Assuming the program is compiled as threebees
, the three-voice SKINI scorefile bachfugue.ski
(located in the scores
directory with the examples) can be redirected to the program as:
For more fun, surf to Kern Scores for a huge assortment of other scorefiles that can be downloaded in the SKINI format.
Another easy extension would be to add the stk::Messager::startMidiInput()
function to the program and then play the instruments via a MIDI keyboard.
The Synthesis ToolKit in C++ (STK) |
©1995--2023 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |