本文整理汇总了C++中Voice类的典型用法代码示例。如果您正苦于以下问题:C++ Voice类的具体用法?C++ Voice怎么用?C++ Voice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Voice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QPointF
void NoteEntryAction::renderKeyboardPreview(QPainter& painter, const MusicCursor& cursor)
{
Staff* staff = cursor.staff();
Part* part = staff->part();
Sheet* sheet = part->sheet();
Bar* bar = sheet->bar(cursor.bar());
QPointF p = bar->position() + QPointF(0, staff->top());
Voice* voice = cursor.staff()->part()->voice(cursor.voice());
VoiceBar* vb = voice->bar(bar);
if (cursor.element() >= vb->elementCount()) {
// cursor is past last element in bar, position of cursor is
// halfway between last element and end of bar
if (vb->elementCount() == 0) {
// unless entire voicebar is still empty
p.rx() += 15.0;
} else {
VoiceElement* ve = vb->element(vb->elementCount()-1);
p.rx() += (ve->x() + bar->size()) / 2;
}
} else {
// cursor is on an element, get the position of that element
p.rx() += vb->element(cursor.element())->x();
}
p.ry() += (cursor.staff()->lineCount() - 1)* cursor.staff()->lineSpacing();
p.ry() -= cursor.staff()->lineSpacing() * cursor.line() / 2;
m_tool->shape()->renderer()->renderNote(painter, m_duration < QuarterNote ? QuarterNote : m_duration, p, 0, Qt::magenta);
}
示例2: assert
bool VoiceManager::stopVoice(NoteUniqueId ID)
{
assert(_initialised);
// find the note in the active note map
ActiveVoiceList::iterator iter = activeVoices.find(ID);
// note not active?!
if(iter == activeVoices.end())
return false;
// release the note
Voice* v = iter->second.voice();
v->release();
// add to inactive voices vector
inactiveVoices.push_back(v);
// remove from active voices map
activeVoices.erase(iter);
assert(_sanityCheck());
// reset note counter on silence
if(activeVoices.empty() && inactiveVoices.empty())
{
_counter = 0;
}
return true;
}
示例3: _freeAllVoices
// kill all voices and move to free stack
void VoiceManager::_freeAllVoices()
{
if(!_initialised)
return;
Voice* v;
// active voices
ActiveVoiceList::iterator iter1;
for(iter1 = activeVoices.begin();
iter1 != activeVoices.end();
++iter1)
{
v = iter1->second.voice();
v->kill();
freeVoices.push(v);
}
activeVoices.clear();
// inactive voices
InactiveVoiceList::iterator iter2;
for(iter2 = inactiveVoices.begin();
iter2 != inactiveVoices.end();
++iter2)
{
v = *iter2;
v->kill();
freeVoices.push(v);
}
inactiveVoices.clear();
// reset the note age counter
_counter = 0;
}
示例4: setPolyphony
void VoiceHandler::process() {
global_router_.process();
int polyphony = static_cast<int>(input(kPolyphony)->at(0));
setPolyphony(utils::iclamp(polyphony, 1, polyphony));
for (int i = 0; i < numOutputs(); ++i) {
int buffer_size = voice_outputs_[i]->owner->getBufferSize();
memset(output(i)->buffer, 0, buffer_size * sizeof(mopo_float));
}
std::list<Voice*>::iterator iter = active_voices_.begin();
while (iter != active_voices_.end()) {
Voice* voice = *iter;
prepareVoiceTriggers(voice);
processVoice(voice);
// Remove voice if the right processor has a full silent buffer.
if (voice_killer_ && voice->state().event != kVoiceOn &&
utils::isSilent(voice_killer_->buffer, buffer_size_)) {
free_voices_.push_back(voice);
iter = active_voices_.erase(iter);
}
else
iter++;
}
}
示例5: new_voice
void Prog::initial_config()
{
Voice *voice = new_voice();
if (!voice) {
abort_example("Could not create initial voice.\n");
}
voice->set_pos(300, 50);
Mixer *mixer = new_mixer();
mixer->set_pos(300, 150);
voice->attach(mixer);
SampleInstance *splinst = new_sample_instance();
splinst->set_pos(220, 300);
mixer->attach(splinst);
splinst->toggle_playing();
SampleInstance *splinst2 = new_sample_instance();
splinst2->set_pos(120, 240);
mixer->attach(splinst2);
splinst2->toggle_playing();
Mixer *mixer2 = new_mixer();
mixer2->set_pos(500, 250);
mixer->attach(mixer2);
Audiostream *stream;
if ((stream = new_audiostream())) {
stream->set_pos(450, 350);
mixer2->attach(stream);
}
}
示例6: Release
void AudioThread::ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity) {
Voice* pVoice = ActiveVoices[MIDIKey];
if (pVoice) {
pVoice->Kill(); //TODO: for now we're rude and just kill the poor, poor voice immediately :), later we add a Release() method to the Voice class and call it here to let the voice go through it's release phase
ActiveVoices[MIDIKey] = NULL;
}
else std::cerr << "Couldn't find active voice for note off command!" << std::endl << std::flush;
}
示例7: allNotesOff
void Zerberus::allNotesOff(int channel)
{
busy = true;
for (Voice* v = activeVoices; v; v = v->next()) {
if (channel == -1 || (v->channel()->idx() == channel))
v->stop();
}
busy = false;
}
示例8: sustainOff
void VoiceHandler::sustainOff() {
sustain_ = false;
std::list<Voice*>::iterator iter = sustained_voices_.begin();
for (; iter != sustained_voices_.end(); ++iter) {
Voice* voice = *iter;
voice->deactivate();
}
sustained_voices_.clear();
}
示例9: setOscillatorPitchMod
static void setOscillatorPitchMod(Voice& voice, int oscillatorNumber, double amount) {
switch (oscillatorNumber) {
case 1:
voice.setOscillatorOnePitchAmount(amount);
break;
case 2:
voice.setOscillatorTwoPitchAmount(amount);
break;
}
}
示例10: findFreeVoice
void VoiceManager::onNoteOn(int noteNumber, int velocity) {
Voice* voice = findFreeVoice();
if (!voice) {
return;
}
voice->reset();
voice->setNoteNumber(noteNumber);
voice->mVelocity = velocity;
voice->isActive = true;
voice->mVolumeEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK);
voice->mFilterEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK);
}
示例11: Voice
Voice *Prog::new_voice()
{
Voice *voice = new Voice();
if (voice->valid()) {
elements.push_back(voice);
}
else {
delete voice;
voice = NULL;
}
return voice;
}
示例12: playNote
void playNote(int note) {
Voice* best = &voices[0];
double busy = best->getBusiness();
for (Voice& v : voices) {
double b = v.getBusiness();
if (b < busy) {
busy = b;
best = &v;
}
}
best->play(note);
}
示例13: MOPO_ASSERT
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;
}
示例14: MidiNote
void mi::MidiNote(int const channel, int const value, int const velocity)
{
Voice * v;
if(velocity > 0)
{
v = voice_manager->GetVoice();
v->SetMidiNote(value);
voice_manager->TriggerNewVoice(helper::midinote_to_buzz(value), filter_freq, v);
}
if(velocity == 0)
{
voice_manager->InitiateReleaseForMidiNote(value);
}
}
示例15: while
void Zerberus::process(unsigned frames, float* p, float*, float*)
{
if (busy)
return;
while (!midiEvents.empty())
process(midiEvents.pop());
Voice* v = activeVoices;
Voice* pv = 0;
int n = 0;
int nn = 0;
while (v) {
++nn;
v->process(frames, p);
if (v->isOff()) {
if (pv)
pv->setNext(v->next());
else
activeVoices = v->next();
++n;
freeVoices.push(v);
}
else
pv = v;
v = v->next();
}
}