updated small size layout issues. fixed offline render to actually work correctly based on the passed in parameters.

This commit is contained in:
essej 2022-04-15 14:29:23 -04:00
parent 681dc4de6b
commit 3510b0ee6f
9 changed files with 161 additions and 52 deletions

View File

@ -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<double> playrange)
void StretchAudioSource::setPlayRange(Range<double> 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 };

View File

@ -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<double> range, int fftsize);
void setOnsetDetection(double x);
void setPlayRange(Range<double> playrange);
void setPlayRange(Range<double> playrange, bool force=false);
Range<double> getPlayRange() { return m_playrange; }
bool isLoopEnabled();
bool hasReachedEnd();

View File

@ -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<int>(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<int>(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<double>(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<double> rng)
int WaveformComponent::getTimeSelectionEdge(int x, int y)
{
int touchradius = 5;
#if JUCE_IOS
touchradius = 10;
#endif
int xcorleft = (int)jmap<double>(m_time_sel_start, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
int xcorright = (int)jmap<double>(m_time_sel_end, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
if (juce::Rectangle<int>(xcorleft - 5, m_topmargin, 10, getHeight() - m_topmargin).contains(x, y))
if (juce::Rectangle<int>(xcorleft - touchradius, m_topmargin, 2*touchradius, getHeight() - m_topmargin).contains(x, y))
return 1;
if (juce::Rectangle<int>(xcorright - 5, m_topmargin, 10, getHeight() - m_topmargin).contains(x, y))
if (juce::Rectangle<int>(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<AudioParameterFloat*>(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>(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<Slider>();
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<Label>();
ratlab->setJustificationType(Justification::centred);
ratlab->setText(String(i+1), dontSendNotification);
addAndMakeVisible(ratlab.get());
m_labels.emplace_back(std::move(ratlab));
}
if (numratios > 0) m_ratio_sliders[0]->setDoubleClickReturnValue(true, 0.25);
if (numratios > 1) m_ratio_sliders[1]->setDoubleClickReturnValue(true, 0.5);
if (numratios > 2) m_ratio_sliders[2]->setDoubleClickReturnValue(true, 1.0);
if (numratios > 3) m_ratio_sliders[3]->setDoubleClickReturnValue(true, 2.0);
if (numratios > 4) m_ratio_sliders[4]->setDoubleClickReturnValue(true, 3.0);
if (numratios > 5) m_ratio_sliders[5]->setDoubleClickReturnValue(true, 4.0);
if (numratios > 6) m_ratio_sliders[6]->setDoubleClickReturnValue(true, 1.5);
if (numratios > 7) m_ratio_sliders[7]->setDoubleClickReturnValue(true, 2/3.0);
startTimer(200);
setOpaque(true);
}
void RatioMixerEditor::resized()
{
int nsliders = m_ratio_sliders.size();
int minslidw = 65;
int maxslidw = 120;
int minslidh = 55;
int minrslidh = 32;
int maxrslidh = 45;
FlexBox contentbox;
contentbox.flexDirection = FlexBox::Direction::row;
contentbox.flexWrap = FlexBox::Wrap::wrap;
//contentbox.alignContent = FlexBox::AlignContent::flexStart;
std::vector<FlexBox> itemboxes;
itemboxes.resize(m_ratio_sliders.size());
int nsliders = (int) m_ratio_sliders.size();
int slidw = getWidth() / nsliders;
for (int i = 0; i < nsliders; ++i)
for (int i = 0; i < nsliders; ++i)
{
m_ratio_level_sliders[i]->setBounds(slidw/2+slidw * i-10, 15, 20, getHeight() - 55);
m_ratio_sliders[i]->setBounds(slidw * i, getHeight() - 48, slidw - 5, 45);
itemboxes[i].flexDirection = FlexBox::Direction::column;
itemboxes[i].items.add(FlexItem(minslidw, minslidh, *m_ratio_level_sliders[i]).withFlex(1));
itemboxes[i].items.add(FlexItem(minslidw, minrslidh, *m_ratio_sliders[i]).withFlex(1).withMaxHeight(maxrslidh));
contentbox.items.add(FlexItem(minslidw, minslidh + minrslidh, itemboxes[i]).withMargin(1).withFlex(1).withMaxWidth(maxslidw));
}
contentbox.performLayout(getLocalBounds().reduced(1));
for (int i = 0; i < nsliders; ++i)
{
m_labels[i]->setBounds(m_ratio_level_sliders[i]->getX(), m_ratio_level_sliders[i]->getY() + 1, m_ratio_level_sliders[i]->getWidth() - 2 , 16);
}
}
void RatioMixerEditor::timerCallback()
@ -2289,11 +2370,13 @@ void RatioMixerEditor::timerCallback()
void RatioMixerEditor::paint(Graphics & g)
{
g.fillAll(Colour(0xff222222));
g.setColour(Colours::white);
/*
g.setColour(Colours::white);
auto nsliders = m_ratio_sliders.size();
int slidw = getWidth() / nsliders;
for (int i = 0; i < 8; ++i)
g.drawText(String(i + 1), slidw / 2 + slidw * i - 8, 1, 15, 15, Justification::centred);
*/
}
FreeFilterComponent::FreeFilterComponent(PaulstretchpluginAudioProcessor* proc)
@ -2485,7 +2568,7 @@ int ParameterGroupComponent::doLayout(Rectangle<int> bounds)
int titlew = m_namelabel ? 100 : m_enableButton ? 40 : 0;
int enablew = m_enableButton ? 40 : 0;
int enablemaxh = 34;
int minitemw = 300;
int minitemw = 260;
int minitemh = 26;
int margin = 1;
int outsidemargin = 4;

View File

@ -225,6 +225,7 @@ private:
bool m_didseek = false;
bool m_didchangetimeselection = false;
int m_topmargin = 0;
bool m_timedrag_started = false;
int getTimeSelectionEdge(int x, int y);
std::pair<Range<double>, Range<double>> m_file_cached;
bool m_image_dirty = false;
@ -299,6 +300,7 @@ public:
private:
uptrvec<Slider> m_ratio_sliders;
uptrvec<Slider> m_ratio_level_sliders;
uptrvec<Label> m_labels;
};
class FreeFilterComponent : public Component

View File

@ -213,9 +213,13 @@ m_bufferingthread("pspluginprebufferthread"), m_is_stand_alone_offline(is_stand_
auto& pars = getParameters();
for (const auto& p : pars)
m_reset_pars.push_back(p->getValue());
setPreBufferAmount(2);
startTimer(1, 50);
m_show_technical_info = m_propsfile->m_props_file->getBoolValue("showtechnicalinfo", false);
if (!m_is_stand_alone_offline) {
setPreBufferAmount(2);
startTimer(1, 50);
}
m_show_technical_info = m_propsfile->m_props_file->getBoolValue("showtechnicalinfo", false);
}
@ -355,7 +359,7 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
if (prebufamt == -1)
m_use_backgroundbuffering = false;
else
setPreBufferAmount(prebufamt);
setPreBufferAmount(m_is_stand_alone_offline ? 0 : prebufamt);
if (m_load_file_with_state == true)
{
String fn = tree.getProperty("importedfile");
@ -464,14 +468,14 @@ void PaulstretchpluginAudioProcessor::parameterGestureChanged(int parameterIndex
{
}
void PaulstretchpluginAudioProcessor::setFFTSize(double size)
void PaulstretchpluginAudioProcessor::setFFTSize(double size, bool force)
{
if (m_prebuffer_amount == 5)
m_fft_size_to_use = pow(2, 7.0 + size * 14.5);
else m_fft_size_to_use = pow(2, 7.0 + size * 10.0); // chicken out from allowing huge FFT sizes if not enough prebuffering
int optim = optimizebufsize(m_fft_size_to_use);
m_fft_size_to_use = optim;
m_stretch_source->setFFTSize(optim);
m_stretch_source->setFFTSize(optim, force);
//Logger::writeToLog(String(m_fft_size_to_use));
}
@ -622,18 +626,25 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
double t0 = *processor->getFloatParameter(cpi_soundstart);
double t1 = *processor->getFloatParameter(cpi_soundend);
sanitizeTimeRange(t0, t1);
sc->setPlayRange({ t0,t1 });
sc->setPlayRange({ t0,t1 }, true);
DBG("play range: " << t0 << " " << t1);
DBG("SC play range s: " << sc->getPlayRange().getStart() << " e: " << sc->getPlayRange().getEnd());
*(processor->getBoolParameter(cpi_pause_enabled)) = false;
sc->setMainVolume(*processor->getFloatParameter(cpi_main_volume));
sc->setRate(*processor->getFloatParameter(cpi_stretchamount));
sc->setDryPlayrate(*processor->getFloatParameter(cpi_dryplayrate));
processor->setFFTSize(*processor->getFloatParameter(cpi_fftsize));
processor->setFFTSize(*processor->getFloatParameter(cpi_fftsize), true);
processor->updateStretchParametersFromPluginParameters(processor->m_ppar);
processor->setPlayConfigDetails(2, numoutchans, outsr, blocksize);
processor->prepareToPlay(outsr, blocksize);
//sc->setProcessParameters(&processor->m_ppar);
//sc->setFFTWindowingType(1);
DBG("SC post play range s: " << sc->getPlayRange().getStart() << " e: " << sc->getPlayRange().getEnd() << " fft: " << sc->getFFTSize() << " ourdur: " << sc->getOutputDurationSecondsForRange(sc->getPlayRange(),sc->getFFTSize()));
auto rendertask = [sc,processor,outputfiletouse, renderpars,blocksize,numoutchans, outsr,this]()
{
@ -671,11 +682,19 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
AudioBuffer<float> renderbuffer{ numoutchans, blocksize };
MidiBuffer dummymidi;
double outlensecs = sc->getOutputDurationSecondsForRange(sc->getPlayRange(),sc->getFFTSize());
if (*processor->getBoolParameter(cpi_looping_enabled)) {
outlensecs *= jmax(1, renderpars.numloops);
}
outlensecs = jmin(outlensecs, renderpars.maxoutdur);
int64_t outlenframes = outlensecs * outsr;
int64_t outcounter{ 0 };
m_offline_render_state = 0;
m_offline_render_cancel_requested = false;
DBG("Starting rendering of " << outlenframes << " frames, " << outlensecs << " secs" << ", loops: " << renderpars.numloops << " play range s: " << sc->getPlayRange().getStart() << " e: " << sc->getPlayRange().getEnd());
while (outcounter < outlenframes)
{
if (m_offline_render_cancel_requested == true)

View File

@ -279,7 +279,7 @@ private:
int mPluginWindowWidth = 820;
int mPluginWindowHeight = 710;
void setFFTSize(double size);
void setFFTSize(double size, bool force=false);
void startplay(Range<double> playrange, int numoutchans, int maxBlockSize, String& err);
SharedResourcePointer<MyThumbCache> m_thumbcache;
AudioParameterInt* m_outchansparam = nullptr;

View File

@ -28,7 +28,7 @@ RenderSettingsComponent::RenderSettingsComponent (PaulstretchpluginAudioProcesso
addAndMakeVisible(&m_editorMaxOutDuration);
m_editorMaxOutDuration.setText("1.0", dontSendNotification);
addAndMakeVisible(&m_toggleFloatClip);
m_toggleFloatClip.setButtonText("Clip floating point output");
m_toggleFloatClip.setButtonText("Clip");
m_toggleFloatClip.setToggleState(false, dontSendNotification);
addAndMakeVisible(&labelSamplerate);
labelSamplerate.setText("Sample rate :", dontSendNotification);
@ -119,7 +119,8 @@ void RenderSettingsComponent::paint (Graphics& g)
void RenderSettingsComponent::resized()
{
int labelw = 120;
int labelw = 100;
int medlabelw = 120;
int widelabelw = 210;
int itemh = 28;
int tallitemh = 40;
@ -157,7 +158,7 @@ void RenderSettingsComponent::resized()
FlexBox loopbox;
loopbox.flexDirection = FlexBox::Direction::row;
loopbox.items.add(FlexItem(labelw, tallitemh, label3).withMargin(margin));
loopbox.items.add(FlexItem(medlabelw, tallitemh, label3).withMargin(margin));
loopbox.items.add(FlexItem(smallitemw, itemh, numLoopsEditor).withMargin(margin).withMaxHeight(itemh).withAlignSelf(FlexItem::AlignSelf::flexStart));
FlexBox maxbox;

View File

@ -56,7 +56,7 @@ private:
String ID_lastrenderpath{ "lastrenderpath" };
String ID_lastrendershare{ "lastrendershare" };
int prefHeight = 400;
int prefWidth = 500;
int prefWidth = 420;
std::unique_ptr<FileChooser> m_filechooser;
bool pendingRender = false;
//==============================================================================

View File

@ -26,13 +26,13 @@ EnvelopeComponent::EnvelopeComponent(CriticalSection* cs) : m_cs(cs)
addChildComponent(&m_bubble);
setOpaque(true);
//#if JUCE_IOS
#if JUCE_IOS
m_menubutton.setButtonText("...");
m_menubutton.onClick = [this]() {
showPopupMenu();
};
addAndMakeVisible(&m_menubutton);
//#endif
#endif
}
EnvelopeComponent::~EnvelopeComponent()
@ -101,13 +101,17 @@ void EnvelopeComponent::paint(Graphics& g)
g.drawText("Envelope is orphaned (may be a bug)", 10, 10, getWidth(), getHeight(), Justification::centred);
return;
}
for (int i = 0; i < 10; ++i)
int freqdivs = jmax(2, jmin(10, (int) (getWidth() / 60.0f)));
int divwidth = getWidth() / freqdivs;
for (int i = 0; i < freqdivs; ++i)
{
double norm = 1.0 / 10 * i;
double norm = 1.0 / freqdivs * i;
double hz = XFromNormalized(norm);
int xcor = getWidth() / 10 * i;
g.drawText(String(hz, 1), xcor, getHeight() - 20, 100, 20, Justification::topLeft);
}
int xcor = divwidth * i;
g.drawFittedText(String(hz, 1), xcor, getHeight() - 20, divwidth, 20, Justification::topLeft, 1);
}
String name = m_envelope->GetName();
if (name.isEmpty() == true)
name = "Untitled envelope";