本文整理汇总了C++中MidiEvent::program方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiEvent::program方法的具体用法?C++ MidiEvent::program怎么用?C++ MidiEvent::program使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiEvent
的用法示例。
在下文中一共展示了MidiEvent::program方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processOutEvent
void MidiAlsaSeq::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port )
{
// HACK!!! - need a better solution which isn't that easy since we
// cannot store const-ptrs in our map because we need to call non-const
// methods of MIDI-port - it's a mess...
MidiPort* p = const_cast<MidiPort *>( port );
snd_seq_event_t ev;
snd_seq_ev_clear( &ev );
snd_seq_ev_set_source( &ev, ( m_portIDs[p][1] != -1 ) ?
m_portIDs[p][1] : m_portIDs[p][0] );
snd_seq_ev_set_subs( &ev );
snd_seq_ev_schedule_tick( &ev, m_queueID, 1, static_cast<int>( time ) );
ev.queue = m_queueID;
switch( event.type() )
{
case MidiNoteOn:
snd_seq_ev_set_noteon( &ev,
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiNoteOff:
snd_seq_ev_set_noteoff( &ev,
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiKeyPressure:
snd_seq_ev_set_keypress( &ev,
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiControlChange:
snd_seq_ev_set_controller( &ev,
event.channel(),
event.controllerNumber(),
event.controllerValue() );
break;
case MidiProgramChange:
snd_seq_ev_set_pgmchange( &ev,
event.channel(),
event.program() );
break;
case MidiChannelPressure:
snd_seq_ev_set_chanpress( &ev,
event.channel(),
event.channelPressure() );
break;
case MidiPitchBend:
snd_seq_ev_set_pitchbend( &ev,
event.channel(),
event.param( 0 ) - 8192 );
break;
default:
qWarning( "MidiAlsaSeq: unhandled output event %d\n", (int) event.type() );
return;
}
m_seqMutex.lock();
snd_seq_event_output( m_seqHandle, &ev );
snd_seq_drain_output( m_seqHandle );
m_seqMutex.unlock();
}
示例2: handleMidiEvent
bool CarlaInstrument::handleMidiEvent(const MidiEvent& event, const MidiTime&, f_cnt_t offset)
{
const QMutexLocker ml(&fMutex);
if (fMidiEventCount >= kMaxMidiEvents)
return false;
NativeMidiEvent& nEvent(fMidiEvents[fMidiEventCount++]);
std::memset(&nEvent, 0, sizeof(NativeMidiEvent));
nEvent.port = 0;
nEvent.time = offset;
nEvent.data[0] = event.type() | (event.channel() & 0x0F);
switch (event.type())
{
case MidiNoteOn:
if (event.velocity() > 0)
{
if (event.key() < 0 || event.key() > MidiMaxKey)
break;
nEvent.data[1] = event.key();
nEvent.data[2] = event.velocity();
nEvent.size = 3;
break;
}
else
{
nEvent.data[0] = MidiNoteOff | (event.channel() & 0x0F);
// nobreak
}
case MidiNoteOff:
if (event.key() < 0 || event.key() > MidiMaxKey)
break;
nEvent.data[1] = event.key();
nEvent.data[2] = event.velocity();
nEvent.size = 3;
break;
case MidiKeyPressure:
nEvent.data[1] = event.key();
nEvent.data[2] = event.velocity();
nEvent.size = 3;
break;
case MidiControlChange:
nEvent.data[1] = event.controllerNumber();
nEvent.data[2] = event.controllerValue();
nEvent.size = 3;
break;
case MidiProgramChange:
nEvent.data[1] = event.program();
nEvent.size = 2;
break;
case MidiChannelPressure:
nEvent.data[1] = event.channelPressure();
nEvent.size = 2;
break;
case MidiPitchBend:
nEvent.data[1] = event.pitchBend() & 0x7f;
nEvent.data[2] = event.pitchBend() >> 7;
nEvent.size = 3;
break;
default:
// unhandled
--fMidiEventCount;
break;
}
return true;
}