Skip to content

Commit

Permalink
Add option to disable auto-sync with kijimi
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Oct 14, 2020
1 parent 416458b commit 6b1db68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Source/FooterComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class FooterComponent: public Component,
PopupMenu m;
m.setLookAndFeel(&babuFrikBaseLookAndFeel);
m.addSubMenu ("MIDI device scan", midiDevicesSubMenu);

int automaticSyncWithSynthTicked = processor->automaticSyncWithSynthEnabled;
m.addItem (MENU_OPTION_TOGGLE_AUTO_SYNC_WITH_SYNTH, "Auto-sync with KIJIMI", true, automaticSyncWithSynthTicked);

selectedActionID = m.showAt(button);

}
Expand All @@ -116,6 +120,8 @@ class FooterComponent: public Component,
processor->setMidiDevicesAutoScan(true);
} else if (actionID == MENU_OPTION_MIDI_SCAN_NOW){
processor->triggerMidiDevicesScan();
} else if (actionID == MENU_OPTION_TOGGLE_AUTO_SYNC_WITH_SYNTH){
processor->toggleAutomaticSyncWithSynth();
}
}

Expand Down
9 changes: 8 additions & 1 deletion Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,11 @@ void BabuFrikAudioProcessor::handleIncomingMidiMessage(MidiInput* source, const
const uint8 *buf = m.getSysExData();
if (((int)buf[0] == 0x02) && (((int)buf[1] == 0x41) || ((int)buf[1] == 0x42) || ((int)buf[1] == 0x43) || ((int)buf[1] == 0x16))){
// This is the sequence that corresponds to "a new preset was loaded", "random patch loaded", "panel mode loaded" or "new menu option set"
delayedRequestLoadControlsSysexThread.run(); // Ask KIJIMI to send current state data, but wait a couple of milliseconds to allow KIJIMI to finish sending other sysex messages that sometimes sends right after sending one of these three. Sending a sysex message to KIJIMI while KIJIMI is sending another can freeze KIJIMI
if (automaticSyncWithSynthEnabled){ // Only request state if Babu Frik is set to sync automatically
delayedRequestLoadControlsSysexThread.run(); // Ask KIJIMI to send current state data, but wait a couple of milliseconds to allow KIJIMI to finish sending other sysex messages that sometimes sends right after sending one of these three. Sending a sysex message to KIJIMI while KIJIMI is sending another can freeze KIJIMI
}
}

} else if (m.getSysExDataSize() == 5){
const uint8 *buf = m.getSysExData();
if (((int)buf[0] == 0x02) && ((int)buf[1] == 0x22)){
Expand Down Expand Up @@ -2249,6 +2252,10 @@ void BabuFrikAudioProcessor::showOrHideKIJIMIPanel(String panelName, bool doShow
}
}

void BabuFrikAudioProcessor::toggleAutomaticSyncWithSynth(){
automaticSyncWithSynthEnabled = !automaticSyncWithSynthEnabled;
}


//==============================================================================
// This creates new instances of the plugin..
Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class BabuFrikAudioProcessor : public AudioProcessor,
void actionListenerCallback (const String &message) override;

// Other
void toggleAutomaticSyncWithSynth();
bool automaticSyncWithSynthEnabled = true;
float getValueForAudioParameter(const String& parameterID);
File getDirectoryForFileSaveLoad ();
void setLastUserDirectoryForFileSaveLoad (File file);
Expand Down
1 change: 1 addition & 0 deletions Source/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@

#define MENU_OPTION_ID_SEND_PATCH_TO_SYNTH 7
#define MENU_OPTION_ID_LOAD_PATCH_FROM_SYNTH 8
#define MENU_OPTION_TOGGLE_AUTO_SYNC_WITH_SYNTH 50

#define MENU_OPTION_ID_RANDOMIZE_PATCH_5_ID 13
#define MENU_OPTION_ID_RANDOMIZE_PATCH_10_ID 14
Expand Down

0 comments on commit 6b1db68

Please sign in to comment.