From 47638ba0c6a59fc5cff54c64b642812df4f60a14 Mon Sep 17 00:00:00 2001 From: xenakios Date: Mon, 26 Feb 2018 16:34:13 +0200 Subject: [PATCH] Prepare to allow adding offline rendering feature --- Source/PS_Source/globals.h | 2 -- Source/PluginProcessor.cpp | 69 +++++++++++++++++--------------------- Source/PluginProcessor.h | 1 + 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index cfb8eb9..3d50a73 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -294,5 +294,3 @@ inline bool is_in_range(T val, T start, T end) { return val >= start && val <= end; } - -//#define SOUNDRANGE_OFFSET_ENABLED diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index a366a91..5761c6e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -143,9 +143,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() m_inchansparam = new AudioParameterInt("numinchans0", "Num ins", 2, 8, 2); // 32 addParameter(m_inchansparam); // 32 addParameter(new AudioParameterBool("bypass_stretch0", "Bypass stretch", false)); // 33 -#ifdef SOUNDRANGE_OFFSET_ENABLED - addParameter(new AudioParameterFloat("playrangeoffset_0", "Play offset", 0.0f, 1.0f, 0.0f)); // 33 -#endif + auto& pars = getParameters(); for (const auto& p : pars) m_reset_pars.push_back(p->getValue()); @@ -385,6 +383,34 @@ void PaulstretchpluginAudioProcessor::setParameters(const std::vector& p } } +void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameters(ProcessParameters & pars) +{ + pars.pitch_shift.cents = *getFloatParameter(cpi_pitchshift) * 100.0; + pars.freq_shift.Hz = *getFloatParameter(cpi_frequencyshift); + + pars.spread.bandwidth = *getFloatParameter(cpi_spreadamount); + + pars.compressor.power = *getFloatParameter(cpi_compress); + + pars.harmonics.nharmonics = *getIntParameter(cpi_numharmonics); + pars.harmonics.freq = *getFloatParameter(cpi_harmonicsfreq); + pars.harmonics.bandwidth = *getFloatParameter(cpi_harmonicsbw); + pars.harmonics.gauss = getParameter(cpi_harmonicsgauss); + + pars.octave.om2 = *getFloatParameter(cpi_octavesm2); + pars.octave.om1 = *getFloatParameter(cpi_octavesm1); + pars.octave.o0 = *getFloatParameter(cpi_octaves0); + pars.octave.o1 = *getFloatParameter(cpi_octaves1); + pars.octave.o15 = *getFloatParameter(cpi_octaves15); + pars.octave.o2 = *getFloatParameter(cpi_octaves2); + + pars.filter.low = *getFloatParameter(cpi_filter_low); + pars.filter.high = *getFloatParameter(cpi_filter_high); + + pars.tonal_vs_noise.bandwidth = *getFloatParameter(cpi_tonalvsnoisebw); + pars.tonal_vs_noise.preserve = *getFloatParameter(cpi_tonalvsnoisepreserve); +} + double PaulstretchpluginAudioProcessor::getSampleRateChecked() { if (m_cur_sr < 1.0) @@ -534,48 +560,15 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount)); m_stretch_source->setPreviewDry(*getBoolParameter(cpi_bypass_stretch)); setFFTSize(*getFloatParameter(cpi_fftsize)); - m_ppar.pitch_shift.cents = *getFloatParameter(cpi_pitchshift) * 100.0; - m_ppar.freq_shift.Hz = *getFloatParameter(cpi_frequencyshift); - m_ppar.spread.bandwidth = *getFloatParameter(cpi_spreadamount); - - m_ppar.compressor.power = *getFloatParameter(cpi_compress); - - m_ppar.harmonics.nharmonics = *getIntParameter(cpi_numharmonics); - m_ppar.harmonics.freq = *getFloatParameter(cpi_harmonicsfreq); - m_ppar.harmonics.bandwidth = *getFloatParameter(cpi_harmonicsbw); - m_ppar.harmonics.gauss = getParameter(cpi_harmonicsgauss); - - m_ppar.octave.om2 = *getFloatParameter(cpi_octavesm2); - m_ppar.octave.om1 = *getFloatParameter(cpi_octavesm1); - m_ppar.octave.o0 = *getFloatParameter(cpi_octaves0); - m_ppar.octave.o1 = *getFloatParameter(cpi_octaves1); - m_ppar.octave.o15 = *getFloatParameter(cpi_octaves15); - m_ppar.octave.o2 = *getFloatParameter(cpi_octaves2); - - m_ppar.filter.low = *getFloatParameter(cpi_filter_low); - m_ppar.filter.high = *getFloatParameter(cpi_filter_high); - - m_ppar.tonal_vs_noise.bandwidth = *getFloatParameter(cpi_tonalvsnoisebw); - m_ppar.tonal_vs_noise.preserve = *getFloatParameter(cpi_tonalvsnoisepreserve); + updateStretchParametersFromPluginParameters(m_ppar); + m_stretch_source->setOnsetDetection(*getFloatParameter(cpi_onsetdetection)); m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen)); double t0 = *getFloatParameter(cpi_soundstart); double t1 = *getFloatParameter(cpi_soundend); sanitizeTimeRange(t0, t1); -#ifdef SOUNDRANGE_OFFSET_ENABLED - if (m_cur_playrangeoffset != (*getFloatParameter(cpi_playrangeoffset))) - { - double prlen = t1 - t0; - m_cur_playrangeoffset = jlimit(0.0f,1.0f-prlen,(float)*getFloatParameter(cpi_playrangeoffset)); - t0 = m_cur_playrangeoffset; - t1 = t0 + prlen; - sanitizeTimeRange(t0, t1); - getFloatParameter(cpi_soundstart)->setValueNotifyingHost(t0); - getFloatParameter(cpi_soundend)->setValueNotifyingHost(t1); - } -#endif m_stretch_source->setPlayRange({ t0,t1 }, true); m_stretch_source->setFreezing(getParameter(cpi_freeze)); m_stretch_source->setPaused(getParameter(cpi_pause_enabled)); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index d57612a..8f72c71 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -206,6 +206,7 @@ private: int m_cur_program = 0; void setParameters(const std::vector& pars); float m_cur_playrangeoffset = 0.0; + void updateStretchParametersFromPluginParameters(ProcessParameters& pars); //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) };