From 3510b0ee6f4b9e720e7b8017f7403e3bcc885659 Mon Sep 17 00:00:00 2001 From: essej Date: Fri, 15 Apr 2022 14:29:23 -0400 Subject: [PATCH] updated small size layout issues. fixed offline render to actually work correctly based on the passed in parameters. --- Source/PS_Source/StretchSource.cpp | 12 +-- Source/PS_Source/StretchSource.h | 4 +- Source/PluginEditor.cpp | 127 ++++++++++++++++++++++++----- Source/PluginEditor.h | 2 + Source/PluginProcessor.cpp | 39 ++++++--- Source/PluginProcessor.h | 2 +- Source/RenderSettingsComponent.cpp | 7 +- Source/RenderSettingsComponent.h | 2 +- Source/envelope_component.cpp | 18 ++-- 9 files changed, 161 insertions(+), 52 deletions(-) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 6a365e3..a703983 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -673,10 +673,10 @@ void StretchAudioSource::setFFTWindowingType(int windowtype) } } -void StretchAudioSource::setFFTSize(int size) +void StretchAudioSource::setFFTSize(int size, bool force) { jassert(size>0); - if (m_xfadetask.state == 0 && (m_process_fftsize == 0 || size != m_process_fftsize)) + if (force || (m_xfadetask.state == 0 && (m_process_fftsize == 0 || size != m_process_fftsize))) { ScopedLock locker(m_cs); if (m_xfadetask.buffer.getNumChannels() < m_num_outchans) @@ -684,7 +684,7 @@ void StretchAudioSource::setFFTSize(int size) m_xfadetask.buffer.setSize(m_num_outchans, m_xfadetask.buffer.getNumSamples()); } - if (m_process_fftsize > 0) + if (!force && m_process_fftsize > 0) { m_xfadetask.state = 1; m_xfadetask.counter = 0; @@ -761,11 +761,11 @@ void StretchAudioSource::setOnsetDetection(double x) } } -void StretchAudioSource::setPlayRange(Range playrange) +void StretchAudioSource::setPlayRange(Range playrange, bool force) { - if (playrange == m_playrange || playrange == m_inputfile->getActiveRange()) + if (!force && (playrange == m_playrange || playrange == m_inputfile->getActiveRange())) return; - if (m_cs.tryEnter()) + if (m_cs.tryEnter() || force) { if (playrange.isEmpty()) m_playrange = { 0.0,1.0 }; diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 943d108..b1f68f7 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -65,7 +65,7 @@ public: double getOutputSamplerate() const { return m_outsr; } void setProcessParameters(ProcessParameters* pars); const ProcessParameters& getProcessParameters(); - void setFFTSize(int size); + void setFFTSize(int size, bool force=false); int getFFTSize() { return m_process_fftsize; } double getFreezePos() const { return m_freeze_pos; } @@ -80,7 +80,7 @@ public: double getOutputDurationSecondsForRange(Range range, int fftsize); void setOnsetDetection(double x); - void setPlayRange(Range playrange); + void setPlayRange(Range playrange, bool force=false); Range getPlayRange() { return m_playrange; } bool isLoopEnabled(); bool hasReachedEnd(); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index b449e3a..0258710 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -607,7 +607,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() int minh = 32; int buttw = 60; int buttminw = 36; - int minitemw = 300; + int minitemw = 260; int margin = 1; #if JUCE_IOS @@ -650,7 +650,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() togglesbox.alignContent = FlexBox::AlignContent::flexStart; togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_capture_trigger]).withMargin(margin).withFlex(1).withMaxWidth(65)); - togglesbox.items.add(FlexItem(buttminw, buttonrowheight).withFlex(0.1)); + togglesbox.items.add(FlexItem(3, buttonrowheight).withFlex(0.1)); togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_rewind_button).withMargin(1).withFlex(1).withMaxWidth(65)); togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10)); @@ -660,7 +660,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10)); togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_freeze]).withMargin(margin).withFlex(1).withMaxWidth(65)); - togglesbox.items.add(FlexItem(buttminw, buttonrowheight).withFlex(0.1)); + togglesbox.items.add(FlexItem(3, buttonrowheight).withFlex(0.1)); //togglesbox.items.add(FlexItem(toggleminw, togglerowheight, *m_parcomps[cpi_bypass_stretch]).withMargin(margin).withFlex(1).withMaxWidth(150)); togglesbox.items.add(FlexItem(buttminw + 15, buttonrowheight, *m_parcomps[cpi_passthrough]).withMargin(margin).withFlex(1.5).withMaxWidth(85)); @@ -680,7 +680,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() #if !JUCE_IOS FlexBox inoutbox; - int inoutminw = 170; + int inoutminw = 140; int inoutmaxw = 200; inoutbox.flexDirection = FlexBox::Direction::row; @@ -895,14 +895,14 @@ void PaulstretchpluginAudioProcessorEditor::resized() mainbox.performLayout(bounds); if ( m_shortMode) { - auto totgroupw = jmax(360, m_groupviewport->getWidth()) - scrollw; + auto totgroupw = jmax(260, m_groupviewport->getWidth()) - scrollw; auto groupsbounds = Rectangle(0, 0, totgroupw, useh); auto layoutbounds = groupsbounds.translated(2, 0).withWidth(totgroupw - 3); m_groupcontainer->setBounds(groupsbounds); groupsbox.performLayout(layoutbounds); } else { - auto totgroupw = jmax(360, w) - scrollw; + auto totgroupw = jmax(260, w) - scrollw; auto groupsbounds = Rectangle(0, 0, totgroupw, useh); m_groupcontainer->setBounds(groupsbounds); groupsbox.performLayout(groupsbounds); @@ -1411,8 +1411,10 @@ void WaveformComponent::mouseDown(const MouseEvent & e) { m_mousedown = true; m_lock_timesel_set = true; + m_timedrag_started = false; + double pos = viewXToNormalized(e.x); - if (e.y < m_topmargin || e.mods.isCommandDown()) + if (e.mods.isCommandDown()) { if (SeekCallback) { @@ -1435,23 +1437,47 @@ void WaveformComponent::mouseDown(const MouseEvent & e) repaint(); } -void WaveformComponent::mouseUp(const MouseEvent & /*e*/) +void WaveformComponent::mouseUp(const MouseEvent & e) { - m_is_dragging_selection = false; - m_lock_timesel_set = false; - m_mousedown = false; - m_didseek = false; + int seektopmargin = getHeight() / 2; + if (m_didchangetimeselection) { TimeSelectionChangedCallback(Range(m_time_sel_start, m_time_sel_end), 1); m_didchangetimeselection = false; } + else if (e.y < seektopmargin) { + double pos = viewXToNormalized(e.x); + if (SeekCallback) + { + SeekCallback(pos); + m_last_startpos = pos; + } + } + + m_is_dragging_selection = false; + m_lock_timesel_set = false; + m_mousedown = false; + m_didseek = false; + m_timedrag_started = false; } void WaveformComponent::mouseDrag(const MouseEvent & e) { if (m_didseek == true) return; + + int dragthresh = 3; +#if JUCE_IOS + dragthresh = 6; +#endif + + if (!m_timedrag_started && abs(e.getDistanceFromDragStartX()) > dragthresh) { + m_timedrag_started = true; + } + + if (!m_timedrag_started) return; + if (m_time_sel_drag_target == 0 && e.y>=50 && m_is_dragging_selection==false) { m_time_sel_start = m_drag_time_start; @@ -1580,11 +1606,15 @@ void WaveformComponent::setTimeSelection(Range rng) int WaveformComponent::getTimeSelectionEdge(int x, int y) { + int touchradius = 5; +#if JUCE_IOS + touchradius = 10; +#endif int xcorleft = (int)jmap(m_time_sel_start, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth()); int xcorright = (int)jmap(m_time_sel_end, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth()); - if (juce::Rectangle(xcorleft - 5, m_topmargin, 10, getHeight() - m_topmargin).contains(x, y)) + if (juce::Rectangle(xcorleft - touchradius, m_topmargin, 2*touchradius, getHeight() - m_topmargin).contains(x, y)) return 1; - if (juce::Rectangle(xcorright - 5, m_topmargin, 10, getHeight() - m_topmargin).contains(x, y)) + if (juce::Rectangle(xcorright - touchradius, m_topmargin, 2*touchradius, getHeight() - m_topmargin).contains(x, y)) return 2; return 0; } @@ -1855,6 +1885,7 @@ ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notif m_labeldefcolor = m_label.findColour(Label::textColourId); m_label.setText(par->getName(50), dontSendNotification); m_label.setJustificationType(Justification::centredRight); + m_label.setFont(16.0f); AudioParameterFloat* floatpar = dynamic_cast(par); if (floatpar) @@ -1924,8 +1955,16 @@ void ParameterComponent::resized() { //int labw = 200; int labw = 120; - if (getWidth() < 350) + if (getWidth() < 280) { + labw = 60; + m_label.setFont(12.0f); + } + else if (getWidth() < 350) { labw = 100; + m_label.setFont(14.0f); + } else { + m_label.setFont(16.0f); + } m_label.setBounds(0, 0, labw, h); m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), h); } @@ -2243,11 +2282,13 @@ RatioMixerEditor::RatioMixerEditor(int numratios) auto ratslid = std::make_unique(Slider::LinearHorizontal,Slider::TextBoxBelow); ratslid->setRange(0.125, 8.0); ratslid->onValueChange = [this,i]() {OnRatioChanged(i, m_ratio_sliders[i]->getValue()); }; - addAndMakeVisible(ratslid.get()); + ratslid->setNumDecimalPlacesToDisplay(3); + addAndMakeVisible(ratslid.get()); m_ratio_sliders.emplace_back(std::move(ratslid)); auto ratlevslid = std::make_unique(); ratlevslid->setRange(0.0, 1.0); + ratlevslid->setNumDecimalPlacesToDisplay(3); ratlevslid->setSliderStyle(Slider::LinearVertical); if (i==3) ratlevslid->setValue(1.0,dontSendNotification); @@ -2255,20 +2296,60 @@ RatioMixerEditor::RatioMixerEditor(int numratios) ratlevslid->onValueChange = [this, i]() { OnRatioLevelChanged(i, m_ratio_level_sliders[i]->getValue()); }; addAndMakeVisible(ratlevslid.get()); m_ratio_level_sliders.emplace_back(std::move(ratlevslid)); + + auto ratlab = std::make_unique