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


C++ RtMidiIn::getMessage方法代码示例

本文整理汇总了C++中RtMidiIn::getMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ RtMidiIn::getMessage方法的具体用法?C++ RtMidiIn::getMessage怎么用?C++ RtMidiIn::getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RtMidiIn的用法示例。


在下文中一共展示了RtMidiIn::getMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: midiInfo

void midiInfo()
{
    cout << "MIDI INFO port = " << portopt << endl;

    std::vector<unsigned char> message;
    double stamp;
    int nBytes;
    int i;

#ifdef MARSYAS_MIDIIO  
    RtMidiIn *midiin = NULL;  
    try {
        midiin = new RtMidiIn();
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);
    }


    try {
        midiin->openPort(portopt);
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);

    }

    // Don't ignore sysex, timing, or active sensing messages.
    midiin->ignoreTypes( false, false, false ); 


    while(1) 

    {  

        stamp = midiin->getMessage( &message );
        nBytes = message.size();
        if (nBytes >0)
        {

            for ( i=0; i<nBytes; i++ )
                std::cout << "Byte " << i << " = " << (int)message[i] << ", ";
            if ( nBytes > 0 )
                std::cout << "stamp = " << stamp << '\n';
        }

        usleep(10);

    }

#endif

}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:55,代码来源:midiTest.cpp

示例2: rtmidi_in_getmessage

value rtmidi_in_getmessage(value obj) {
  RtMidiIn *midiin = (RtMidiIn *)(intptr_t)val_float(obj);
  std::vector<unsigned char> message;
  double stamp = midiin->getMessage(&message);
  // ignore stamp for now
  value ret = alloc_array(message.size());
  for (int i = 0; i < message.size(); ++i) {
    val_array_set_i(ret, i, alloc_int(message[i]));
  }
  return ret;
}
开发者ID:fserb,项目名称:RTMidi,代码行数:11,代码来源:ExternalInterface.cpp

示例3: if

void *MIDIReadThread(FREContext ctx)
{
	printf("MIDI Start read thread\n");
	std::vector<unsigned char> message;
	int nBytes;
	double stamp;

	while(!exitRunThread)
	{
		//printf("Check thread, %i devices\n",openMidiIn.size());
		for(unsigned int di=0;di<openMidiIn.size();di++)
		{
			
			RtMidiIn * in = openMidiIn[di];

			while(true)
			{
				stamp = in->getMessage(&message );
				nBytes = message.size();

				if(nBytes == 3) //complete midi message
				{
			
					midiMessage m;
					m.device = in;
					m.stamp = stamp;
					m.status = message[0];
					//printf("Status %i from %i\n",m.status,in);
					m.data1 = message[1];
					m.data2 = message[2];

					messageQueue.push_back(m);

					FREDispatchStatusEventAsync(ctx,(const uint8_t *)"data",(const uint8_t *)"none");
					
				}else if(nBytes == 0) break;
			}

		}

		// Sleep for 10 milliseconds ... platform-dependent.
		Sleep( 1 );
	   //FREDispatchStatusEventAsync(ctx,(const uint8_t *)"data",(const uint8_t *)"myo");
	}

	printf("Exit Run Thread !\n");

	return 0;
}
开发者ID:benkuper,项目名称:AIR-NativeExtensions,代码行数:49,代码来源:NativeMIDI.cpp

示例4: rtmidi_in_get_message

double rtmidi_in_get_message (RtMidiInPtr device, 
                              unsigned char *message,
                              size_t *size)
{
#if defined(__NO_EXCEPTIONS__)
    // FIXME: use allocator to achieve efficient buffering
    std::vector<unsigned char> v;
    RtMidiIn* rtm = (RtMidiIn*) device->ptr;
    rtm->resetError();
    double ret = rtm->getMessage (&v);
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return -1;
    }

    if (v.size () > 0 && v.size() <= *size) {
        memcpy (message, v.data (), (int) v.size ());
    }

    *size = v.size();
    return ret;
#else
    try {
        // FIXME: use allocator to achieve efficient buffering
        std::vector<unsigned char> v;
        double ret = ((RtMidiIn*) device->ptr)->getMessage (&v);

        if (v.size () > 0 && v.size() <= *size) {
            memcpy (message, v.data (), (int) v.size ());
        }

        *size = v.size();
        return ret;
    } 
    catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
        return -1;
    }
    catch (...) {
        device->ok  = false;
        device->msg = "Unknown error";
        return -1;
    }
#endif
}
开发者ID:jwurzer,项目名称:rtmidi,代码行数:47,代码来源:rtmidi_c.cpp

示例5: while

    /* returns 0 if no new messages, otherwise populates message */
    int
    get_midi_message(MidiMsg *message)
    {
        std::vector<unsigned char> rtmsg;

        while(true) {
            midi.getMessage(&rtmsg);
            if(rtmsg.size() == 0)
                return 0;

            int type = (rtmsg[0] & 0xf0) >> 4;

            message->control = 0;
            message->pitch_bend = 0;

            if(type == MIDI_NOTE_OFF || (type == MIDI_NOTE_ON && rtmsg[2] == 0)) {
                message->velocity = 0;

            } else if(type == MIDI_NOTE_ON) {
                message->velocity = rtmsg[2] / 127.0;

            } else if(type == MIDI_KEY_PRESSURE) {
                message->velocity = rtmsg[2] / 127.0;

            } else if(type == MIDI_CONTROL) {
                message->control = 1;
                message->velocity = rtmsg[2] / 127.0;

            } else if(type == MIDI_PITCH_BEND) {
                message->pitch_bend = 1;
                message->velocity = rtmsg[2] / 127.0;

            } else {
                printf("unknown: %d size %ld [%d %d %d]\n", type, rtmsg.size(), rtmsg[0], rtmsg[1], rtmsg[2]);
                continue; // unrecognized
            }

            message->channel = rtmsg[0] & 0x0f;
            message->note = rtmsg[1];

            return 1;
        }
    }
开发者ID:alltom,项目名称:ckv,代码行数:44,代码来源:rtmidi_wrapper.cpp

示例6: rtMidiIn_getData

static VALUE rtMidiIn_getData(VALUE self)
{
	RtMidiIn *device;
	Data_Get_Struct(self, RtMidiIn, device);

	std::vector<unsigned char> message;
	VALUE messages = rb_ary_new();
	try {
		double stamp = device->getMessage(&message);
		for(int x = 0; x < message.size(); x++)
		{
			rb_ary_push(messages, INT2FIX((int)message[x]));
		}
	}
	catch(RtError &error)
	{
		rb_warn("getData failed");
	}
	
	return messages;
}
开发者ID:yiyi,项目名称:dmxLib,代码行数:21,代码来源:rtMidiWrapper.cpp

示例7: run

void MidiListener::run() {

	vector<unsigned char> message;
	int nBytes;
	double stamp;
	RtMidiIn *midiIn =  tmidi_data->midiIn;

	int this_patch_num;

	if ( tmidi_data->verboseMode ) cout << "MidiListener thread running\n";

	// Install an interrupt handler function
	//(void) signal(SIGINT, finish);

	while ( true ) {

		stamp = midiIn->getMessage( &message );
		nBytes = message.size();

		if ( nBytes > 0 ) {

			if ( message[0] == MIDI_SYSEX_HEADER ) {
              // if ( tmidi_data->verboseMode ) cout << "MidiListener: SysEx response received " << nBytes << " bytes\n";
              switch (message[4]) {
                case MIDI_PRESET_DUMP:            
				  if ( tmidi_data->verboseMode ) cout << "MidiListener: SysEx Preset Dump response received " << nBytes << " bytes\n";

				  patch_t this_patch;

                  if (nBytes != EWI_SYSEX_PRESET_DUMP_LEN) {
                    cout << "Invalid Preset Dump received from EWI (" << nBytes << " bytes)\n";
                    break;
                  }
                  
				  for ( int i = 0; i < EWI_PATCH_LENGTH; i++ ) this_patch.whole_patch[i] = message[i];

                  if ( this_patch.parameters.header[3] == MIDI_SYSEX_ALLCHANNELS ) {
					  this_patch_num = ( int ) this_patch.parameters.patch_num++;
                      if (this_patch_num < 0 || this_patch_num >= EWI_NUM_PATCHES) {
                        cout << "Illegal patch number recieved from EWI - " << this_patch_num << "\n";
                        break;                  
                      }               
					  for ( int i = 0; i < EWI_PATCH_LENGTH; i++ ) tmidi_data->patches[this_patch_num].whole_patch[i] = message[i];
					  tmidi_data->last_patch_loaded = this_patch_num;

					  if ( tmidi_data->verboseMode ) cout << "MidiListener: Received " << this_patch_num + 1 << " - " << this_patch.parameters.name << "\n";
				  }
                  break;
                case MIDI_QUICKPC_DUMP:
                  if ( tmidi_data->verboseMode ) cout << "MidiListener: SysEx QuickPC Dump response received " << nBytes << " bytes\n";
                  if (nBytes != EWI_SYSEX_QUICKPC_DUMP_LEN) {
                    cout << "Invalid QuickPC Dump received from EWI (" << nBytes << " bytes)\n";
                    break;
                  }
                  for (int i = 0; i < EWI_NUM_QUICKPCS; i++) {
                    tmidi_data->quickPCs[i] = message[i+6];
                  }
                  break;
                default:
                   cerr << "MidiListener: Unrecognised SysEx type received (type " << message[4] <<")\n";
                  break;
              }            
			  tmidi_data->mymutex.lock();
              tmidi_data->sysexDone.wakeAll();
			  tmidi_data->mymutex.unlock();
              
            }
              // All non-SysEx messages are ignored
		}

		SLEEP( 10 );
	}
}
开发者ID:admiyo,项目名称:ewitool,代码行数:73,代码来源:midilistener.cpp

示例8: main

int main( int argc, char *argv[] )
{
  RtMidiIn *midiin = 0;
  std::vector<unsigned char> message;
  int nBytes, i;
  double stamp;

  // Minimal command-line check.
  if ( argc > 2 ) usage();

  // RtMidiIn constructor
  try {
    midiin = new RtMidiIn();
  }
  catch ( RtError &error ) {
    error.printMessage();
    exit( EXIT_FAILURE );
  }

  // Check available ports vs. specified.
  unsigned int port = 0;
  unsigned int nPorts = midiin->getPortCount();
  if ( argc == 2 ) port = (unsigned int) atoi( argv[1] );
  if ( port >= nPorts ) {
    delete midiin;
    std::cout << "Invalid port specifier!\n";
    usage();
  }

  try {
    midiin->openPort( port );
  }
  catch ( RtError &error ) {
    error.printMessage();
    goto cleanup;
  }

  // Don't ignore sysex, timing, or active sensing messages.
  midiin->ignoreTypes( false, false, false );

  // Install an interrupt handler function.
  done = false;
  (void) signal(SIGINT, finish);

  // Periodically check input queue.
  std::cout << "Reading MIDI from port ... quit with Ctrl-C.\n";
  while ( !done ) {
    stamp = midiin->getMessage( &message );
    nBytes = message.size();
    for ( i=0; i<nBytes; i++ )
      std::cout << "Byte " << i << " = " << (int)message[i] << ", ";
    if ( nBytes > 0 )
      std::cout << "stamp = " << stamp << std::endl;

    // Sleep for 10 milliseconds.
    SLEEP( 10 );
  }

  // Clean up
 cleanup:
  delete midiin;

  return 0;
}
开发者ID:AlanStones,项目名称:IanniX,代码行数:64,代码来源:qmidiin.cpp

示例9: PluckLive

//Pluck Karplus Strong Model Plucked.cpp outputs to DAC
void PluckLive(string deviceopt, mrs_real pos, mrs_real fre, mrs_real loz, mrs_real stret)
{



#ifdef MARSYAS_MIDIIO  
    RtMidiIn *midiin = 0;
    std::vector<unsigned char> message;
    double stamp;
    int nBytes;
    int i;

    // initialize RtMidi
    try {
        midiin = new RtMidiIn();
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);
    }

    // find input midi port 
    try {
        midiin->openPort(portopt);
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);

    }
    MarSystemManager mng;
    MarSystem* series = mng.create("Series", "series");


    // create 16 plucked Karplus-Strong strings
    MarSystem* mix  = mng.create("Fanout", "mix");
    for (mrs_natural i = 0; i < 16; i++) 
    {
        ostringstream oss;
        oss << "src" << i;
        mix->addMarSystem(mng.create("Plucked", oss.str()));  
    }

    series->addMarSystem(mix);
    series->addMarSystem(mng.create("Sum", "sum"));
    series->addMarSystem(mng.create("Gain", "gain"));
    series->addMarSystem(mng.create("AudioSink", "dest"));
    series->update();


    series->updctrl("Gain/gain/mrs_real/gain", 0.10);
    series->updctrl("AudioSink/dest/mrs_real/israte", 
					series->getctrl("Fanout/mix/Plucked/src0/mrs_real/osrate"));

    series->updctrl("AudioSink/dest/mrs_natural/bufferSize", 128); 
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/frequency",fre);
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/pluckpos",pos);
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/loss",loz);
    series->updctrl("mrs_natural/inSamples", 64);
    series->update();


    // initially only play one string 
    for (int i=1; i < 16; i++)
    {
        ostringstream oss1;
        oss1 << "Fanout/mix/Plucked/src" 
			 << i << "/mrs_real/nton";
        series->updctrl(oss1.str(), 0.0);      
    }



    mrs_natural t=0;

    int channel, type, byte2, byte3;
    int mes_count = 0;
    mrs_real freq;
    int p0byte3, p1byte3, p2byte3;


    // used to keep track of polyphony
    vector<int> voices;
    for (int i=0; i < 16; i++) 
    {
        voices.push_back(0);
    }




    while(1)
    {

        // for (int i=0; i < 4; i++)
        // {
        stamp = midiin->getMessage( &message );
        // }

//.........这里部分代码省略.........
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:101,代码来源:midiTest.cpp


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