Arduino STK
4.6.2
|
STK voice manager class. More...
#include <Voicer.h>
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. More... | |
void | removeInstrument (Instrmnt *instrument) |
Remove the given instrument pointer from the voice manager's control. More... | |
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. More... | |
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). More... | |
void | noteOff (long tag, StkFloat amplitude) |
Send a noteOff to the voice with the given note tag. More... | |
void | setFrequency (StkFloat noteNumber, int group=0) |
Send a frequency update message to all voices assigned to the optional group argument (default group = 0). More... | |
void | setFrequency (long tag, StkFloat noteNumber) |
Send a frequency update message to the voice with the given note tag. More... | |
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 StkFrames & | lastFrame (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. More... | |
StkFloat | tick (unsigned int channel=0) |
Mix one sample frame of all sounding voices and return the specified channel value. More... | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Fill the StkFrames argument with computed frames and return the same reference. More... | |
void | ignoreSampleRateChange (bool ignore=true) |
A function to enable/disable the automatic updating of class data when the STK sample rate changes. More... | |
Static Public Member Functions | |
static StkFloat | sampleRate (void) |
Static method that returns the current STK sample rate. | |
static void | setSampleRate (StkFloat rate) |
Static method that sets the STK sample rate. More... | |
static void | clear_alertList () |
Static method that frees memory from alertList_. | |
static std::string | rawwavePath (void) |
Static method that returns the current rawwave path. | |
static void | setRawwavePath (std::string path) |
Static method that sets the STK rawwave path. | |
static void | swap16 (unsigned char *ptr) |
Static method that byte-swaps a 16-bit data type. | |
static void | swap32 (unsigned char *ptr) |
Static method that byte-swaps a 32-bit data type. | |
static void | swap64 (unsigned char *ptr) |
Static method that byte-swaps a 64-bit data type. | |
static void | sleep (unsigned long milliseconds) |
Static cross-platform method to sleep for a number of milliseconds. | |
static bool | inRange (StkFloat value, StkFloat min, StkFloat max) |
Static method to check whether a value is within a specified range. | |
static void | handleError (const char *message, StkError::Type type) |
Static function for error reporting and handling using c-strings. | |
static void | handleError (std::string message, StkError::Type type) |
Static function for error reporting and handling using c++ strings. | |
static void | showWarnings (bool status) |
Toggle display of WARNING and STATUS messages. | |
static void | printErrors (bool status) |
Toggle display of error messages before throwing exceptions. | |
Static Public Attributes | |
static const StkFormat | STK_SINT8 |
static const StkFormat | STK_SINT16 |
static const StkFormat | STK_SINT24 |
static const StkFormat | STK_SINT32 |
static const StkFormat | STK_FLOAT32 |
static const StkFormat | STK_FLOAT64 |
Protected Member Functions | |
void | handleError (StkError::Type type) const |
Internal function for error reporting that assumes message in oStream_ variable. | |
virtual void | sampleRateChanged (StkFloat newRate, StkFloat oldRate) |
This function should be implemented in subclasses that depend on the sample rate. | |
void | addSampleRateAlert (Stk *ptr) |
Add class pointer to list for sample rate change notification. | |
void | removeSampleRateAlert (Stk *ptr) |
Remove class pointer from list for sample rate change notification. | |
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–2019.
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.
|
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.
|
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.
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).
|
staticinherited |
Static method that sets the STK sample rate.
The sample rate set using this method is queried by all STK classes that depend on its value. It is initialized to the default SRATE set in Stk.h. Many STK classes use the sample rate during instantiation. Therefore, if you wish to use a rate that is different from the default rate, it is imperative that it be set BEFORE STK objects are instantiated. A few classes that make use of the global STK sample rate are automatically notified when the rate changes so that internal class data can be appropriately updated. However, this has not been fully implemented. Specifically, classes that appropriately update their own data when either a setFrequency() or noteOn() function is called do not currently receive the automatic notification of rate change. If the user wants a specific class instance to ignore such notifications, perhaps in a multi-rate context, the function Stk::ignoreSampleRateChange() should be called.
|
inlineinherited |
|
staticinherited |
-128 to +127
|
staticinherited |
-32768 to +32767
|
staticinherited |
Lower 3 bytes of 32-bit signed integer.
|
staticinherited |
-2147483648 to +2147483647.
|
staticinherited |
Normalized between plus/minus 1.0.
|
staticinherited |
Normalized between plus/minus 1.0.