38 Voicer( StkFloat decayTime = 0.2 );
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 );
91 void pitchBend( StkFloat value,
int group=0 );
94 void pitchBend(
long tag, StkFloat value );
97 void controlChange(
int number, StkFloat value,
int group=0 );
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];