From 3171940a6768a90e48a1545d642f6ff83251528a Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 15 Feb 2018 16:03:00 +0200 Subject: [PATCH] Experimented with adding a sound play range offset parameter but not going to be able to support it properly for now. Show debug build title in about screen. --- Source/PS_Source/globals.h | 2 ++ Source/PluginEditor.cpp | 26 +++++++++++++++++++------- Source/PluginProcessor.cpp | 29 +++++++++++++++++++++++++---- Source/PluginProcessor.h | 3 ++- readme.txt | 2 +- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 4c3cd5c..d31d53c 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -257,3 +257,5 @@ inline bool is_in_range(T val, T start, T end) { return val >= start && val <= end; } + +//#define SOUNDRANGE_OFFSET_ENABLED diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 1dd6bb1..5d7eef5 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -214,19 +214,27 @@ void PaulstretchpluginAudioProcessorEditor::resized() m_parcomps[cpi_tonalvsnoisepreserve]->setBounds(xoffs, yoffs, div - 1, 24); xoffs = 1; yoffs += 25; - m_parcomps[cpi_soundstart]->setBounds(xoffs, yoffs, div - 1, 24); - xoffs += div; - m_parcomps[cpi_soundend]->setBounds(xoffs, yoffs, div - 1, 24); - xoffs = 1; - yoffs += 25; + // filter here m_parcomps[cpi_filter_low]->setBounds(xoffs, yoffs, div - 1, 24); xoffs += div; m_parcomps[cpi_filter_high]->setBounds(xoffs, yoffs, div - 1, 24); + xoffs = 1; yoffs += 25; + m_parcomps[cpi_loopxfadelen]->setBounds(xoffs, yoffs, div - 1, 24); xoffs += div; m_parcomps[cpi_onsetdetection]->setBounds(xoffs, yoffs, div - 1, 24); + xoffs = 1; + yoffs += 25; + m_parcomps[cpi_soundstart]->setBounds(xoffs, yoffs, div - 1, 24); + xoffs += div; + m_parcomps[cpi_soundend]->setBounds(xoffs, yoffs, div - 1, 24); +#ifdef SOUNDRANGE_OFFSET_ENABLED + yoffs += 25; + xoffs = 1; + m_parcomps[cpi_playrangeoffset]->setBounds(xoffs, yoffs, getWidth() - 2, 24); +#endif yoffs += 25; int remain_h = getHeight() - 1 - yoffs -15; m_spec_order_ed.setBounds(1, yoffs, getWidth() - 2, remain_h / 5 * 1); @@ -370,9 +378,13 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() if (r == 3) { String fftlib = fftwf_version; -String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + String(JUCE_MINOR_VERSION); + String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + String(JUCE_MINOR_VERSION); + String title = g_plugintitle; +#ifdef JUCE_DEBUG + title += " (DEBUG)"; +#endif AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon, - g_plugintitle, + title, "Plugin for extreme time stretching and other sound processing\nBuilt on " + String(__DATE__) + " " + String(__TIME__) + "\n" "Copyright (C) 2006-2011 Nasca Octavian Paul, Tg. Mures, Romania\n" "(C) 2017-2018 Xenakios\n\n" diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 9816c1e..6e9ceed 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -142,6 +142,9 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() addParameter(new AudioParameterBool("markdirty0", "Internal (don't use)", false)); // 31 m_inchansparam = new AudioParameterInt("numinchans0", "Num ins", 2, 8, 2); // 32 addParameter(m_inchansparam); // 32 +#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()); @@ -478,6 +481,14 @@ void copyAudioBufferWrappingPosition(const AudioBuffer& src, AudioBuffer< } } +inline void sanitizeTimeRange(double& t0, double& t1) +{ + if (t0 > t1) + std::swap(t0, t1); + if (t1 - t0 < 0.001) + t1 = t0 + 0.001; +} + void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { ScopedLock locker(m_cs); @@ -555,10 +566,20 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen)); double t0 = *getFloatParameter(cpi_soundstart); double t1 = *getFloatParameter(cpi_soundend); - if (t0 > t1) - std::swap(t0, t1); - if (t1 - t0 < 0.001) - t1 = t0 + 0.001; + 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 3a89cc4..0a21fec 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -58,6 +58,7 @@ const int cpi_max_capture_len = 29; const int cpi_passthrough = 30; const int cpi_markdirty = 31; const int cpi_num_inchans = 32; +const int cpi_playrangeoffset = 33; class MyPropertiesFile { @@ -203,7 +204,7 @@ private: std::vector m_reset_pars; int m_cur_program = 0; void setParameters(const std::vector& pars); - + float m_cur_playrangeoffset = 0.0; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) }; diff --git a/readme.txt b/readme.txt index 00e4565..6fc8870 100644 --- a/readme.txt +++ b/readme.txt @@ -8,7 +8,7 @@ Released under GNU General Public License v.2 license. History : -02-14-2018 1.0.1 +02-15-2018 1.0.1 -Increased maximum number of input channels to 8 -Added zoom/scroll bar for waveform -GUI performance improvement/bug fix during capture mode