本文整理汇总了C++中MidiEvent类的典型用法代码示例。如果您正苦于以下问题:C++ MidiEvent类的具体用法?C++ MidiEvent怎么用?C++ MidiEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MidiEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void FugueSampler::update(unsigned long long tick) {
for(unsigned track=0; track < nTracks; track++) {
unsigned index = indices.at(track);
if(file.getEventCount(track) > index) {
if(file[track][index].isNoteOn()) {
MidiEvent event = file.getEvent(track, index);
float duration = file[track][index].getDurationInSeconds();
if(event.tick < tick) {
const char name = event.at(1);
if(sampler.isRecorded(name)) {
sampler.play(name, duration);
} else {
sampler.record(name);
cout << "REC" << endl;
}
indices.at(track)++;
eventCounter++;
unsigned percent =
(float)eventCounter/(float)nEvents*100;
if(percent!=oldPercent) {
cout << percent << "%" << endl;
}
oldPercent = percent;
}
} else {
indices.at(track)++;
}
}
}
}
示例2: while
void MidiTrack::readTrackData(istream & input)
{
long totalTicks = 0;
while (!input.eof()) {
VariableLengthInt delta(input);
totalTicks += delta.getValue();
MidiEvent * E = MidiEvent::parseEvent(totalTicks, delta.getValue(), input);
if (E == NULL) {
cout << "Event skipped!";
continue;
}
if (VERBOSE) {
cout << E->toString().c_str();
}
// Not adding the EndOfTrack event here allows the track to be edited
// after being read in from file.
if (E->getType() == MetaEvent::END_OF_TRACK) {
break;
}
mEvents.push_back(E);
}
}
示例3: getNextMidiMsg
int FILE_IO::getNextMidiMsg(int channel, int tick)
{
MidiEvent event;
while((event = midiFile.getEvent(0, index)).tick == tick){
//if() continue; //cases to ignore
printf("0\n");
MidiMessage msg;
msg.setSize(event.getSize());
for(int i=0; i < event.getSize(); i++){
msg[i] = event[i];
}
writeInMidiMsg(channel, msg);
index++;
if (index == midiFile.getNumEvents(0)){
resetIndex();
return 0;
}
}
return 1;
}
示例4: 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 );
}
}
}
示例5: main
int main(int argc, char* argv[]) {
checkOptions(options, argc, argv);
MidiFile outfile;
outfile.joinTracks();
outfile.deltaTicks();
int i;
int initQ = 0;
for (i=1; i<=options.getArgCount(); i++) {
appendMidi(outfile, options.getArg(i).data(), seconds, initQ++);
}
// insert an end-of track Meta Event
int tpq = outfile.getTicksPerQuarterNote();
MidiEvent mfevent;
mfevent.tick = tpq;
mfevent.track = 0;
mfevent.resize(3);
mfevent[0] = 0xff;
mfevent[1] = 0x2f;
mfevent[2] = 0;
outfile.addEvent(mfevent);
if (binaryQ) {
outfile.write(cout);
} else {
cout << outfile;
}
return 0;
}
示例6: printMidiEvent
void printMidiEvent(MidiEvent& event) {
// print the time:
cout << "v" << event.tick << "\t";
// print the command byte in hex format (two digits):
int commandbyte = event[0];
printHexByte(commandbyte);
int i;
switch (commandbyte & 0xf0) {
case 0x90:
case 0x80:
for (i=1; i<(int)event.size(); i++) {
cout << " ";
printDecByte(event[i]);
}
break;
default:
for (i=1; i<(int)event.size(); i++) {
cout << " ";
printHexByte(event[i]);
}
}
cout << endl;
}
示例7: 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;
}
示例8: unlinkEvent
void MidiEvent::unlinkEvent(void) {
if (m_eventlink == NULL) {
return;
}
MidiEvent* mev = m_eventlink;
m_eventlink = NULL;
mev->unlinkEvent();
}
示例9: closeTrack
void MidiTrack::closeTrack() {
long lastTick = 0;
if (mEvents.size() > 0) {
MidiEvent * last = *(--mEvents.end());
lastTick = last->getTick() + 1;
}
insertEvent(new EndOfTrack(lastTick, 0));
}
示例10: getLengthInTicks
long MidiTrack::getLengthInTicks() {
if (mEvents.size() == 0) {
return 0;
}
// get the last note
MidiEvent * E = *(--mEvents.end());
return E->getTick();
}
示例11: sourcePortName
QString MidiWinMM::sourcePortName( const MidiEvent& event ) const
{
if( event.sourcePort() )
{
return m_inputDevices.value( *static_cast<const HMIDIIN *>( event.sourcePort() ) );
}
return MidiClient::sourcePortName( event );
}
示例12: sourcePortName
QString MidiAlsaSeq::sourcePortName( const MidiEvent & _event ) const
{
if( _event.sourcePort() )
{
const snd_seq_addr_t * addr =
static_cast<const snd_seq_addr_t *>( _event.sourcePort() );
return __portName( m_seqHandle, addr );
}
return MidiClient::sourcePortName( _event );
}
示例13: processMidiCommand
void processMidiCommand(MidiEvent& message) {
if (message.getP0() != 0x90 || message.getP2() == 0) {
return;
}
switch (message.getP1()) {
case 60: // Middle C = beat
keyboardCommand(' ');
break;
case 61: // C# = amplitude control
{
double amp = performance.getAmp();
amp = amp * message.getP2() / 64;
if (amp < 0) {
amp = 0;
} else if (amp > 127) {
amp = 127;
}
performance.setAmp((int)amp);
}
break;
case 71: // B = 1 beat tempo follow
keyboardCommand('1');
break;
case 72: // C = 2 beat tempo follow
keyboardCommand('2');
break;
case 73: // C# = 3 beat tempo follow
keyboardCommand('3');
break;
case 74: // D = 4 beat tempo follow
keyboardCommand('4');
break;
case 79: // G = constant tempo follow
keyboardCommand('9');
break;
case 80: // G# = automatic
keyboardCommand('0');
break;
case 62: // amplitude decrease
keyboardCommand('[');
break;
case 63: // amplitude increase
keyboardCommand(']');
break;
case 64: // tempo decrease
keyboardCommand('-');
break;
case 65: // tempo increase
keyboardCommand('=');
break;
}
}
示例14: 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;
}
示例15: m
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();
}