MCPcopy Create free account
hub / github.com/VCVRack/Befaco / appendContextMenu

Method appendContextMenu

src/MidiThing.cpp:763–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

761 }
762
763 void appendContextMenu(Menu* menu) override {
764 MidiThing* module = dynamic_cast<MidiThing*>(this->module);
765 assert(module);
766
767 menu->addChild(new MenuSeparator());
768
769 menu->addChild(createSubmenuItem("Select MIDI Device", "",
770 [ = ](Menu * menu) {
771
772 for (auto driverId : rack::midi::getDriverIds()) {
773 midi::Driver* driver = midi::getDriver(driverId);
774 const bool activeDriver = module->midiOut.getDriverId() == driverId;
775
776 menu->addChild(createSubmenuItem(driver->getName(), CHECKMARK(activeDriver),
777 [ = ](Menu * menu) {
778
779 for (auto deviceId : driver->getOutputDeviceIds()) {
780 const bool activeDevice = activeDriver && module->midiOut.getDeviceId() == deviceId;
781
782 menu->addChild(createMenuItem(driver->getOutputDeviceName(deviceId),
783 CHECKMARK(activeDevice),
784 [ = ]() {
785 module->midiOut.setDriverId(driverId);
786 module->midiOut.setDeviceId(deviceId);
787
788 module->inputQueue.setDriverId(driverId);
789 module->inputQueue.setDeviceId(deviceId);
790 module->inputQueue.setChannel(0); // TODO update
791
792 module->doSync();
793
794 // DEBUG("Updating Output MIDI settings - driver: %s, device: %s",
795 // driver->getName().c_str(), driver->getOutputDeviceName(deviceId).c_str());
796 }));
797 }
798 }));
799 }
800 }));
801
802 menu->addChild(createIndexPtrSubmenuItem("All channels MIDI update rate",
803 module->updateRateNames,
804 &module->updateRateIdx));
805
806 float updateRate = module->updateRates[module->updateRateIdx] / module->numActiveChannels;
807 menu->addChild(createMenuLabel(string::f("Per-channel MIDI update rate: %.3g Hz", updateRate)));
808
809 menu->addChild(createIndexSubmenuItem("Set mode for all channels",
810 {"0 to 10v", "-5 to 5v", "0 to 8v", "0 to 5v"},
811 [ = ]() {
812 return -1;
813 },
814 [ = ](int modeIdx) {
815 MidiThing::PORTMODE_t mode = (MidiThing::PORTMODE_t)(modeIdx + 1);
816 module->setVoltageModeOnHardwareAllChannels(mode);
817 }
818 ));
819 }
820};

Callers

nothing calls this directly

Calls 2

doSyncMethod · 0.80

Tested by

no test coverage detected