Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


stk::Voicer Class Reference

STK voice manager class. More...

#include <Voicer.h>

Inheritance diagram for stk::Voicer:
stk::Stk

List of all members.

Public Member Functions

 Voicer (StkFloat decayTime=0.2)
 Class constructor taking an optional note decay time (in seconds).
void addInstrument (Instrmnt *instrument, int group=0)
 Add an instrument with an optional group number to the voice manager.
void removeInstrument (Instrmnt *instrument)
 Remove the given instrument pointer from the voice manager's control.
long noteOn (StkFloat noteNumber, StkFloat amplitude, int group=0)
 Initiate a noteOn event with the given note number and amplitude and return a unique note tag.
void noteOff (StkFloat noteNumber, StkFloat amplitude, int group=0)
 Send a noteOff to all voices having the given noteNumber and optional group (default group = 0).
void noteOff (long tag, StkFloat amplitude)
 Send a noteOff to the voice with the given note tag.
void setFrequency (StkFloat noteNumber, int group=0)
 Send a frequency update message to all voices assigned to the optional group argument (default group = 0).
void setFrequency (long tag, StkFloat noteNumber)
 Send a frequency update message to the voice with the given note tag.
void pitchBend (StkFloat value, int group=0)
 Send a pitchBend message to all voices assigned to the optional group argument (default group = 0).
void pitchBend (long tag, StkFloat value)
 Send a pitchBend message to the voice with the given note tag.
void controlChange (int number, StkFloat value, int group=0)
 Send a controlChange to all instruments assigned to the optional group argument (default group = 0).
void controlChange (long tag, int number, StkFloat value)
 Send a controlChange to the voice with the given note tag.
void silence (void)
 Send a noteOff message to all existing voices.
unsigned int channelsOut (void) const
 Return the current number of output channels.
const StkFrameslastFrame (void) const
 Return an StkFrames reference to the last output sample frame.
StkFloat lastOut (unsigned int channel=0)
 Return the specified channel value of the last computed frame.
StkFloat tick (unsigned int channel=0)
 Mix one sample frame of all sounding voices and return the specified channel value.
StkFramestick (StkFrames &frames, unsigned int channel=0)
 Fill the StkFrames argument with computed frames and return the same reference.

Detailed Description

STK voice manager class.

This class can be used to manage a group of STK instrument classes. Individual voices can be controlled via unique note tags. Instrument groups can be controlled by group number.

A previously constructed STK instrument class is linked with a voice manager using the addInstrument() function. An optional group number argument can be specified to the addInstrument() function as well (default group = 0). The voice manager does not delete any instrument instances ... it is the responsibility of the user to allocate and deallocate all instruments.

The tick() function returns the mix of all sounding voices. Each noteOn returns a unique tag (credits to the NeXT MusicKit), so you can send control changes to specific voices within an ensemble. Alternately, control changes can be sent to all voices in a given group.

by Perry R. Cook and Gary P. Scavone, 1995 - 2010.


Member Function Documentation

void stk::Voicer::addInstrument ( Instrmnt instrument,
int  group = 0 
)

Add an instrument with an optional group number to the voice manager.

A set of instruments can be grouped by group number and controlled via the functions that take a group number argument.

void stk::Voicer::removeInstrument ( Instrmnt instrument  ) 

Remove the given instrument pointer from the voice manager's control.

It is important that any instruments which are to be deleted by the user while the voice manager is running be first removed from the manager's control via this function!!

long stk::Voicer::noteOn ( StkFloat  noteNumber,
StkFloat  amplitude,
int  group = 0 
)

Initiate a noteOn event with the given note number and amplitude and return a unique note tag.

Send the noteOn message to the first available unused voice. If all voices are sounding, the oldest voice is interrupted and sent the noteOn message. If the optional group argument is non-zero, only voices in that group are used. If no voices are found for a specified non-zero group value, the function returns -1. The amplitude value should be in the range 0.0 - 128.0.

void stk::Voicer::noteOff ( StkFloat  noteNumber,
StkFloat  amplitude,
int  group = 0 
)

Send a noteOff to all voices having the given noteNumber and optional group (default group = 0).

The amplitude value should be in the range 0.0 - 128.0.

void stk::Voicer::noteOff ( long  tag,
StkFloat  amplitude 
)

Send a noteOff to the voice with the given note tag.

The amplitude value should be in the range 0.0 - 128.0.

void stk::Voicer::setFrequency ( StkFloat  noteNumber,
int  group = 0 
)

Send a frequency update message to all voices assigned to the optional group argument (default group = 0).

The noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range.

void stk::Voicer::setFrequency ( long  tag,
StkFloat  noteNumber 
)

Send a frequency update message to the voice with the given note tag.

The noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range.

StkFloat stk::Voicer::lastOut ( unsigned int  channel = 0  )  [inline]

Return the specified channel value of the last computed frame.

The channel argument must be less than the number of output channels, which can be determined with the channelsOut() function (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.

See also:
lastFrame()
StkFloat stk::Voicer::tick ( unsigned int  channel = 0  )  [inline]

Mix one sample frame of all sounding voices and return the specified channel value.

The channel argument must be less than the number of output channels, which can be determined with the channelsOut() function (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.

StkFrames & stk::Voicer::tick ( StkFrames frames,
unsigned int  channel = 0 
) [inline]

Fill the StkFrames argument with computed frames and return the same reference.

The number of channels in the StkFrames argument must equal the number of channels in the file data. However, this is only checked if _STK_DEBUG_ is defined during compilation, in which case an incompatibility will trigger an StkError exception. If no file data is loaded, the function does nothing (a warning will be issued if _STK_DEBUG_ is defined during compilation).


The documentation for this class was generated from the following file:

The Synthesis ToolKit in C++ (STK)
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved.