当前位置: 首页>>代码示例>>C++>>正文


C++ MidiEvent类代码示例

本文整理汇总了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)++;
			}
		}
	}
}
开发者ID:AskBre,项目名称:fugueSampler,代码行数:34,代码来源:FugueSampler.cpp

示例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);
	}
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:27,代码来源:MidiTrack.cpp

示例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;
}
开发者ID:JoseCM,项目名称:MIdi-Box,代码行数:27,代码来源:FILE_IO.cpp

示例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 );
		}
	}
}
开发者ID:CallisteHanriat,项目名称:lmms,代码行数:27,代码来源:MidiWinMM.cpp

示例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;
}
开发者ID:0n0dera,项目名称:AudioToSheetMusic,代码行数:31,代码来源:midicat.cpp

示例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;
}
开发者ID:0n0dera,项目名称:AudioToSheetMusic,代码行数:26,代码来源:midi2binasc.cpp

示例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;
}
开发者ID:RebeccaDeField,项目名称:lmms,代码行数:26,代码来源:ZynAddSubFx.cpp

示例8: unlinkEvent

void MidiEvent::unlinkEvent(void) {
	if (m_eventlink == NULL) {
		return;
	}
	MidiEvent* mev = m_eventlink;
	m_eventlink = NULL;
	mev->unlinkEvent();
}
开发者ID:rettinghaus,项目名称:verovio,代码行数:8,代码来源:MidiEvent.cpp

示例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));
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:9,代码来源:MidiTrack.cpp

示例10: getLengthInTicks

long MidiTrack::getLengthInTicks() {
	if (mEvents.size() == 0) {
		return 0;
	}

	// get the last note
	MidiEvent * E = *(--mEvents.end());
	return E->getTick();
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:9,代码来源:MidiTrack.cpp

示例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 );
}
开发者ID:CallisteHanriat,项目名称:lmms,代码行数:9,代码来源:MidiWinMM.cpp

示例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 );
}
开发者ID:AmeliaDeField,项目名称:lmms-test,代码行数:10,代码来源:MidiAlsaSeq.cpp

示例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;
   }

}
开发者ID:craigsapp,项目名称:improv,代码行数:54,代码来源:midiperform.cpp

示例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;
}
开发者ID:DeRobyJ,项目名称:lmms,代码行数:12,代码来源:MidiApple.cpp

示例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();
}
开发者ID:Lukas-W,项目名称:lmms,代码行数:13,代码来源:RemotePlugin.cpp


注:本文中的MidiEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。