From d4a224767980e5697603971421a009a9f91680a3 Mon Sep 17 00:00:00 2001 From: xenakios Date: Tue, 12 Feb 2019 14:56:37 +0200 Subject: [PATCH] Reverted Capture parameter to a normal parameter to again allow host MIDI learn etc. It is now instead ignored when saving the state tree. This may not fix the parameter being recalled when undoing in all hosts but this is the best that can be done with the plugin format limitations at this point. --- Source/PS_Source/globals.h | 8 ++++++-- Source/PluginEditor.cpp | 33 ++++++--------------------------- Source/PluginEditor.h | 2 +- Source/PluginProcessor.cpp | 6 ++---- Source/PluginProcessor.h | 4 ++-- readme.txt | 6 ++++-- 6 files changed, 21 insertions(+), 38 deletions(-) diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 5e9ed45..aae8754 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -19,9 +19,10 @@ #include #include +#include #include "../JuceLibraryCode/JuceHeader.h" -const String g_plugintitle{ "PaulXStretch 1.3.0" }; +const String g_plugintitle{ "PaulXStretch 1.2.4" }; using REALTYPE = float; @@ -115,10 +116,13 @@ inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, AudioParame if (par) dest.setProperty(par->paramID,(int)*par,uman); } -inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, const OwnedArray& pars) +inline void storeToTreeProperties(ValueTree dest, UndoManager* uman, const OwnedArray& pars, + const std::set& ignorepars = {}) { for (auto& e : pars) { + if (ignorepars.count(e)) + continue; auto parf = dynamic_cast(e); if (parf != nullptr) storeToTreeProperties(dest, nullptr, parf); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 03cb1c0..e0dafc2 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -124,8 +124,6 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau { m_parcomps.emplace_back(std::make_unique(pars[i], notifyonlyonrelease)); m_parcomps.back()->m_group_id = group_id; - if (i == cpi_capture_trigger) - m_parcomps.back()->m_nonparamstate = &processor.m_is_recording; if (group_id >= -1) addAndMakeVisible(m_parcomps.back().get()); } @@ -1255,20 +1253,10 @@ void ParameterComponent::sliderDragEnded(Slider * slid) void ParameterComponent::buttonClicked(Button * but) { AudioParameterBool* boolpar = dynamic_cast(m_par); - if (m_togglebut != nullptr) // && m_togglebut->getToggleState() != *boolpar) + if (m_togglebut != nullptr) { - if (m_nonparamstate == nullptr) - { - if (m_togglebut->getToggleState()!=*boolpar) - *boolpar = m_togglebut->getToggleState(); - } - else - { - // If we have the non-parameter state pointer, just set the target parameter to true. - // Logic in the AudioProcessor determines what should be done and it sets the parameter immediately back - // to false when it sees the parameter is true. - *boolpar = true; - } + if (m_togglebut->getToggleState()!=*boolpar) + *boolpar = m_togglebut->getToggleState(); } } @@ -1285,19 +1273,10 @@ void ParameterComponent::updateComponent() m_slider->setValue(*intpar, dontSendNotification); } AudioParameterBool* boolpar = dynamic_cast(m_par); - if (m_togglebut != nullptr) + if (boolpar!=nullptr && m_togglebut != nullptr) { - if (m_nonparamstate == nullptr) - { - if (m_togglebut->getToggleState() != *boolpar) - m_togglebut->setToggleState(*boolpar, dontSendNotification); - } - else - { - // If we have the non-parameter state pointer, get the button toggle state from that - if (m_togglebut->getToggleState()!=*m_nonparamstate) - m_togglebut->setToggleState(*m_nonparamstate, dontSendNotification); - } + if (m_togglebut->getToggleState() != *boolpar) + m_togglebut->setToggleState(*boolpar, dontSendNotification); } } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 37ff045..1b8e6a7 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -91,7 +91,7 @@ public: void setHighLighted(bool b); int m_group_id = -1; Slider* getSlider() { return m_slider.get(); } - bool* m_nonparamstate = nullptr; + private: Label m_label; AudioProcessorParameter* m_par = nullptr; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 827cb3b..d88e8c3 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -259,7 +259,7 @@ int PaulstretchpluginAudioProcessor::getPreBufferAmount() ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool ignorefile) { ValueTree paramtree("paulstretch3pluginstate"); - storeToTreeProperties(paramtree, nullptr, getParameters()); + storeToTreeProperties(paramtree, nullptr, getParameters(), { getBoolParameter(cpi_capture_trigger) }); if (m_current_file != File() && ignorefile == false) { paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr); @@ -1014,13 +1014,11 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id) if (capture == true && m_is_recording == false) { setRecordingEnabled(true); - *getBoolParameter(cpi_capture_trigger)=false; return; } - if (capture == true && m_is_recording == true) + if (capture == false && m_is_recording == true) { setRecordingEnabled(false); - *getBoolParameter(cpi_capture_trigger) = false; return; } if (m_cur_num_out_chans != *m_outchansparam) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 6c52421..964c7fb 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -237,7 +237,7 @@ public: void* ptr, float opt) override; int m_cur_tab_index = 0; - bool m_is_recording = false; + bool m_save_captured_audio = true; String m_capture_location; bool m_midinote_control = false; @@ -255,7 +255,7 @@ private: CriticalSection m_cs; File m_current_file; Time m_current_file_date; - + bool m_is_recording = false; TimeSliceThread m_bufferingthread; std::unique_ptr m_stretch_source; std::unique_ptr m_buffering_source; diff --git a/readme.txt b/readme.txt index 05cf608..d1eb202 100644 --- a/readme.txt +++ b/readme.txt @@ -7,9 +7,11 @@ Copyright (C) 2017-2018 Xenakios Released under GNU General Public License v.3 license. History : -01-21-2019 1.3.0 - -Changed Import file button to show/hide a file browser for audio files. (This seems to be the only +02-12-2019 1.2.4 + -Changed Import file button to show/hide an overlaid file browser for audio files. (This seems to be the only technically correct way to browse for the files.) + -Fix the fix for the Capture parameter. (Recalling it when undoing and loading project should now be ignored, + while still allowing automation and MIDI learn.) 01-17-2019 1.2.3 -Captured audio buffers can optionally be saved as files on disk for later recall. -Added varispeed (resampling speed change) feature when spectral stretch engine is bypassed