Skip to content

Commit

Permalink
Update faderbank 14-bit config sysex to match final spec (#209)
Browse files Browse the repository at this point in the history
* Faderbank: 3-byte sysex format for 14-bit cc

* faderbank: allow 14-bit CCs on any valid pair
  • Loading branch information
Dewb authored Jan 23, 2025
1 parent a3f300f commit b3090d3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/faderbank/FaderbankModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ void FaderbankModule::processMIDIMessages(const ProcessArgs& args)
}
}

if (ccNum >= 32 && ccNum < 64)
if (ccNum >= 32)
{
// look for potential LSB CC of 14-bit CC 0-31
// look for potential LSB CC of 14-bit CC
key = (msg.getChannel() << 8) | (ccNum - 32);
iter = inputMap.find(key);
if (iter != inputMap.end())
Expand Down Expand Up @@ -105,10 +105,10 @@ void FaderbankModule::processMIDIMessages(const ProcessArgs& args)
uint8_t ccNum = msg.bytes[9 + 48 + i] & 0x7F;
records[i].ccNum = ccNum;
records[i].channel = channel;
if (msg.bytes.size() >= 9 + 82)
if (msg.bytes.size() >= 9 + 83)
{
uint16_t ccMode = msg.bytes[9 + 80] << 8 | msg.bytes[9 + 81];
records[i].faderMode = (ccMode & (1 << i)) == 0 ? FaderMode14bitCC : FaderModeCC;
uint16_t ccMode = (msg.bytes[9 + 80] & 0x7F) | ((msg.bytes[9 + 81] & 0x7F) << 7) | ((msg.bytes[9 + 82] & 0x03) << 14);
records[i].faderMode = (ccMode & (1 << i)) == 0 ? FaderModeCC : FaderMode14bitCC;
}
}
updateInputMap();
Expand All @@ -124,7 +124,7 @@ void FaderbankModule::processMIDIMessages(const ProcessArgs& args)
{
uint16_t value;
bool updateable = false;
bool expect14bit = records[i].faderMode == FaderMode14bitCC && records[i].ccNum < 32;
bool expect14bit = records[i].faderMode == FaderMode14bitCC && records[i].ccNum < 96;

if (records[i].highValue != 0xFF)
{
Expand Down Expand Up @@ -280,27 +280,28 @@ void FaderbankModule::writeConfigSysex()
if (midiOutput.deviceId != -1)
{
rack::midi::Message msg;
msg.setSize(40);
msg.setSize(41);

uint8_t header[] = { 0xF0, 0x7d, 0x00, 0x00, 0x0C };
for (int i = 0; i < 5; i++)
{
msg.bytes[i] = header[i];
}

uint16_t modeBits = 0xFFFF;
uint16_t modeBits = 0x0000;
for (int i = 0; i < NUM_FADERS; i++)
{
msg.bytes[5 + i] = (records[i].channel + 1) & 0x1F;
msg.bytes[21 + i] = records[i].ccNum & 0x7F;
if (records[i].faderMode == FaderMode14bitCC)
{
modeBits ^= 1 << i;
modeBits |= (1 << i);
}
}
msg.bytes[37] = (modeBits >> 8) & 0x7F;
msg.bytes[38] = modeBits & 0x7F;
msg.bytes[39] = 0xF7;
msg.bytes[37] = modeBits & 0x7F;
msg.bytes[38] = (modeBits >> 7) & 0x7F;
msg.bytes[39] = (modeBits >> 14) & 0x03;
msg.bytes[40] = 0xF7;

midiOutput.sendMessage(msg);
}
Expand Down

0 comments on commit b3090d3

Please sign in to comment.