layout updates, other ios compatibility updates
This commit is contained in:
		@@ -441,9 +441,9 @@ void PaulstretchpluginAudioProcessorEditor::setSpectrumProcGroupEnabled(int grou
 | 
			
		||||
void PaulstretchpluginAudioProcessorEditor::showRenderDialog()
 | 
			
		||||
{
 | 
			
		||||
	auto contentraw =  new RenderSettingsComponent(&processor);
 | 
			
		||||
	contentraw->setSize(contentraw->getWidth(), contentraw->getPreferredHeight());
 | 
			
		||||
	contentraw->setSize(contentraw->getPreferredWidth(), contentraw->getPreferredHeight());
 | 
			
		||||
	std::unique_ptr<Component> content(contentraw);
 | 
			
		||||
	CallOutBox::launchAsynchronously(std::move(content), m_render_button.getBounds(), this);
 | 
			
		||||
	auto & cb = CallOutBox::launchAsynchronously(std::move(content), m_render_button.getBounds(), this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PaulstretchpluginAudioProcessorEditor::showAudioSetup()
 | 
			
		||||
@@ -537,7 +537,7 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
    int buttw = 60;
 | 
			
		||||
    int buttminw = 36;
 | 
			
		||||
    int minitemw = 300;
 | 
			
		||||
    int margin = 2;
 | 
			
		||||
    int margin = 1;
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    togglerowheight = 32;
 | 
			
		||||
@@ -561,7 +561,8 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
 | 
			
		||||
    topbox.items.add(FlexItem(buttw, buttonrowheight, m_import_button).withMargin(1).withFlex(1).withMaxWidth(130));
 | 
			
		||||
    topbox.items.add(FlexItem(buttw, buttonrowheight, m_settings_button).withMargin(1).withFlex(1).withMaxWidth(130));
 | 
			
		||||
    if (JUCEApplicationBase::isStandaloneApp()) {
 | 
			
		||||
    if (JUCEApplicationBase::isStandaloneApp())
 | 
			
		||||
    {
 | 
			
		||||
        topbox.items.add(FlexItem(buttw, buttonrowheight, m_render_button).withMargin(1).withFlex(1).withMaxWidth(130));
 | 
			
		||||
    }
 | 
			
		||||
    topbox.items.add(FlexItem(buttminw, buttonrowheight, m_rewind_button).withMargin(1));
 | 
			
		||||
@@ -617,7 +618,7 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
    int scrollw = m_groupviewport->getScrollBarThickness() ;
 | 
			
		||||
 | 
			
		||||
    int gheight = 0;
 | 
			
		||||
    int groupmargin = 2;
 | 
			
		||||
    int groupmargin = 1;
 | 
			
		||||
    int groupw = w - 2*groupmargin - scrollw;
 | 
			
		||||
    // groups
 | 
			
		||||
 | 
			
		||||
@@ -698,6 +699,8 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
 | 
			
		||||
    int totminh = vpminh + orderminh + tabminh + topboxh + toggleh + volh + stretchH;
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 2));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(minw, topboxh, topbox).withMargin(margin).withFlex(0));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -744,19 +747,21 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
        mainbox.items.add(FlexItem(minw, stretchH, *m_stretchgroup).withMargin(margin).withFlex(0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 4));
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 3));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(w, vpminh, *m_groupviewport).withMargin(0).withFlex(1).withMaxHeight(useh + 4));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 5));
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 2));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(w, orderminh, m_spec_order_ed).withMargin(2).withFlex(0.1).withMaxHeight(60));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 6));
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 2));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(w, tabminh, m_wavefilter_tab).withMargin(0).withFlex(0.1));
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(6, 4));
 | 
			
		||||
 | 
			
		||||
    mainbox.performLayout(bounds);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -764,10 +769,17 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
    m_groupcontainer->setBounds(groupsbounds);
 | 
			
		||||
    groupsbox.performLayout(groupsbounds);
 | 
			
		||||
 | 
			
		||||
    int zscrollh = 18;
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    zscrollh = 28;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    m_wavecomponent.setBounds(m_wave_container->getX(), 0, m_wave_container->getWidth(),
 | 
			
		||||
		m_wave_container->getHeight()-16);
 | 
			
		||||
	m_zs.setBounds(m_wave_container->getX(), m_wavecomponent.getBottom(), m_wave_container->getWidth(), 15);
 | 
			
		||||
		m_wave_container->getHeight()-zscrollh-1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	m_zs.setBounds(m_wave_container->getX(), m_wavecomponent.getBottom(), m_wave_container->getWidth(), zscrollh);
 | 
			
		||||
	//m_wavecomponent.setBounds(1, m_spec_order_ed.getBottom()+1, getWidth()-2, remain_h/5*4);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -824,6 +836,12 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
 | 
			
		||||
        for (auto & group : m_pargroups) {
 | 
			
		||||
            group.second->updateParameterComponents();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ;
 | 
			
		||||
        if (AudioParameterBool* enablepar = dynamic_cast<AudioParameterBool*>(processor.getBoolParameter(cpi_pause_enabled))) {
 | 
			
		||||
            m_perfmeter.enabled = !enablepar->get();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	if (id == 2)
 | 
			
		||||
	{
 | 
			
		||||
@@ -944,7 +962,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
 | 
			
		||||
 | 
			
		||||
void PaulstretchpluginAudioProcessorEditor::showAbout()
 | 
			
		||||
{
 | 
			
		||||
	String fftlib = fftwf_version;
 | 
			
		||||
    String fftlib;
 | 
			
		||||
#if !PS_USE_VDSP_FFT
 | 
			
		||||
    fftlib = fftwf_version;
 | 
			
		||||
#endif
 | 
			
		||||
	String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + String(JUCE_MINOR_VERSION);
 | 
			
		||||
	String title = String(JucePlugin_Name) + " " + String(JucePlugin_VersionString);
 | 
			
		||||
#ifdef JUCE_DEBUG
 | 
			
		||||
@@ -958,14 +979,19 @@ void PaulstretchpluginAudioProcessorEditor::showAbout()
 | 
			
		||||
 | 
			
		||||
    auto * content = new Label();
 | 
			
		||||
    String text = title + "\n\n" +
 | 
			
		||||
    "Plugin for extreme time stretching and other sound processing\nBuilt on " + String(__DATE__) + " " + String(__TIME__) + "\n"
 | 
			
		||||
    "Plugin/Application 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-2021 Xenakios\n"
 | 
			
		||||
    "(C) 2022 Jesse Chappell\n\n"
 | 
			
		||||
    +vstInfo+
 | 
			
		||||
    "Using " + fftlib + " for FFT\n\n"
 | 
			
		||||
    + juceversiontxt + " used under the GPL license.\n\n"
 | 
			
		||||
    "GPL licensed source code for this plugin at : https://bitbucket.org/xenakios/paulstretchplugin/overview\n";
 | 
			
		||||
    +vstInfo;
 | 
			
		||||
 | 
			
		||||
    if (fftlib.isNotEmpty())
 | 
			
		||||
        text += String("Using ") + fftlib + String(" for FFT\n\n");
 | 
			
		||||
 | 
			
		||||
#if !JUCE_IOS
 | 
			
		||||
    text += juceversiontxt + String(" used under the GPL license.\n\n");
 | 
			
		||||
    text += String("GPL licensed source code for this plugin at : https://bitbucket.org/xenakios/paulstretchplugin/overview\n");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (host.type != juce::PluginHostType::UnknownHost) {
 | 
			
		||||
        text += String("Running in : ") + host.getHostDescription()+ String("\n");
 | 
			
		||||
@@ -1347,20 +1373,28 @@ void WaveformComponent::mouseDoubleClick(const MouseEvent & e)
 | 
			
		||||
 | 
			
		||||
void WaveformComponent::mouseWheelMove(const MouseEvent & e, const MouseWheelDetails & wd)
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
	/*
 | 
			
		||||
	double factor = 0.9;
 | 
			
		||||
	if (wd.deltaY < 0.0)
 | 
			
		||||
		factor = 1.11111;
 | 
			
		||||
	//return;
 | 
			
		||||
 | 
			
		||||
    double width = getWidth();
 | 
			
		||||
	double normt = viewXToNormalized(e.x);
 | 
			
		||||
	double curlen = m_view_range.getLength();
 | 
			
		||||
	double newlen = curlen * factor;
 | 
			
		||||
	double oldt0 = m_view_range.getStart();
 | 
			
		||||
	double oldt1 = m_view_range.getEnd();
 | 
			
		||||
	double t0 = jlimit(0.0,1.0, normt + (curlen - newlen));
 | 
			
		||||
	double t1 = jlimit(0.0,1.0, t0+newlen);
 | 
			
		||||
	jassert(t1 > t0);
 | 
			
		||||
    double zoomFactor = 1.0 - curlen;
 | 
			
		||||
 | 
			
		||||
    double newfact = jlimit(0.0, 1.0, zoomFactor + wd.deltaY);
 | 
			
		||||
    double xratio = e.x / width;
 | 
			
		||||
    auto newScale = jmax (0.001, 1.0 * (1.0 - jlimit (0.0, 0.99, newfact)));
 | 
			
		||||
 | 
			
		||||
    double t0 = normt - newScale * xratio;
 | 
			
		||||
    double t1 = normt + newScale * (1.0 - xratio);
 | 
			
		||||
 | 
			
		||||
    t0 = jlimit(0.0,1.0, t0);
 | 
			
		||||
    t1 = jlimit(0.0,1.0, t1);
 | 
			
		||||
 | 
			
		||||
    DBG("normt: " << normt << " posratio: " << xratio << " curlen: " << curlen << " t0: " << t0 << " t1: " << t1 << " delta: " << wd.deltaY);
 | 
			
		||||
 | 
			
		||||
    jassert(t1 > t0);
 | 
			
		||||
	m_view_range = { t0,t1 };
 | 
			
		||||
 | 
			
		||||
	//m_view_range = m_view_range.constrainRange({ 0.0, 1.0 });
 | 
			
		||||
	jassert(m_view_range.getStart() >= 0.0 && m_view_range.getEnd() <= 1.0);
 | 
			
		||||
	jassert(m_view_range.getLength() > 0.001);
 | 
			
		||||
@@ -1368,7 +1402,7 @@ void WaveformComponent::mouseWheelMove(const MouseEvent & e, const MouseWheelDet
 | 
			
		||||
		ViewRangeChangedCallback(m_view_range);
 | 
			
		||||
	m_image_dirty = true;
 | 
			
		||||
	repaint();
 | 
			
		||||
	*/
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WaveformComponent::setAudioInfo(double sr, double seekpos, int fftsize)
 | 
			
		||||
@@ -1482,7 +1516,9 @@ void SpectralVisualizer::paint(Graphics & g)
 | 
			
		||||
 | 
			
		||||
void SpectralChainEditor::paint(Graphics & g)
 | 
			
		||||
{
 | 
			
		||||
	g.fillAll(Colours::black);
 | 
			
		||||
	//g.fillAll(Colours::black);
 | 
			
		||||
    g.fillRoundedRectangle(getLocalBounds().toFloat(), 4.0f);
 | 
			
		||||
 | 
			
		||||
	if (m_src == nullptr)
 | 
			
		||||
		return;
 | 
			
		||||
	
 | 
			
		||||
@@ -1815,7 +1851,13 @@ void PerfMeterComponent::paint(Graphics & g)
 | 
			
		||||
    m_gradient.point2 = {(float)getWidth(),0.0f};
 | 
			
		||||
    g.fillAll(Colours::grey);
 | 
			
		||||
	double amt = m_proc->getPreBufferingPercent();
 | 
			
		||||
	g.setColour(Colours::green.withAlpha(0.8f));
 | 
			
		||||
 | 
			
		||||
    if (enabled) {
 | 
			
		||||
        g.setColour(Colours::green.withAlpha(0.8f));
 | 
			
		||||
    } else {
 | 
			
		||||
        g.setColour(Colours::darkgrey.withAlpha(0.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	int w = amt * getWidth();
 | 
			
		||||
    //g.setGradientFill(m_gradient);
 | 
			
		||||
    g.fillRect(0, 0, w, getHeight());
 | 
			
		||||
@@ -1871,6 +1913,18 @@ void zoom_scrollbar::mouseDown(const MouseEvent &e)
 | 
			
		||||
	m_drag_start_x = e.x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void zoom_scrollbar::mouseDoubleClick (const MouseEvent&)
 | 
			
		||||
{
 | 
			
		||||
    // reset
 | 
			
		||||
    m_therange.setStart(0.0);
 | 
			
		||||
    m_therange.setEnd(1.0);
 | 
			
		||||
    repaint();
 | 
			
		||||
 | 
			
		||||
    if (RangeChanged)
 | 
			
		||||
        RangeChanged(m_therange);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void zoom_scrollbar::mouseMove(const MouseEvent &e)
 | 
			
		||||
{
 | 
			
		||||
	auto ha = get_hot_area(e.x, e.y);
 | 
			
		||||
@@ -1935,9 +1989,11 @@ void zoom_scrollbar::paint(Graphics &g)
 | 
			
		||||
	int x0 = (int)(getWidth()*m_therange.getStart());
 | 
			
		||||
	int x1 = (int)(getWidth()*m_therange.getEnd());
 | 
			
		||||
	if (m_hot_area != ha_none)
 | 
			
		||||
		g.setColour(Colours::white);
 | 
			
		||||
	else g.setColour(Colours::lightgrey);
 | 
			
		||||
	g.fillRect(x0, 0, x1 - x0, getHeight());
 | 
			
		||||
		g.setColour(Colours::white.withAlpha(0.8f));
 | 
			
		||||
	else g.setColour(Colours::grey);
 | 
			
		||||
	//g.fillRect(x0, 0, x1 - x0, getHeight());
 | 
			
		||||
    g.fillRoundedRectangle(x0, 0, x1 - x0, getHeight(), 8.0f);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void zoom_scrollbar::setRange(Range<double> rng, bool docallback)
 | 
			
		||||
@@ -1952,13 +2008,14 @@ void zoom_scrollbar::setRange(Range<double> rng, bool docallback)
 | 
			
		||||
 | 
			
		||||
zoom_scrollbar::hot_area zoom_scrollbar::get_hot_area(int x, int)
 | 
			
		||||
{
 | 
			
		||||
    int radius = 10;
 | 
			
		||||
	int x0 = (int)(getWidth()*m_therange.getStart());
 | 
			
		||||
	int x1 = (int)(getWidth()*m_therange.getEnd());
 | 
			
		||||
	if (is_in_range(x, x0 - 5, x0 + 5))
 | 
			
		||||
	if (is_in_range(x, x0 - radius, x0 + radius))
 | 
			
		||||
		return ha_left_edge;
 | 
			
		||||
	if (is_in_range(x, x1 - 5, x1 + 5))
 | 
			
		||||
	if (is_in_range(x, x1 - radius, x1 + radius))
 | 
			
		||||
		return ha_right_edge;
 | 
			
		||||
	if (is_in_range(x, x0 + 5, x1 - 5))
 | 
			
		||||
	if (is_in_range(x, x0 + radius, x1 - radius))
 | 
			
		||||
		return ha_handle;
 | 
			
		||||
	return ha_none;
 | 
			
		||||
}
 | 
			
		||||
@@ -2088,7 +2145,7 @@ void FreeFilterComponent::updateParameterComponents()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ParameterGroupComponent::ParameterGroupComponent(const String & name_, int groupid, PaulstretchpluginAudioProcessor* proc, bool showtoggle)
 | 
			
		||||
:name(name_), groupId(groupid), m_proc(proc), m_bgcolor(0xff1a1a1a)
 | 
			
		||||
:name(name_), groupId(groupid), m_proc(proc), m_bgcolor(0xff1a1a1a), m_selbgcolor(0xff0d1922)
 | 
			
		||||
{
 | 
			
		||||
    if (name_.isNotEmpty()) {
 | 
			
		||||
        m_namelabel = std::make_unique<Label>("name", name);
 | 
			
		||||
@@ -2097,9 +2154,18 @@ ParameterGroupComponent::ParameterGroupComponent(const String & name_, int group
 | 
			
		||||
 | 
			
		||||
    if (showtoggle) {
 | 
			
		||||
        //m_enableButton = std::make_unique<DrawableButton>("ena", DrawableButton::ImageFitted);
 | 
			
		||||
        m_enableButton = std::make_unique<ToggleButton>();
 | 
			
		||||
        //m_enableButton = std::make_unique<ToggleButton>();
 | 
			
		||||
        //m_enableButton->setColour(DrawableButton::backgroundOnColourId, Colours::blue);
 | 
			
		||||
        m_enableButton = std::make_unique<DrawableButton>("reven", DrawableButton::ButtonStyle::ImageFitted);
 | 
			
		||||
        std::unique_ptr<Drawable> powerimg(Drawable::createFromImageData(BinaryData::power_svg, BinaryData::power_svgSize));
 | 
			
		||||
        std::unique_ptr<Drawable> powerselimg(Drawable::createFromImageData(BinaryData::power_sel_svg, BinaryData::power_sel_svgSize));
 | 
			
		||||
        m_enableButton->setImages(powerimg.get(), nullptr, nullptr, nullptr, powerselimg.get());
 | 
			
		||||
        m_enableButton->setClickingTogglesState(true);
 | 
			
		||||
        m_enableButton->setColour(TextButton::buttonColourId, Colours::transparentBlack);
 | 
			
		||||
        m_enableButton->setColour(TextButton::buttonOnColourId, Colours::transparentBlack);
 | 
			
		||||
        m_enableButton->setColour(DrawableButton::backgroundColourId, Colours::transparentBlack);
 | 
			
		||||
        m_enableButton->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
 | 
			
		||||
 | 
			
		||||
        m_enableButton->onClick = [this]() {
 | 
			
		||||
            auto order = m_proc->getStretchSource()->getSpectrumProcessOrder();
 | 
			
		||||
            for (int i=0; i < order.size(); ++i) {
 | 
			
		||||
@@ -2158,13 +2224,15 @@ 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 minitemh = 28;
 | 
			
		||||
    int margin = 2;
 | 
			
		||||
    int minitemh = 26;
 | 
			
		||||
    int margin = 1;
 | 
			
		||||
    int outsidemargin = 4;
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    minitemh = 36;
 | 
			
		||||
    minitemh = 34;
 | 
			
		||||
    outsidemargin = 4;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -2184,14 +2252,14 @@ int ParameterGroupComponent::doLayout(Rectangle<int> bounds)
 | 
			
		||||
        //titlebox.items.add(FlexItem(4, minitemh));
 | 
			
		||||
 | 
			
		||||
        if (m_enableButton) {
 | 
			
		||||
            titlebox.items.add(FlexItem(enablew, minitemh, *m_enableButton).withMargin(margin));
 | 
			
		||||
            titlebox.items.add(FlexItem(enablew, minitemh, *m_enableButton).withMargin(margin).withMaxHeight(enablemaxh));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (m_namelabel) {
 | 
			
		||||
            titlebox.items.add(FlexItem(titlew-enablew, minitemh, *m_namelabel).withMargin(margin).withFlex(1));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        mainbox.items.add(FlexItem(titlew, minitemh, titlebox).withMargin(outsidemargin));
 | 
			
		||||
        mainbox.items.add(FlexItem(titlew, enablemaxh, titlebox).withMargin(1)/*.withAlignSelf(FlexItem::AlignSelf::center)*/);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < m_parcomps.size(); ++i)
 | 
			
		||||
@@ -2217,8 +2285,12 @@ void ParameterGroupComponent::resized()
 | 
			
		||||
 | 
			
		||||
void ParameterGroupComponent::paint(Graphics & g)
 | 
			
		||||
{
 | 
			
		||||
    g.setColour(m_bgcolor);
 | 
			
		||||
    g.fillRoundedRectangle(getLocalBounds().toFloat().reduced(0.0f), 4.0f);
 | 
			
		||||
    if (m_enableButton && m_enableButton->getToggleState()) {
 | 
			
		||||
        g.setColour(m_selbgcolor);
 | 
			
		||||
    } else {
 | 
			
		||||
        g.setColour(m_bgcolor);
 | 
			
		||||
    }
 | 
			
		||||
    g.fillRoundedRectangle(getLocalBounds().toFloat(), 4.0f);
 | 
			
		||||
    //g.fillRect(0, 0, getWidth(), getHeight());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2241,7 +2313,7 @@ void ParameterGroupComponent::updateParameterComponents()
 | 
			
		||||
        e->updateComponent();
 | 
			
		||||
        e->setAlpha(enabled ? 1.0f : 0.5f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    repaint();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AudioFilePreviewComponent::processBlock(double sr, AudioBuffer<float>& buf)
 | 
			
		||||
@@ -2256,7 +2328,7 @@ void AudioFilePreviewComponent::processBlock(double sr, AudioBuffer<float>& buf)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MyFileBrowserComponent::MyFileBrowserComponent(PaulstretchpluginAudioProcessor & p) :
 | 
			
		||||
	m_proc(p), m_filefilter(p.m_afm->getWildcardForAllFormats(),String(),String())
 | 
			
		||||
	 m_filefilter(p.m_afm->getWildcardForAllFormats(),String(),String()), m_proc(p)
 | 
			
		||||
{
 | 
			
		||||
	String initiallocfn = m_proc.m_propsfile->m_props_file->getValue("importfilefolder",
 | 
			
		||||
		File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,8 @@ public:
 | 
			
		||||
	void mouseDrag(const MouseEvent& e) override;
 | 
			
		||||
	void mouseEnter(const MouseEvent &event) override;
 | 
			
		||||
	void mouseExit(const MouseEvent &event) override;
 | 
			
		||||
    void mouseDoubleClick (const MouseEvent&) override;
 | 
			
		||||
 | 
			
		||||
	void paint(Graphics &g) override;
 | 
			
		||||
	std::function<void(Range<double>)> RangeChanged;
 | 
			
		||||
	Range<double> get_range() const { return m_therange; }
 | 
			
		||||
@@ -135,14 +137,15 @@ private:
 | 
			
		||||
    //uptrvec<ParameterComponent> m_parcomps;
 | 
			
		||||
    std::vector<ParameterComponent*> m_parcomps;
 | 
			
		||||
    std::unique_ptr<Label> m_namelabel;
 | 
			
		||||
    //std::unique_ptr<DrawableButton> m_enableButton;
 | 
			
		||||
    std::unique_ptr<ToggleButton> m_enableButton;
 | 
			
		||||
    std::unique_ptr<DrawableButton> m_enableButton;
 | 
			
		||||
    //std::unique_ptr<ToggleButton> m_enableButton;
 | 
			
		||||
 | 
			
		||||
    CriticalSection* m_cs = nullptr;
 | 
			
		||||
    PaulstretchpluginAudioProcessor* m_proc = nullptr;
 | 
			
		||||
    int m_slidwidth = 400;
 | 
			
		||||
 | 
			
		||||
    Colour m_bgcolor;
 | 
			
		||||
    Colour m_selbgcolor;
 | 
			
		||||
 | 
			
		||||
    int m_minHeight = 0;
 | 
			
		||||
    int m_lastForWidth = -1;
 | 
			
		||||
@@ -158,6 +161,8 @@ public:
 | 
			
		||||
	void mouseDown(const MouseEvent& ev) override;
 | 
			
		||||
	void timerCallback() override;
 | 
			
		||||
	PaulstretchpluginAudioProcessor* m_proc = nullptr;
 | 
			
		||||
 | 
			
		||||
    bool enabled = true;
 | 
			
		||||
private:
 | 
			
		||||
    ColourGradient m_gradient;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -30,12 +30,15 @@ int get_optimized_updown(int n, bool up) {
 | 
			
		||||
	while (true) {
 | 
			
		||||
		n = orig_n;
 | 
			
		||||
 | 
			
		||||
		while (!(n % 11)) n /= 11;
 | 
			
		||||
        // only powers of two allowed if using VDSP FFT
 | 
			
		||||
#if !PS_USE_VDSP_FFT
 | 
			
		||||
        while (!(n % 11)) n /= 11;
 | 
			
		||||
		while (!(n % 7)) n /= 7;
 | 
			
		||||
 | 
			
		||||
		while (!(n % 5)) n /= 5;
 | 
			
		||||
		while (!(n % 3)) n /= 3;
 | 
			
		||||
		while (!(n % 2)) n /= 2;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        while (!(n % 2)) n /= 2;
 | 
			
		||||
		if (n<2) break;
 | 
			
		||||
		if (up) orig_n++;
 | 
			
		||||
		else orig_n--;
 | 
			
		||||
@@ -566,9 +569,13 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
 | 
			
		||||
	processor->setNonRealtime(true);
 | 
			
		||||
	processor->setStateFromTree(state);
 | 
			
		||||
	double outsr{ renderpars.outsr };
 | 
			
		||||
	if (outsr < 10.0)
 | 
			
		||||
		outsr = processor->getStretchSource()->getInfileSamplerate();
 | 
			
		||||
	Logger::writeToLog(outputfiletouse.getFullPathName() + " " + String(outsr) + " " + String(renderpars.outputformat));
 | 
			
		||||
    if (outsr < 10.0) {
 | 
			
		||||
        outsr = processor->getStretchSource()->getInfileSamplerate();
 | 
			
		||||
        if (outsr < 10.0)
 | 
			
		||||
            outsr = 44100;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Logger::writeToLog(outputfiletouse.getFullPathName() + " " + String(outsr) + " " + String(renderpars.outputformat));
 | 
			
		||||
	int blocksize{ 1024 };
 | 
			
		||||
	int numoutchans = *processor->getIntParameter(cpi_num_outchans);
 | 
			
		||||
	auto sc = processor->getStretchSource();
 | 
			
		||||
@@ -611,6 +618,10 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
 | 
			
		||||
 | 
			
		||||
            m_offline_render_state = 200;
 | 
			
		||||
            Logger::writeToLog("Render failed, could not open file!");
 | 
			
		||||
            if (renderpars.completionHandler) {
 | 
			
		||||
                renderpars.completionHandler(false, outputfiletouse);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return;
 | 
			
		||||
        } else {
 | 
			
		||||
            outstream.release(); // the writer takes ownership
 | 
			
		||||
@@ -634,6 +645,10 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
 | 
			
		||||
                m_offline_render_state = 100.0 / outlenframes * outcounter;
 | 
			
		||||
            }
 | 
			
		||||
            m_offline_render_state = 200;
 | 
			
		||||
 | 
			
		||||
            if (renderpars.completionHandler) {
 | 
			
		||||
                renderpars.completionHandler(true, outputfiletouse);
 | 
			
		||||
            }
 | 
			
		||||
            Logger::writeToLog("Rendered ok!");
 | 
			
		||||
        }
 | 
			
		||||
	};
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,9 @@ www.gnu.org/licenses
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "../JuceLibraryCode/JuceHeader.h"
 | 
			
		||||
#include "PS_Source/PaulStretchControl.h"
 | 
			
		||||
 | 
			
		||||
#include "../JuceLibraryCode/JuceHeader.h"
 | 
			
		||||
#include "jcdp_envelope.h"
 | 
			
		||||
#include <array>
 | 
			
		||||
 | 
			
		||||
@@ -122,8 +123,8 @@ class PaulstretchpluginAudioProcessorEditor;
 | 
			
		||||
 | 
			
		||||
struct OfflineRenderParams
 | 
			
		||||
{
 | 
			
		||||
	OfflineRenderParams(File ofile, double osr, int oformat, double omaxdur, int onumloops, CallOutBox* ocb=nullptr) :
 | 
			
		||||
		outputfile(ofile), outsr(osr), maxoutdur(omaxdur), numloops(onumloops), outputformat(oformat), cbox(ocb)
 | 
			
		||||
	OfflineRenderParams(File ofile, double osr, int oformat, double omaxdur, int onumloops, CallOutBox* ocb=nullptr, std::function<void(bool,File file)> completion=nullptr) :
 | 
			
		||||
		outputfile(ofile), outsr(osr), maxoutdur(omaxdur), numloops(onumloops), outputformat(oformat), cbox(ocb), completionHandler(completion)
 | 
			
		||||
	{}
 | 
			
		||||
	File outputfile;
 | 
			
		||||
	double outsr = 44100.0;
 | 
			
		||||
@@ -131,6 +132,7 @@ struct OfflineRenderParams
 | 
			
		||||
	int numloops = 1;
 | 
			
		||||
	int outputformat = 0; // 0=16 bit pcm, 1=24 bit pcm, 2=32 bit float, 3=32 bit float clipped
 | 
			
		||||
	CallOutBox* cbox = nullptr;
 | 
			
		||||
    std::function<void(bool,File file)> completionHandler;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class PaulstretchpluginAudioProcessor  : public AudioProcessor, 
 | 
			
		||||
@@ -274,8 +276,8 @@ private:
 | 
			
		||||
	double m_last_in_pos = 0.0;
 | 
			
		||||
	std::vector<int> m_bufamounts{ 4096,8192,16384,32768,65536,262144 };
 | 
			
		||||
	ProcessParameters m_ppar;
 | 
			
		||||
    int mPluginWindowWidth = 870;
 | 
			
		||||
    int mPluginWindowHeight = 770;
 | 
			
		||||
    int mPluginWindowWidth = 820;
 | 
			
		||||
    int mPluginWindowHeight = 692;
 | 
			
		||||
 | 
			
		||||
	void setFFTSize(double size);
 | 
			
		||||
	void startplay(Range<double> playrange, int numoutchans, int maxBlockSize, String& err);
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,12 @@ RenderSettingsComponent::RenderSettingsComponent (PaulstretchpluginAudioProcesso
 | 
			
		||||
	addAndMakeVisible(&label4);
 | 
			
		||||
	label4.setText("Output file :\n", dontSendNotification);
 | 
			
		||||
    
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    addAndMakeVisible(&m_shareAfterRenderToggle);
 | 
			
		||||
    m_shareAfterRenderToggle.setButtonText("Share after render");
 | 
			
		||||
    bool lastshare = m_proc->m_propsfile->m_props_file->getBoolValue(ID_lastrendershare, false);
 | 
			
		||||
    m_shareAfterRenderToggle.setToggleState(lastshare, dontSendNotification);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	addAndMakeVisible(&outfileNameEditor);
 | 
			
		||||
    outfileNameEditor.setMultiLine (false);
 | 
			
		||||
@@ -78,18 +84,24 @@ RenderSettingsComponent::RenderSettingsComponent (PaulstretchpluginAudioProcesso
 | 
			
		||||
	buttonSelectFile.setTooltip("Open dialog to choose file to render to");
 | 
			
		||||
	buttonSelectFile.setButtonText (TRANS("..."));
 | 
			
		||||
    buttonSelectFile.addListener (this);
 | 
			
		||||
	setSize (600, 400);
 | 
			
		||||
	setSize (prefWidth, prefHeight);
 | 
			
		||||
	comboBoxSamplerate.setSelectedId(1);
 | 
			
		||||
    comboBoxBitDepth.setSelectedId(3);
 | 
			
		||||
	String lastexportfile = m_proc->m_propsfile->m_props_file->getValue(ID_lastrenderpath);
 | 
			
		||||
	auto sep = File::getSeparatorChar();
 | 
			
		||||
	File temp(lastexportfile);
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    outfileNameEditor.setText(temp.getFileName(), dontSendNotification);
 | 
			
		||||
#else
 | 
			
		||||
	if (temp.getParentDirectory().exists())
 | 
			
		||||
		outfileNameEditor.setText(lastexportfile, dontSendNotification);
 | 
			
		||||
	else
 | 
			
		||||
		outfileNameEditor.setText(File::getSpecialLocation(File::userDocumentsDirectory).getFullPathName()+sep+"pxsrender.wav",
 | 
			
		||||
			dontSendNotification);
 | 
			
		||||
	numLoopsEditor.setVisible(m_proc->getStretchSource()->isLoopingEnabled());
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    numLoopsEditor.setVisible(m_proc->getStretchSource()->isLoopingEnabled());
 | 
			
		||||
	label3.setVisible(m_proc->getStretchSource()->isLoopingEnabled());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -101,40 +113,88 @@ RenderSettingsComponent::~RenderSettingsComponent()
 | 
			
		||||
//==============================================================================
 | 
			
		||||
void RenderSettingsComponent::paint (Graphics& g)
 | 
			
		||||
{
 | 
			
		||||
    g.fillAll (Colour (0xff323e44));
 | 
			
		||||
    //g.fillAll (Colour (0xff323e44));
 | 
			
		||||
    g.fillAll(Colour::fromFloatRGBA(0.1, 0.1, 0.1, 1.0));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RenderSettingsComponent::resized()
 | 
			
		||||
{
 | 
			
		||||
	int xoffs = 8;
 | 
			
		||||
	int yoffs = 1;
 | 
			
		||||
	int labelw = 160;
 | 
			
		||||
	int labelh = 24;
 | 
			
		||||
	
 | 
			
		||||
	label4.setBounds(xoffs, yoffs, labelw, 24);
 | 
			
		||||
	outfileNameEditor.setBounds(label4.getRight()+1, yoffs, getWidth() - labelw - 34 - xoffs, 24);
 | 
			
		||||
	buttonSelectFile.setBounds(outfileNameEditor.getRight() + 1, yoffs, 31, 24);
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	labelSamplerate.setBounds (xoffs, yoffs, labelw, labelh);
 | 
			
		||||
    comboBoxSamplerate.setBounds (labelSamplerate.getRight()+1, yoffs, 150, 24);
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	labelBitDepth.setBounds (xoffs, yoffs, labelw, 24);
 | 
			
		||||
    comboBoxBitDepth.setBounds (labelBitDepth.getRight()+1, yoffs, 150, 24);
 | 
			
		||||
	m_toggleFloatClip.setBounds(comboBoxBitDepth.getRight() + 1, yoffs, 10, 24);
 | 
			
		||||
	m_toggleFloatClip.changeWidthToFitText();
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	if (m_proc->getStretchSource()->isLoopingEnabled())
 | 
			
		||||
	{
 | 
			
		||||
		label3.setBounds(xoffs, yoffs, labelw, 48);
 | 
			
		||||
		numLoopsEditor.setBounds(label3.getRight() + 1, yoffs, 150, 24);
 | 
			
		||||
		yoffs += 50;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	m_labelMaxOutDuration.setBounds(xoffs, yoffs, 220, 24);
 | 
			
		||||
	m_editorMaxOutDuration.setBounds(m_labelMaxOutDuration.getRight() + 1, yoffs, 50, 24);
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	buttonRender.setBounds(getWidth() - 152, getHeight()-25, 150, 24);
 | 
			
		||||
	int labelw = 120;
 | 
			
		||||
    int widelabelw = 210;
 | 
			
		||||
	int itemh = 28;
 | 
			
		||||
    int tallitemh = 40;
 | 
			
		||||
    int minitemw = 150;
 | 
			
		||||
    int smallitemw = 50;
 | 
			
		||||
    int margin = 2;
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    itemh = 36;
 | 
			
		||||
    tallitemh = 42;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    FlexBox mainbox;
 | 
			
		||||
    mainbox.flexDirection = FlexBox::Direction::column;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    FlexBox outbox;
 | 
			
		||||
    outbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    outbox.items.add(FlexItem(labelw, itemh, label4).withMargin(margin));
 | 
			
		||||
    outbox.items.add(FlexItem(minitemw, itemh, outfileNameEditor).withMargin(margin).withFlex(1));
 | 
			
		||||
#if !JUCE_IOS
 | 
			
		||||
    outbox.items.add(FlexItem(36, itemh, buttonSelectFile).withMargin(margin));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    FlexBox srbox;
 | 
			
		||||
    srbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    srbox.items.add(FlexItem(labelw, itemh, labelSamplerate).withMargin(margin));
 | 
			
		||||
    srbox.items.add(FlexItem(minitemw, itemh, comboBoxSamplerate).withMargin(margin));
 | 
			
		||||
 | 
			
		||||
    FlexBox forbox;
 | 
			
		||||
    forbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    forbox.items.add(FlexItem(labelw, itemh, labelBitDepth).withMargin(margin));
 | 
			
		||||
    forbox.items.add(FlexItem(minitemw, itemh, comboBoxBitDepth).withMargin(margin));
 | 
			
		||||
    forbox.items.add(FlexItem(minitemw, itemh, m_toggleFloatClip).withMargin(margin).withFlex(1));
 | 
			
		||||
 | 
			
		||||
    FlexBox loopbox;
 | 
			
		||||
    loopbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    loopbox.items.add(FlexItem(labelw, tallitemh, label3).withMargin(margin));
 | 
			
		||||
    loopbox.items.add(FlexItem(smallitemw, itemh, numLoopsEditor).withMargin(margin).withMaxHeight(itemh).withAlignSelf(FlexItem::AlignSelf::flexStart));
 | 
			
		||||
 | 
			
		||||
    FlexBox maxbox;
 | 
			
		||||
    maxbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    maxbox.items.add(FlexItem(widelabelw, itemh, m_labelMaxOutDuration).withMargin(margin));
 | 
			
		||||
    maxbox.items.add(FlexItem(smallitemw, itemh, m_editorMaxOutDuration).withMargin(margin));
 | 
			
		||||
 | 
			
		||||
    FlexBox buttonbox;
 | 
			
		||||
    buttonbox.flexDirection = FlexBox::Direction::row;
 | 
			
		||||
    buttonbox.items.add(FlexItem(minitemw, itemh).withFlex(1));
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    buttonbox.items.add(FlexItem(labelw, itemh, m_shareAfterRenderToggle).withMargin(margin).withFlex(1));
 | 
			
		||||
    buttonbox.items.add(FlexItem(4, itemh).withFlex(0.1).withMaxWidth(20));
 | 
			
		||||
#endif
 | 
			
		||||
    buttonbox.items.add(FlexItem(minitemw, itemh, buttonRender).withMargin(margin));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, itemh, outbox).withMargin(margin));
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, itemh, srbox).withMargin(margin));
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, itemh, forbox).withMargin(margin));
 | 
			
		||||
 | 
			
		||||
    if (m_proc->getStretchSource()->isLoopingEnabled()) {
 | 
			
		||||
        mainbox.items.add(FlexItem(minitemw, tallitemh, loopbox).withMargin(margin));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, itemh, maxbox).withMargin(margin));
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, 2).withFlex(0.1));
 | 
			
		||||
    mainbox.items.add(FlexItem(minitemw, itemh, buttonbox).withMargin(margin));
 | 
			
		||||
 | 
			
		||||
    mainbox.performLayout(getLocalBounds().reduced(2));
 | 
			
		||||
 | 
			
		||||
    prefHeight = 4;
 | 
			
		||||
 | 
			
		||||
    for (auto & item : mainbox.items) {
 | 
			
		||||
        prefHeight += item.minHeight + item.margin.top + item.margin.bottom;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RenderSettingsComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
 | 
			
		||||
@@ -152,15 +212,32 @@ void RenderSettingsComponent::buttonClicked (Button* buttonThatWasClicked)
 | 
			
		||||
{
 | 
			
		||||
    if (buttonThatWasClicked == &buttonRender)
 | 
			
		||||
    {
 | 
			
		||||
		File outfile(outfileNameEditor.getText());
 | 
			
		||||
		if (outfile.getParentDirectory().exists()==false)
 | 
			
		||||
        File outfile;
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
        // force outfile to be in Documents
 | 
			
		||||
        outfile = File::getSpecialLocation(File::SpecialLocationType::userDocumentsDirectory).getChildFile(outfileNameEditor.getText());
 | 
			
		||||
#else
 | 
			
		||||
        outfile = File(outfileNameEditor.getText());
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        if (!pendingRender && outfile.getParentDirectory().exists()==false) {
 | 
			
		||||
			buttonClicked(&buttonSelectFile);
 | 
			
		||||
		outfile = File(outfileNameEditor.getText());
 | 
			
		||||
		if (outfile.getParentDirectory().exists()==false)
 | 
			
		||||
			return;
 | 
			
		||||
            pendingRender = true;
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        else if (outfile.getParentDirectory().exists()==false) {
 | 
			
		||||
            pendingRender = false;
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!outfile.getFileExtension().equalsIgnoreCase(".wav")) {
 | 
			
		||||
            outfile = outfile.withFileExtension(".wav");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		int numLoops = 0; 
 | 
			
		||||
		if (numLoopsEditor.isVisible())
 | 
			
		||||
			numLoops = numLoopsEditor.getText().getLargeIntValue();
 | 
			
		||||
			numLoops = (int) numLoopsEditor.getText().getLargeIntValue();
 | 
			
		||||
		numLoops = jlimit<int>(0, 1000000, numLoops);
 | 
			
		||||
		int sampleRate = comboBoxSamplerate.getSelectedId();
 | 
			
		||||
		if (sampleRate == 1)
 | 
			
		||||
@@ -170,50 +247,91 @@ void RenderSettingsComponent::buttonClicked (Button* buttonThatWasClicked)
 | 
			
		||||
		int oformat = comboBoxBitDepth.getSelectedId() - 1;
 | 
			
		||||
		if (oformat == 2 && m_toggleFloatClip.getToggleState())
 | 
			
		||||
			oformat = 3;
 | 
			
		||||
		OfflineRenderParams renderpars{ File(outfileNameEditor.getText()),(double)comboBoxSamplerate.getSelectedId(),
 | 
			
		||||
			oformat,maxrenderlen,numLoops };
 | 
			
		||||
		m_proc->m_propsfile->m_props_file->setValue(ID_lastrenderpath, outfileNameEditor.getText());
 | 
			
		||||
 | 
			
		||||
        std::function<void(bool,File file)> completion;
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
        if (m_shareAfterRenderToggle.getToggleState()) {
 | 
			
		||||
            completion = [](bool status,File file) {
 | 
			
		||||
                // this completion handler will be called from another thread
 | 
			
		||||
                MessageManager::callAsync([status,file]() {
 | 
			
		||||
 | 
			
		||||
                    if (status) {
 | 
			
		||||
                        DBG("Finished render, sharing");
 | 
			
		||||
                        Array<URL> files;
 | 
			
		||||
                        files.add(URL(file));
 | 
			
		||||
 | 
			
		||||
                        ContentSharer::getInstance()->shareFiles(files, [](bool status, const String & message) {
 | 
			
		||||
                            if (status) {
 | 
			
		||||
                                DBG("Finished share");
 | 
			
		||||
                            } else {
 | 
			
		||||
                                DBG("Error sharing: " << message);
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                    } else {
 | 
			
		||||
                        DBG("error rendering");
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		OfflineRenderParams renderpars{ outfile,(double)comboBoxSamplerate.getSelectedId(),
 | 
			
		||||
			oformat,maxrenderlen,numLoops, nullptr, completion };
 | 
			
		||||
		m_proc->m_propsfile->m_props_file->setValue(ID_lastrenderpath, outfile.getFullPathName());
 | 
			
		||||
        m_proc->m_propsfile->m_props_file->setValue(ID_lastrendershare, m_shareAfterRenderToggle.getToggleState());
 | 
			
		||||
		m_proc->offlineRender(renderpars);
 | 
			
		||||
		if (auto pardlg = dynamic_cast<CallOutBox*>(getParentComponent()); pardlg!=nullptr)
 | 
			
		||||
		{
 | 
			
		||||
			pardlg->exitModalState(1);
 | 
			
		||||
            pardlg->dismiss();
 | 
			
		||||
            //pardlg->exitModalState(1);
 | 
			
		||||
		}
 | 
			
		||||
		return;
 | 
			
		||||
    }
 | 
			
		||||
    else if (buttonThatWasClicked == &buttonSelectFile)
 | 
			
		||||
    {
 | 
			
		||||
		File lastexportfolder; // File(g_propsfile->getValue("last_export_file")).getParentDirectory();
 | 
			
		||||
		FileChooser myChooser("Please select audio file to render...",
 | 
			
		||||
			lastexportfolder,
 | 
			
		||||
			"*.wav");
 | 
			
		||||
        myChooser.launchAsync(FileBrowserComponent::saveMode, [this](const FileChooser &chooser) {
 | 
			
		||||
			outfileNameEditor.setText(chooser.getResult().getFullPathName(), dontSendNotification);
 | 
			
		||||
 | 
			
		||||
        m_filechooser = std::make_unique<FileChooser>("Please select audio file to render...",
 | 
			
		||||
                                                      lastexportfolder,
 | 
			
		||||
                                                      "*.wav");
 | 
			
		||||
        m_filechooser->launchAsync(FileBrowserComponent::saveMode, [this](const FileChooser &chooser) {
 | 
			
		||||
            String newpath = chooser.getResult().getFullPathName();
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
            // not actually used here, but just in case for later
 | 
			
		||||
            newpath = chooser.getResult().getFileName();
 | 
			
		||||
#endif
 | 
			
		||||
			outfileNameEditor.setText(newpath, dontSendNotification);
 | 
			
		||||
            if (newpath.isNotEmpty() && pendingRender) {
 | 
			
		||||
                buttonClicked(&buttonRender);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int RenderSettingsComponent::getPreferredHeight()
 | 
			
		||||
int RenderSettingsComponent::getPreferredHeight() const
 | 
			
		||||
{
 | 
			
		||||
	if (m_proc->getStretchSource()->isLoopingEnabled())
 | 
			
		||||
		return 180;
 | 
			
		||||
	return 150;
 | 
			
		||||
    return prefHeight;
 | 
			
		||||
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    if (m_proc->getStretchSource()->isLoopingEnabled())
 | 
			
		||||
        return 300;
 | 
			
		||||
    return 260;
 | 
			
		||||
#else
 | 
			
		||||
    if (m_proc->getStretchSource()->isLoopingEnabled())
 | 
			
		||||
        return 230;
 | 
			
		||||
    return 190;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int RenderSettingsComponent::getPreferredWidth() const
 | 
			
		||||
{
 | 
			
		||||
    return prefWidth;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void RenderSettingsComponent::textEditorTextChanged(TextEditor & ed)
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
	if (&ed == &outfileNameEditor)
 | 
			
		||||
	{
 | 
			
		||||
		File temp(outfileNameEditor.getText());
 | 
			
		||||
		if (temp.getParentDirectory().exists() == false)
 | 
			
		||||
		{
 | 
			
		||||
			Logger::writeToLog("directory does not exist");
 | 
			
		||||
		}
 | 
			
		||||
		if (temp.exists() == true)
 | 
			
		||||
		{
 | 
			
		||||
			File temp2 = temp.getNonexistentSibling();
 | 
			
		||||
			Logger::writeToLog(temp.getFullPathName() + " exists, will instead use " + temp2.getFullPathName());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,8 @@ public:
 | 
			
		||||
    void resized() override;
 | 
			
		||||
    void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override;
 | 
			
		||||
    void buttonClicked (Button* buttonThatWasClicked) override;
 | 
			
		||||
	int getPreferredHeight();
 | 
			
		||||
	int getPreferredHeight() const;
 | 
			
		||||
    int getPreferredWidth() const;
 | 
			
		||||
	void textEditorTextChanged(TextEditor& ed) override;
 | 
			
		||||
private:
 | 
			
		||||
	PaulstretchpluginAudioProcessor * m_proc = nullptr;
 | 
			
		||||
@@ -51,7 +52,13 @@ private:
 | 
			
		||||
	Label m_labelMaxOutDuration;
 | 
			
		||||
	TextEditor m_editorMaxOutDuration;
 | 
			
		||||
	ToggleButton m_toggleFloatClip;
 | 
			
		||||
    ToggleButton m_shareAfterRenderToggle;
 | 
			
		||||
	String ID_lastrenderpath{ "lastrenderpath" };
 | 
			
		||||
    String ID_lastrendershare{ "lastrendershare" };
 | 
			
		||||
    int prefHeight = 400;
 | 
			
		||||
    int prefWidth = 500;
 | 
			
		||||
    std::unique_ptr<FileChooser> m_filechooser;
 | 
			
		||||
    bool pendingRender = false;
 | 
			
		||||
	//==============================================================================
 | 
			
		||||
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RenderSettingsComponent)
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,11 @@ void EnvelopeComponent::show_bubble(int x, int y, const envelope_point& node)
 | 
			
		||||
 | 
			
		||||
void EnvelopeComponent::paint(Graphics& g)
 | 
			
		||||
{
 | 
			
		||||
    float targsize = 8.0;
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    targsize = 16.0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (!EnvelopeUnderlayDraw)
 | 
			
		||||
	{
 | 
			
		||||
		g.fillAll(Colours::black);
 | 
			
		||||
@@ -119,8 +124,8 @@ void EnvelopeComponent::paint(Graphics& g)
 | 
			
		||||
		double ycor = (double)getHeight() - jmap(pt.pt_y, m_view_start_value, m_view_end_value, 0.0, (double)getHeight());
 | 
			
		||||
		g.setColour(Colours::white);
 | 
			
		||||
		if (pt.Status == 0)
 | 
			
		||||
			g.drawRect((float)xcor - 4.0f, (float)ycor - 4.0f, 8.0f, 8.0f, 1.0f);
 | 
			
		||||
		else g.fillRect((float)xcor - 4.0f, (float)ycor - 4.0f, 8.0f, 8.0f);
 | 
			
		||||
			g.drawRect((float)xcor - targsize*0.5f, (float)ycor - targsize*0.5f, targsize, targsize, 1.0f);
 | 
			
		||||
		else g.fillRect((float)xcor - targsize*0.5f, (float)ycor - targsize*0.5f, targsize, targsize);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -406,7 +411,11 @@ int EnvelopeComponent::find_hot_envelope_point(double xcor, double ycor)
 | 
			
		||||
		const envelope_point& pt = m_envelope->GetNodeAtIndex(i);
 | 
			
		||||
		double ptxcor = jmap(pt.pt_x, m_view_start_time, m_view_end_time, 0.0, (double)getWidth());
 | 
			
		||||
		double ptycor = (double)getHeight() - jmap(pt.pt_y, m_view_start_value, m_view_end_value, 0.0, (double)getHeight());
 | 
			
		||||
		juce::Rectangle<double> target(ptxcor - 4.0, ptycor - 4.0, 8.0, 8.0);
 | 
			
		||||
        float targsize = 8.0;
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
        targsize = 16.0;
 | 
			
		||||
#endif
 | 
			
		||||
        juce::Rectangle<double> target(ptxcor - targsize*0.5f, ptycor - targsize*0.5, targsize, targsize);
 | 
			
		||||
		if (target.contains(xcor, ycor) == true)
 | 
			
		||||
		{
 | 
			
		||||
			return i;
 | 
			
		||||
@@ -417,6 +426,11 @@ int EnvelopeComponent::find_hot_envelope_point(double xcor, double ycor)
 | 
			
		||||
 | 
			
		||||
int EnvelopeComponent::findHotEnvelopeSegment(double xcor, double ycor, bool detectsegment)
 | 
			
		||||
{
 | 
			
		||||
    float targsize = 8.0;
 | 
			
		||||
#if JUCE_IOS
 | 
			
		||||
    targsize = 16.0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (m_envelope == nullptr)
 | 
			
		||||
		return -1;
 | 
			
		||||
	for (int i = 0; i < m_envelope->GetNumPoints()-1; ++i)
 | 
			
		||||
 
 | 
			
		||||
@@ -52,12 +52,16 @@
 | 
			
		||||
            file="Source/PluginProcessor.cpp"/>
 | 
			
		||||
      <FILE id="pt5tX8" name="PluginProcessor.h" compile="0" resource="0"
 | 
			
		||||
            file="Source/PluginProcessor.h"/>
 | 
			
		||||
      <FILE id="id3jov" name="power.svg" compile="0" resource="1" file="Source/power.svg"/>
 | 
			
		||||
      <FILE id="qKY0Ks" name="power_sel.svg" compile="0" resource="1" file="Source/power_sel.svg"/>
 | 
			
		||||
      <FILE id="KcXfhC" name="ps3_BufferingAudioSource.cpp" compile="1" resource="0"
 | 
			
		||||
            file="Source/ps3_BufferingAudioSource.cpp"/>
 | 
			
		||||
      <FILE id="oWbh5E" name="ps3_BufferingAudioSource.h" compile="0" resource="0"
 | 
			
		||||
            file="Source/ps3_BufferingAudioSource.h"/>
 | 
			
		||||
      <FILE id="RanaVV" name="RenderSettingsComponent.cpp" compile="1" resource="0"
 | 
			
		||||
            file="Source/RenderSettingsComponent.cpp"/>
 | 
			
		||||
      <FILE id="ShLJi7" name="RenderSettingsComponent.h" compile="0" resource="0"
 | 
			
		||||
            file="Source/RenderSettingsComponent.h"/>
 | 
			
		||||
      <FILE id="TDOHpE" name="resample.cpp" compile="1" resource="0" file="Source/WDL/resample.cpp"/>
 | 
			
		||||
    </GROUP>
 | 
			
		||||
  </MAINGROUP>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user