//============================================================================== void AudioDeviceManager::setMidiInputEnabled (const String& name, const bool enabled) { if (enabled != isMidiInputEnabled (name)) { if (enabled) { const int index = MidiInput::getDevices().indexOf (name); if (index >= 0) { MidiInput* const midiIn = MidiInput::openDevice (index, &callbackHandler); if (midiIn != nullptr) { enabledMidiInputs.add (midiIn); midiIn->start(); } } } else { for (int i = enabledMidiInputs.size(); --i >= 0;) if (enabledMidiInputs[i]->getName() == name) enabledMidiInputs.remove (i); } updateXml(); sendChangeMessage(); } }
void MidiIODeviceManager::setMidiNoteEnabled (const String& midiDeviceName, bool input, bool enabled) { if(input) { appProperties->getUserSettings()->setValue(midiDeviceName + "noteInputEnabled", enabled); // lets see if we need to turn the inputs on or off if(enabled == true && isMidiInputEnabled(midiDeviceName) == false) { // we want to start listening to midi from this input setMidiInputEnabled(midiDeviceName, true); } else if(enabled == false && isMidiInputEnabled(midiDeviceName) == true && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "noteInputEnabled") == false && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "ccInputEnabled") == false) { // no one is listening to this midi device, so lets turn it off setMidiInputEnabled(midiDeviceName, false); } } else if(!input) { appProperties->getUserSettings()->setValue(midiDeviceName + "noteOutputEnabled", var(enabled)); // lets see if we need to turn the outputs on or off if(enabled == true && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "noteOutputEnabled") == false) { // we want to start sending midi to this output appProperties->getUserSettings()->setValue(midiDeviceName + "outputEnabled", var(true)); } else if(enabled == false && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "outputEnabled") == true && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "noteOutputEnabled") == false && appProperties->getUserSettings()->getBoolValue(midiDeviceName + "ccOutputEnabled") == false) { // no one wants to send to this midi device, so lets turn it off appProperties->getUserSettings()->setValue(midiDeviceName + "outputEnabled", var(false)); } sendChangeMessage (); appProperties->saveIfNeeded(); } }
void AudioDeviceManager::addMidiInputCallback (const String& name, MidiInputCallback* callbackToAdd) { removeMidiInputCallback (name, callbackToAdd); if (name.isEmpty() || isMidiInputEnabled (name)) { const ScopedLock sl (midiCallbackLock); midiCallbacks.add (callbackToAdd); midiCallbackDevices.add (name); } }
void AudioDeviceManager::addMidiInputCallback (const String& name, MidiInputCallback* callbackToAdd) { removeMidiInputCallback (name, callbackToAdd); if (name.isEmpty() || isMidiInputEnabled (name)) { const ScopedLock sl (midiCallbackLock); MidiCallbackInfo mc; mc.deviceName = name; mc.callback = callbackToAdd; midiCallbacks.add (mc); } }