Skip to content

Commit

Permalink
Tweak faderbank MIDI menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewb committed Sep 21, 2023
1 parent 3a9d791 commit de9dd48
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/faderbank/FaderbankModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ FaderbankModule::FaderbankModule()
configParam<FBFaderParam>(i, 0.0, 10.0, 0.0);
}

for (int i = 0; i < 16; i++)
{
// by default, assign CC faders starting with 32, all on channel 1
inputMap[32 + i] = i;
}
resetConfig();
}

FaderbankModule::~FaderbankModule()
Expand Down Expand Up @@ -91,6 +87,16 @@ void FaderbankModule::processMIDIMessage(const rack::midi::Message& msg)
}
}

void FaderbankModule::resetConfig()
{
inputMap.clear();
for (int i = 0; i < NUM_FADERS; i++)
{
// by default, assign CC faders starting with 32, all on channel 1
inputMap[32 + i] = i;
}
}

json_t* FaderbankModule::dataToJson()
{
json_t* rootJ = json_object();
Expand Down
1 change: 1 addition & 0 deletions src/faderbank/FaderbankModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct FaderbankModule : rack::Module
void process(const ProcessArgs& args) override;

void processMIDIMessage(const rack::midi::Message& msg);
void resetConfig();

json_t* dataToJson() override;
void dataFromJson(json_t* rootJ) override;
Expand Down
21 changes: 15 additions & 6 deletions src/faderbank/FaderbankWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,29 @@ void FaderbankWidget::appendContextMenu(Menu* menu)
}
));

menu->addChild(createSubmenuItem("MIDI connection", "", [=](Menu *childMenu) {
appendMidiMenu(childMenu, &fb->midiInput);
}));
menu->addChild(createSubmenuItem("MIDI connection", fb->midiInput.getDeviceName(fb->midiInput.getDeviceId()),
[=](Menu* childMenu)
{
appendMidiMenu(childMenu, &fb->midiInput);
// remove channel selection
auto last = childMenu->children.back();
childMenu->removeChild(last);
delete last;
}));

menu->addChild(createMenuItem("Autodetect 16n configuration", "",
[=]() {
[=]()
{
fb->resetConfig();

// Send a sysex message to request device channel/CC config.
midi::Message msg;
msg.setSize(6);
msg.bytes = { 0xF0, 0x7d, 0x00, 0x00, 0x1F, 0xF7 };

midi::Output output;
output.setDriverId(fb->midiInput.getDriverId());
output.setDeviceId(fb->midiInput.getDeviceId());
output.sendMessage(msg);
}
));
}));
}

0 comments on commit de9dd48

Please sign in to comment.