Skip to content

Commit

Permalink
Bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 10, 2024
1 parent 30698d9 commit 6ccedb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/hid/include/hid/Midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace l::hid::midi {
return mInDevice >= 0;
}
bool HasMidiOut() {
return mInDevice >= 0;
return mOutDevice >= 0;
}
uint32_t GetMidiIn() {
return static_cast<uint32_t>(mInDevice);
Expand Down
14 changes: 7 additions & 7 deletions packages/nodegraph/include/nodegraph/NodeGraphOpInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ namespace l::nodegraph {
{
mChannel.resize(1);

SetDevice(0);

mMidiManager->RegisterCallback([&](l::hid::midi::MidiData data) {
if (mMidiDeviceInId >= 0 && data.deviceIn == static_cast<uint32_t>(mMidiDeviceInId)) {
MidiEvent(data);
}
});

SetDevice(0);
}

std::string defaultOutStrings[5] = { "Freq", "Velocity", "Note On Id", "Note Off Id", "Device Id"};
Expand Down Expand Up @@ -139,13 +139,13 @@ namespace l::nodegraph {
NodeGraphOp(node, 0, 9, 9),
mMidiManager(midiManager)
{
SetDevice(0);

mMidiManager->RegisterCallback([&](l::hid::midi::MidiData data) {
if (mMidiDeviceInId >= 0 && data.deviceIn == static_cast<uint32_t>(mMidiDeviceInId)) {
MidiEvent(data);
}
});

SetDevice(0);
}

std::string defaultOutStrings[9] = { "Knob 1", "Knob 2", "Knob 3", "Knob 4", "Knob 5", "Knob 6", "Knob 7", "Knob 8", "Device Id"};
Expand Down Expand Up @@ -232,6 +232,8 @@ namespace l::nodegraph {
}
defaultOutStrings[8] = "Device Id";

SetDevice(0);

if (mMidiManager) {
mCallbackId = mMidiManager->RegisterCallback([&](l::hid::midi::MidiData data) {
if (mMidiDeviceInId >= 0 && data.deviceIn == static_cast<uint32_t>(mMidiDeviceInId)) {
Expand All @@ -244,8 +246,6 @@ namespace l::nodegraph {
UpdateButton(i, BUTTON_ALLOCATED);
}
}

SetDevice(0);
}

std::string defaultOutStrings[9];
Expand Down Expand Up @@ -280,7 +280,7 @@ namespace l::nodegraph {
if (mMidiManager) {
int8_t buttonColor = remapToButtonStatesToColor.at(buttonState);
auto deviceInfo = mMidiManager->GetDeviceInfo(mMidiDeviceInId);
if (deviceInfo) {
if (deviceInfo && deviceInfo->HasMidiOut()) {
mMidiManager->SendToDevice(deviceInfo->GetMidiOut(), 0x90, 0, mButtonGroup * 8 + buttonId, buttonColor);
}
mButtonStates.at(buttonId) = buttonState;
Expand Down

0 comments on commit 6ccedb9

Please sign in to comment.