本文整理汇总了C++中MidiEvent::type方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiEvent::type方法的具体用法?C++ MidiEvent::type怎么用?C++ MidiEvent::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiEvent
的用法示例。
在下文中一共展示了MidiEvent::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void Zerberus::process(const MidiEvent& event)
{
if (busy)
return;
Channel* cp = _channel[int(event.channel())];
if (cp->instrument() == 0) {
// printf("Zerberus::process(): no instrument for channel %d\n", event.channel());
return;
}
switch(event.type()) {
case MidiEventType::NOTEOFF:
processNoteOff(cp, event.dataA());
break;
case MidiEventType::NOTEON: {
int key = event.dataA();
int vel = event.dataB();
if (vel)
processNoteOn(cp, key, vel);
else
processNoteOff(cp, key);
}
break;
case MidiEventType::CONTROLLER:
cp->controller(event.dataA(), event.dataB());
break;
default:
printf("event type 0x%02x\n", event.type());
break;
}
}
示例2: processInEvent
void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time )
{
// mask event
if( isInputEnabled() &&
( inputChannel() == 0 || inputChannel()-1 == event.channel() ) )
{
MidiEvent inEvent = event;
if( event.type() == MidiNoteOn ||
event.type() == MidiNoteOff ||
event.type() == MidiKeyPressure )
{
if( inEvent.key() < 0 || inEvent.key() >= NumKeys )
{
return;
}
}
if( fixedInputVelocity() >= 0 && inEvent.velocity() > 0 )
{
inEvent.setVelocity( fixedInputVelocity() );
}
m_midiEventProcessor->processInEvent( inEvent, time );
}
}
示例3: processOutEvent
void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time )
{
// mask event
if( isOutputEnabled() && realOutputChannel() == event.channel() )
{
MidiEvent outEvent = event;
if( fixedOutputVelocity() >= 0 && event.velocity() > 0 &&
( event.type() == MidiNoteOn || event.type() == MidiKeyPressure ) )
{
outEvent.setVelocity( fixedOutputVelocity() );
}
m_midiClient->processOutEvent( outEvent, time, this );
}
}
示例4: handleMidiEvent
bool ZynAddSubFxInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
{
// do not forward external MIDI Control Change events if the according
// LED is not checked
if( event.type() == MidiControlChange &&
event.sourcePort() != this &&
m_forwardMidiCcModel.value() == false )
{
return true;
}
MidiEvent localEvent = event;
localEvent.setChannel( 0 );
m_pluginMutex.lock();
if( m_remotePlugin )
{
m_remotePlugin->processMidiEvent( localEvent, 0 );
}
else
{
m_plugin->processMidiEvent( localEvent );
}
m_pluginMutex.unlock();
return true;
}
示例5: processOutEvent
void MidiWinMM::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port )
{
const DWORD shortMsg = ( event.type() + event.channel() ) +
( ( event.param( 0 ) & 0xff ) << 8 ) +
( ( event.param( 1 ) & 0xff ) << 16 );
QStringList outDevs;
for( SubMap::ConstIterator it = m_outputSubs.begin(); it != m_outputSubs.end(); ++it )
{
for( MidiPortList::ConstIterator jt = it.value().begin(); jt != it.value().end(); ++jt )
{
if( *jt == port )
{
outDevs += it.key();
break;
}
}
}
for( QMap<HMIDIOUT, QString>::Iterator it = m_outputDevices.begin(); it != m_outputDevices.end(); ++it )
{
if( outDevs.contains( *it ) )
{
midiOutShortMsg( it.key(), shortMsg );
}
}
}
示例6: writeEvent
void MidiFile::writeEvent(const MidiEvent& event)
{
switch(event.type()) {
case ME_NOTEON:
writeStatus(ME_NOTEON, event.channel());
put(event.pitch());
put(event.velo());
break;
case ME_NOTEOFF:
writeStatus(ME_NOTEOFF, event.channel());
put(event.pitch());
put(event.velo());
break;
case ME_CONTROLLER:
switch(event.controller()) {
case CTRL_PROGRAM:
writeStatus(ME_PROGRAM, event.channel());
put(event.value() & 0x7f);
break;
case CTRL_PITCH:
{
writeStatus(ME_PITCHBEND, event.channel());
int v = event.value() + 8192;
put(v & 0x7f);
put((v >> 7) & 0x7f);
}
break;
case CTRL_PRESS:
writeStatus(ME_AFTERTOUCH, event.channel());
put(event.value() & 0x7f);
break;
default:
writeStatus(ME_CONTROLLER, event.channel());
put(event.controller());
put(event.value() & 0x7f);
break;
}
break;
case ME_META:
put(ME_META);
put(event.metaType());
putvl(event.len());
write(event.edata(), event.len());
resetRunningStatus(); // really ?!
break;
case ME_SYSEX:
put(ME_SYSEX);
putvl(event.len() + 1); // including 0xf7
write(event.edata(), event.len());
put(ME_ENDSYSEX);
resetRunningStatus();
break;
}
}
示例7: createMidiPacketList
MIDIPacketList MidiApple::createMidiPacketList( const MidiEvent& event )
{
MIDIPacketList packetList;
packetList.numPackets = 1;
MIDIPacket* firstPacket = &packetList.packet[0];
firstPacket->timeStamp = 0; // send immediately
firstPacket->length = 3;
firstPacket->data[0] = ( event.type() + event.channel() );
firstPacket->data[1] = ( event.param( 0 ) & 0xff );
firstPacket->data[2] = ( event.param( 1 ) & 0xff );
return packetList;
}
示例8: processMidiEvent
void RemotePlugin::processMidiEvent( const MidiEvent & _e,
const f_cnt_t _offset )
{
message m( IdMidiEvent );
m.addInt( _e.type() );
m.addInt( _e.channel() );
m.addInt( _e.param( 0 ) );
m.addInt( _e.param( 1 ) );
m.addInt( _offset );
lock();
sendMessage( m );
unlock();
}
示例9: processOutEvent
void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
{
// do nothing if we do not have an instrument instance (e.g. when loading settings)
if( m_instrument == NULL )
{
return;
}
const MidiEvent transposedEvent = applyMasterKey( event );
const int key = transposedEvent.key();
switch( event.type() )
{
case MidiNoteOn:
m_midiNotesMutex.lock();
m_piano.setKeyState( event.key(), true ); // event.key() = original key
if( key >= 0 && key < NumKeys )
{
if( m_runningMidiNotes[key] > 0 )
{
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time, offset );
}
++m_runningMidiNotes[key];
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOn, midiPort()->realOutputChannel(), key, event.velocity() ), time, offset );
}
m_midiNotesMutex.unlock();
emit newNote();
break;
case MidiNoteOff:
m_midiNotesMutex.lock();
m_piano.setKeyState( event.key(), false ); // event.key() = original key
if( key >= 0 && key < NumKeys && --m_runningMidiNotes[key] <= 0 )
{
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), key, 0 ), time, offset );
}
m_midiNotesMutex.unlock();
break;
default:
m_instrument->handleMidiEvent( transposedEvent, time, offset );
break;
}
// if appropriate, midi-port does futher routing
m_midiPort.processOutEvent( event, time );
}
示例10: applyMasterKey
MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event )
{
MidiEvent copy( event );
switch( event.type() )
{
case MidiNoteOn:
case MidiNoteOff:
case MidiKeyPressure:
copy.setKey( masterKey( event.key() ) );
break;
default:
break;
}
return copy;
}
示例11: processMidiEvent
void LocalZynAddSubFx::processMidiEvent( const MidiEvent& event )
{
// all functions are called while m_master->mutex is held
static NULLMidiIn midiIn;
switch( event.type() )
{
case MidiNoteOn:
if( event.velocity() > 0 )
{
if( event.key() <= 0 || event.key() >= 128 )
{
break;
}
if( m_runningNotes[event.key()] > 0 )
{
m_master->NoteOff( event.channel(), event.key() );
}
++m_runningNotes[event.key()];
m_master->NoteOn( event.channel(), event.key(), event.velocity() );
break;
}
case MidiNoteOff:
if( event.key() <= 0 || event.key() >= 128 )
{
break;
}
if( --m_runningNotes[event.key()] <= 0 )
{
m_master->NoteOff( event.channel(), event.key() );
}
break;
case MidiPitchBend:
m_master->SetController( event.channel(), C_pitchwheel, event.pitchBend()-8192 );
break;
case MidiControlChange:
m_master->SetController( event.channel(), midiIn.getcontroller( event.controllerNumber() ), event.controllerValue() );
break;
default:
break;
}
}
示例12: processMidiEvent
void LocalZynAddSubFx::processMidiEvent( const MidiEvent& event )
{
switch( event.type() )
{
case MidiNoteOn:
if( event.velocity() > 0 )
{
if( event.key() < 0 || event.key() > MidiMaxKey )
{
break;
}
if( m_runningNotes[event.key()] > 0 )
{
m_master->noteOff( event.channel(), event.key() );
}
++m_runningNotes[event.key()];
m_master->noteOn( event.channel(), event.key(), event.velocity() );
break;
}
case MidiNoteOff:
if( event.key() < 0 || event.key() > MidiMaxKey )
{
break;
}
if( --m_runningNotes[event.key()] <= 0 )
{
m_master->noteOff( event.channel(), event.key() );
}
break;
case MidiPitchBend:
m_master->setController( event.channel(), C_pitchwheel, event.pitchBend()-8192 );
break;
case MidiControlChange:
m_master->setController( event.channel(), event.controllerNumber(), event.controllerValue() );
break;
default:
break;
}
}
示例13: readTrack
bool MidiFile::readTrack()
{
char tmp[4];
read(tmp, 4);
if (memcmp(tmp, "MTrk", 4))
throw(QString("bad midifile: MTrk expected"));
int len = readLong(); // len
qint64 endPos = curPos + len;
status = -1;
sstatus = -1; // running status, will not be reset on meta or sysex
click = 0;
_tracks.push_back(MidiTrack());
int port = 0;
_tracks.back().setOutPort(port);
_tracks.back().setOutChannel(-1);
for (;;) {
MidiEvent event;
if (!readEvent(&event))
return true;
// check for end of track:
if ((event.type() == ME_META) && (event.metaType() == META_EOT))
break;
_tracks.back().insert(click, event);
}
if (curPos != endPos) {
qWarning("bad track len: %lld != %lld, %lld bytes too much\n", endPos, curPos, endPos - curPos);
if (curPos < endPos) {
qWarning(" skip %lld\n", endPos-curPos);
skip(endPos - curPos);
}
}
return false;
}
示例14: processInEvent
void MidiController::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
{
unsigned char controllerNum;
switch( event.type() )
{
case MidiControlChange:
controllerNum = event.controllerNumber();
if( m_midiPort.inputController() == controllerNum + 1 &&
( m_midiPort.inputChannel() == event.channel() + 1 ||
m_midiPort.inputChannel() == 0 ) )
{
unsigned char val = event.controllerValue();
m_previousValue = m_lastValue;
m_lastValue = (float)( val ) / 127.0f;
emit valueChanged();
}
break;
default:
// Don't care - maybe add special cases for pitch and mod later
break;
}
}
示例15: isLyricEvent
bool isLyricEvent(const MidiEvent &e)
{
return e.type() == ME_META && (e.metaType() == META_TEXT
|| e.metaType() == META_LYRIC);
}