diff --git a/modules/gin b/modules/gin index 67c6880..3848b8e 160000 --- a/modules/gin +++ b/modules/gin @@ -1 +1 @@ -Subproject commit 67c6880dd9f204d7762970777d12614b458738b7 +Subproject commit 3848b8e66f9783ac770e9dd459eb390d635eca77 diff --git a/plugin/Source/PluginEditor.cpp b/plugin/Source/PluginEditor.cpp index 5c41714..701d2cb 100644 --- a/plugin/Source/PluginEditor.cpp +++ b/plugin/Source/PluginEditor.cpp @@ -3,7 +3,7 @@ //============================================================================== WavetableAudioProcessorEditor::WavetableAudioProcessorEditor (WavetableAudioProcessor& p) - : ProcessorEditor (p), vaProc (p) + : ProcessorEditor (p), wtProc (p) { scope.setName ("scope"); scope.setNumChannels (2); @@ -14,6 +14,8 @@ WavetableAudioProcessorEditor::WavetableAudioProcessorEditor (WavetableAudioProc addAndMakeVisible (editor); addAndMakeVisible (scope); + + usage.panic.onClick = [this] { wtProc.presetLoaded = true; }; addAndMakeVisible (usage); usage.setBounds (45, 12, 150, 16); @@ -67,9 +69,9 @@ void WavetableAudioProcessorEditor::resized() void WavetableAudioProcessorEditor::addMenuItems (juce::PopupMenu& m) { m.addSeparator(); - m.addItem ("MPE", true, vaProc.globalParams.mpe->getUserValueBool(), [this] + m.addItem ("MPE", true, wtProc.globalParams.mpe->getUserValueBool(), [this] { - vaProc.globalParams.mpe->setUserValue (vaProc.globalParams.mpe->getUserValueBool() ? 0.0f : 1.0f); + wtProc.globalParams.mpe->setUserValue (wtProc.globalParams.mpe->getUserValueBool() ? 0.0f : 1.0f); }); auto setSize = [this] (float scale) diff --git a/plugin/Source/PluginEditor.h b/plugin/Source/PluginEditor.h index 5076b6d..80beba4 100644 --- a/plugin/Source/PluginEditor.h +++ b/plugin/Source/PluginEditor.h @@ -21,12 +21,12 @@ public: void showAboutInfo() override; private: - WavetableAudioProcessor& vaProc; + WavetableAudioProcessor& wtProc; - gin::TriggeredScope scope { vaProc.scopeFifo }; - gin::SynthesiserUsage usage { vaProc }; + gin::TriggeredScope scope { wtProc.scopeFifo }; + gin::SynthesiserUsage usage { wtProc }; - Editor editor { vaProc }; + Editor editor { wtProc }; #if JUCE_DEBUG std::unique_ptr inspector; diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index a41a85b..51bbabd 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -615,6 +615,7 @@ void WavetableAudioProcessor::stateUpdated() userTable2.fromBase64Encoding (state.getProperty ("wt2Data").toString()); reloadWavetables(); + presetLoaded = true; } void WavetableAudioProcessor::updateState() @@ -728,9 +729,9 @@ void WavetableAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju return; } - if (blockMissed) + if (blockMissed || presetLoaded) { - blockMissed = false; + blockMissed = presetLoaded = false; turnOffAllVoices (false); } diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index 898d0bb..e590289 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -270,6 +270,7 @@ public: juce::AudioPlayHead* playhead = nullptr; bool blockMissed = false; + bool presetLoaded = false; struct CurTable { diff --git a/plugin/Source/WavetableVoice.cpp b/plugin/Source/WavetableVoice.cpp index 20256a2..5ac815c 100644 --- a/plugin/Source/WavetableVoice.cpp +++ b/plugin/Source/WavetableVoice.cpp @@ -413,7 +413,7 @@ bool WavetableVoice::isVoiceActive() float WavetableVoice::getFilterCutoffNormalized() { float freq = filter.getFrequency(); - return proc.filterParams.frequency->getUserRange().convertTo0to1 (gin::getMidiNoteFromHertz (freq)); + return proc.filterParams.frequency->getUserRange().convertTo0to1 (juce::jlimit (0.0f, 1.0f, gin::getMidiNoteFromHertz (freq))); } gin::WTOscillator::Params WavetableVoice::getLiveWTParams (int osc)