diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 83fc9be..748d391 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -279,10 +279,11 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile() void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() { PopupMenu menu; + menu.addItem(4, "Reset parameters", true, false); menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); - //menu.addItem(3, "Prebuffering", true, processor.m_use_backgroundbuffering); + PopupMenu bufferingmenu; int curbufamount = processor.getPreBufferAmount(); bufferingmenu.addItem(100,"None",true,curbufamount == -1); @@ -302,6 +303,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() { processor.m_capture_when_host_plays = !processor.m_capture_when_host_plays; } + if (r == 4) + { + processor.resetParameters(); + } if (r == 3) { String fftlib = fftwf_version; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 8e0326b..d68d1d2 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -160,6 +160,9 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() addParameter(new AudioParameterBool("pause_enabled0", "Pause", false)); // 28 addParameter(new AudioParameterFloat("maxcapturelen_0", "Max capture length", 1.0f, 120.0f, 10.0f)); // 29 addParameter(new AudioParameterBool("passthrough0", "Pass input through", false)); // 30 + auto& pars = getParameters(); + for (const auto& p : pars) + m_reset_pars.push_back(p->getValue()); setPreBufferAmount(2); startTimer(1, 50); } @@ -170,6 +173,16 @@ PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor() m_bufferingthread.stopThread(1000); } +void PaulstretchpluginAudioProcessor::resetParameters() +{ + ScopedLock locker(m_cs); + for (int i = 0; i < m_reset_pars.size(); ++i) + { + if (i!=cpi_main_volume && i!=cpi_passthrough) + setParameter(i, m_reset_pars[i]); + } +} + void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x) { int temp = jlimit(0, 5, x); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 0caf75e..7f2b38a 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -80,10 +80,11 @@ public: std::unique_ptr m_props_file; }; -class PaulstretchpluginAudioProcessor : public AudioProcessor, public MultiTimer +class PaulstretchpluginAudioProcessor : public AudioProcessor, + public MultiTimer { public: - //============================================================================== + PaulstretchpluginAudioProcessor(); ~PaulstretchpluginAudioProcessor(); @@ -140,7 +141,7 @@ public: bool m_play_when_host_plays = false; bool m_capture_when_host_plays = false; bool m_use_backgroundbuffering = true; - + void resetParameters(); void setPreBufferAmount(int x); int getPreBufferAmount(); private: @@ -178,6 +179,7 @@ private: double m_cur_sr = 0.0; bool m_last_host_playing = false; AudioBuffer m_input_buffer; + std::vector m_reset_pars; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) };