diff --git a/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate b/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate index 4952004..b2f594e 100644 Binary files a/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate and b/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/PluginData.cpp b/Source/PluginData.cpp index 4df1558..83423b2 100644 --- a/Source/PluginData.cpp +++ b/Source/PluginData.cpp @@ -194,7 +194,7 @@ void DexedAudioProcessor::packProgram(int idx, const char *name) { void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { memcpy(data, rawdata, 160); - refreshUI = true; + triggerAsyncUpdate(); } void DexedAudioProcessor::loadBuiltin(int idx) { diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 1486954..20614f3 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -250,8 +250,6 @@ void DexedAudioProcessorEditor::timerCallback() { int32_t env[6]; if ( processor->refreshUI ) { - if ( processor->refreshUI & DexedAudioProcessor::REFRESH_COMP ) - updateUI(); if ( processor->refreshUI & DexedAudioProcessor::REFRESH_MSG ) global.repaint(); processor->refreshUI = 0; diff --git a/Source/PluginParam.cpp b/Source/PluginParam.cpp index 243b247..2e8b370 100755 --- a/Source/PluginParam.cpp +++ b/Source/PluginParam.cpp @@ -417,7 +417,7 @@ void DexedAudioProcessor::setCurrentProgram(int index) { unpackProgram(index); lfo.reset(data + 137); currentProgram = index; - updateUI(); + triggerAsyncUpdate(); } const String DexedAudioProcessor::getProgramName(int index) { diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index da11ba6..682ce8f 100755 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -28,6 +28,7 @@ #include "msfa/pitchenv.h" #include "msfa/aligned_buf.h" + //============================================================================== DexedAudioProcessor::DexedAudioProcessor() { #ifdef DEBUG @@ -189,7 +190,7 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) { } TRACE("program update sysex"); updateProgramFromSysex(buf+4); - refreshUI |= REFRESH_COMP; + triggerAsyncUpdate(); return; } @@ -202,7 +203,7 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) { TRACE("update 32bulk voice)"); importSysex((const char *)buf+4); currentProgram = 0; - refreshUI |= REFRESH_COMP; + triggerAsyncUpdate(); } return; } @@ -222,6 +223,8 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) { case 0xb0 : { int controller = buf[1]; int value = buf[2]; + + // pedal if (controller == 64) { sustain = value != 0; if (!sustain) { @@ -417,6 +420,9 @@ bool DexedAudioProcessor::hasEditor() const { void DexedAudioProcessor::updateUI() { + // notify host something has changed + updateHostDisplay(); + AudioProcessorEditor *editor = getActiveEditor(); if ( editor == NULL ) { return; @@ -429,6 +435,11 @@ AudioProcessorEditor* DexedAudioProcessor::createEditor() { return new DexedAudioProcessorEditor (this); } +void DexedAudioProcessor::handleAsyncUpdate() { + updateUI(); +} + + void DexedAudioProcessor::log(const char *source, const char *fmt, ...) { char output[4096]; va_list argptr; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 38fbd68..2e6b00a 100755 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -41,7 +41,7 @@ struct ProcessorVoice { //============================================================================== /** */ -class DexedAudioProcessor : public AudioProcessor +class DexedAudioProcessor : public AudioProcessor, public AsyncUpdater { static const int MAX_ACTIVE_NOTES = 16; ProcessorVoice voices[MAX_ACTIVE_NOTES]; @@ -89,13 +89,17 @@ class DexedAudioProcessor : public AudioProcessor void keydown(uint8_t pitch, uint8_t velo); void keyup(uint8_t pitch); void processSamples(int n_samples, int16_t *buffer); - + + /** + * this is called from the Audio thread to tell + * to update the UI / hostdata + */ + void handleAsyncUpdate(); + void initCtrl(); public : static const int REFRESH_MSG = 1; - static const int REFRESH_COMP = 1 << 1; - int refreshUI; char data[161];