2018-05-09 11:02:22 +00:00
|
|
|
|
/*
|
2017-11-13 15:06:08 +00:00
|
|
|
|
|
2017-12-17 19:40:35 +00:00
|
|
|
|
Copyright (C) 2017 Xenakios
|
2017-11-13 15:06:08 +00:00
|
|
|
|
|
2017-12-17 19:40:35 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
2018-06-04 19:04:53 +00:00
|
|
|
|
it under the terms of version 3 of the GNU General Public License
|
2017-12-17 19:40:35 +00:00
|
|
|
|
as published by the Free Software Foundation.
|
2017-11-13 15:06:08 +00:00
|
|
|
|
|
2017-12-17 19:40:35 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-06-04 19:04:53 +00:00
|
|
|
|
GNU General Public License (version 3) for more details.
|
|
|
|
|
|
|
|
|
|
www.gnu.org/licenses
|
2017-12-17 19:40:35 +00:00
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2018-06-04 19:04:53 +00:00
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
|
#include "PluginProcessor.h"
|
|
|
|
|
#include "PluginEditor.h"
|
2017-12-19 01:50:55 +00:00
|
|
|
|
#include <array>
|
2018-05-07 17:43:27 +00:00
|
|
|
|
#include "RenderSettingsComponent.h"
|
2017-11-13 15:06:08 +00:00
|
|
|
|
|
|
|
|
|
//==============================================================================
|
2018-01-03 15:15:57 +00:00
|
|
|
|
PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p)
|
|
|
|
|
: AudioProcessorEditor(&p),
|
2018-01-17 16:57:56 +00:00
|
|
|
|
m_wavecomponent(p.m_afm,p.m_thumb.get()),
|
2018-02-27 00:33:41 +00:00
|
|
|
|
processor(p), m_perfmeter(&p),
|
2018-06-29 12:13:49 +00:00
|
|
|
|
m_wavefilter_tab(p.m_cur_tab_index),
|
2018-06-29 11:49:11 +00:00
|
|
|
|
m_free_filter_component(&p)
|
2017-11-13 15:06:08 +00:00
|
|
|
|
{
|
2018-02-27 20:15:14 +00:00
|
|
|
|
m_wave_container = new Component;
|
2018-06-29 11:23:48 +00:00
|
|
|
|
m_free_filter_component.getEnvelopeComponent()->set_envelope(processor.m_free_filter_envelope);
|
2018-07-08 11:38:50 +00:00
|
|
|
|
m_free_filter_component.getEnvelopeComponent()->XFromNormalized = [this](double x)
|
2018-02-27 13:02:34 +00:00
|
|
|
|
{
|
2018-02-27 17:21:00 +00:00
|
|
|
|
//return jmap<double>(pow(x, 3.0), 0.0, 1.0, 30.0, processor.getSampleRateChecked()/2.0);
|
|
|
|
|
return 30.0*pow(1.05946309436, x*115.0);
|
2018-02-27 13:02:34 +00:00
|
|
|
|
};
|
2018-07-08 11:38:50 +00:00
|
|
|
|
m_free_filter_component.getEnvelopeComponent()->YFromNormalized = [this](double x)
|
2018-02-27 13:02:34 +00:00
|
|
|
|
{
|
2018-03-03 13:57:24 +00:00
|
|
|
|
return jmap<double>(x, 0.0, 1.0, -48.0, 12.0);
|
2018-02-27 13:02:34 +00:00
|
|
|
|
};
|
|
|
|
|
m_wavefilter_tab.setTabBarDepth(20);
|
2018-02-27 00:33:41 +00:00
|
|
|
|
|
|
|
|
|
addAndMakeVisible(&m_perfmeter);
|
2018-01-31 18:58:16 +00:00
|
|
|
|
|
2017-11-14 16:14:14 +00:00
|
|
|
|
addAndMakeVisible(&m_import_button);
|
|
|
|
|
m_import_button.setButtonText("Import file...");
|
2018-01-03 15:15:57 +00:00
|
|
|
|
m_import_button.onClick = [this]() { chooseFile(); };
|
2017-11-16 15:38:59 +00:00
|
|
|
|
|
2017-12-19 22:50:47 +00:00
|
|
|
|
addAndMakeVisible(&m_settings_button);
|
|
|
|
|
m_settings_button.setButtonText("Settings...");
|
2018-01-03 15:15:57 +00:00
|
|
|
|
m_settings_button.onClick = [this]() { showSettingsMenu(); };
|
|
|
|
|
|
2018-05-07 17:21:42 +00:00
|
|
|
|
if (processor.wrapperType == AudioProcessor::wrapperType_Standalone)
|
|
|
|
|
{
|
|
|
|
|
addAndMakeVisible(&m_render_button);
|
|
|
|
|
m_render_button.setButtonText("Render...");
|
|
|
|
|
m_render_button.onClick = [this]() { showRenderDialog(); };
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 11:02:22 +00:00
|
|
|
|
addAndMakeVisible(m_rewind_button);
|
|
|
|
|
m_rewind_button.setButtonText("<<");
|
|
|
|
|
m_rewind_button.onClick = [this]()
|
|
|
|
|
{
|
2018-05-18 13:20:51 +00:00
|
|
|
|
*processor.getBoolParameter(cpi_rewind) = true;
|
|
|
|
|
//processor.getStretchSource()->seekPercent(processor.getStretchSource()->getPlayRange().getStart());
|
2018-05-09 11:02:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-11-13 20:35:36 +00:00
|
|
|
|
addAndMakeVisible(&m_info_label);
|
2017-12-28 20:50:52 +00:00
|
|
|
|
m_info_label.setJustificationType(Justification::centredRight);
|
|
|
|
|
|
2018-01-20 19:50:24 +00:00
|
|
|
|
m_wavecomponent.GetFileCallback = [this]() { return processor.getAudioFile(); };
|
2018-02-27 20:15:14 +00:00
|
|
|
|
|
2018-02-27 00:33:41 +00:00
|
|
|
|
const auto& pars = processor.getParameters();
|
2017-11-13 18:45:23 +00:00
|
|
|
|
for (int i=0;i<pars.size();++i)
|
|
|
|
|
{
|
2017-11-17 14:41:33 +00:00
|
|
|
|
AudioProcessorParameterWithID* parid = dynamic_cast<AudioProcessorParameterWithID*>(pars[i]);
|
|
|
|
|
jassert(parid);
|
2017-12-29 17:31:12 +00:00
|
|
|
|
bool notifyonlyonrelease = false;
|
2018-02-12 14:44:21 +00:00
|
|
|
|
if (parid->paramID.startsWith("fftsize") || parid->paramID.startsWith("numoutchans")
|
|
|
|
|
|| parid->paramID.startsWith("numinchans"))
|
|
|
|
|
notifyonlyonrelease = true;
|
2018-02-01 13:11:41 +00:00
|
|
|
|
int group_id = -1;
|
|
|
|
|
if (i == cpi_harmonicsbw || i == cpi_harmonicsfreq || i == cpi_harmonicsgauss || i == cpi_numharmonics)
|
|
|
|
|
group_id = 0;
|
|
|
|
|
if (i == cpi_octavesm2 || i == cpi_octavesm1 || i == cpi_octaves0 || i == cpi_octaves1 || i == cpi_octaves15 ||
|
2018-04-13 12:24:18 +00:00
|
|
|
|
i == cpi_octaves2 || i==cpi_octaves_extra1 || i==cpi_octaves_extra2)
|
|
|
|
|
group_id = -2; // -2 for not included in the main parameters page
|
2018-05-09 09:33:06 +00:00
|
|
|
|
if (i >= cpi_octaves_ratio0 && i <= cpi_octaves_ratio7)
|
2018-04-13 12:24:18 +00:00
|
|
|
|
group_id = -2;
|
2018-05-09 09:33:06 +00:00
|
|
|
|
if ((i >= cpi_enable_spec_module0 && i <= cpi_enable_spec_module8))
|
2018-04-13 12:24:18 +00:00
|
|
|
|
group_id = -2;
|
2018-02-01 13:11:41 +00:00
|
|
|
|
if (i == cpi_tonalvsnoisebw || i == cpi_tonalvsnoisepreserve)
|
|
|
|
|
group_id = 1;
|
|
|
|
|
if (i == cpi_filter_low || i == cpi_filter_high)
|
|
|
|
|
group_id = 6;
|
|
|
|
|
if (i == cpi_compress)
|
2018-03-21 11:43:03 +00:00
|
|
|
|
group_id = 8;
|
2018-02-01 13:11:41 +00:00
|
|
|
|
if (i == cpi_spreadamount)
|
|
|
|
|
group_id = 5;
|
|
|
|
|
if (i == cpi_frequencyshift)
|
|
|
|
|
group_id = 2;
|
|
|
|
|
if (i == cpi_pitchshift)
|
|
|
|
|
group_id = 3;
|
2018-02-28 16:57:28 +00:00
|
|
|
|
if (i == cpi_freefilter_scaley || i == cpi_freefilter_shiftx || i == cpi_freefilter_shifty ||
|
2018-03-03 15:55:02 +00:00
|
|
|
|
i == cpi_freefilter_tilty || i == cpi_freefilter_randomy_amount || i == cpi_freefilter_randomy_numbands
|
|
|
|
|
|| i == cpi_freefilter_randomy_rate)
|
2018-06-29 11:53:22 +00:00
|
|
|
|
group_id = -2;
|
2018-04-29 14:04:21 +00:00
|
|
|
|
if (group_id >= -1)
|
2018-04-29 15:48:28 +00:00
|
|
|
|
{
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[i], notifyonlyonrelease));
|
|
|
|
|
m_parcomps.back()->m_group_id = group_id;
|
|
|
|
|
if (group_id >= -1)
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_parcomps.push_back(nullptr);
|
|
|
|
|
}
|
2017-11-13 18:45:23 +00:00
|
|
|
|
}
|
2018-08-20 12:49:51 +00:00
|
|
|
|
//m_parcomps[cpi_dryplayrate]->getSlider()->setSkewFactorFromMidPoint(1.0);
|
2017-12-12 17:14:43 +00:00
|
|
|
|
//addAndMakeVisible(&m_specvis);
|
2018-02-27 20:15:14 +00:00
|
|
|
|
m_wave_container->addAndMakeVisible(&m_zs);
|
2018-02-14 13:18:35 +00:00
|
|
|
|
m_zs.RangeChanged = [this](Range<double> r)
|
|
|
|
|
{
|
|
|
|
|
m_wavecomponent.setViewRange(r);
|
2018-02-14 16:38:54 +00:00
|
|
|
|
processor.m_wave_view_range = r;
|
2018-02-14 13:18:35 +00:00
|
|
|
|
};
|
2018-02-14 16:38:54 +00:00
|
|
|
|
m_zs.setRange(processor.m_wave_view_range, true);
|
2018-02-27 00:33:41 +00:00
|
|
|
|
|
2018-03-02 20:49:32 +00:00
|
|
|
|
m_wavecomponent.ViewRangeChangedCallback = [this](Range<double> rng)
|
|
|
|
|
{
|
|
|
|
|
m_zs.setRange(rng, false);
|
|
|
|
|
};
|
2017-11-13 21:42:13 +00:00
|
|
|
|
m_wavecomponent.TimeSelectionChangedCallback = [this](Range<double> range, int which)
|
|
|
|
|
{
|
2018-01-20 20:21:26 +00:00
|
|
|
|
*processor.getFloatParameter(cpi_soundstart) = range.getStart();
|
|
|
|
|
*processor.getFloatParameter(cpi_soundend) = range.getEnd();
|
2017-11-13 21:42:13 +00:00
|
|
|
|
};
|
2017-11-13 22:50:12 +00:00
|
|
|
|
m_wavecomponent.CursorPosCallback = [this]()
|
|
|
|
|
{
|
2017-11-20 22:39:07 +00:00
|
|
|
|
return processor.getStretchSource()->getInfilePositionPercent();
|
2017-11-13 22:50:12 +00:00
|
|
|
|
};
|
2018-02-06 15:38:26 +00:00
|
|
|
|
m_wavecomponent.SeekCallback = [this](double pos)
|
|
|
|
|
{
|
|
|
|
|
if (processor.getStretchSource()->getPlayRange().contains(pos))
|
|
|
|
|
processor.getStretchSource()->seekPercent(pos);
|
|
|
|
|
};
|
2017-11-13 21:42:13 +00:00
|
|
|
|
m_wavecomponent.ShowFileCacheRange = true;
|
2017-12-13 17:55:35 +00:00
|
|
|
|
m_spec_order_ed.setSource(processor.getStretchSource());
|
|
|
|
|
addAndMakeVisible(&m_spec_order_ed);
|
2018-02-01 13:11:41 +00:00
|
|
|
|
m_spec_order_ed.ModuleSelectedCallback = [this](int id)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
|
{
|
2018-04-29 14:04:21 +00:00
|
|
|
|
if (m_parcomps[i] != nullptr)
|
|
|
|
|
{
|
|
|
|
|
if (m_parcomps[i]->m_group_id == id)
|
|
|
|
|
m_parcomps[i]->setHighLighted(true);
|
|
|
|
|
else
|
|
|
|
|
m_parcomps[i]->setHighLighted(false);
|
|
|
|
|
}
|
2018-02-01 13:11:41 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2018-02-09 11:02:10 +00:00
|
|
|
|
m_spec_order_ed.ModuleOrderOrEnabledChangedCallback = [this]()
|
|
|
|
|
{
|
2018-03-02 17:33:47 +00:00
|
|
|
|
/*
|
|
|
|
|
const auto& specord = processor.getStretchSource()->getSpectrumProcessOrder();
|
|
|
|
|
for (int i = 0; i < specord.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
int grtofind = specord[i].m_index;
|
|
|
|
|
for (int j = 0; j < m_parcomps.size(); ++j)
|
|
|
|
|
{
|
|
|
|
|
int gid = m_parcomps[j]->m_group_id;
|
|
|
|
|
if (gid == grtofind)
|
|
|
|
|
{
|
|
|
|
|
m_parcomps[j]->setEnabled(specord[i].m_enabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
2018-02-09 11:02:10 +00:00
|
|
|
|
processor.setDirty();
|
|
|
|
|
};
|
2018-04-03 13:34:20 +00:00
|
|
|
|
|
|
|
|
|
m_ratiomixeditor.GetParameterValue = [this](int which, int index)
|
|
|
|
|
{
|
|
|
|
|
if (which == 0)
|
2018-04-03 15:32:53 +00:00
|
|
|
|
return (double)*processor.getFloatParameter((int)cpi_octaves_ratio0 + index);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
if (which == 1)
|
|
|
|
|
{
|
|
|
|
|
if (index == 0)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octavesm2);
|
|
|
|
|
if (index == 1)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octavesm1);
|
|
|
|
|
if (index == 2)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves0);
|
|
|
|
|
if (index == 3)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves1);
|
|
|
|
|
if (index == 4)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves15);
|
|
|
|
|
if (index == 5)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves2);
|
2018-04-03 15:32:53 +00:00
|
|
|
|
if (index == 6)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves_extra1);
|
|
|
|
|
if (index == 7)
|
|
|
|
|
return (double)*processor.getFloatParameter(cpi_octaves_extra2);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
|
};
|
|
|
|
|
m_ratiomixeditor.OnRatioLevelChanged = [this](int index, double val)
|
|
|
|
|
{
|
|
|
|
|
if (index == 0)
|
|
|
|
|
*processor.getFloatParameter(cpi_octavesm2) = val;
|
|
|
|
|
if (index == 1)
|
|
|
|
|
*processor.getFloatParameter(cpi_octavesm1) = val;
|
|
|
|
|
if (index == 2)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves0) = val;
|
|
|
|
|
if (index == 3)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves1) = val;
|
|
|
|
|
if (index == 4)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves15) = val;
|
|
|
|
|
if (index == 5)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves2) = val;
|
2018-04-03 15:32:53 +00:00
|
|
|
|
if (index == 6)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves_extra1) = val;
|
|
|
|
|
if (index == 7)
|
|
|
|
|
*processor.getFloatParameter(cpi_octaves_extra2) = val;
|
|
|
|
|
};
|
|
|
|
|
m_ratiomixeditor.OnRatioChanged = [this](int index, double val)
|
|
|
|
|
{
|
|
|
|
|
*processor.getFloatParameter((int)cpi_octaves_ratio0 + index) = val;
|
2018-04-03 13:34:20 +00:00
|
|
|
|
};
|
2018-02-27 20:15:14 +00:00
|
|
|
|
m_wave_container->addAndMakeVisible(&m_wavecomponent);
|
|
|
|
|
m_wavefilter_tab.addTab("Waveform", Colours::white, m_wave_container, true);
|
2018-04-03 19:04:10 +00:00
|
|
|
|
m_wavefilter_tab.addTab("Ratio mixer", Colours::white, &m_ratiomixeditor, false);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
m_wavefilter_tab.addTab("Free filter", Colours::white, &m_free_filter_component, false);
|
2018-02-27 00:33:41 +00:00
|
|
|
|
|
|
|
|
|
addAndMakeVisible(&m_wavefilter_tab);
|
2018-04-13 12:24:18 +00:00
|
|
|
|
setSize (1200, 320+14*25);
|
2018-02-27 00:33:41 +00:00
|
|
|
|
startTimer(1, 100);
|
2017-11-16 14:58:04 +00:00
|
|
|
|
startTimer(2, 1000);
|
2017-12-03 20:51:57 +00:00
|
|
|
|
startTimer(3, 200);
|
2017-11-13 23:50:44 +00:00
|
|
|
|
m_wavecomponent.startTimer(100);
|
2017-11-13 15:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaulstretchpluginAudioProcessorEditor::~PaulstretchpluginAudioProcessorEditor()
|
|
|
|
|
{
|
2018-08-07 21:10:27 +00:00
|
|
|
|
//Logger::writeToLog("PaulX Editor destroyed");
|
2017-11-13 15:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-07 17:21:42 +00:00
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::showRenderDialog()
|
|
|
|
|
{
|
2018-05-07 17:43:27 +00:00
|
|
|
|
auto content = new RenderSettingsComponent(&processor);
|
2018-05-07 17:47:17 +00:00
|
|
|
|
content->setSize(content->getWidth(), content->getPreferredHeight());
|
|
|
|
|
CallOutBox& myBox = CallOutBox::launchAsynchronously(content, m_render_button.getBounds(), this);
|
2018-05-07 17:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g)
|
|
|
|
|
{
|
2017-11-13 18:45:23 +00:00
|
|
|
|
g.fillAll(Colours::darkgrey);
|
2017-11-13 15:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::resized()
|
|
|
|
|
{
|
2017-11-16 18:58:26 +00:00
|
|
|
|
m_import_button.setBounds(1, 1, 60, 24);
|
2017-11-14 16:14:14 +00:00
|
|
|
|
m_import_button.changeWidthToFitText();
|
2017-12-19 22:50:47 +00:00
|
|
|
|
m_settings_button.setBounds(m_import_button.getRight() + 1, 1, 60, 24);
|
|
|
|
|
m_settings_button.changeWidthToFitText();
|
2018-05-07 17:21:42 +00:00
|
|
|
|
int yoffs = m_settings_button.getRight() + 1;
|
|
|
|
|
if (processor.wrapperType == AudioProcessor::wrapperType_Standalone)
|
|
|
|
|
{
|
|
|
|
|
m_render_button.setBounds(yoffs, 1, 60, 24);
|
|
|
|
|
m_render_button.changeWidthToFitText();
|
|
|
|
|
yoffs = m_render_button.getRight() + 1;
|
|
|
|
|
}
|
2018-05-09 11:02:22 +00:00
|
|
|
|
m_rewind_button.setBounds(yoffs, 1, 30, 24);
|
|
|
|
|
yoffs = m_rewind_button.getRight() + 1;
|
2018-05-07 17:21:42 +00:00
|
|
|
|
m_perfmeter.setBounds(yoffs, 1, 150, 24);
|
2018-02-07 13:12:10 +00:00
|
|
|
|
m_info_label.setBounds(m_perfmeter.getRight() + 1, m_settings_button.getY(),
|
|
|
|
|
getWidth()- m_perfmeter.getRight()-1, 24);
|
2017-12-22 20:35:02 +00:00
|
|
|
|
int w = getWidth();
|
|
|
|
|
int xoffs = 1;
|
2018-05-07 17:21:42 +00:00
|
|
|
|
yoffs = 30;
|
2018-05-09 09:33:06 +00:00
|
|
|
|
int div = w / 6;
|
2018-02-13 13:47:17 +00:00
|
|
|
|
//std::vector<std::vector<int>> layout;
|
|
|
|
|
//layout.emplace_back(cpi_capture_enabled, cpi_passthrough, cpi_pause_enabled, cpi_freeze);
|
|
|
|
|
//layout.emplace_back(cpi_main_volume, cpi_num_inchans, cpi_num_outchans);
|
2017-12-22 20:35:02 +00:00
|
|
|
|
m_parcomps[cpi_capture_enabled]->setBounds(xoffs, yoffs, div-1, 24);
|
2018-01-17 19:53:26 +00:00
|
|
|
|
//xoffs += div;
|
|
|
|
|
//m_parcomps[cpi_max_capture_len]->setBounds(xoffs, yoffs, div - 1, 24);
|
2017-12-22 20:35:02 +00:00
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_passthrough]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_pause_enabled]->setBounds(xoffs, yoffs, div-1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_freeze]->setBounds(xoffs, yoffs, div - 1, 24);
|
2018-02-21 17:49:16 +00:00
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_bypass_stretch]->setBounds(xoffs, yoffs, div - 1, 24);
|
2018-05-09 09:33:06 +00:00
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_looping_enabled]->setBounds(xoffs, yoffs, div - 1, 24);
|
2017-12-22 20:35:02 +00:00
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
2018-02-12 14:44:21 +00:00
|
|
|
|
div = w / 3;
|
2017-12-22 20:35:02 +00:00
|
|
|
|
m_parcomps[cpi_main_volume]->setBounds(xoffs, yoffs, div-1, 24);
|
|
|
|
|
xoffs += div;
|
2018-02-12 14:44:21 +00:00
|
|
|
|
m_parcomps[cpi_num_inchans]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
2017-12-22 20:35:02 +00:00
|
|
|
|
m_parcomps[cpi_num_outchans]->setBounds(xoffs, yoffs, div-1, 24);
|
2018-02-12 14:44:21 +00:00
|
|
|
|
div = w / 2;
|
2017-12-22 20:35:02 +00:00
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_fftsize]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_stretchamount]->setBounds(xoffs, yoffs, div - 1, 24);
|
2018-08-21 09:13:04 +00:00
|
|
|
|
m_parcomps[cpi_dryplayrate]->setBounds(xoffs, yoffs, div - 1, 24);
|
2017-12-22 20:35:02 +00:00
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_pitchshift]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_frequencyshift]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_numharmonics]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_harmonicsfreq]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_harmonicsbw]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_harmonicsgauss]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_spreadamount]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_compress]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
|
|
|
|
m_parcomps[cpi_tonalvsnoisebw]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_tonalvsnoisepreserve]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
2018-02-15 14:03:00 +00:00
|
|
|
|
// filter here
|
2017-12-22 20:35:02 +00:00
|
|
|
|
m_parcomps[cpi_filter_low]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_filter_high]->setBounds(xoffs, yoffs, div - 1, 24);
|
2018-02-15 14:03:00 +00:00
|
|
|
|
|
2017-12-22 20:35:02 +00:00
|
|
|
|
xoffs = 1;
|
|
|
|
|
yoffs += 25;
|
2018-02-15 14:03:00 +00:00
|
|
|
|
|
2017-12-22 20:35:02 +00:00
|
|
|
|
m_parcomps[cpi_loopxfadelen]->setBounds(xoffs, yoffs, div - 1, 24);
|
|
|
|
|
xoffs += div;
|
|
|
|
|
m_parcomps[cpi_onsetdetection]->setBounds(xoffs, yoffs, div - 1, 24);
|
2018-02-15 14:03:00 +00:00
|
|
|
|
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);
|
2018-08-21 09:13:04 +00:00
|
|
|
|
//yoffs += 25;
|
|
|
|
|
//xoffs = 1;
|
|
|
|
|
|
2018-08-20 12:49:51 +00:00
|
|
|
|
yoffs += 25;
|
2018-02-27 20:15:14 +00:00
|
|
|
|
int remain_h = getHeight() - 1 - yoffs;
|
2018-03-12 22:33:47 +00:00
|
|
|
|
m_spec_order_ed.setBounds(1, yoffs, getWidth() - 2, remain_h / 9 * 1);
|
|
|
|
|
m_wavefilter_tab.setBounds(1, m_spec_order_ed.getBottom() + 1, getWidth() - 2, remain_h / 9 * 8);
|
2018-02-27 20:15:14 +00:00
|
|
|
|
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);
|
2018-02-27 00:33:41 +00:00
|
|
|
|
//m_wavecomponent.setBounds(1, m_spec_order_ed.getBottom()+1, getWidth()-2, remain_h/5*4);
|
|
|
|
|
|
2018-02-27 20:15:14 +00:00
|
|
|
|
|
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
|
}
|
2017-11-13 18:54:08 +00:00
|
|
|
|
|
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
|
|
|
|
|
{
|
|
|
|
|
if (id == 1)
|
|
|
|
|
{
|
2018-03-02 17:33:47 +00:00
|
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
|
{
|
2018-04-29 14:04:21 +00:00
|
|
|
|
if (m_parcomps[i]!=nullptr)
|
|
|
|
|
m_parcomps[i]->updateComponent();
|
2018-03-02 17:33:47 +00:00
|
|
|
|
}
|
2018-06-29 11:49:11 +00:00
|
|
|
|
m_free_filter_component.updateParameterComponents();
|
2017-11-14 17:44:13 +00:00
|
|
|
|
if (processor.isRecordingEnabled())
|
2017-11-15 15:52:47 +00:00
|
|
|
|
{
|
|
|
|
|
m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent());
|
|
|
|
|
} else
|
|
|
|
|
m_wavecomponent.setRecordingPosition(-1.0);
|
2018-05-11 13:45:34 +00:00
|
|
|
|
m_wavecomponent.setAudioInfo(processor.getSampleRateChecked(), processor.getStretchSource()->getLastSeekPos(),
|
|
|
|
|
processor.getStretchSource()->getFFTSize());
|
2018-02-13 14:51:57 +00:00
|
|
|
|
String infotext;
|
|
|
|
|
if (processor.m_show_technical_info)
|
|
|
|
|
{
|
2018-05-19 12:03:30 +00:00
|
|
|
|
infotext += String(processor.getStretchSource()->getDiskReadSampleCount()) + " ";
|
|
|
|
|
infotext += String(processor.m_prepare_count)+" ";
|
2018-02-21 23:54:21 +00:00
|
|
|
|
infotext += String(processor.getStretchSource()->m_param_change_count);
|
2018-02-13 14:51:57 +00:00
|
|
|
|
infotext += " param changes ";
|
|
|
|
|
}
|
2018-02-19 15:39:10 +00:00
|
|
|
|
infotext += m_last_err + " [FFT size " +
|
|
|
|
|
String(processor.getStretchSource()->getFFTSize())+"]";
|
2018-03-23 23:01:40 +00:00
|
|
|
|
double outlen = processor.getStretchSource()->getOutputDurationSecondsForRange(processor.getStretchSource()->getPlayRange(),
|
|
|
|
|
processor.getStretchSource()->getFFTSize());
|
2018-02-19 15:39:10 +00:00
|
|
|
|
infotext += " [Output length " + secondsToString2(outlen)+"]";
|
2017-12-18 20:27:12 +00:00
|
|
|
|
if (processor.m_abnormal_output_samples > 0)
|
|
|
|
|
infotext += " " + String(processor.m_abnormal_output_samples) + " invalid sample values";
|
2017-12-18 22:37:02 +00:00
|
|
|
|
if (processor.isNonRealtime())
|
|
|
|
|
infotext += " (offline rendering)";
|
2017-12-19 21:00:42 +00:00
|
|
|
|
if (processor.m_playposinfo.isPlaying)
|
|
|
|
|
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
|
2018-02-13 14:51:57 +00:00
|
|
|
|
if (processor.m_show_technical_info)
|
2018-02-26 17:55:32 +00:00
|
|
|
|
infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count)+ " ";
|
|
|
|
|
if (processor.m_offline_render_state >= 0 && processor.m_offline_render_state <= 100)
|
|
|
|
|
infotext += String(processor.m_offline_render_state)+"%";
|
2017-11-17 14:41:33 +00:00
|
|
|
|
m_info_label.setText(infotext, dontSendNotification);
|
2018-05-01 15:35:00 +00:00
|
|
|
|
|
2017-11-13 18:54:08 +00:00
|
|
|
|
}
|
2017-11-16 14:58:04 +00:00
|
|
|
|
if (id == 2)
|
|
|
|
|
{
|
|
|
|
|
m_wavecomponent.setTimeSelection(processor.getTimeSelection());
|
2017-12-27 20:43:07 +00:00
|
|
|
|
if (processor.m_state_dirty)
|
|
|
|
|
{
|
2018-03-09 17:39:39 +00:00
|
|
|
|
//m_spec_order_ed.setSource(processor.getStretchSource());
|
2017-12-27 20:43:07 +00:00
|
|
|
|
processor.m_state_dirty = false;
|
|
|
|
|
}
|
2017-12-03 20:00:40 +00:00
|
|
|
|
}
|
|
|
|
|
if (id == 3)
|
|
|
|
|
{
|
2018-02-28 14:34:16 +00:00
|
|
|
|
processor.m_free_filter_envelope->updateMinMaxValues();
|
2018-02-28 12:20:26 +00:00
|
|
|
|
m_free_filter_component.repaint();
|
2018-03-21 12:37:15 +00:00
|
|
|
|
m_spec_order_ed.repaint();
|
2018-08-21 09:13:04 +00:00
|
|
|
|
m_parcomps[cpi_dryplayrate]->setVisible(*processor.getBoolParameter(cpi_bypass_stretch));
|
|
|
|
|
m_parcomps[cpi_stretchamount]->setVisible(!(*processor.getBoolParameter(cpi_bypass_stretch)));
|
2018-06-29 12:13:49 +00:00
|
|
|
|
//if (m_wavefilter_tab.getCurrentTabIndex() != processor.m_cur_tab_index)
|
|
|
|
|
// m_wavefilter_tab.setCurrentTabIndex(processor.m_cur_tab_index, false);
|
2017-11-16 14:58:04 +00:00
|
|
|
|
}
|
2017-11-13 18:54:08 +00:00
|
|
|
|
}
|
2017-11-13 21:42:13 +00:00
|
|
|
|
|
2017-12-27 14:56:37 +00:00
|
|
|
|
bool PaulstretchpluginAudioProcessorEditor::isInterestedInFileDrag(const StringArray & files)
|
|
|
|
|
{
|
|
|
|
|
if (files.size() == 0)
|
|
|
|
|
return false;
|
|
|
|
|
File f(files[0]);
|
|
|
|
|
String extension = f.getFileExtension().toLowerCase();
|
|
|
|
|
if (processor.m_afm->getWildcardForAllFormats().containsIgnoreCase(extension))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::filesDropped(const StringArray & files, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
if (files.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
File f(files[0]);
|
|
|
|
|
processor.setAudioFile(f);
|
|
|
|
|
toFront(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-16 15:38:59 +00:00
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::chooseFile()
|
|
|
|
|
{
|
2018-01-08 16:04:28 +00:00
|
|
|
|
String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder",
|
2017-12-19 03:24:27 +00:00
|
|
|
|
File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
|
|
|
|
|
File initialloc(initiallocfn);
|
2017-12-17 16:43:29 +00:00
|
|
|
|
String filterstring = processor.m_afm->getWildcardForAllFormats();
|
2017-11-16 15:38:59 +00:00
|
|
|
|
FileChooser myChooser("Please select audio file...",
|
|
|
|
|
initialloc,
|
2018-03-21 11:48:01 +00:00
|
|
|
|
filterstring,true);
|
2017-11-16 15:38:59 +00:00
|
|
|
|
if (myChooser.browseForFileToOpen())
|
|
|
|
|
{
|
2017-12-15 04:17:11 +00:00
|
|
|
|
File resu = myChooser.getResult();
|
|
|
|
|
String pathname = resu.getFullPathName();
|
|
|
|
|
if (pathname.startsWith("/localhost"))
|
|
|
|
|
{
|
|
|
|
|
pathname = pathname.substring(10);
|
|
|
|
|
resu = File(pathname);
|
|
|
|
|
}
|
2017-12-19 03:24:27 +00:00
|
|
|
|
processor.m_propsfile->m_props_file->setValue("importfilefolder", resu.getParentDirectory().getFullPathName());
|
2017-12-15 04:17:11 +00:00
|
|
|
|
m_last_err = processor.setAudioFile(resu);
|
2017-11-16 15:38:59 +00:00
|
|
|
|
}
|
2018-03-03 20:48:24 +00:00
|
|
|
|
|
2017-11-16 15:38:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 22:50:47 +00:00
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
|
|
|
|
|
{
|
|
|
|
|
PopupMenu menu;
|
2017-12-26 16:12:22 +00:00
|
|
|
|
menu.addItem(4, "Reset parameters", true, false);
|
2017-12-26 18:24:10 +00:00
|
|
|
|
menu.addItem(5, "Load file with plugin state", true, processor.m_load_file_with_state);
|
2017-12-19 23:12:47 +00:00
|
|
|
|
menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays);
|
|
|
|
|
menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays);
|
2018-06-01 13:31:31 +00:00
|
|
|
|
menu.addItem(8, "Mute audio while capturing", true, processor.m_mute_while_capturing);
|
2018-01-17 19:53:26 +00:00
|
|
|
|
int capturelen = *processor.getFloatParameter(cpi_max_capture_len);
|
|
|
|
|
PopupMenu capturelenmenu;
|
|
|
|
|
std::vector<int> capturelens{ 2,5,10,30,60,120 };
|
|
|
|
|
for (int i=0;i<capturelens.size();++i)
|
|
|
|
|
capturelenmenu.addItem(200+i, String(capturelens[i])+" seconds", true, capturelen == capturelens[i]);
|
|
|
|
|
menu.addSubMenu("Capture buffer length", capturelenmenu);
|
2018-05-07 17:21:42 +00:00
|
|
|
|
|
2017-12-24 14:56:22 +00:00
|
|
|
|
menu.addItem(3, "About...", true, false);
|
2017-12-27 20:20:44 +00:00
|
|
|
|
#ifdef JUCE_DEBUG
|
|
|
|
|
menu.addItem(6, "Dump preset to clipboard", true, false);
|
|
|
|
|
#endif
|
2018-02-13 14:51:57 +00:00
|
|
|
|
menu.addItem(7, "Show technical info", true, processor.m_show_technical_info);
|
2017-12-27 20:20:44 +00:00
|
|
|
|
int r = menu.show();
|
2018-01-17 19:53:26 +00:00
|
|
|
|
if (r >= 200 && r < 210)
|
|
|
|
|
{
|
|
|
|
|
int caplen = capturelens[r - 200];
|
|
|
|
|
*processor.getFloatParameter(cpi_max_capture_len) = (float)caplen;
|
|
|
|
|
}
|
2017-12-19 23:12:47 +00:00
|
|
|
|
if (r == 1)
|
|
|
|
|
{
|
2018-02-13 14:51:57 +00:00
|
|
|
|
toggleBool(processor.m_play_when_host_plays);
|
2017-12-19 23:12:47 +00:00
|
|
|
|
}
|
|
|
|
|
if (r == 2)
|
|
|
|
|
{
|
2018-02-13 14:51:57 +00:00
|
|
|
|
toggleBool(processor.m_capture_when_host_plays);
|
2017-12-19 23:12:47 +00:00
|
|
|
|
}
|
2018-06-01 13:31:31 +00:00
|
|
|
|
if (r == 8)
|
|
|
|
|
{
|
|
|
|
|
toggleBool(processor.m_mute_while_capturing);
|
|
|
|
|
}
|
2017-12-26 16:12:22 +00:00
|
|
|
|
if (r == 4)
|
|
|
|
|
{
|
|
|
|
|
processor.resetParameters();
|
|
|
|
|
}
|
2017-12-26 18:24:10 +00:00
|
|
|
|
if (r == 5)
|
|
|
|
|
{
|
2018-02-13 14:51:57 +00:00
|
|
|
|
toggleBool(processor.m_load_file_with_state);
|
2017-12-26 18:24:10 +00:00
|
|
|
|
}
|
2017-12-24 14:56:22 +00:00
|
|
|
|
if (r == 3)
|
|
|
|
|
{
|
|
|
|
|
String fftlib = fftwf_version;
|
2018-02-15 14:03:00 +00:00
|
|
|
|
String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + String(JUCE_MINOR_VERSION);
|
|
|
|
|
String title = g_plugintitle;
|
|
|
|
|
#ifdef JUCE_DEBUG
|
|
|
|
|
title += " (DEBUG)";
|
|
|
|
|
#endif
|
2017-12-24 14:56:22 +00:00
|
|
|
|
AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon,
|
2018-02-15 14:03:00 +00:00
|
|
|
|
title,
|
2018-01-18 04:56:23 +00:00
|
|
|
|
"Plugin for extreme time stretching and other sound processing\nBuilt on " + String(__DATE__) + " " + String(__TIME__) + "\n"
|
2017-12-24 14:56:22 +00:00
|
|
|
|
"Copyright (C) 2006-2011 Nasca Octavian Paul, Tg. Mures, Romania\n"
|
2018-01-05 19:57:43 +00:00
|
|
|
|
"(C) 2017-2018 Xenakios\n\n"
|
2017-12-24 14:56:22 +00:00
|
|
|
|
"Using " + fftlib + " for FFT\n\n"
|
|
|
|
|
+ juceversiontxt + " (c) Roli. Used under the GPL license.\n\n"
|
|
|
|
|
"GPL licensed source code for this plugin at : https://bitbucket.org/xenakios/paulstretchplugin/overview\n"
|
|
|
|
|
, "OK",
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
}
|
2018-02-07 13:12:10 +00:00
|
|
|
|
|
2017-12-27 20:20:44 +00:00
|
|
|
|
if (r == 6)
|
|
|
|
|
{
|
2017-12-27 20:43:07 +00:00
|
|
|
|
ValueTree tree = processor.getStateTree(true,true);
|
2017-12-27 20:20:44 +00:00
|
|
|
|
MemoryBlock destData;
|
|
|
|
|
MemoryOutputStream stream(destData, true);
|
|
|
|
|
tree.writeToStream(stream);
|
|
|
|
|
String txt = Base64::toBase64(destData.getData(), destData.getSize());
|
|
|
|
|
SystemClipboard::copyTextToClipboard(txt);
|
|
|
|
|
}
|
2018-02-13 14:51:57 +00:00
|
|
|
|
if (r == 7)
|
|
|
|
|
{
|
|
|
|
|
toggleBool(processor.m_show_technical_info);
|
2018-02-13 15:52:45 +00:00
|
|
|
|
processor.m_propsfile->m_props_file->setValue("showtechnicalinfo", processor.m_show_technical_info);
|
2018-02-13 14:51:57 +00:00
|
|
|
|
}
|
2018-05-07 17:21:42 +00:00
|
|
|
|
|
2017-12-19 22:50:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 16:57:56 +00:00
|
|
|
|
WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb)
|
2017-11-13 21:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
TimeSelectionChangedCallback = [](Range<double>, int) {};
|
2018-04-02 17:07:55 +00:00
|
|
|
|
#ifdef JUCE_MODULE_AVAILABLE_juce_opengl
|
2017-11-13 21:42:13 +00:00
|
|
|
|
if (m_use_opengl == true)
|
|
|
|
|
m_ogl.attachTo(*this);
|
2018-04-02 17:07:55 +00:00
|
|
|
|
#endif
|
2018-01-17 16:57:56 +00:00
|
|
|
|
m_thumbnail = thumb;
|
|
|
|
|
m_thumbnail->addChangeListener(this);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
setOpaque(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WaveformComponent::~WaveformComponent()
|
|
|
|
|
{
|
2018-04-02 17:07:55 +00:00
|
|
|
|
#ifdef JUCE_MODULE_AVAILABLE_juce_opengl
|
2017-11-13 21:42:13 +00:00
|
|
|
|
if (m_use_opengl == true)
|
|
|
|
|
m_ogl.detach();
|
2018-04-02 17:07:55 +00:00
|
|
|
|
#endif
|
2018-01-17 16:57:56 +00:00
|
|
|
|
m_thumbnail->removeChangeListener(this);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::changeListenerCallback(ChangeBroadcaster * /*cb*/)
|
|
|
|
|
{
|
2018-02-12 18:51:05 +00:00
|
|
|
|
jassert(MessageManager::getInstance()->isThisTheMessageThread());
|
|
|
|
|
m_image_dirty = true;
|
|
|
|
|
//repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::updateCachedImage()
|
|
|
|
|
{
|
|
|
|
|
Graphics tempg(m_waveimage);
|
|
|
|
|
tempg.fillAll(Colours::black);
|
|
|
|
|
tempg.setColour(Colours::darkgrey);
|
|
|
|
|
double thumblen = m_thumbnail->getTotalLength();
|
|
|
|
|
m_thumbnail->drawChannels(tempg, { 0,0,getWidth(),getHeight() - m_topmargin },
|
|
|
|
|
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f);
|
|
|
|
|
m_image_dirty = false;
|
|
|
|
|
++m_image_update_count;
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::paint(Graphics & g)
|
|
|
|
|
{
|
2018-01-20 19:50:24 +00:00
|
|
|
|
jassert(GetFileCallback);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
//Logger::writeToLog("Waveform component paint");
|
|
|
|
|
g.fillAll(Colours::black);
|
|
|
|
|
g.setColour(Colours::darkgrey);
|
|
|
|
|
g.fillRect(0, 0, getWidth(), m_topmargin);
|
2018-01-17 16:57:56 +00:00
|
|
|
|
if (m_thumbnail == nullptr || m_thumbnail->getTotalLength() < 0.01)
|
2017-11-13 21:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::aqua.darker());
|
|
|
|
|
g.drawText("No file loaded", 2, m_topmargin + 2, getWidth(), 20, Justification::topLeft);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
g.setColour(Colours::lightslategrey);
|
2018-01-17 16:57:56 +00:00
|
|
|
|
double thumblen = m_thumbnail->getTotalLength();
|
2017-11-13 21:42:13 +00:00
|
|
|
|
double tick_interval = 1.0;
|
|
|
|
|
if (thumblen > 60.0)
|
|
|
|
|
tick_interval = 5.0;
|
|
|
|
|
for (double secs = 0.0; secs < thumblen; secs += tick_interval)
|
|
|
|
|
{
|
|
|
|
|
float tickxcor = (float)jmap<double>(secs,
|
|
|
|
|
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 0.0f, (float)getWidth());
|
|
|
|
|
g.drawLine(tickxcor, 0.0, tickxcor, (float)m_topmargin, 1.0f);
|
|
|
|
|
}
|
2018-05-11 13:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
2017-11-13 21:42:13 +00:00
|
|
|
|
bool m_use_cached_image = true;
|
|
|
|
|
if (m_use_cached_image == true)
|
|
|
|
|
{
|
2018-02-12 18:51:05 +00:00
|
|
|
|
if (m_image_dirty == true || m_waveimage.getWidth() != getWidth()
|
2017-11-13 21:42:13 +00:00
|
|
|
|
|| m_waveimage.getHeight() != getHeight() - m_topmargin)
|
|
|
|
|
{
|
2018-02-12 18:51:05 +00:00
|
|
|
|
if (m_waveimage.getWidth() != getWidth()
|
|
|
|
|
|| m_waveimage.getHeight() != getHeight() - m_topmargin)
|
|
|
|
|
{
|
|
|
|
|
m_waveimage = Image(Image::ARGB, getWidth(), getHeight() - m_topmargin, true);
|
|
|
|
|
++m_image_init_count;
|
|
|
|
|
}
|
|
|
|
|
updateCachedImage();
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
g.drawImage(m_waveimage, 0, m_topmargin, getWidth(), getHeight() - m_topmargin, 0, 0, getWidth(), getHeight() - m_topmargin);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::darkgrey);
|
2018-01-17 16:57:56 +00:00
|
|
|
|
m_thumbnail->drawChannels(g, { 0,m_topmargin,getWidth(),getHeight() - m_topmargin },
|
2017-11-13 21:42:13 +00:00
|
|
|
|
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f);
|
|
|
|
|
}
|
2018-05-11 13:45:34 +00:00
|
|
|
|
if (m_sr > 0.0 && m_fft_size > 0 && m_time_sel_start>=0.0)
|
|
|
|
|
{
|
|
|
|
|
tick_interval = 1.0 / m_sr * m_fft_size;
|
|
|
|
|
/*
|
|
|
|
|
for (double secs = m_time_sel_start*thumblen; secs < m_time_sel_end*thumblen; secs += tick_interval)
|
|
|
|
|
{
|
|
|
|
|
float tickxcor = (float)jmap<double>(fmod(secs, thumblen),
|
|
|
|
|
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 0.0f, (float)getWidth());
|
|
|
|
|
g.drawLine(tickxcor, (float)m_topmargin, tickxcor, (float)50, 2.0f);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
2018-02-23 15:43:29 +00:00
|
|
|
|
if (m_is_at_selection_drag_area)
|
|
|
|
|
g.setColour(Colours::white.withAlpha(0.6f));
|
|
|
|
|
else
|
|
|
|
|
g.setColour(Colours::white.withAlpha(0.5f));
|
2017-11-13 21:42:13 +00:00
|
|
|
|
|
2018-01-20 20:39:33 +00:00
|
|
|
|
double sel_len = m_time_sel_end - m_time_sel_start;
|
|
|
|
|
//if (sel_len > 0.0 && sel_len < 1.0)
|
|
|
|
|
{
|
2018-02-22 12:22:06 +00:00
|
|
|
|
int xcorleft = normalizedToViewX<int>(m_time_sel_start);
|
|
|
|
|
int xcorright = normalizedToViewX<int>(m_time_sel_end);
|
2018-01-20 20:39:33 +00:00
|
|
|
|
g.fillRect(xcorleft, m_topmargin, xcorright - xcorleft, getHeight() - m_topmargin);
|
|
|
|
|
}
|
2017-11-13 21:42:13 +00:00
|
|
|
|
if (m_file_cached.first.getLength() > 0.0 &&
|
|
|
|
|
(bool)ShowFileCacheRange.getValue())
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::red.withAlpha(0.2f));
|
2018-01-20 20:39:33 +00:00
|
|
|
|
int xcorleft = (int)jmap<double>(m_file_cached.first.getStart(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
|
|
|
|
|
int xcorright = (int)jmap<double>(m_file_cached.first.getEnd(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
|
2017-11-13 21:42:13 +00:00
|
|
|
|
g.fillRect(xcorleft, 0, xcorright - xcorleft, m_topmargin / 2);
|
|
|
|
|
xcorleft = (int)jmap<double>(m_file_cached.second.getStart(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
|
|
|
|
|
xcorright = (int)jmap<double>(m_file_cached.second.getEnd(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
|
|
|
|
|
if (xcorright - xcorleft>0)
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::blue.withAlpha(0.2f));
|
|
|
|
|
g.fillRect(xcorleft, m_topmargin / 2, xcorright - xcorleft, m_topmargin / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
|
if (CursorPosCallback)
|
|
|
|
|
{
|
2018-02-22 12:22:06 +00:00
|
|
|
|
g.fillRect(normalizedToViewX<int>(CursorPosCallback()), m_topmargin, 1, getHeight() - m_topmargin);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
2017-11-15 15:52:47 +00:00
|
|
|
|
if (m_rec_pos >= 0.0)
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::lightpink);
|
2018-02-22 12:22:06 +00:00
|
|
|
|
g.fillRect(normalizedToViewX<int>(m_rec_pos), m_topmargin, 1, getHeight() - m_topmargin);
|
2017-11-15 15:52:47 +00:00
|
|
|
|
}
|
2018-02-07 12:52:22 +00:00
|
|
|
|
g.setColour(Colours::aqua);
|
2018-01-20 19:50:24 +00:00
|
|
|
|
g.drawText(GetFileCallback().getFileName(), 2, m_topmargin + 2, getWidth(), 20, Justification::topLeft);
|
2018-02-07 12:52:22 +00:00
|
|
|
|
g.drawText(secondsToString2(thumblen), getWidth() - 200, m_topmargin + 2, 200, 20, Justification::topRight);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::timerCallback()
|
|
|
|
|
{
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::setFileCachedRange(std::pair<Range<double>, Range<double>> rng)
|
|
|
|
|
{
|
|
|
|
|
m_file_cached = rng;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::setTimerEnabled(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (b == true)
|
|
|
|
|
startTimer(100);
|
|
|
|
|
else
|
|
|
|
|
stopTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::setViewRange(Range<double> rng)
|
|
|
|
|
{
|
|
|
|
|
m_view_range = rng;
|
|
|
|
|
m_waveimage = Image();
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::mouseDown(const MouseEvent & e)
|
|
|
|
|
{
|
|
|
|
|
m_mousedown = true;
|
2017-11-16 14:58:04 +00:00
|
|
|
|
m_lock_timesel_set = true;
|
2018-02-22 12:22:06 +00:00
|
|
|
|
double pos = viewXToNormalized(e.x);
|
2018-02-06 15:38:26 +00:00
|
|
|
|
if (e.y < m_topmargin || e.mods.isCommandDown())
|
2017-11-13 21:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
if (SeekCallback)
|
2018-05-11 13:45:34 +00:00
|
|
|
|
{
|
2017-11-13 21:42:13 +00:00
|
|
|
|
SeekCallback(pos);
|
2018-05-11 13:45:34 +00:00
|
|
|
|
m_last_startpos = pos;
|
|
|
|
|
}
|
2017-11-13 21:42:13 +00:00
|
|
|
|
m_didseek = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_time_sel_drag_target = getTimeSelectionEdge(e.x, e.y);
|
|
|
|
|
m_drag_time_start = pos;
|
|
|
|
|
if (m_time_sel_drag_target == 0)
|
|
|
|
|
{
|
2018-01-20 20:21:26 +00:00
|
|
|
|
//m_time_sel_start = 0.0;
|
|
|
|
|
//m_time_sel_end = 1.0;
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::mouseUp(const MouseEvent & /*e*/)
|
|
|
|
|
{
|
2018-02-23 16:21:28 +00:00
|
|
|
|
m_is_dragging_selection = false;
|
2017-11-16 14:58:04 +00:00
|
|
|
|
m_lock_timesel_set = false;
|
2017-11-13 21:42:13 +00:00
|
|
|
|
m_mousedown = false;
|
|
|
|
|
m_didseek = false;
|
|
|
|
|
if (m_didchangetimeselection)
|
|
|
|
|
{
|
|
|
|
|
TimeSelectionChangedCallback(Range<double>(m_time_sel_start, m_time_sel_end), 1);
|
|
|
|
|
m_didchangetimeselection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::mouseDrag(const MouseEvent & e)
|
|
|
|
|
{
|
|
|
|
|
if (m_didseek == true)
|
|
|
|
|
return;
|
2018-02-23 16:21:28 +00:00
|
|
|
|
if (m_time_sel_drag_target == 0 && e.y>=50 && m_is_dragging_selection==false)
|
2017-11-13 21:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
m_time_sel_start = m_drag_time_start;
|
2018-02-22 12:22:06 +00:00
|
|
|
|
m_time_sel_end = viewXToNormalized(e.x);
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
2018-02-22 12:56:18 +00:00
|
|
|
|
double curlen = m_time_sel_end - m_time_sel_start;
|
2018-02-23 16:21:28 +00:00
|
|
|
|
if (m_time_sel_drag_target == 0 && m_is_at_selection_drag_area)
|
2018-02-22 12:49:53 +00:00
|
|
|
|
{
|
2018-02-23 16:21:28 +00:00
|
|
|
|
m_is_dragging_selection = true;
|
2018-02-22 12:49:53 +00:00
|
|
|
|
double diff = m_drag_time_start - viewXToNormalized(e.x);
|
2018-02-22 12:56:18 +00:00
|
|
|
|
m_time_sel_start = jlimit<double>(0.0, 1.0-curlen, m_time_sel_start - diff);
|
|
|
|
|
m_time_sel_end = jlimit<double>(curlen, 1.0, m_time_sel_end - diff);
|
2018-02-22 12:49:53 +00:00
|
|
|
|
m_drag_time_start -= diff;
|
|
|
|
|
}
|
2018-02-22 12:56:18 +00:00
|
|
|
|
curlen = m_time_sel_end - m_time_sel_start;
|
2018-02-22 03:23:39 +00:00
|
|
|
|
|
|
|
|
|
if (m_time_sel_drag_target == 1)
|
2017-11-13 21:42:13 +00:00
|
|
|
|
{
|
2018-02-22 12:49:53 +00:00
|
|
|
|
m_time_sel_start = viewXToNormalized(e.x);
|
|
|
|
|
}
|
2017-11-13 21:42:13 +00:00
|
|
|
|
if (m_time_sel_drag_target == 2)
|
|
|
|
|
{
|
2018-02-22 12:49:53 +00:00
|
|
|
|
m_time_sel_end = viewXToNormalized(e.x);
|
|
|
|
|
}
|
2017-11-13 21:42:13 +00:00
|
|
|
|
if (m_time_sel_start > m_time_sel_end)
|
|
|
|
|
{
|
|
|
|
|
std::swap(m_time_sel_start, m_time_sel_end);
|
|
|
|
|
if (m_time_sel_drag_target == 1)
|
|
|
|
|
m_time_sel_drag_target = 2;
|
|
|
|
|
else if (m_time_sel_drag_target == 2)
|
|
|
|
|
m_time_sel_drag_target = 1;
|
|
|
|
|
}
|
|
|
|
|
m_time_sel_start = jlimit(0.0, 1.0, m_time_sel_start);
|
|
|
|
|
m_time_sel_end = jlimit(0.0, 1.0, m_time_sel_end);
|
|
|
|
|
|
|
|
|
|
if (TimeSelectionChangedCallback)
|
|
|
|
|
{
|
|
|
|
|
if (m_time_sel_end>m_time_sel_start)
|
|
|
|
|
TimeSelectionChangedCallback(Range<double>(m_time_sel_start, m_time_sel_end), 0);
|
|
|
|
|
else
|
|
|
|
|
TimeSelectionChangedCallback(Range<double>(0.0, 1.0), 0);
|
|
|
|
|
}
|
|
|
|
|
m_didchangetimeselection = true;
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::mouseMove(const MouseEvent & e)
|
|
|
|
|
{
|
|
|
|
|
m_time_sel_drag_target = getTimeSelectionEdge(e.x, e.y);
|
|
|
|
|
if (m_time_sel_drag_target == 0)
|
|
|
|
|
setMouseCursor(MouseCursor::NormalCursor);
|
|
|
|
|
if (m_time_sel_drag_target == 1)
|
|
|
|
|
setMouseCursor(MouseCursor::LeftRightResizeCursor);
|
|
|
|
|
if (m_time_sel_drag_target == 2)
|
|
|
|
|
setMouseCursor(MouseCursor::LeftRightResizeCursor);
|
2018-02-23 15:43:29 +00:00
|
|
|
|
Range<int> temp(normalizedToViewX<int>(m_time_sel_start), normalizedToViewX<int>(m_time_sel_end));
|
|
|
|
|
m_is_at_selection_drag_area = temp.contains(e.x) == true && e.y < 50;
|
2017-11-13 21:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-20 20:21:26 +00:00
|
|
|
|
void WaveformComponent::mouseDoubleClick(const MouseEvent & e)
|
|
|
|
|
{
|
|
|
|
|
m_time_sel_start = 0.0;
|
|
|
|
|
m_time_sel_end = 1.0;
|
|
|
|
|
TimeSelectionChangedCallback({ 0.0,1.0 }, 0);
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 20:49:32 +00:00
|
|
|
|
void WaveformComponent::mouseWheelMove(const MouseEvent & e, const MouseWheelDetails & wd)
|
|
|
|
|
{
|
2018-03-21 13:36:15 +00:00
|
|
|
|
return;
|
2018-04-19 19:57:47 +00:00
|
|
|
|
/*
|
2018-03-02 20:49:32 +00:00
|
|
|
|
double factor = 0.9;
|
|
|
|
|
if (wd.deltaY < 0.0)
|
|
|
|
|
factor = 1.11111;
|
|
|
|
|
double normt = viewXToNormalized(e.x);
|
|
|
|
|
double curlen = m_view_range.getLength();
|
|
|
|
|
double newlen = curlen * factor;
|
2018-03-02 21:37:52 +00:00
|
|
|
|
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);
|
2018-03-02 20:49:32 +00:00
|
|
|
|
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);
|
2018-03-02 21:14:08 +00:00
|
|
|
|
jassert(m_view_range.getLength() > 0.001);
|
2018-03-02 20:49:32 +00:00
|
|
|
|
if (ViewRangeChangedCallback)
|
|
|
|
|
ViewRangeChangedCallback(m_view_range);
|
|
|
|
|
m_image_dirty = true;
|
|
|
|
|
repaint();
|
2018-04-19 19:57:47 +00:00
|
|
|
|
*/
|
2018-03-02 20:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-11 13:45:34 +00:00
|
|
|
|
void WaveformComponent::setAudioInfo(double sr, double seekpos, int fftsize)
|
|
|
|
|
{
|
|
|
|
|
m_sr = sr;
|
|
|
|
|
m_fft_size = fftsize;
|
|
|
|
|
m_last_startpos = seekpos;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 17:32:53 +00:00
|
|
|
|
Range<double> WaveformComponent::getTimeSelection()
|
|
|
|
|
{
|
|
|
|
|
if (m_time_sel_start >= 0.0 && m_time_sel_end>m_time_sel_start + 0.001)
|
|
|
|
|
return { m_time_sel_start, m_time_sel_end };
|
|
|
|
|
return { 0.0, 1.0 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WaveformComponent::setTimeSelection(Range<double> rng)
|
|
|
|
|
{
|
|
|
|
|
if (m_lock_timesel_set == true)
|
|
|
|
|
return;
|
|
|
|
|
if (rng.isEmpty())
|
|
|
|
|
rng = { -1.0,1.0 };
|
|
|
|
|
m_time_sel_start = rng.getStart();
|
|
|
|
|
m_time_sel_end = rng.getEnd();
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 21:42:13 +00:00
|
|
|
|
int WaveformComponent::getTimeSelectionEdge(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
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))
|
|
|
|
|
return 1;
|
|
|
|
|
if (juce::Rectangle<int>(xcorright - 5, m_topmargin, 10, getHeight() - m_topmargin).contains(x, y))
|
|
|
|
|
return 2;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-11-23 17:12:29 +00:00
|
|
|
|
|
2017-12-03 20:00:40 +00:00
|
|
|
|
SpectralVisualizer::SpectralVisualizer()
|
|
|
|
|
{
|
|
|
|
|
m_img = Image(Image::RGB, 500, 200, true);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-03 21:28:54 +00:00
|
|
|
|
void SpectralVisualizer::setState(const ProcessParameters & pars, int nfreqs, double samplerate)
|
2017-12-03 20:00:40 +00:00
|
|
|
|
{
|
2017-12-03 20:51:57 +00:00
|
|
|
|
double t0 = Time::getMillisecondCounterHiRes();
|
2017-12-03 20:00:40 +00:00
|
|
|
|
double hz = 440.0;
|
|
|
|
|
int numharmonics = 40;
|
|
|
|
|
double scaler = 1.0 / numharmonics;
|
2017-12-03 20:51:57 +00:00
|
|
|
|
if (m_img.getWidth()!=getWidth() || m_img.getHeight()!=getHeight())
|
|
|
|
|
m_img = Image(Image::RGB, getWidth(), getHeight(), true);
|
|
|
|
|
if (m_nfreqs == 0 || nfreqs != m_nfreqs)
|
2017-12-03 20:00:40 +00:00
|
|
|
|
{
|
2017-12-03 20:51:57 +00:00
|
|
|
|
m_nfreqs = nfreqs;
|
|
|
|
|
m_insamples = std::vector<REALTYPE>(nfreqs * 2);
|
|
|
|
|
m_freqs1 = std::vector<REALTYPE>(nfreqs);
|
|
|
|
|
m_freqs2 = std::vector<REALTYPE>(nfreqs);
|
|
|
|
|
m_freqs3 = std::vector<REALTYPE>(nfreqs);
|
|
|
|
|
m_fft = std::make_unique<FFT>(nfreqs*2);
|
|
|
|
|
std::fill(m_insamples.begin(), m_insamples.end(), 0.0f);
|
|
|
|
|
for (int i = 0; i < nfreqs; ++i)
|
2017-12-03 20:00:40 +00:00
|
|
|
|
{
|
2017-12-03 20:51:57 +00:00
|
|
|
|
for (int j = 0; j < numharmonics; ++j)
|
|
|
|
|
{
|
|
|
|
|
double oscgain = 1.0 - (1.0 / numharmonics)*j;
|
2018-03-26 12:40:30 +00:00
|
|
|
|
m_insamples[i] += scaler * oscgain * sin(2 * c_PI / samplerate * i* (hz + hz * j));
|
2017-12-03 20:51:57 +00:00
|
|
|
|
}
|
2017-12-03 20:00:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-03 20:51:57 +00:00
|
|
|
|
|
|
|
|
|
//std::fill(m_freqs1.begin(), m_freqs1.end(), 0.0f);
|
|
|
|
|
//std::fill(m_freqs2.begin(), m_freqs2.end(), 0.0f);
|
|
|
|
|
//std::fill(m_freqs3.begin(), m_freqs3.end(), 0.0f);
|
|
|
|
|
//std::fill(m_fft->freq.begin(), m_fft->freq.end(), 0.0f);
|
2017-12-03 20:00:40 +00:00
|
|
|
|
for (int i = 0; i < nfreqs; ++i)
|
|
|
|
|
{
|
2017-12-03 20:51:57 +00:00
|
|
|
|
m_fft->smp[i] = m_insamples[i];
|
2017-12-03 20:00:40 +00:00
|
|
|
|
}
|
2017-12-03 20:51:57 +00:00
|
|
|
|
m_fft->applywindow(W_HAMMING);
|
|
|
|
|
m_fft->smp2freq();
|
2017-12-03 20:00:40 +00:00
|
|
|
|
double ratio = pow(2.0f, pars.pitch_shift.cents / 1200.0f);
|
2017-12-03 20:51:57 +00:00
|
|
|
|
spectrum_do_pitch_shift(pars, nfreqs, m_fft->freq.data(), m_freqs2.data(), ratio);
|
|
|
|
|
spectrum_do_freq_shift(pars, nfreqs, samplerate, m_freqs2.data(), m_freqs1.data());
|
|
|
|
|
spectrum_do_compressor(pars, nfreqs, m_freqs1.data(), m_freqs2.data());
|
|
|
|
|
spectrum_spread(nfreqs, samplerate, m_freqs3, m_freqs2.data(), m_freqs1.data(), pars.spread.bandwidth);
|
2018-01-30 16:49:00 +00:00
|
|
|
|
//if (pars.harmonics.enabled)
|
|
|
|
|
// spectrum_do_harmonics(pars, m_freqs3, nfreqs, samplerate, m_freqs1.data(), m_freqs2.data());
|
|
|
|
|
//else spectrum_copy(nfreqs, m_freqs1.data(), m_freqs2.data());
|
2017-12-03 20:00:40 +00:00
|
|
|
|
Graphics g(m_img);
|
2017-12-03 20:51:57 +00:00
|
|
|
|
g.fillAll(Colours::black);
|
2017-12-03 20:00:40 +00:00
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
|
for (int i = 0; i < nfreqs; ++i)
|
|
|
|
|
{
|
|
|
|
|
double binfreq = (samplerate / 2 / nfreqs)*i;
|
|
|
|
|
double xcor = jmap<double>(binfreq, 0.0, samplerate / 2.0, 0.0, getWidth());
|
2017-12-03 21:47:28 +00:00
|
|
|
|
double ycor = getHeight()- jmap<double>(m_freqs2[i], 0.0, nfreqs/128, 0.0, getHeight());
|
2017-12-03 20:00:40 +00:00
|
|
|
|
ycor = jlimit<double>(0.0, getHeight(), ycor);
|
|
|
|
|
g.drawLine(xcor, getHeight(), xcor, ycor, 1.0);
|
|
|
|
|
}
|
2017-12-03 20:51:57 +00:00
|
|
|
|
double t1 = Time::getMillisecondCounterHiRes();
|
|
|
|
|
m_elapsed = t1 - t0;
|
2017-12-03 20:00:40 +00:00
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpectralVisualizer::paint(Graphics & g)
|
|
|
|
|
{
|
|
|
|
|
g.drawImage(m_img, 0, 0, getWidth(), getHeight(), 0, 0, m_img.getWidth(), m_img.getHeight());
|
2017-12-03 20:51:57 +00:00
|
|
|
|
g.setColour(Colours::yellow);
|
|
|
|
|
g.drawText(String(m_elapsed, 1)+" ms", 1, 1, getWidth(), 30, Justification::topLeft);
|
2017-12-03 20:00:40 +00:00
|
|
|
|
}
|
2017-12-13 17:55:35 +00:00
|
|
|
|
|
|
|
|
|
void SpectralChainEditor::paint(Graphics & g)
|
|
|
|
|
{
|
|
|
|
|
g.fillAll(Colours::black);
|
|
|
|
|
if (m_src == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int box_w = getWidth() / m_order.size();
|
|
|
|
|
int box_h = getHeight();
|
|
|
|
|
for (int i = 0; i < m_order.size(); ++i)
|
|
|
|
|
{
|
2017-12-13 21:49:21 +00:00
|
|
|
|
//if (i!=m_cur_index)
|
2018-02-27 13:02:34 +00:00
|
|
|
|
drawBox(g, i, i*box_w, 0, box_w - 20, box_h);
|
2017-12-13 17:55:35 +00:00
|
|
|
|
if (i<m_order.size() - 1)
|
2018-02-27 13:02:34 +00:00
|
|
|
|
g.drawArrow(juce::Line<float>(i*box_w + (box_w - 20), box_h / 2, i*box_w + box_w, box_h / 2), 2.0f, 12.0f, 12.0f);
|
2017-12-13 17:55:35 +00:00
|
|
|
|
}
|
2017-12-13 19:25:42 +00:00
|
|
|
|
if (m_drag_x>=0 && m_drag_x<getWidth() && m_cur_index>=0)
|
|
|
|
|
drawBox(g, m_cur_index, m_drag_x, 0, box_w - 30, box_h);
|
2017-12-13 17:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 17:32:53 +00:00
|
|
|
|
void SpectralChainEditor::setSource(StretchAudioSource * src)
|
|
|
|
|
{
|
|
|
|
|
m_src = src;
|
|
|
|
|
m_order = m_src->getSpectrumProcessOrder();
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
|
void SpectralChainEditor::mouseDown(const MouseEvent & ev)
|
|
|
|
|
{
|
|
|
|
|
m_did_drag = false;
|
2018-01-31 22:06:32 +00:00
|
|
|
|
int box_w = getWidth() / m_order.size();
|
2017-12-13 17:55:35 +00:00
|
|
|
|
int box_h = getHeight();
|
|
|
|
|
m_cur_index = ev.x / box_w;
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_cur_index >= 0)
|
|
|
|
|
{
|
2018-02-01 13:11:41 +00:00
|
|
|
|
if (ModuleSelectedCallback)
|
|
|
|
|
ModuleSelectedCallback(m_order[m_cur_index].m_index);
|
2018-01-30 15:54:06 +00:00
|
|
|
|
juce::Rectangle<int> r(box_w*m_cur_index, 1, 12, 12);
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (r.contains(ev.x, ev.y))
|
|
|
|
|
{
|
2018-03-09 16:05:33 +00:00
|
|
|
|
toggleBool(m_order[m_cur_index].m_enabled);
|
2018-01-30 15:32:23 +00:00
|
|
|
|
repaint();
|
2018-01-31 22:06:32 +00:00
|
|
|
|
return;
|
2018-01-30 15:32:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-22 13:15:11 +00:00
|
|
|
|
m_drag_x = ev.x;
|
2017-12-13 17:55:35 +00:00
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpectralChainEditor::mouseDrag(const MouseEvent & ev)
|
|
|
|
|
{
|
2018-01-31 22:06:32 +00:00
|
|
|
|
int box_w = getWidth() / m_order.size();
|
|
|
|
|
juce::Rectangle<int> r(box_w*m_cur_index, 1, 12, 12);
|
|
|
|
|
if (r.contains(ev.x, ev.y))
|
|
|
|
|
return;
|
|
|
|
|
if (m_cur_index >= 0 && m_cur_index < m_order.size())
|
2017-12-13 17:55:35 +00:00
|
|
|
|
{
|
2018-01-31 22:06:32 +00:00
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
|
int box_h = getHeight();
|
2017-12-13 21:49:21 +00:00
|
|
|
|
int new_index = ev.x / box_w;
|
2017-12-13 17:55:35 +00:00
|
|
|
|
if (new_index >= 0 && new_index < m_order.size() && new_index != m_cur_index)
|
|
|
|
|
{
|
2018-03-09 17:39:39 +00:00
|
|
|
|
swapSpectrumProcesses(m_order[m_cur_index], m_order[new_index]);
|
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
|
m_cur_index = new_index;
|
2017-12-13 18:16:20 +00:00
|
|
|
|
m_did_drag = true;
|
2017-12-13 21:49:21 +00:00
|
|
|
|
m_src->setSpectrumProcessOrder(m_order);
|
2018-02-09 11:02:10 +00:00
|
|
|
|
if (ModuleOrderOrEnabledChangedCallback)
|
|
|
|
|
ModuleOrderOrEnabledChangedCallback();
|
2017-12-13 17:55:35 +00:00
|
|
|
|
}
|
2018-02-22 13:15:11 +00:00
|
|
|
|
int diff = m_drag_x - ev.x;
|
|
|
|
|
m_drag_x -= diff;
|
2017-12-13 19:25:42 +00:00
|
|
|
|
repaint();
|
2017-12-13 17:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpectralChainEditor::mouseUp(const MouseEvent & ev)
|
|
|
|
|
{
|
2017-12-13 19:25:42 +00:00
|
|
|
|
m_drag_x = -1;
|
2017-12-13 21:49:21 +00:00
|
|
|
|
//m_cur_index = -1;
|
2017-12-13 19:25:42 +00:00
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-03 20:48:24 +00:00
|
|
|
|
void SpectralChainEditor::setModuleSelected(int id)
|
|
|
|
|
{
|
|
|
|
|
if (id != m_cur_index)
|
|
|
|
|
{
|
|
|
|
|
m_cur_index = id;
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-03 21:06:06 +00:00
|
|
|
|
void SpectralChainEditor::moveModule(int old_id, int new_id)
|
|
|
|
|
{
|
|
|
|
|
if (old_id == m_cur_index)
|
|
|
|
|
return;
|
|
|
|
|
std::swap(m_order[old_id], m_order[new_id]);
|
|
|
|
|
m_cur_index = new_id;
|
|
|
|
|
m_src->setSpectrumProcessOrder(m_order);
|
|
|
|
|
repaint();
|
|
|
|
|
if (ModuleOrderOrEnabledChangedCallback)
|
|
|
|
|
ModuleOrderOrEnabledChangedCallback();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 19:25:42 +00:00
|
|
|
|
void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w, int h)
|
|
|
|
|
{
|
2018-03-09 16:05:33 +00:00
|
|
|
|
jassert(m_order[index].m_enabled != nullptr);
|
2017-12-13 19:25:42 +00:00
|
|
|
|
String txt;
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 0)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Harmonics";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 1)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Tonal vs Noise";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 2)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Frequency shift";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 3)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Pitch shift";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 4)
|
2018-04-13 12:24:18 +00:00
|
|
|
|
txt = "Ratios";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 5)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Spread";
|
2018-01-30 15:32:23 +00:00
|
|
|
|
if (m_order[index].m_index == 6)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Filter";
|
2018-03-21 11:43:03 +00:00
|
|
|
|
if (m_order[index].m_index == 8)
|
2017-12-13 19:25:42 +00:00
|
|
|
|
txt = "Compressor";
|
2018-03-21 11:43:03 +00:00
|
|
|
|
if (m_order[index].m_index == 7)
|
2018-02-27 02:06:53 +00:00
|
|
|
|
txt = "Free filter";
|
2017-12-13 19:25:42 +00:00
|
|
|
|
if (index == m_cur_index)
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::darkgrey);
|
|
|
|
|
//g.fillRect(i*box_w, 0, box_w - 30, box_h - 1);
|
|
|
|
|
g.fillRect(x, y, w, h);
|
|
|
|
|
}
|
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
|
g.drawRect(x, y, w, h);
|
2018-03-12 22:33:47 +00:00
|
|
|
|
g.drawFittedText(txt, x,y,w,h-5, Justification::centredBottom, 3);
|
2018-03-09 16:05:33 +00:00
|
|
|
|
//g.drawFittedText(m_order[index].m_enabled->name, x, y, w, h, Justification::centred, 3);
|
2018-01-30 15:32:23 +00:00
|
|
|
|
g.setColour(Colours::gold);
|
2018-01-30 15:54:06 +00:00
|
|
|
|
g.drawRect(x + 2, y + 2, 12, 12);
|
2018-03-09 17:39:39 +00:00
|
|
|
|
if ((bool)*m_order[index].m_enabled == true)
|
2018-01-30 15:32:23 +00:00
|
|
|
|
{
|
2018-01-30 15:54:06 +00:00
|
|
|
|
g.drawLine(x+2, y+2, x+14, y+14);
|
|
|
|
|
g.drawLine(x+2, y+14, x+14, y+2);
|
2018-01-30 15:32:23 +00:00
|
|
|
|
}
|
|
|
|
|
g.setColour(Colours::white);
|
2017-12-13 17:55:35 +00:00
|
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
|
|
|
|
|
|
ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notifyOnlyOnRelease) : m_par(par)
|
|
|
|
|
{
|
|
|
|
|
addAndMakeVisible(&m_label);
|
2018-02-01 13:11:41 +00:00
|
|
|
|
m_labeldefcolor = m_label.findColour(Label::textColourId);
|
2017-12-22 20:59:45 +00:00
|
|
|
|
m_label.setText(par->getName(50), dontSendNotification);
|
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
|
|
|
|
|
if (floatpar)
|
|
|
|
|
{
|
2018-05-31 10:21:35 +00:00
|
|
|
|
m_slider = makeAddAndMakeVisible<MySlider>(&floatpar->range);
|
2017-12-22 20:59:45 +00:00
|
|
|
|
m_notify_only_on_release = notifyOnlyOnRelease;
|
|
|
|
|
m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval);
|
|
|
|
|
m_slider->setValue(*floatpar, dontSendNotification);
|
|
|
|
|
m_slider->addListener(this);
|
2018-02-01 18:09:12 +00:00
|
|
|
|
m_slider->setDoubleClickReturnValue(true, floatpar->range.convertFrom0to1(par->getDefaultValue()));
|
2017-12-22 20:59:45 +00:00
|
|
|
|
}
|
|
|
|
|
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(par);
|
|
|
|
|
if (intpar)
|
|
|
|
|
{
|
2018-05-31 10:21:35 +00:00
|
|
|
|
m_slider = makeAddAndMakeVisible<MySlider>();
|
2017-12-22 20:59:45 +00:00
|
|
|
|
m_notify_only_on_release = notifyOnlyOnRelease;
|
|
|
|
|
m_slider->setRange(intpar->getRange().getStart(), intpar->getRange().getEnd(), 1.0);
|
|
|
|
|
m_slider->setValue(*intpar, dontSendNotification);
|
|
|
|
|
m_slider->addListener(this);
|
|
|
|
|
}
|
|
|
|
|
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(par);
|
|
|
|
|
if (choicepar)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(par);
|
|
|
|
|
if (boolpar)
|
|
|
|
|
{
|
|
|
|
|
m_togglebut = std::make_unique<ToggleButton>();
|
|
|
|
|
m_togglebut->setToggleState(*boolpar, dontSendNotification);
|
|
|
|
|
m_togglebut->addListener(this);
|
|
|
|
|
m_togglebut->setButtonText(par->getName(50));
|
|
|
|
|
addAndMakeVisible(m_togglebut.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::resized()
|
|
|
|
|
{
|
|
|
|
|
if (m_slider)
|
|
|
|
|
{
|
2018-02-13 13:47:17 +00:00
|
|
|
|
int labw = 200;
|
|
|
|
|
if (getWidth() < 400)
|
|
|
|
|
labw = 100;
|
|
|
|
|
m_label.setBounds(0, 0, labw, 24);
|
2017-12-22 20:59:45 +00:00
|
|
|
|
m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), 24);
|
|
|
|
|
}
|
|
|
|
|
if (m_togglebut)
|
|
|
|
|
m_togglebut->setBounds(1, 0, getWidth() - 1, 24);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::sliderValueChanged(Slider * slid)
|
|
|
|
|
{
|
|
|
|
|
if (m_notify_only_on_release == true)
|
|
|
|
|
return;
|
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
|
|
|
|
if (floatpar != nullptr)
|
|
|
|
|
*floatpar = slid->getValue();
|
|
|
|
|
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
|
|
|
|
if (intpar != nullptr)
|
|
|
|
|
*intpar = slid->getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::sliderDragStarted(Slider * slid)
|
|
|
|
|
{
|
|
|
|
|
m_dragging = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::sliderDragEnded(Slider * slid)
|
|
|
|
|
{
|
|
|
|
|
m_dragging = false;
|
|
|
|
|
if (m_notify_only_on_release == false)
|
|
|
|
|
return;
|
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
|
|
|
|
if (floatpar != nullptr)
|
|
|
|
|
*floatpar = slid->getValue();
|
|
|
|
|
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
|
|
|
|
if (intpar != nullptr)
|
|
|
|
|
*intpar = slid->getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::buttonClicked(Button * but)
|
|
|
|
|
{
|
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
|
|
|
|
if (m_togglebut != nullptr && m_togglebut->getToggleState() != *boolpar)
|
|
|
|
|
{
|
|
|
|
|
*boolpar = m_togglebut->getToggleState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParameterComponent::updateComponent()
|
|
|
|
|
{
|
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
|
|
|
|
if (floatpar != nullptr && m_slider != nullptr && m_dragging == false && (float)m_slider->getValue() != *floatpar)
|
|
|
|
|
{
|
|
|
|
|
m_slider->setValue(*floatpar, dontSendNotification);
|
|
|
|
|
}
|
|
|
|
|
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
|
|
|
|
if (intpar != nullptr && m_slider != nullptr && m_dragging == false && (int)m_slider->getValue() != *intpar)
|
|
|
|
|
{
|
|
|
|
|
m_slider->setValue(*intpar, dontSendNotification);
|
|
|
|
|
}
|
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
|
|
|
|
if (m_togglebut != nullptr && m_togglebut->getToggleState() != *boolpar)
|
|
|
|
|
{
|
|
|
|
|
m_togglebut->setToggleState(*boolpar, dontSendNotification);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-03 17:32:53 +00:00
|
|
|
|
|
2018-02-01 13:11:41 +00:00
|
|
|
|
void ParameterComponent::setHighLighted(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (b == false)
|
|
|
|
|
{
|
|
|
|
|
m_label.setColour(Label::textColourId, m_labeldefcolor);
|
|
|
|
|
if (m_togglebut)
|
|
|
|
|
m_togglebut->setColour(ToggleButton::textColourId, m_labeldefcolor);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_label.setColour(Label::textColourId, Colours::yellow);
|
|
|
|
|
if (m_togglebut)
|
|
|
|
|
m_togglebut->setColour(ToggleButton::textColourId, Colours::yellow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 17:32:53 +00:00
|
|
|
|
MySlider::MySlider(NormalisableRange<float>* range) : m_range(range)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double MySlider::proportionOfLengthToValue(double x)
|
|
|
|
|
{
|
|
|
|
|
if (m_range)
|
|
|
|
|
return m_range->convertFrom0to1(x);
|
|
|
|
|
return Slider::proportionOfLengthToValue(x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double MySlider::valueToProportionOfLength(double x)
|
|
|
|
|
{
|
|
|
|
|
if (m_range)
|
|
|
|
|
return m_range->convertTo0to1(x);
|
|
|
|
|
return Slider::valueToProportionOfLength(x);
|
|
|
|
|
}
|
2018-02-02 10:23:57 +00:00
|
|
|
|
|
|
|
|
|
PerfMeterComponent::PerfMeterComponent(PaulstretchpluginAudioProcessor * p)
|
|
|
|
|
: m_proc(p)
|
2018-02-15 23:55:33 +00:00
|
|
|
|
{
|
|
|
|
|
m_gradient.isRadial = false;
|
|
|
|
|
m_gradient.addColour(0.0, Colours::red);
|
|
|
|
|
m_gradient.addColour(0.25, Colours::yellow);
|
|
|
|
|
m_gradient.addColour(1.0, Colours::green);
|
2018-05-01 15:35:00 +00:00
|
|
|
|
startTimer(30);
|
2018-02-15 23:55:33 +00:00
|
|
|
|
}
|
2018-02-02 10:23:57 +00:00
|
|
|
|
|
|
|
|
|
void PerfMeterComponent::paint(Graphics & g)
|
|
|
|
|
{
|
2018-02-15 23:55:33 +00:00
|
|
|
|
m_gradient.point1 = {0.0f,0.0f};
|
|
|
|
|
m_gradient.point2 = {(float)getWidth(),0.0f};
|
|
|
|
|
g.fillAll(Colours::grey);
|
2018-05-01 15:22:21 +00:00
|
|
|
|
double amt = m_proc->getPreBufferingPercent();
|
2018-02-02 10:23:57 +00:00
|
|
|
|
g.setColour(Colours::green);
|
|
|
|
|
int w = amt * getWidth();
|
2018-02-16 11:51:48 +00:00
|
|
|
|
//g.setGradientFill(m_gradient);
|
2018-02-15 23:55:33 +00:00
|
|
|
|
g.fillRect(0, 0, w, getHeight());
|
2018-02-02 10:23:57 +00:00
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
|
g.drawRect(0, 0, getWidth(), getHeight());
|
|
|
|
|
g.setFont(10.0f);
|
2018-02-07 13:12:10 +00:00
|
|
|
|
if (m_proc->getPreBufferAmount()>0)
|
|
|
|
|
g.drawText("PREBUFFER", 0, 0, getWidth(), getHeight(), Justification::centred);
|
|
|
|
|
else
|
|
|
|
|
g.drawText("NO PREBUFFER", 0, 0, getWidth(), getHeight(), Justification::centred);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerfMeterComponent::mouseDown(const MouseEvent & ev)
|
|
|
|
|
{
|
|
|
|
|
PopupMenu bufferingmenu;
|
|
|
|
|
int curbufamount = m_proc->getPreBufferAmount();
|
|
|
|
|
bufferingmenu.addItem(100, "None", true, curbufamount == -1);
|
|
|
|
|
bufferingmenu.addItem(101, "Small", true, curbufamount == 1);
|
|
|
|
|
bufferingmenu.addItem(102, "Medium", true, curbufamount == 2);
|
|
|
|
|
bufferingmenu.addItem(103, "Large", true, curbufamount == 3);
|
|
|
|
|
bufferingmenu.addItem(104, "Very large", true, curbufamount == 4);
|
|
|
|
|
bufferingmenu.addItem(105, "Huge", true, curbufamount == 5);
|
|
|
|
|
int r = bufferingmenu.show();
|
|
|
|
|
if (r >= 100 && r < 200)
|
|
|
|
|
{
|
|
|
|
|
if (r == 100)
|
|
|
|
|
m_proc->m_use_backgroundbuffering = false;
|
|
|
|
|
if (r > 100)
|
|
|
|
|
m_proc->setPreBufferAmount(r - 100);
|
|
|
|
|
}
|
2018-02-02 10:23:57 +00:00
|
|
|
|
}
|
2018-02-14 13:18:35 +00:00
|
|
|
|
|
2018-05-01 15:35:00 +00:00
|
|
|
|
void PerfMeterComponent::timerCallback()
|
|
|
|
|
{
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-14 13:18:35 +00:00
|
|
|
|
void zoom_scrollbar::mouseDown(const MouseEvent &e)
|
|
|
|
|
{
|
|
|
|
|
m_drag_start_x = e.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::mouseMove(const MouseEvent &e)
|
|
|
|
|
{
|
|
|
|
|
auto ha = get_hot_area(e.x, e.y);
|
|
|
|
|
if (ha == ha_left_edge || m_hot_area == ha_right_edge)
|
|
|
|
|
setMouseCursor(MouseCursor::LeftRightResizeCursor);
|
|
|
|
|
else
|
|
|
|
|
setMouseCursor(MouseCursor::NormalCursor);
|
|
|
|
|
if (ha != m_hot_area)
|
|
|
|
|
{
|
|
|
|
|
m_hot_area = ha;
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::mouseDrag(const MouseEvent &e)
|
|
|
|
|
{
|
|
|
|
|
if (m_hot_area == ha_none)
|
|
|
|
|
return;
|
|
|
|
|
if (m_hot_area == ha_left_edge)
|
|
|
|
|
{
|
|
|
|
|
double new_left_edge = 1.0 / getWidth()*e.x;
|
|
|
|
|
m_therange.setStart(jlimit(0.0, m_therange.getEnd() - 0.01, new_left_edge));
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
if (m_hot_area == ha_right_edge)
|
|
|
|
|
{
|
|
|
|
|
double new_right_edge = 1.0 / getWidth()*e.x;
|
|
|
|
|
m_therange.setEnd(jlimit(m_therange.getStart() + 0.01, 1.0, new_right_edge));
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
if (m_hot_area == ha_handle)
|
|
|
|
|
{
|
|
|
|
|
double delta = 1.0 / getWidth()*(e.x - m_drag_start_x);
|
|
|
|
|
//double old_start = m_start;
|
|
|
|
|
//double old_end = m_end;
|
|
|
|
|
double old_len = m_therange.getLength();
|
|
|
|
|
m_therange.setStart(jlimit(0.0, 1.0 - old_len, m_therange.getStart() + delta));
|
|
|
|
|
m_therange.setEnd(jlimit(old_len, m_therange.getStart() + old_len, m_therange.getEnd() + delta));
|
|
|
|
|
m_drag_start_x = e.x;
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
if (RangeChanged)
|
|
|
|
|
RangeChanged(m_therange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::mouseEnter(const MouseEvent & event)
|
|
|
|
|
{
|
|
|
|
|
m_hot_area = get_hot_area(event.x, event.y);
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::mouseExit(const MouseEvent &)
|
|
|
|
|
{
|
|
|
|
|
m_hot_area = ha_none;
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::paint(Graphics &g)
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::darkgrey);
|
|
|
|
|
g.fillRect(0, 0, getWidth(), getHeight());
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void zoom_scrollbar::setRange(Range<double> rng, bool docallback)
|
|
|
|
|
{
|
2018-02-14 16:38:54 +00:00
|
|
|
|
if (rng.isEmpty())
|
|
|
|
|
return;
|
2018-02-14 13:18:35 +00:00
|
|
|
|
m_therange = rng.constrainRange({ 0.0,1.0 });
|
|
|
|
|
if (RangeChanged && docallback)
|
|
|
|
|
RangeChanged(m_therange);
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zoom_scrollbar::hot_area zoom_scrollbar::get_hot_area(int x, int)
|
|
|
|
|
{
|
|
|
|
|
int x0 = (int)(getWidth()*m_therange.getStart());
|
|
|
|
|
int x1 = (int)(getWidth()*m_therange.getEnd());
|
|
|
|
|
if (is_in_range(x, x0 - 5, x0 + 5))
|
|
|
|
|
return ha_left_edge;
|
|
|
|
|
if (is_in_range(x, x1 - 5, x1 + 5))
|
|
|
|
|
return ha_right_edge;
|
|
|
|
|
if (is_in_range(x, x0 + 5, x1 - 5))
|
|
|
|
|
return ha_handle;
|
|
|
|
|
return ha_none;
|
|
|
|
|
}
|
2018-04-03 13:34:20 +00:00
|
|
|
|
|
|
|
|
|
RatioMixerEditor::RatioMixerEditor(int numratios)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < numratios; ++i)
|
|
|
|
|
{
|
|
|
|
|
auto ratslid = std::make_unique<Slider>(Slider::LinearHorizontal,Slider::TextBoxBelow);
|
|
|
|
|
ratslid->setRange(0.125, 8.0);
|
2018-04-03 15:32:53 +00:00
|
|
|
|
ratslid->onValueChange = [this,i]() {OnRatioChanged(i, m_ratio_sliders[i]->getValue()); };
|
2018-04-03 13:34:20 +00:00
|
|
|
|
addAndMakeVisible(ratslid.get());
|
|
|
|
|
m_ratio_sliders.emplace_back(std::move(ratslid));
|
|
|
|
|
|
|
|
|
|
auto ratlevslid = std::make_unique<Slider>();
|
|
|
|
|
ratlevslid->setRange(0.0, 1.0);
|
|
|
|
|
ratlevslid->setSliderStyle(Slider::LinearVertical);
|
|
|
|
|
if (i==3)
|
|
|
|
|
ratlevslid->setValue(1.0,dontSendNotification);
|
|
|
|
|
else ratlevslid->setValue(0.0,dontSendNotification);
|
|
|
|
|
ratlevslid->onValueChange = [this, i]() { OnRatioLevelChanged(i, m_ratio_level_sliders[i]->getValue()); };
|
|
|
|
|
addAndMakeVisible(ratlevslid.get());
|
|
|
|
|
m_ratio_level_sliders.emplace_back(std::move(ratlevslid));
|
|
|
|
|
}
|
|
|
|
|
startTimer(200);
|
2018-04-03 19:04:10 +00:00
|
|
|
|
setOpaque(true);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RatioMixerEditor::resized()
|
|
|
|
|
{
|
|
|
|
|
int nsliders = m_ratio_sliders.size();
|
|
|
|
|
int slidw = getWidth() / nsliders;
|
|
|
|
|
for (int i = 0; i < nsliders; ++i)
|
|
|
|
|
{
|
2018-05-02 10:14:02 +00:00
|
|
|
|
m_ratio_level_sliders[i]->setBounds(slidw/2+slidw * i-10, 15, 20, getHeight() - 55);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
m_ratio_sliders[i]->setBounds(slidw * i, getHeight() - 48, slidw - 5, 47);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RatioMixerEditor::timerCallback()
|
|
|
|
|
{
|
2018-04-29 15:48:28 +00:00
|
|
|
|
if (!GetParameterValue)
|
|
|
|
|
return;
|
2018-04-03 13:34:20 +00:00
|
|
|
|
for (int i = 0; i < m_ratio_level_sliders.size(); ++i)
|
|
|
|
|
{
|
2018-04-03 15:32:53 +00:00
|
|
|
|
double v = GetParameterValue(0, i);
|
|
|
|
|
if (v!=m_ratio_sliders[i]->getValue())
|
|
|
|
|
m_ratio_sliders[i]->setValue(v, dontSendNotification);
|
|
|
|
|
v = GetParameterValue(1, i);
|
|
|
|
|
if (v!=m_ratio_level_sliders[i]->getValue())
|
|
|
|
|
m_ratio_level_sliders[i]->setValue(v, dontSendNotification);
|
2018-04-03 13:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-03 19:04:10 +00:00
|
|
|
|
|
|
|
|
|
void RatioMixerEditor::paint(Graphics & g)
|
|
|
|
|
{
|
|
|
|
|
g.fillAll(Colours::grey);
|
2018-05-02 10:14:02 +00:00
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
|
int 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);
|
2018-04-03 19:04:10 +00:00
|
|
|
|
}
|
2018-06-29 11:23:48 +00:00
|
|
|
|
|
2018-06-29 11:49:11 +00:00
|
|
|
|
FreeFilterComponent::FreeFilterComponent(PaulstretchpluginAudioProcessor* proc)
|
|
|
|
|
: m_env(proc->getStretchSource()->getMutex()), m_cs(proc->getStretchSource()->getMutex()), m_proc(proc)
|
2018-06-29 11:23:48 +00:00
|
|
|
|
{
|
|
|
|
|
addAndMakeVisible(m_env);
|
2018-06-29 11:49:11 +00:00
|
|
|
|
const auto& pars = m_proc->getParameters();
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_shiftx],false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_shifty], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_scaley], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_tilty], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_numbands], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_rate], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
|
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_amount], false));
|
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:23:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FreeFilterComponent::resized()
|
|
|
|
|
{
|
2018-06-29 11:49:11 +00:00
|
|
|
|
m_env.setBounds(m_slidwidth, 0, getWidth() - m_slidwidth, getHeight());
|
|
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
m_parcomps[i]->setBounds(1, 1+25*i, m_slidwidth - 2, 24);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FreeFilterComponent::paint(Graphics & g)
|
|
|
|
|
{
|
|
|
|
|
g.setColour(Colours::grey);
|
|
|
|
|
g.fillRect(0, 0, m_slidwidth, getHeight());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FreeFilterComponent::updateParameterComponents()
|
|
|
|
|
{
|
|
|
|
|
for (auto& e : m_parcomps)
|
|
|
|
|
e->updateComponent();
|
2018-06-29 11:23:48 +00:00
|
|
|
|
}
|