64 long noteOn( StkFloat noteNumber, StkFloat amplitude,
int group=0 );
70 void noteOff( StkFloat noteNumber, StkFloat amplitude,
int group=0 );
76 void noteOff(
long tag, StkFloat amplitude );
120 StkFloat
lastOut(
unsigned int channel = 0 );
131 StkFloat
tick(
unsigned int channel = 0 );
156 :instrument(0), tag(0), noteNumber(-1.0), frequency(0.0), sounding(0), group(0) {}
159 std::vector<Voice> voices_;
162 StkFrames lastFrame_;
167 #if defined(_STK_DEBUG_)
168 if ( channel >= lastFrame_.
channels() ) {
169 oStream_ <<
"Voicer::lastOut(): channel argument is invalid!";
174 return lastFrame_[channel];
181 for ( j=0; j<lastFrame_.
channels(); j++ ) lastFrame_[j] = 0.0;
182 for (
unsigned int i=0; i<voices_.size(); i++ ) {
183 if ( voices_[i].sounding != 0 ) {
184 voices_[i].instrument->tick();
185 for ( j=0; j<voices_[i].instrument->channelsOut(); j++ ) lastFrame_[j] += voices_[i].instrument->lastOut( j );
187 if ( voices_[i].sounding < 0 )
188 voices_[i].sounding++;
189 if ( voices_[i].sounding == 0 )
190 voices_[i].noteNumber = -1;
193 return lastFrame_[channel];
198 unsigned int nChannels = lastFrame_.
channels();
199 #if defined(_STK_DEBUG_)
200 if ( channel > frames.
channels() - nChannels ) {
201 oStream_ <<
"Voicer::tick(): channel and StkFrames arguments are incompatible!";
206 StkFloat *samples = &frames[channel];
207 unsigned int j, hop = frames.
channels() - nChannels;
208 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
210 for ( j=0; j<nChannels; j++ )
211 *samples++ = lastFrame_[j];
STK instrument abstract base class.
Definition: Instrmnt.h:20
An STK class to handle vectorized audio data.
Definition: Stk.h:287
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:415
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:418
STK base class.
Definition: Stk.h:144
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
STK voice manager class.
Definition: Voicer.h:35
void silence(void)
Send a noteOff message to all existing voices.
StkFloat tick(unsigned int channel=0)
Mix one sample frame of all sounding voices and return the specified channel value.
Definition: Voicer.h:178
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).
Voicer(StkFloat decayTime=0.2)
Class constructor taking an optional note decay time (in seconds).
void setFrequency(long tag, StkFloat noteNumber)
Send a frequency update message to the voice with the given note tag.
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 ...
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition: Voicer.h:165
void pitchBend(long tag, StkFloat value)
Send a pitchBend message to the voice with the given note tag.
const StkFrames & lastFrame(void) const
Return an StkFrames reference to the last output sample frame.
Definition: Voicer.h:109
void controlChange(int number, StkFloat value, int group=0)
Send a controlChange to all instruments assigned to the optional group argument (default group = 0).
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 controlChange(long tag, int number, StkFloat value)
Send a controlChange to the voice with the given note tag.
void removeInstrument(Instrmnt *instrument)
Remove the given instrument pointer from the voice manager's control.
void pitchBend(StkFloat value, int group=0)
Send a pitchBend message to all voices assigned to the optional group argument (default group = 0).
unsigned int channelsOut(void) const
Return the current number of output channels.
Definition: Voicer.h:106
void addInstrument(Instrmnt *instrument, int group=0)
Add an instrument with an optional group number to the voice manager.
The STK namespace.
Definition: ADSR.h:8