From 08398392ca1144a2b879bceb4b6c6057da036f28 Mon Sep 17 00:00:00 2001 From: xenakios Date: Tue, 3 Apr 2018 18:32:53 +0300 Subject: [PATCH] Implement more ratiomixer parameters etc --- Source/PS_Source/ProcessedStretch.h | 2 +- Source/PluginEditor.cpp | 24 ++++++++++++++++++++---- Source/PluginProcessor.cpp | 15 +++++++++++++++ Source/PluginProcessor.h | 11 +++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index 653bcbe..3e73b6d 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -29,7 +29,7 @@ struct ProcessParameters { pitch_shift.cents=0; - ratiomix.ratios = { 0.25,0.5,1.0,2.0,3.0,4.0,0.0,0.0 }; + ratiomix.ratios = { 0.25,0.5,1.0,2.0,3.0,4.0,1.5,1.0/1.5 }; octave.om2=octave.om1=octave.o1=octave.o15=octave.o2=0.0f; octave.o0=1.0f; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 23b0776..6f6bbf1 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -159,7 +159,7 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau m_ratiomixeditor.GetParameterValue = [this](int which, int index) { if (which == 0) - return processor.getStretchSource()->getProcessParameters().ratiomix.ratios[index]; + return (double)*processor.getFloatParameter((int)cpi_octaves_ratio0 + index); if (which == 1) { if (index == 0) @@ -174,6 +174,10 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau return (double)*processor.getFloatParameter(cpi_octaves15); if (index == 5) return (double)*processor.getFloatParameter(cpi_octaves2); + if (index == 6) + return (double)*processor.getFloatParameter(cpi_octaves_extra1); + if (index == 7) + return (double)*processor.getFloatParameter(cpi_octaves_extra2); } return 0.0; @@ -192,6 +196,14 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau *processor.getFloatParameter(cpi_octaves15) = val; if (index == 5) *processor.getFloatParameter(cpi_octaves2) = val; + if (index == 6) + *processor.getFloatParameter(cpi_octaves_extra1) = val; + if (index == 7) + *processor.getFloatParameter(cpi_octaves_extra2) = val; + }; + m_ratiomixeditor.OnRatioChanged = [this](int index, double val) + { + *processor.getFloatParameter((int)cpi_octaves_ratio0 + index) = val; }; m_wave_container->addAndMakeVisible(&m_wavecomponent); m_wavefilter_tab.addTab("Waveform", Colours::white, m_wave_container, true); @@ -1380,7 +1392,7 @@ RatioMixerEditor::RatioMixerEditor(int numratios) { auto ratslid = std::make_unique(Slider::LinearHorizontal,Slider::TextBoxBelow); ratslid->setRange(0.125, 8.0); - ratslid->onValueChange = [this]() {}; + ratslid->onValueChange = [this,i]() {OnRatioChanged(i, m_ratio_sliders[i]->getValue()); }; addAndMakeVisible(ratslid.get()); m_ratio_sliders.emplace_back(std::move(ratslid)); @@ -1412,7 +1424,11 @@ void RatioMixerEditor::timerCallback() { for (int i = 0; i < m_ratio_level_sliders.size(); ++i) { - m_ratio_sliders[i]->setValue(GetParameterValue(0, i), dontSendNotification); - m_ratio_level_sliders[i]->setValue(GetParameterValue(1, i), dontSendNotification); + double v = GetParameterValue(0, i); + if (v!=m_ratio_sliders[i]->getValue()) + m_ratio_sliders[i]->setValue(v, dontSendNotification); + v = GetParameterValue(1, i); + if (v!=m_ratio_level_sliders[i]->getValue()) + m_ratio_level_sliders[i]->setValue(v, dontSendNotification); } } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index eb1e585..efe1a5e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -158,6 +158,16 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() { addParameter(m_sm_enab_pars[i]); } + + addParameter(make_floatpar("octavemix_extra0_0", "Ratio mix 7 level", 0.0f, 1.0f, 0.0f, 0.001, 1.0)); // 50 + addParameter(make_floatpar("octavemix_extra1_0", "Ratio mix 8 level", 0.0f, 1.0f, 0.0f, 0.001, 1.0)); // 51 + + // 52-59 + for (int i = 0; i < 8; ++i) + { + addParameter(make_floatpar("ratiomix_ratio_"+String(i)+"_0", "Ratio mix ratio "+String(i+1), 0.125f, 8.0f, 1.0f, 0.001, 1.0)); + } + auto& pars = getParameters(); for (const auto& p : pars) m_reset_pars.push_back(p->getValue()); @@ -418,6 +428,11 @@ void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameter pars.ratiomix.ratiolevels[3] = *getFloatParameter(cpi_octaves1); pars.ratiomix.ratiolevels[4] = *getFloatParameter(cpi_octaves15); pars.ratiomix.ratiolevels[5] = *getFloatParameter(cpi_octaves2); + pars.ratiomix.ratiolevels[6] = *getFloatParameter(cpi_octaves_extra1); + pars.ratiomix.ratiolevels[7] = *getFloatParameter(cpi_octaves_extra2); + + for (int i = 0; i < 8; ++i) + pars.ratiomix.ratios[i] = *getFloatParameter((int)cpi_octaves_ratio0 + i); pars.filter.low = *getFloatParameter(cpi_filter_low); pars.filter.high = *getFloatParameter(cpi_filter_high); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index fec0073..15ba187 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -77,6 +77,17 @@ const int cpi_enable_spec_module5 = 46; const int cpi_enable_spec_module6 = 47; const int cpi_enable_spec_module7 = 48; const int cpi_enable_spec_module8 = 49; +const int cpi_octaves_extra1 = 50; +const int cpi_octaves_extra2 = 51; +const int cpi_octaves_ratio0 = 52; +const int cpi_octaves_ratio1 = 53; +const int cpi_octaves_ratio2 = 54; +const int cpi_octaves_ratio3 = 55; +const int cpi_octaves_ratio4 = 56; +const int cpi_octaves_ratio5 = 57; +const int cpi_octaves_ratio6 = 58; +const int cpi_octaves_ratio7 = 59; + class MyPropertiesFile {