diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 1eb55bb..86edf8c 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -112,6 +112,8 @@ 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()); } @@ -288,7 +290,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() //std::vector> layout; //layout.emplace_back(cpi_capture_enabled, cpi_passthrough, cpi_pause_enabled, cpi_freeze); //layout.emplace_back(cpi_main_volume, cpi_num_inchans, cpi_num_outchans); - m_parcomps[cpi_capture_enabled]->setBounds(xoffs, yoffs, div-1, 24); + m_parcomps[cpi_capture_trigger]->setBounds(xoffs, yoffs, div-1, 24); //xoffs += div; //m_parcomps[cpi_max_capture_len]->setBounds(xoffs, yoffs, div - 1, 24); xoffs += div; @@ -1250,9 +1252,17 @@ 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) // && m_togglebut->getToggleState() != *boolpar) { - *boolpar = m_togglebut->getToggleState(); + if (m_nonparamstate == nullptr) + { + if (m_togglebut->getToggleState()!=*boolpar) + *boolpar = m_togglebut->getToggleState(); + } + else + { + *boolpar = true; + } } } @@ -1269,9 +1279,18 @@ void ParameterComponent::updateComponent() m_slider->setValue(*intpar, dontSendNotification); } AudioParameterBool* boolpar = dynamic_cast(m_par); - if (m_togglebut != nullptr && m_togglebut->getToggleState() != *boolpar) + if (m_togglebut != nullptr) // && m_togglebut->getToggleState() != *boolpar) { - m_togglebut->setToggleState(*boolpar, dontSendNotification); + if (m_nonparamstate == nullptr) + { + if (m_togglebut->getToggleState() != *boolpar) + m_togglebut->setToggleState(*boolpar, dontSendNotification); + } + else + { + if (m_togglebut->getToggleState()!=*m_nonparamstate) + m_togglebut->setToggleState(*m_nonparamstate, dontSendNotification); + } } } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 78a1b90..52d3eb4 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -91,6 +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 6247b16..e6ceb66 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -903,7 +903,7 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id) { if (id == 1) { - bool capture = *getBoolParameter(cpi_capture_enabled); + bool capture = *getBoolParameter(cpi_capture_trigger); if (capture == false && m_max_reclen != *getFloatParameter(cpi_max_capture_len)) { m_max_reclen = *getFloatParameter(cpi_max_capture_len); @@ -912,11 +912,13 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id) if (capture == true && m_is_recording == false) { setRecordingEnabled(true); + *getBoolParameter(cpi_capture_trigger)=false; return; } - if (capture == false && m_is_recording == true) + if (capture == true && 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 dd16435..e52b794 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -51,7 +51,7 @@ const int cpi_tonalvsnoisepreserve = 22; const int cpi_filter_low = 23; const int cpi_filter_high = 24; const int cpi_onsetdetection = 25; -const int cpi_capture_enabled = 26; +const int cpi_capture_trigger = 26; const int cpi_num_outchans = 27; const int cpi_pause_enabled = 28; const int cpi_max_capture_len = 29; @@ -217,13 +217,11 @@ public: void* ptr, float opt) override; int m_cur_tab_index = 0; + bool m_is_recording = false; private: - - bool m_prebuffering_inited = false; AudioBuffer m_recbuffer; double m_max_reclen = 10.0; - bool m_is_recording = false; int m_rec_pos = 0; int m_rec_count = 0; Range m_recorded_range;