本文整理汇总了C++中Voice::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ Voice::activate方法的具体用法?C++ Voice::activate怎么用?C++ Voice::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voice
的用法示例。
在下文中一共展示了Voice::activate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: noteOn
void VoiceHandler::noteOn(mopo_float note, mopo_float velocity, int sample, int channel) {
MOPO_ASSERT(sample >= 0 && sample < buffer_size_);
MOPO_ASSERT(channel >= 0 && channel < NUM_MIDI_CHANNELS);
Voice* voice = grabVoice();
pressed_notes_.push_front(note);
if (last_played_note_ < 0)
last_played_note_ = note;
voice->activate(note, velocity, last_played_note_, pressed_notes_.size(), sample, channel);
active_voices_.push_back(voice);
last_played_note_ = note;
}
示例2: noteOn
void VoiceHandler::noteOn(mopo_float note, mopo_float velocity) {
Voice* voice = 0;
pressed_notes_.push_back(note);
if (free_voices_.size() && active_voices_.size() < polyphony_) {
voice = free_voices_.front();
free_voices_.pop_front();
}
else {
voice = active_voices_.front();
active_voices_.pop_front();
}
voice->activate(note, velocity);
active_voices_.push_back(voice);
}
示例3: noteOff
void VoiceHandler::noteOff(mopo_float note) {
std::list<mopo_float>::iterator note_iter = pressed_notes_.begin();
while (note_iter != pressed_notes_.end()) {
if (*note_iter == note)
note_iter = pressed_notes_.erase(note_iter);
else
note_iter++;
}
std::list<Voice*>::iterator iter = active_voices_.begin();
for (; iter != active_voices_.end(); ++iter) {
Voice* voice = *iter;
if (voice->state()->note == note) {
if (sustain_)
sustained_voices_.push_back(voice);
else {
if (polyphony_ == 1 && pressed_notes_.size())
voice->activate(pressed_notes_.back(), voice->state()->velocity);
else
voice->deactivate();
}
}
}
}