void RtMidiDriver::start(const QList<bool> &deviceStatuses){ setInputDevicesStatus(deviceStatuses); if(!hasInputDevices()){ return; } stop(); for(int deviceIndex=0; deviceIndex < inputDevicesEnabledStatuses.size(); deviceIndex++) { if(deviceIndex < midiStreams.size()){ RtMidiIn* stream = midiStreams.at(deviceIndex); if(stream && inputDevicesEnabledStatuses.at(deviceIndex)){//device is globally enabled? if(!stream->isPortOpen()){ try{ qCInfo(jtMidi) << "Starting MIDI in " << QString::fromStdString(stream->getPortName(deviceIndex)); stream->openPort(deviceIndex); } catch(RtMidiError e){ qCCritical(jtMidi) << "Error opening midi port " << QString::fromStdString(e.getMessage()); } } else{ qCCritical(jtMidi) << "Port " << QString::fromStdString(stream->getPortName(deviceIndex)) << " already opened!"; } } } } }
FREObject closeInputDevice(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) { int pointer = 0; FREGetObjectAsInt32(argv[0],&pointer); try { RtMidiIn *in = (RtMidiIn *)pointer; if(in->isPortOpen()) in->closePort(); removeDeviceIn(in); delete in; //printf("Num open midi devices %i\n",openMidiIn.size()); }catch(std::exception e) { printf("Error closing input device.\n"); } FREObject result; FRENewObjectFromBool(true,&result); return result; }