Esempio n. 1
0
void midi_receive_usb_buffer(uint8_t *buffer, uint16_t length){
  for(int i=1; i<length; ++i){ // skip first of 4 bytes
    if(handler.read(buffer[i]) == ERROR_STATUS){
      handler.clear();
      break;
    }
  }
}
Esempio n. 2
0
static void midiInMessageCallback(double deltatime,
								std::vector< unsigned char > *message,
								void *userData)
{
	MidiHandler *midiHandler = (MidiHandler *) userData;
	midiHandler->passMidiMessage(message);
	//  if (nBytes > 0) {
	//    qDebug() << "stamp = " << deltatime;
	//  }
}
Esempio n. 3
0
void midi_receive_usb_buffer(uint8_t *buffer, uint16_t length){    
  for(int i=1; i<length; ++i){
    // skip every 4th byte
    if(i & 0x3){
      MidiReaderStatus status = handler.read(buffer[i]);
      if(status == ERROR_STATUS){
	handler.clear();
	// todo: error message
	return; // discard the rest of the message
      }
    }
  }
}
Esempio n. 4
0
    MIDI(Section* configuration):Module_base(configuration) {
        Section_prop * section=static_cast<Section_prop *>(configuration);
        const char * dev=section->Get_string("mididevice");
        std::string fullconf=section->Get_string("midiconfig");
        /* If device = "default" go for first handler that works */
        MidiHandler * handler;
//		MAPPER_AddHandler(MIDI_SaveRawEvent,MK_f8,MMOD1|MMOD2,"caprawmidi","Cap MIDI");
        midi.sysex.delay = 0;
        midi.sysex.start = 0;
        if (fullconf.find("delaysysex") != std::string::npos) {
            midi.sysex.start = GetTicks();
            fullconf.erase(fullconf.find("delaysysex"));
            LOG_MSG("MIDI:Using delayed SysEx processing");
        }
        std::remove(fullconf.begin(), fullconf.end(), ' ');
        const char * conf = fullconf.c_str();
        midi.status=0x00;
        midi.cmd_pos=0;
        midi.cmd_len=0;
        if (!strcasecmp(dev,"default")) goto getdefault;
        handler=handler_list;
        while (handler) {
            if (!strcasecmp(dev,handler->GetName())) {
#if defined(__LIBRETRO__) && defined(C_FLUIDSYNTH) // Add Fluidsynth support
                if(!strcasecmp(dev,"synth"))    // synth device, get sample rate from config
                    synthsamplerate=section->Get_int("samplerate");
#endif
                if (!handler->Open(conf)) {
                    LOG_MSG("MIDI:Can't open device:%s with config:%s.",dev,conf);
                    goto getdefault;
                }
                midi.handler=handler;
                midi.available=true;
                LOG_MSG("MIDI:Opened device:%s",handler->GetName());
                return;
            }
            handler=handler->next;
        }
        LOG_MSG("MIDI:Can't find device:%s, finding default handler.",dev);
getdefault:
        handler=handler_list;
        while (handler) {
            if (handler->Open(conf)) {
                midi.available=true;
                midi.handler=handler;
                LOG_MSG("MIDI:Opened device:%s",handler->GetName());
                return;
            }
            handler=handler->next;
        }
        /* This shouldn't be possible */
    }