From a01455c18d3f4db76dc5550c1889a068764a1b55 Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Sat, 30 Sep 2023 07:42:15 -0700 Subject: [PATCH] Fix AU crash --- CMakeLists.txt | 2 +- Changelist.txt | 4 ++++ plugin/Resources/layout.json | 2 +- plugin/Source/Panels.h | 18 ++++++++++++++++-- plugin/Source/PluginProcessor.cpp | 13 ++++++++++++- plugin/Source/PluginProcessor.h | 1 + 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5445ef4..583e5ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.24.0 FATAL_ERROR) # Set for each plugin # set (PLUGIN_NAME Wavetable) -set (PLUGIN_VERSION 1.0.4) +set (PLUGIN_VERSION 1.0.5) set (BUNDLE_ID com.socalabs.wavetable) set (AU_ID WavetableAU) set (LV2_URI "https://socalabs.com/wavetable/") diff --git a/Changelist.txt b/Changelist.txt index 93dd082..372490f 100644 --- a/Changelist.txt +++ b/Changelist.txt @@ -1,3 +1,7 @@ +1.0.5: + +- Fix AU crash + 1.0.4: - Allow mod matrix entries to be disabled diff --git a/plugin/Resources/layout.json b/plugin/Resources/layout.json index 7fdf7d3..d2d6578 100644 --- a/plugin/Resources/layout.json +++ b/plugin/Resources/layout.json @@ -143,9 +143,9 @@ { "id": "global", "x": "prevR()+1", "y": "prevY()", "w": 168, "h": 137, "children": [ { "id": "Mono", "x": 0, "y": 23, "w": 42, "h": 57 }, - { "id": "Legato", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Glide", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Time", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, + { "id": "Legato", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "PB Range", "x": 0, "y": "prevB()", "w": 42, "h": 57 }, { "id": "Voices", "x": "prevR()", "y": "prevY()", "w": 42, "h": 57 }, { "id": "Level", "x": "prevR() + 42", "y": "prevY()", "w": 42, "h": 57 } diff --git a/plugin/Source/Panels.h b/plugin/Source/Panels.h index 419c62b..907fc5d 100644 --- a/plugin/Source/Panels.h +++ b/plugin/Source/Panels.h @@ -533,14 +533,28 @@ public: addControl (new gin::Knob (proc.globalParams.level)); addControl (new gin::Select (proc.globalParams.glideMode)); - addControl (new gin::Knob (proc.globalParams.glideRate)); + addControl (rate = new gin::Knob (proc.globalParams.glideRate)); addControl (new gin::Knob (proc.globalParams.voices)); - addControl (new gin::Switch (proc.globalParams.legato)); + addControl (legato = new gin::Switch (proc.globalParams.legato)); addControl (new gin::Switch (proc.globalParams.mono)); addControl (new gin::Knob (proc.globalParams.pitchBend)); + + watchParam (proc.globalParams.glideMode); + paramChanged(); + } + + void paramChanged() override + { + gin::ParamBox::paramChanged(); + + rate->setEnabled (proc.globalParams.glideMode->getUserValueInt() > 0); + legato->setEnabled (proc.globalParams.glideMode->getUserValueInt() > 0); } WavetableAudioProcessor& proc; + + gin::Knob* rate; + gin::Switch* legato; }; //============================================================================== diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index bedf7b1..734f074 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -747,6 +747,14 @@ void WavetableAudioProcessor::releaseResources() { } +bool WavetableAudioProcessor::isBusesLayoutSupported (const BusesLayout& layout) const +{ + if (layout.inputBuses.size() != 0 || layout.outputBuses.size() != 1) + return false; + + return layout.outputBuses[0].size() == 2; +} + void WavetableAudioProcessor::processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& midi) { juce::ScopedNoDenormals noDenormals; @@ -755,6 +763,9 @@ void WavetableAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju blockMissed = true; return; } + + if (buffer.getNumChannels() != 2) + return; if (blockMissed || presetLoaded || lastMono != globalParams.mono->isOn()) { @@ -802,7 +813,7 @@ void WavetableAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju playHead = nullptr; - if (buffer.getNumSamples() <= scopeFifo.getFreeSpace()) + if (buffer.getNumSamples() <= scopeFifo.getFreeSpace() && buffer.getNumChannels() == scopeFifo.getNumChannels()) scopeFifo.write (buffer); endBlock (buffer.getNumSamples()); diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index ce81c9c..a4f336b 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -22,6 +22,7 @@ public: void reset() override; void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; + bool isBusesLayoutSupported (const BusesLayout&) const override; void processBlock (juce::AudioBuffer&, juce::MidiBuffer&) override;