2022-04-22 03:04:30 +00:00
|
|
|
// SPDX-License-Identifier: GPLv3-or-later WITH Appstore-exception
|
|
|
|
// Copyright (C) 2017 Xenakios
|
|
|
|
// Copyright (C) 2020 Jesse Chappell
|
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
|
|
|
|
2022-04-02 16:45:02 +00:00
|
|
|
#include "CrossPlatformUtils.h"
|
2022-06-14 23:11:57 +00:00
|
|
|
#include "OptionsView.h"
|
2018-11-13 20:18:05 +00:00
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
enum ParameterGroupIds
|
|
|
|
{
|
|
|
|
HarmonicsGroup = 0,
|
|
|
|
TonalNoiseGroup = 1,
|
|
|
|
FrequencyShiftGroup = 2,
|
|
|
|
PitchShiftGroup = 3,
|
|
|
|
RatiosGroup = 4,
|
|
|
|
FrequencySpreadGroup = 5,
|
|
|
|
FilterGroup = 6,
|
|
|
|
FreeFilterGroup = 7,
|
|
|
|
CompressGroup = 8
|
|
|
|
};
|
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
//==============================================================================
|
2018-01-03 15:15:57 +00:00
|
|
|
PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p)
|
|
|
|
: AudioProcessorEditor(&p),
|
2018-09-13 10:47:19 +00:00
|
|
|
m_wavecomponent(p.m_afm,p.m_thumb.get(), p.getStretchSource()),
|
2018-02-27 00:33:41 +00:00
|
|
|
processor(p), m_perfmeter(&p),
|
2018-09-19 21:58:24 +00:00
|
|
|
m_free_filter_component(&p),
|
2019-01-21 17:25:27 +00:00
|
|
|
m_wavefilter_tab(p.m_cur_tab_index),
|
|
|
|
m_filefilter(p.m_afm->getWildcardForAllFormats(),String(),String())
|
2017-11-13 15:06:08 +00:00
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
LookAndFeel::setDefaultLookAndFeel(&m_lookandfeel);
|
|
|
|
setLookAndFeel(&m_lookandfeel);
|
2019-01-21 19:17:05 +00:00
|
|
|
|
|
|
|
|
2018-10-07 11:29:50 +00:00
|
|
|
setWantsKeyboardFocus(true);
|
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
|
|
|
};
|
2022-04-22 03:04:30 +00:00
|
|
|
int tabdepth = 26;
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
#if JUCE_IOS
|
|
|
|
tabdepth = 36;
|
|
|
|
#endif
|
|
|
|
m_wavefilter_tab.setTabBarDepth(tabdepth);
|
|
|
|
m_wavefilter_tab.getTabbedButtonBar().setMinimumTabScaleFactor(0.25f);
|
|
|
|
|
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);
|
2022-04-11 22:50:55 +00:00
|
|
|
#if JUCE_IOS
|
|
|
|
m_import_button.setButtonText("Load Audio...");
|
|
|
|
#else
|
|
|
|
m_import_button.setButtonText("Show browser");
|
|
|
|
#endif
|
2019-01-21 22:09:28 +00:00
|
|
|
m_import_button.onClick = [this]()
|
2019-01-21 17:25:27 +00:00
|
|
|
{
|
2019-01-21 22:09:28 +00:00
|
|
|
toggleFileBrowser();
|
2019-01-21 17:25:27 +00:00
|
|
|
};
|
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...");
|
2022-06-14 23:11:57 +00:00
|
|
|
m_settings_button.onClick = [this]() {
|
|
|
|
showSettings(true);
|
|
|
|
};
|
2018-01-03 15:15:57 +00:00
|
|
|
|
2022-06-15 18:54:49 +00:00
|
|
|
addAndMakeVisible(&m_render_button);
|
|
|
|
m_render_button.setButtonText("Render...");
|
|
|
|
m_render_button.onClick = [this]() { showRenderDialog(); };
|
2018-05-07 17:21:42 +00:00
|
|
|
|
2022-04-15 23:42:43 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
m_rewind_button = std::make_unique<DrawableButton>("rewind", DrawableButton::ButtonStyle::ImageFitted);
|
|
|
|
std::unique_ptr<Drawable> rewimg(Drawable::createFromImageData(BinaryData::skipback_icon_svg, BinaryData::skipback_icon_svgSize));
|
|
|
|
m_rewind_button->setImages(rewimg.get());
|
|
|
|
m_rewind_button->setColour(TextButton::buttonColourId, Colours::transparentBlack);
|
|
|
|
m_rewind_button->setColour(TextButton::buttonOnColourId, Colours::transparentBlack);
|
|
|
|
m_rewind_button->setColour(DrawableButton::backgroundColourId, Colours::transparentBlack);
|
|
|
|
m_rewind_button->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
|
|
|
|
|
|
|
|
addAndMakeVisible(m_rewind_button.get());
|
|
|
|
m_rewind_button->setTitle("Return to start");
|
|
|
|
m_rewind_button->setTooltip("Return to start");
|
|
|
|
m_rewind_button->onClick = [this]()
|
2018-05-09 11:02:22 +00:00
|
|
|
{
|
2022-04-22 04:55:35 +00:00
|
|
|
processor.setParameter( cpi_rewind, 1.0f);
|
2018-05-18 13:20:51 +00:00
|
|
|
//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);
|
2022-04-14 07:26:26 +00:00
|
|
|
m_info_label.setFont(14.0f);
|
2017-12-28 20:50:52 +00:00
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
|
|
|
|
m_recordingButton = std::make_unique<DrawableButton>("rewind", DrawableButton::ButtonStyle::ImageFitted);
|
|
|
|
std::unique_ptr<Drawable> reconimg(Drawable::createFromImageData(BinaryData::record_output_active_svg, BinaryData::record_output_active_svgSize));
|
|
|
|
std::unique_ptr<Drawable> recoffimg(Drawable::createFromImageData(BinaryData::record_output_svg, BinaryData::record_output_svgSize));
|
|
|
|
m_recordingButton->setImages(recoffimg.get(), nullptr, nullptr, nullptr, reconimg.get());
|
|
|
|
m_recordingButton->setColour(DrawableButton::backgroundOnColourId, Colour::fromFloatRGBA(0.6, 0.3, 0.3, 0.5));
|
|
|
|
addAndMakeVisible(m_recordingButton.get());
|
|
|
|
//m_recordingButton->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
|
|
|
|
m_recordingButton->setTooltip(TRANS("Start/Stop recording output to file"));
|
|
|
|
m_recordingButton->setTitle(TRANS("Record Output"));
|
|
|
|
m_recordingButton->setClickingTogglesState(true);
|
|
|
|
m_recordingButton->onClick = [this]() { toggleOutputRecording(); };
|
|
|
|
|
|
|
|
m_fileRecordingLabel = std::make_unique<Label>("rectime", "");
|
|
|
|
m_fileRecordingLabel->setJustificationType(Justification::centredBottom);
|
|
|
|
m_fileRecordingLabel->setFont(12);
|
|
|
|
m_fileRecordingLabel->setColour(Label::textColourId, Colour(0x88ffbbbb));
|
|
|
|
m_fileRecordingLabel->setAccessible(false);
|
|
|
|
|
|
|
|
addAndMakeVisible(m_fileRecordingLabel.get());
|
|
|
|
|
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;
|
2022-04-14 07:26:26 +00:00
|
|
|
|
|
|
|
bool usedrawable = false;
|
|
|
|
if (i == cpi_pause_enabled || i == cpi_looping_enabled || i == cpi_capture_trigger || i == cpi_freeze || i == cpi_passthrough)
|
|
|
|
usedrawable = true;
|
|
|
|
|
|
|
|
|
|
|
|
int group_id = -1;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_harmonicsbw || i == cpi_harmonicsfreq || i == cpi_harmonicsgauss || i == cpi_numharmonics)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = HarmonicsGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
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)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = TonalNoiseGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_filter_low || i == cpi_filter_high)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = FilterGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_compress)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = CompressGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_spreadamount)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = FrequencySpreadGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_frequencyshift)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = FrequencyShiftGroup;
|
2018-02-01 13:11:41 +00:00
|
|
|
if (i == cpi_pitchshift)
|
2022-04-11 17:23:10 +00:00
|
|
|
group_id = PitchShiftGroup;
|
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
|
|
|
{
|
2022-04-14 07:26:26 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[i], notifyonlyonrelease, usedrawable));
|
2018-04-29 15:48:28 +00:00
|
|
|
m_parcomps.back()->m_group_id = group_id;
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
if (group_id == -1) // only add ones that aren't in groups
|
|
|
|
addAndMakeVisible(m_parcomps.back().get());
|
2018-04-29 15:48:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_parcomps.push_back(nullptr);
|
|
|
|
}
|
2017-11-13 18:45:23 +00:00
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-13 17:48:09 +00:00
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
m_parcomps[cpi_num_inchans]->getSlider()->setSliderStyle(Slider::SliderStyle::IncDecButtons);
|
|
|
|
m_parcomps[cpi_num_inchans]->getSlider()->setTextBoxStyle(Slider::TextEntryBoxPosition::TextBoxLeft, false, 30, 34);
|
|
|
|
m_parcomps[cpi_num_outchans]->getSlider()->setSliderStyle(Slider::SliderStyle::IncDecButtons);
|
|
|
|
m_parcomps[cpi_num_outchans]->getSlider()->setTextBoxStyle(Slider::TextEntryBoxPosition::TextBoxLeft, false, 30, 34);
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
removeChildComponent(m_parcomps[cpi_bypass_stretch].get());
|
|
|
|
|
|
|
|
|
|
|
|
if (auto * pausebut = m_parcomps[cpi_pause_enabled]->getDrawableButton()) {
|
|
|
|
std::unique_ptr<Drawable> playimg(Drawable::createFromImageData(BinaryData::play_icon_svg, BinaryData::play_icon_svgSize));
|
|
|
|
std::unique_ptr<Drawable> pauseimg(Drawable::createFromImageData(BinaryData::pause_icon_svg, BinaryData::pause_icon_svgSize));
|
|
|
|
pausebut->setImages(pauseimg.get(), nullptr, nullptr, nullptr, playimg.get());
|
|
|
|
pausebut->setColour(DrawableButton::backgroundColourId, Colour::fromFloatRGBA(0.1f, 0.5f, 0.1f, 0.55f));
|
2022-04-22 03:04:30 +00:00
|
|
|
pausebut->setTooltip("Play / Pause");
|
2022-04-14 07:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (auto * loopbut = m_parcomps[cpi_looping_enabled]->getDrawableButton()) {
|
|
|
|
std::unique_ptr<Drawable> loopimg(Drawable::createFromImageData(BinaryData::loop_icon_svg, BinaryData::loop_icon_svgSize));
|
|
|
|
loopbut->setImages(loopimg.get());
|
|
|
|
loopbut->setColour(DrawableButton::backgroundOnColourId, Colour::fromFloatRGBA(0.6, 0.4, 0.6, 0.4));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto * recbut = m_parcomps[cpi_capture_trigger]->getDrawableButton()) {
|
2022-06-14 23:11:57 +00:00
|
|
|
std::unique_ptr<Drawable> ireconimg(Drawable::createFromImageData(BinaryData::record_input_active_svg, BinaryData::record_input_active_svgSize));
|
|
|
|
std::unique_ptr<Drawable> irecoffimg(Drawable::createFromImageData(BinaryData::record_input_svg, BinaryData::record_input_svgSize));
|
|
|
|
recbut->setImages(irecoffimg.get(), nullptr, nullptr, nullptr, ireconimg.get());
|
2022-04-14 07:26:26 +00:00
|
|
|
recbut->setColour(DrawableButton::backgroundOnColourId, Colour::fromFloatRGBA(0.6, 0.3, 0.3, 0.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto * freezebut = m_parcomps[cpi_freeze]->getDrawableButton()) {
|
|
|
|
std::unique_ptr<Drawable> img(Drawable::createFromImageData(BinaryData::freeze_svg, BinaryData::freeze_svgSize));
|
|
|
|
freezebut->setImages(img.get());
|
|
|
|
freezebut->setColour(DrawableButton::backgroundOnColourId, Colour::fromFloatRGBA(0.2, 0.5, 0.7, 0.55));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto * thrubut = m_parcomps[cpi_passthrough]->getDrawableButton()) {
|
|
|
|
std::unique_ptr<Drawable> img(Drawable::createFromImageData(BinaryData::passthru_svg, BinaryData::passthru_svgSize));
|
|
|
|
std::unique_ptr<Drawable> imgon(Drawable::createFromImageData(BinaryData::passthru_enabled_svg, BinaryData::passthru_enabled_svgSize));
|
|
|
|
thrubut->setImages(img.get(), nullptr, nullptr, nullptr, imgon.get());
|
|
|
|
thrubut->setColour(DrawableButton::backgroundOnColourId, Colour::fromFloatRGBA(0.5, 0.3, 0.0, 0.55));
|
|
|
|
}
|
|
|
|
|
2022-04-13 17:48:09 +00:00
|
|
|
|
|
|
|
#if JUCE_IOS
|
|
|
|
// just don't include chan counts on ios for now
|
|
|
|
removeChildComponent(m_parcomps[cpi_num_inchans].get());
|
|
|
|
removeChildComponent(m_parcomps[cpi_num_outchans].get());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
m_groupviewport = std::make_unique<Viewport>();
|
|
|
|
m_groupcontainer = std::make_unique<Component>();
|
|
|
|
m_groupviewport->setViewedComponent(m_groupcontainer.get(), false);
|
|
|
|
|
|
|
|
addAndMakeVisible(m_groupviewport.get());
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
m_stretchgroup = std::make_unique<ParameterGroupComponent>("", -1, &processor, true);
|
2022-04-28 02:52:40 +00:00
|
|
|
m_stretchgroup->setBackgroundColor(Colour(0xcc332244));
|
|
|
|
m_stretchgroup->setSelectedBackgroundColor(Colour(0xff332244));
|
|
|
|
m_stretchgroup->allowDisableFade = false;
|
2022-04-14 07:26:26 +00:00
|
|
|
m_stretchgroup->setToggleEnabled( ! *processor.getBoolParameter(cpi_bypass_stretch));
|
2022-04-11 22:50:55 +00:00
|
|
|
if (*processor.getBoolParameter(cpi_bypass_stretch)) {
|
|
|
|
m_stretchgroup->addParameterComponent(m_parcomps[cpi_dryplayrate].get());
|
|
|
|
removeChildComponent(m_parcomps[cpi_stretchamount].get());
|
|
|
|
} else {
|
|
|
|
m_stretchgroup->addParameterComponent(m_parcomps[cpi_stretchamount].get());
|
|
|
|
removeChildComponent(m_parcomps[cpi_dryplayrate].get());
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
m_stretchgroup->addParameterComponent(m_parcomps[cpi_fftsize].get());
|
2022-04-14 07:26:26 +00:00
|
|
|
m_stretchgroup->EnabledChangedCallback = [this]() {
|
|
|
|
toggleBool(processor.getBoolParameter(cpi_bypass_stretch));
|
|
|
|
m_stretchgroup->setToggleEnabled( ! *processor.getBoolParameter(cpi_bypass_stretch));
|
2022-04-28 02:52:40 +00:00
|
|
|
m_stretchgroup->updateParameterComponents();
|
2022-04-14 07:26:26 +00:00
|
|
|
};
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
addAndMakeVisible(m_stretchgroup.get());
|
|
|
|
|
|
|
|
|
2022-04-28 02:52:40 +00:00
|
|
|
m_binauralgroup = std::make_unique<ParameterGroupComponent>("", -1, &processor, true);
|
|
|
|
//m_binauralgroup->setBackgroundColor(Colour(0xff332244));
|
|
|
|
m_binauralgroup->setToggleEnabled( *processor.getBoolParameter(cpi_binauralbeats));
|
|
|
|
m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_mono].get());
|
|
|
|
m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_mode].get());
|
|
|
|
m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_freq].get());
|
|
|
|
m_parcomps[cpi_binauralbeats_freq]->getSlider()->setNumDecimalPlacesToDisplay(2);
|
|
|
|
m_binauralgroup->EnabledChangedCallback = [this]() {
|
|
|
|
toggleBool(processor.getBoolParameter(cpi_binauralbeats));
|
|
|
|
m_binauralgroup->setToggleEnabled( *processor.getBoolParameter(cpi_binauralbeats));
|
|
|
|
m_binauralgroup->updateParameterComponents();
|
|
|
|
};
|
|
|
|
|
|
|
|
m_groupcontainer->addAndMakeVisible(m_binauralgroup.get());
|
|
|
|
removeChildComponent(m_parcomps[cpi_binauralbeats].get());
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
m_posgroup = std::make_unique<ParameterGroupComponent>("", -1, &processor, false);
|
|
|
|
m_posgroup->addParameterComponent(m_parcomps[cpi_loopxfadelen].get());
|
|
|
|
m_posgroup->addParameterComponent(m_parcomps[cpi_onsetdetection].get());
|
|
|
|
m_posgroup->addParameterComponent(m_parcomps[cpi_soundstart].get());
|
|
|
|
m_posgroup->addParameterComponent(m_parcomps[cpi_soundend].get());
|
|
|
|
|
|
|
|
m_groupcontainer->addAndMakeVisible(m_posgroup.get());
|
|
|
|
|
|
|
|
|
|
|
|
auto harmgroup = std::make_unique<ParameterGroupComponent>("", HarmonicsGroup, &processor);
|
|
|
|
harmgroup->addParameterComponent(m_parcomps[cpi_numharmonics].get());
|
|
|
|
harmgroup->addParameterComponent(m_parcomps[cpi_harmonicsfreq].get());
|
|
|
|
harmgroup->addParameterComponent(m_parcomps[cpi_harmonicsbw].get());
|
|
|
|
harmgroup->addParameterComponent(m_parcomps[cpi_harmonicsgauss].get());
|
|
|
|
harmgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
|
|
|
|
m_groupcontainer->addAndMakeVisible(harmgroup.get());
|
|
|
|
m_pargroups.insert( {HarmonicsGroup, std::move(harmgroup) });
|
|
|
|
|
|
|
|
auto tonegroup = std::make_unique<ParameterGroupComponent>("", TonalNoiseGroup, &processor);
|
|
|
|
tonegroup->addParameterComponent(m_parcomps[cpi_tonalvsnoisebw].get());
|
|
|
|
tonegroup->addParameterComponent(m_parcomps[cpi_tonalvsnoisepreserve].get());
|
|
|
|
tonegroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(tonegroup.get());
|
|
|
|
m_pargroups.insert( {TonalNoiseGroup, std::move(tonegroup) });
|
|
|
|
|
|
|
|
auto fsgroup = std::make_unique<ParameterGroupComponent>("", FrequencyShiftGroup, &processor);
|
|
|
|
fsgroup->addParameterComponent(m_parcomps[cpi_frequencyshift].get());
|
|
|
|
fsgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(fsgroup.get());
|
|
|
|
m_pargroups.insert( {FrequencyShiftGroup, std::move(fsgroup) });
|
|
|
|
|
|
|
|
auto psgroup = std::make_unique<ParameterGroupComponent>("", PitchShiftGroup, &processor);
|
|
|
|
psgroup->addParameterComponent(m_parcomps[cpi_pitchshift].get());
|
|
|
|
psgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(psgroup.get());
|
|
|
|
m_pargroups.insert( {PitchShiftGroup, std::move(psgroup) });
|
|
|
|
|
|
|
|
auto spreadgroup = std::make_unique<ParameterGroupComponent>("", FrequencySpreadGroup, &processor);
|
|
|
|
spreadgroup->addParameterComponent(m_parcomps[cpi_spreadamount].get());
|
|
|
|
spreadgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(spreadgroup.get());
|
|
|
|
m_pargroups.insert( {FrequencySpreadGroup, std::move(spreadgroup) });
|
|
|
|
|
|
|
|
auto filtgroup = std::make_unique<ParameterGroupComponent>("", FilterGroup, &processor);
|
|
|
|
filtgroup->addParameterComponent(m_parcomps[cpi_filter_low].get());
|
|
|
|
filtgroup->addParameterComponent(m_parcomps[cpi_filter_high].get());
|
2022-04-18 19:11:22 +00:00
|
|
|
if (auto * slid = m_parcomps[cpi_filter_low]->getSlider()) {
|
|
|
|
slid->setNumDecimalPlacesToDisplay(0);
|
|
|
|
}
|
|
|
|
if (auto * slid = m_parcomps[cpi_filter_high]->getSlider()) {
|
|
|
|
slid->setNumDecimalPlacesToDisplay(0);
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
filtgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(filtgroup.get());
|
|
|
|
m_pargroups.insert( {FilterGroup, std::move(filtgroup) });
|
|
|
|
|
|
|
|
auto compgroup = std::make_unique<ParameterGroupComponent>("", CompressGroup, &processor);
|
|
|
|
compgroup->addParameterComponent(m_parcomps[cpi_compress].get());
|
|
|
|
compgroup->EnabledChangedCallback = [this]() {
|
|
|
|
processor.setDirty();
|
|
|
|
};
|
|
|
|
m_groupcontainer->addAndMakeVisible(compgroup.get());
|
|
|
|
m_pargroups.insert( {CompressGroup, std::move(compgroup) });
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
2019-02-28 14:04:04 +00:00
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
m_spec_order_ed.setSource(processor.getStretchSource());
|
|
|
|
addAndMakeVisible(&m_spec_order_ed);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
|
2018-02-01 13:11:41 +00:00
|
|
|
m_spec_order_ed.ModuleSelectedCallback = [this](int id)
|
|
|
|
{
|
2022-04-11 22:50:55 +00:00
|
|
|
auto nowtime = Time::getMillisecondCounterHiRes() * 1e-3;
|
|
|
|
|
|
|
|
if (m_lastspec_select_group == id && nowtime < m_lastspec_select_time + 0.5) {
|
|
|
|
// double click toggles enabled
|
|
|
|
setSpectrumProcGroupEnabled(id, !isSpectrumProcGroupEnabled(id));
|
|
|
|
}
|
|
|
|
m_lastspec_select_group = id;
|
|
|
|
m_lastspec_select_time = nowtime;
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
if (id == FreeFilterGroup) {
|
2022-04-13 23:24:44 +00:00
|
|
|
if (isSpectrumProcGroupEnabled(id) && !m_shortMode) {
|
2022-04-11 17:23:10 +00:00
|
|
|
m_wavefilter_tab.setCurrentTabIndex(2);
|
|
|
|
}
|
|
|
|
} else if (id == RatiosGroup) {
|
2022-04-13 23:24:44 +00:00
|
|
|
if (isSpectrumProcGroupEnabled(id) && !m_shortMode) {
|
2022-04-11 17:23:10 +00:00
|
|
|
m_wavefilter_tab.setCurrentTabIndex(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 13:11:41 +00:00
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
{
|
2018-04-29 14:04:21 +00:00
|
|
|
if (m_parcomps[i] != nullptr)
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
if (m_parcomps[i]->m_group_id == id)
|
2018-04-29 14:04:21 +00:00
|
|
|
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]()
|
|
|
|
{
|
|
|
|
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);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
auto tabbgcol = Colour(0xff303030);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
m_wavefilter_tab.addTab("Waveform", tabbgcol, m_wave_container, true);
|
|
|
|
m_wavefilter_tab.addTab("Ratio mixer", tabbgcol, &m_ratiomixeditor, false);
|
|
|
|
m_wavefilter_tab.addTab("Free filter", tabbgcol, &m_free_filter_component, false);
|
2019-02-12 12:59:51 +00:00
|
|
|
//m_wavefilter_tab.addTab("Spectrum", Colours::white, &m_sonogram, false);
|
2019-01-17 16:30:40 +00:00
|
|
|
|
2022-04-15 23:42:43 +00:00
|
|
|
|
2022-04-18 19:11:22 +00:00
|
|
|
#if 1
|
2022-04-15 23:42:43 +00:00
|
|
|
// TODO
|
|
|
|
auto * ratiotoggle = new DrawableButton("rt", DrawableButton::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));
|
|
|
|
ratiotoggle->setImages(powerimg.get(), nullptr, nullptr, nullptr, powerselimg.get());
|
|
|
|
ratiotoggle->setClickingTogglesState(true);
|
|
|
|
ratiotoggle->setColour(DrawableButton::backgroundColourId, Colours::transparentBlack);
|
|
|
|
ratiotoggle->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
|
2022-04-18 19:11:22 +00:00
|
|
|
ratiotoggle->setSize(32,32);
|
2022-04-15 23:42:43 +00:00
|
|
|
ratiotoggle->onClick = [this]() {
|
|
|
|
setSpectrumProcGroupEnabled(RatiosGroup, !isSpectrumProcGroupEnabled(RatiosGroup));
|
|
|
|
};
|
|
|
|
|
|
|
|
auto * fftoggle = new DrawableButton("rt", DrawableButton::ImageFitted);
|
|
|
|
fftoggle->setImages(powerimg.get(), nullptr, nullptr, nullptr, powerselimg.get());
|
|
|
|
fftoggle->setClickingTogglesState(true);
|
|
|
|
fftoggle->setColour(DrawableButton::backgroundColourId, Colours::transparentBlack);
|
|
|
|
fftoggle->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
|
2022-04-18 19:11:22 +00:00
|
|
|
fftoggle->setSize(32,32);
|
2022-04-15 23:42:43 +00:00
|
|
|
fftoggle->onClick = [this]() {
|
|
|
|
setSpectrumProcGroupEnabled(FreeFilterGroup, !isSpectrumProcGroupEnabled(FreeFilterGroup));
|
|
|
|
};
|
|
|
|
|
|
|
|
m_wavefilter_tab.getTabbedButtonBar().getTabButton(1)->setExtraComponent(ratiotoggle, TabBarButton::ExtraComponentPlacement::beforeText);
|
|
|
|
m_wavefilter_tab.getTabbedButtonBar().getTabButton(2)->setExtraComponent(fftoggle, TabBarButton::ExtraComponentPlacement::beforeText);
|
|
|
|
#endif
|
|
|
|
|
2019-01-17 16:30:40 +00:00
|
|
|
addAndMakeVisible(&m_wavefilter_tab);
|
2022-04-11 22:50:55 +00:00
|
|
|
|
|
|
|
auto defbounds = processor.getLastPluginBounds();
|
|
|
|
|
|
|
|
setSize (defbounds.getWidth(), defbounds.getHeight());
|
|
|
|
|
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);
|
2022-04-02 16:45:02 +00:00
|
|
|
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
setResizeLimits(320, 430, 40000, 4000);
|
2022-04-02 16:45:02 +00:00
|
|
|
|
|
|
|
setResizable(true, !JUCEApplicationBase::isStandaloneApp());
|
|
|
|
|
|
|
|
#if JUCE_MAC
|
|
|
|
disableAppNap();
|
|
|
|
#endif
|
2017-11-13 15:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PaulstretchpluginAudioProcessorEditor::~PaulstretchpluginAudioProcessorEditor()
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
LookAndFeel::setDefaultLookAndFeel(nullptr);
|
|
|
|
setLookAndFeel(nullptr);
|
2018-08-07 21:10:27 +00:00
|
|
|
//Logger::writeToLog("PaulX Editor destroyed");
|
2017-11-13 15:06:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
bool PaulstretchpluginAudioProcessorEditor::isSpectrumProcGroupEnabled(int groupid)
|
|
|
|
{
|
|
|
|
auto order = processor.getStretchSource()->getSpectrumProcessOrder();
|
|
|
|
for (int i=0; i < order.size(); ++i) {
|
|
|
|
if (order[i].m_index == groupid) {
|
|
|
|
return order[i].m_enabled->get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::setSpectrumProcGroupEnabled(int groupid, bool enabled)
|
|
|
|
{
|
|
|
|
auto order = processor.getStretchSource()->getSpectrumProcessOrder();
|
|
|
|
for (int i=0; i < order.size(); ++i) {
|
|
|
|
if (order[i].m_index == groupid) {
|
|
|
|
*(order[i].m_enabled) = enabled; //->setValueNotifyingHost(enabled ? 1.0f : 0.0f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2018-05-07 17:21:42 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::showRenderDialog()
|
|
|
|
{
|
2020-12-11 02:02:36 +00:00
|
|
|
auto contentraw = new RenderSettingsComponent(&processor);
|
2022-04-13 23:24:44 +00:00
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
int prefw = jmin(contentraw->getPreferredWidth(), getWidth() - 40);
|
2022-04-13 23:24:44 +00:00
|
|
|
int prefh = jmin(contentraw->getPreferredHeight(), getHeight() - 10);
|
|
|
|
contentraw->setSize(prefw, prefh);
|
2020-12-11 02:02:36 +00:00
|
|
|
std::unique_ptr<Component> content(contentraw);
|
2022-04-26 21:58:45 +00:00
|
|
|
auto & cb = CallOutBox::launchAsynchronously(std::move(content), m_render_button.getBounds(), this, false);
|
2022-04-24 22:11:57 +00:00
|
|
|
cb.setDismissalMouseClicksAreAlwaysConsumed(true);
|
2018-05-07 17:21:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::showAudioSetup()
|
|
|
|
{
|
|
|
|
if (showAudioSettingsDialog) {
|
|
|
|
showAudioSettingsDialog(&m_settings_button, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::showSettings(bool flag)
|
2018-11-13 20:18:05 +00:00
|
|
|
{
|
2022-06-14 23:11:57 +00:00
|
|
|
DBG("Got settings click");
|
|
|
|
|
|
|
|
if (flag && settingsCalloutBox == nullptr) {
|
|
|
|
|
|
|
|
//Viewport * wrap = new Viewport();
|
|
|
|
|
|
|
|
Component* dw = this;
|
|
|
|
|
|
|
|
#if JUCE_IOS || JUCE_ANDROID
|
|
|
|
int defWidth = 320;
|
|
|
|
int defHeight = 420;
|
|
|
|
#else
|
|
|
|
int defWidth = 340;
|
|
|
|
int defHeight = 400;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
bool firsttime = false;
|
|
|
|
if (!m_optionsView) {
|
|
|
|
m_optionsView = std::make_unique<OptionsView>(processor, getAudioDeviceManager);
|
|
|
|
m_optionsView->updateSliderSnap = [this]() { updateAllSliders(); };
|
|
|
|
//m_optionsView->saveSettingsIfNeeded = [this]() { if (saveSettingsIfNeeded) saveSettingsIfNeeded(); };
|
|
|
|
m_optionsView->addComponentListener(this);
|
|
|
|
firsttime = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// presize it so the preferred gets calculated
|
|
|
|
m_optionsView->setBounds(Rectangle<int>(0,0,defWidth,defHeight));
|
|
|
|
|
|
|
|
auto prefbounds = m_optionsView->getPreferredContentBounds();
|
|
|
|
|
|
|
|
defHeight = prefbounds.getHeight();
|
|
|
|
|
|
|
|
defWidth = jmin(defWidth + 8, dw->getWidth() - 30);
|
|
|
|
defHeight = jmin(defHeight + 8, dw->getHeight() - 90); // 24
|
|
|
|
|
|
|
|
|
|
|
|
auto wrap = std::make_unique<Component>();
|
|
|
|
|
|
|
|
wrap->addAndMakeVisible(m_optionsView.get());
|
|
|
|
|
|
|
|
m_optionsView->setBounds(Rectangle<int>(0,0,defWidth,defHeight));
|
|
|
|
|
|
|
|
wrap->setSize(defWidth,defHeight);
|
|
|
|
|
|
|
|
m_optionsView->updateState();
|
|
|
|
|
|
|
|
Rectangle<int> bounds = dw->getLocalArea(nullptr, m_settings_button.getScreenBounds().reduced(10));
|
|
|
|
DBG("callout bounds: " << bounds.toString());
|
|
|
|
settingsCalloutBox = & CallOutBox::launchAsynchronously (std::move(wrap), bounds , dw, false);
|
|
|
|
if (CallOutBox * box = dynamic_cast<CallOutBox*>(settingsCalloutBox.get())) {
|
|
|
|
box->setDismissalMouseClicksAreAlwaysConsumed(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
settingsClosedTimestamp = 0;
|
|
|
|
|
|
|
|
m_optionsView->grabInitialFocus();
|
2022-04-15 23:13:55 +00:00
|
|
|
|
|
|
|
}
|
2022-06-14 23:11:57 +00:00
|
|
|
else {
|
|
|
|
// dismiss it
|
|
|
|
if (CallOutBox * box = dynamic_cast<CallOutBox*>(settingsCalloutBox.get())) {
|
|
|
|
box->dismiss();
|
|
|
|
settingsCalloutBox = nullptr;
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
2022-06-14 23:11:57 +00:00
|
|
|
}
|
2018-11-13 20:18:05 +00:00
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::componentParentHierarchyChanged (Component& component)
|
|
|
|
{
|
|
|
|
if (&component == m_optionsView.get()) {
|
|
|
|
if (component.getParentComponent() == nullptr) {
|
|
|
|
DBG("setting parent changed: " << (uint64) component.getParentComponent());
|
|
|
|
settingsClosedTimestamp = Time::getMillisecondCounter();
|
|
|
|
}
|
|
|
|
}
|
2018-11-13 20:18:05 +00:00
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
|
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::updateAllSliders()
|
|
|
|
{
|
|
|
|
for (auto& e : m_parcomps) {
|
|
|
|
if (!e) continue;
|
|
|
|
if (auto * slider = e->getSlider()) {
|
|
|
|
slider->setSliderSnapsToMousePosition(processor.m_use_jumpsliders);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_free_filter_component.setSlidersSnap(processor.m_use_jumpsliders);
|
|
|
|
m_ratiomixeditor.setSlidersSnap(processor.m_use_jumpsliders);;
|
|
|
|
}
|
2019-01-21 17:25:27 +00:00
|
|
|
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g)
|
|
|
|
{
|
2022-04-15 23:13:55 +00:00
|
|
|
// g.fillAll(Colour(0xff404040));
|
2022-04-15 23:42:43 +00:00
|
|
|
g.fillAll(Colour(0xff101010));
|
2017-11-13 15:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::resized()
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
auto bounds = getLocalBounds();
|
|
|
|
|
|
|
|
bounds.reduce(4, 0);
|
2022-04-13 23:24:44 +00:00
|
|
|
//bounds.removeFromRight(4);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
int w = bounds.getWidth();
|
|
|
|
int rowheight = 24;
|
|
|
|
int togglerowheight = 24;
|
|
|
|
int buttonrowheight = 32;
|
|
|
|
int minw = w / 3;
|
|
|
|
int toggleminw = 90;
|
|
|
|
int minh = 32;
|
|
|
|
int buttw = 60;
|
|
|
|
int buttminw = 36;
|
2022-04-15 18:29:23 +00:00
|
|
|
int minitemw = 260;
|
2022-04-12 22:47:43 +00:00
|
|
|
int margin = 1;
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
#if JUCE_IOS
|
|
|
|
togglerowheight = 32;
|
|
|
|
rowheight = 36;
|
|
|
|
buttonrowheight = 40;
|
|
|
|
minh = 40;
|
|
|
|
#endif
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
DBG("Resized: " << getWidth() << " " << getHeight());
|
|
|
|
|
|
|
|
processor.setLastPluginBounds(getLocalBounds());
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
FlexBox mainbox;
|
|
|
|
mainbox.flexDirection = FlexBox::Direction::column;
|
|
|
|
|
|
|
|
|
|
|
|
FlexBox topbox;
|
|
|
|
topbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
topbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
topbox.alignContent = FlexBox::AlignContent::flexStart;
|
|
|
|
|
|
|
|
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));
|
2022-06-15 18:54:49 +00:00
|
|
|
topbox.items.add(FlexItem(buttw, buttonrowheight, m_render_button).withMargin(1).withFlex(1).withMaxWidth(130));
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
topbox.items.add(FlexItem(4, 4));
|
|
|
|
topbox.items.add(FlexItem(80, buttonrowheight, m_perfmeter).withMargin(1).withFlex(1).withMaxWidth(110).withMaxHeight(24).withAlignSelf(FlexItem::AlignSelf::center));
|
|
|
|
topbox.items.add(FlexItem(140, 26, m_info_label).withMargin(1).withFlex(2));
|
|
|
|
|
|
|
|
topbox.performLayout(Rectangle<int>(0,0,w - 2*margin,400)); // test run to calculate actual used height
|
|
|
|
int topboxh = topbox.items.getLast().currentBounds.getBottom() + + topbox.items.getLast().margin.bottom;
|
|
|
|
|
|
|
|
|
|
|
|
FlexBox togglesbox;
|
|
|
|
togglesbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
togglesbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
togglesbox.alignContent = FlexBox::AlignContent::flexStart;
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_capture_trigger]).withMargin(margin).withFlex(1).withMaxWidth(65));
|
2022-04-15 18:29:23 +00:00
|
|
|
togglesbox.items.add(FlexItem(3, buttonrowheight).withFlex(0.1));
|
2022-04-14 07:26:26 +00:00
|
|
|
|
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_rewind_button).withMargin(1).withFlex(1).withMaxWidth(65));
|
|
|
|
togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10));
|
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_pause_enabled]).withMargin(margin).withFlex(1).withMaxWidth(65));
|
|
|
|
togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10));
|
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_looping_enabled]).withMargin(margin).withFlex(1).withMaxWidth(65));
|
|
|
|
togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10));
|
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_parcomps[cpi_freeze]).withMargin(margin).withFlex(1).withMaxWidth(65));
|
|
|
|
|
2022-04-15 18:29:23 +00:00
|
|
|
togglesbox.items.add(FlexItem(3, buttonrowheight).withFlex(0.1));
|
2022-04-13 17:48:09 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
//togglesbox.items.add(FlexItem(toggleminw, togglerowheight, *m_parcomps[cpi_bypass_stretch]).withMargin(margin).withFlex(1).withMaxWidth(150));
|
|
|
|
togglesbox.items.add(FlexItem(buttminw + 15, buttonrowheight, *m_parcomps[cpi_passthrough]).withMargin(margin).withFlex(1.5).withMaxWidth(85));
|
2022-06-14 23:11:57 +00:00
|
|
|
if (m_recordingButton) {
|
|
|
|
togglesbox.items.add(FlexItem(0, buttonrowheight).withFlex(0.1).withMaxWidth(10));
|
|
|
|
togglesbox.items.add(FlexItem(buttminw, buttonrowheight, *m_recordingButton).withMargin(1).withFlex(1).withMaxWidth(65));
|
|
|
|
}
|
2022-04-14 07:26:26 +00:00
|
|
|
|
|
|
|
togglesbox.items.add(FlexItem(2, buttonrowheight));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
togglesbox.performLayout(Rectangle<int>(0,0,w - 2*margin,400)); // test run to calculate actual used height
|
|
|
|
int toggleh = togglesbox.items.getLast().currentBounds.getBottom() + togglesbox.items.getLast().margin.bottom;
|
|
|
|
DBG("toggle h: " << toggleh);
|
|
|
|
|
|
|
|
FlexBox volbox;
|
|
|
|
volbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
volbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
volbox.alignContent = FlexBox::AlignContent::flexStart;
|
|
|
|
volbox.items.add(FlexItem(minitemw*0.75f, rowheight, *m_parcomps[cpi_main_volume]).withMargin(margin).withFlex(1));
|
|
|
|
|
2022-04-13 17:48:09 +00:00
|
|
|
|
|
|
|
#if !JUCE_IOS
|
2022-04-11 17:23:10 +00:00
|
|
|
FlexBox inoutbox;
|
2022-04-15 18:29:23 +00:00
|
|
|
int inoutminw = 140;
|
2022-04-11 17:23:10 +00:00
|
|
|
int inoutmaxw = 200;
|
|
|
|
|
|
|
|
inoutbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
inoutbox.items.add(FlexItem(inoutminw, rowheight, *m_parcomps[cpi_num_inchans]).withMargin(margin).withFlex(0.5).withMaxWidth(inoutmaxw));
|
|
|
|
inoutbox.items.add(FlexItem(inoutminw, rowheight, *m_parcomps[cpi_num_outchans]).withMargin(margin).withFlex(0.5).withMaxWidth(inoutmaxw));
|
|
|
|
|
|
|
|
volbox.items.add(FlexItem(2*inoutminw, rowheight, inoutbox).withMargin(margin).withFlex(1.5).withMaxWidth(2*inoutmaxw + 10));
|
2022-04-13 17:48:09 +00:00
|
|
|
#endif
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
volbox.performLayout(Rectangle<int>(0,0,w - 2*margin,400)); // test run to calculate actual used height
|
|
|
|
int volh = volbox.items.getLast().currentBounds.getBottom() + volbox.items.getLast().margin.bottom;
|
|
|
|
int stretchH = m_stretchgroup->getMinimumHeight(w - 2*margin);
|
2022-04-14 07:26:26 +00:00
|
|
|
stretchH = jmax(stretchH, (int) (minh*1.1f));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
FlexBox groupsbox;
|
|
|
|
groupsbox.flexDirection = FlexBox::Direction::column;
|
|
|
|
|
|
|
|
int scrollw = m_groupviewport->getScrollBarThickness() ;
|
|
|
|
|
|
|
|
int gheight = 0;
|
2022-04-12 22:47:43 +00:00
|
|
|
int groupmargin = 1;
|
2022-04-11 17:23:10 +00:00
|
|
|
int groupw = w - 2*groupmargin - scrollw;
|
|
|
|
// groups
|
|
|
|
|
|
|
|
|
|
|
|
minh = m_pargroups[HarmonicsGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[HarmonicsGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
minh = m_pargroups[TonalNoiseGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[TonalNoiseGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
FlexBox shiftbox;
|
|
|
|
FlexBox scompbox;
|
|
|
|
|
|
|
|
if (w >= 700) {
|
2022-04-18 19:11:22 +00:00
|
|
|
int halfgroupw = groupw/2 - 2*groupmargin;
|
2022-04-11 17:23:10 +00:00
|
|
|
shiftbox.flexDirection = FlexBox::Direction::row;
|
2022-04-18 19:11:22 +00:00
|
|
|
minh = m_pargroups[FrequencyShiftGroup]->getMinimumHeight(halfgroupw);
|
2022-04-11 17:23:10 +00:00
|
|
|
shiftbox.items.add(FlexItem(minw, minh, *m_pargroups[FrequencyShiftGroup]).withFlex(1));
|
2022-04-18 19:11:22 +00:00
|
|
|
shiftbox.items.add(FlexItem(groupmargin*2, minh));
|
2022-04-11 17:23:10 +00:00
|
|
|
shiftbox.items.add(FlexItem(minw, minh, *m_pargroups[PitchShiftGroup]).withFlex(1));
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, shiftbox).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
scompbox.flexDirection = FlexBox::Direction::row;
|
2022-04-18 19:11:22 +00:00
|
|
|
minh = m_pargroups[FrequencySpreadGroup]->getMinimumHeight(halfgroupw);
|
2022-04-11 17:23:10 +00:00
|
|
|
scompbox.items.add(FlexItem(minw, minh, *m_pargroups[FrequencySpreadGroup]).withFlex(1));
|
2022-04-18 19:11:22 +00:00
|
|
|
scompbox.items.add(FlexItem(groupmargin*2, minh));
|
2022-04-11 17:23:10 +00:00
|
|
|
scompbox.items.add(FlexItem(minw, minh, *m_pargroups[CompressGroup]).withFlex(1));
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, scompbox).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
} else {
|
|
|
|
minh = m_pargroups[FrequencyShiftGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[FrequencyShiftGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
minh = m_pargroups[PitchShiftGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[PitchShiftGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
minh = m_pargroups[FrequencySpreadGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[FrequencySpreadGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
minh = m_pargroups[CompressGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[CompressGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
minh = m_pargroups[FilterGroup]->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[FilterGroup]).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
2022-04-28 02:52:40 +00:00
|
|
|
minh = m_binauralgroup->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_binauralgroup).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
minh = m_posgroup->getMinimumHeight(groupw);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minh, *m_posgroup).withMargin(groupmargin));
|
|
|
|
gheight += minh + 2*groupmargin;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
/*
|
|
|
|
for (const auto & group : m_pargroups) {
|
|
|
|
int minheight = group.second->getMinimumHeight(w);
|
|
|
|
groupsbox.items.add(FlexItem(minw, minheight, *(group.second)).withMargin(2));
|
|
|
|
gheight += minheight + 4;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
DBG("group tot height: " << gheight);
|
|
|
|
|
|
|
|
int useh = gheight;
|
|
|
|
int vpminh = jmin(useh, 140);
|
2022-04-24 23:10:41 +00:00
|
|
|
int tabminh = getHeight() > 500 ? 200 : 160;
|
2022-04-13 23:24:44 +00:00
|
|
|
int orderminh = 38;
|
2022-04-24 22:11:57 +00:00
|
|
|
int ordermaxh = 44;
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
#if JUCE_IOS
|
2022-04-24 23:10:41 +00:00
|
|
|
tabminh = getHeight() > 500 ? 234 : 170;
|
2022-04-11 22:50:55 +00:00
|
|
|
orderminh = 44;
|
2022-04-24 22:11:57 +00:00
|
|
|
ordermaxh = 50;
|
2022-04-11 17:23:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 2));
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
auto reparentIfNecessary = [] (Component * comp, Component *newparent) {
|
|
|
|
if (comp->getParentComponent() != newparent)
|
|
|
|
newparent->addAndMakeVisible(comp);
|
|
|
|
};
|
|
|
|
|
|
|
|
std::function<void(FlexBox & box, Component *newparent)> reparentItemsIfNecessary;
|
|
|
|
reparentItemsIfNecessary = [&reparentItemsIfNecessary,&reparentIfNecessary] (FlexBox & box, Component *newparent) {
|
|
|
|
for (auto & item : box.items ) {
|
|
|
|
if (item.associatedFlexBox) {
|
|
|
|
reparentItemsIfNecessary(*item.associatedFlexBox, newparent);
|
|
|
|
}
|
|
|
|
else if (item.associatedComponent) {
|
|
|
|
reparentIfNecessary(item.associatedComponent, newparent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
int totminh = vpminh + orderminh + tabminh + topboxh + toggleh + volh + stretchH + 18;
|
|
|
|
|
|
|
|
int shortthresh = vpminh + orderminh + tabminh + topboxh + toggleh;
|
2022-04-24 23:10:41 +00:00
|
|
|
int veryshortthresh = tabminh + topboxh + toggleh + 40;
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
if (getHeight() < totminh) {
|
2022-04-11 17:23:10 +00:00
|
|
|
// not enough vertical space, put the top items in the scrollable viewport
|
|
|
|
// may have to reparent them
|
|
|
|
reparentIfNecessary(m_stretchgroup.get(), m_groupcontainer.get());
|
2022-04-14 07:26:26 +00:00
|
|
|
//reparentItemsIfNecessary(togglesbox, m_groupcontainer.get());
|
2022-04-11 17:23:10 +00:00
|
|
|
reparentItemsIfNecessary(volbox, m_groupcontainer.get());
|
|
|
|
|
|
|
|
groupsbox.items.insert(0, FlexItem(minw, stretchH, *m_stretchgroup).withMargin(groupmargin).withFlex(0));
|
|
|
|
groupsbox.items.insert(0, FlexItem(minw, volh, volbox).withMargin(groupmargin).withFlex(0));
|
2022-04-14 07:26:26 +00:00
|
|
|
//groupsbox.items.insert(0, FlexItem(minw, toggleh, togglesbox).withMargin(groupmargin).withFlex(0));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
useh += /*toggleh + */ volh + stretchH + 6*groupmargin;
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
if (getHeight() < shortthresh) {
|
|
|
|
// really not much space, put group scroll in a new tab
|
|
|
|
if (m_wavefilter_tab.getNumTabs() <= 3) {
|
2022-04-22 03:04:30 +00:00
|
|
|
m_wavefilter_tab.addTab("Controls", Colour(0xff333333), m_groupviewport.get(), false);
|
2022-04-13 23:24:44 +00:00
|
|
|
m_wavefilter_tab.setCurrentTabIndex(3);
|
|
|
|
}
|
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
if (getHeight() < veryshortthresh) {
|
|
|
|
|
|
|
|
reparentItemsIfNecessary(topbox, m_groupcontainer.get());
|
|
|
|
reparentItemsIfNecessary(togglesbox, m_groupcontainer.get());
|
|
|
|
|
|
|
|
groupsbox.items.insert(0, FlexItem(minw, toggleh, togglesbox).withMargin(groupmargin).withFlex(0));
|
|
|
|
groupsbox.items.insert(0, FlexItem(minw, topboxh, topbox).withMargin(groupmargin).withFlex(0));
|
|
|
|
|
|
|
|
useh += toggleh + topboxh + groupmargin*4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
reparentItemsIfNecessary(topbox, this);
|
|
|
|
reparentItemsIfNecessary(togglesbox, this);
|
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(minw, topboxh, topbox).withMargin(margin).withFlex(0));
|
|
|
|
mainbox.items.add(FlexItem(minw, toggleh, togglesbox).withMargin(margin).withFlex(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
reparentIfNecessary(&m_spec_order_ed, m_groupcontainer.get());
|
|
|
|
|
|
|
|
groupsbox.items.add(FlexItem(minw, orderminh, m_spec_order_ed).withMargin(2));
|
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
useh += orderminh + 4;
|
|
|
|
|
|
|
|
m_shortMode = true;
|
|
|
|
} else {
|
|
|
|
reparentIfNecessary(&m_spec_order_ed, this);
|
2022-04-22 03:04:30 +00:00
|
|
|
reparentItemsIfNecessary(topbox, this);
|
|
|
|
reparentItemsIfNecessary(togglesbox, this);
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
if (m_wavefilter_tab.getNumTabs() > 3) {
|
|
|
|
// bring it back
|
2022-04-18 19:11:22 +00:00
|
|
|
int currtab = m_wavefilter_tab.getCurrentTabIndex();
|
2022-04-13 23:24:44 +00:00
|
|
|
m_wavefilter_tab.removeTab(3);
|
2022-04-18 19:11:22 +00:00
|
|
|
if (currtab == 3) {
|
|
|
|
m_wavefilter_tab.setCurrentTabIndex(0);
|
|
|
|
}
|
2022-04-13 23:24:44 +00:00
|
|
|
addAndMakeVisible(m_groupviewport.get());
|
|
|
|
}
|
|
|
|
m_shortMode = false;
|
2022-04-22 03:04:30 +00:00
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(minw, topboxh, topbox).withMargin(margin).withFlex(0));
|
|
|
|
mainbox.items.add(FlexItem(minw, toggleh, togglesbox).withMargin(margin).withFlex(0));
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
} else {
|
2022-04-13 23:24:44 +00:00
|
|
|
m_shortMode = false;
|
|
|
|
|
|
|
|
if (m_wavefilter_tab.getNumTabs() > 3) {
|
|
|
|
// bring it back
|
2022-04-18 19:11:22 +00:00
|
|
|
int currtab = m_wavefilter_tab.getCurrentTabIndex();
|
2022-04-13 23:24:44 +00:00
|
|
|
m_wavefilter_tab.removeTab(3);
|
2022-04-18 19:11:22 +00:00
|
|
|
if (currtab == 3) {
|
|
|
|
m_wavefilter_tab.setCurrentTabIndex(0);
|
|
|
|
}
|
2022-04-13 23:24:44 +00:00
|
|
|
addAndMakeVisible(m_groupviewport.get());
|
|
|
|
}
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
// may have to reparent them
|
2022-04-13 23:24:44 +00:00
|
|
|
reparentIfNecessary(m_groupviewport.get(), this);
|
|
|
|
reparentIfNecessary(&m_spec_order_ed, this);
|
2022-04-11 17:23:10 +00:00
|
|
|
reparentIfNecessary(m_stretchgroup.get(), this);
|
|
|
|
reparentItemsIfNecessary(volbox, this);
|
2022-04-22 03:04:30 +00:00
|
|
|
reparentItemsIfNecessary(topbox, this);
|
|
|
|
reparentItemsIfNecessary(togglesbox, this);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
mainbox.items.add(FlexItem(minw, topboxh, topbox).withMargin(margin).withFlex(0));
|
|
|
|
mainbox.items.add(FlexItem(minw, toggleh, togglesbox).withMargin(margin).withFlex(0));
|
2022-04-13 23:24:44 +00:00
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
mainbox.items.add(FlexItem(minw, volh, volbox).withMargin(margin).withFlex(0));
|
2022-04-18 19:11:22 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 3));
|
2022-04-11 17:23:10 +00:00
|
|
|
mainbox.items.add(FlexItem(minw, stretchH, *m_stretchgroup).withMargin(margin).withFlex(0));
|
|
|
|
}
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 3));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
if (!m_shortMode) {
|
|
|
|
mainbox.items.add(FlexItem(w, vpminh, *m_groupviewport).withMargin(0).withFlex(1).withMaxHeight(useh + 4));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 2));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-24 22:11:57 +00:00
|
|
|
mainbox.items.add(FlexItem(w-4, orderminh, m_spec_order_ed).withMargin(2).withFlex(0.1).withMaxHeight(ordermaxh));
|
2022-04-13 23:24:44 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 2));
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(w, tabminh, m_wavefilter_tab).withMargin(0).withFlex(0.1));
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
mainbox.items.add(FlexItem(6, 4));
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
mainbox.performLayout(bounds);
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
if ( m_shortMode) {
|
2022-04-15 18:29:23 +00:00
|
|
|
auto totgroupw = jmax(260, m_groupviewport->getWidth()) - scrollw;
|
2022-04-13 23:24:44 +00:00
|
|
|
auto groupsbounds = Rectangle<int>(0, 0, totgroupw, useh);
|
|
|
|
auto layoutbounds = groupsbounds.translated(2, 0).withWidth(totgroupw - 3);
|
|
|
|
m_groupcontainer->setBounds(groupsbounds);
|
|
|
|
groupsbox.performLayout(layoutbounds);
|
|
|
|
}
|
|
|
|
else {
|
2022-04-15 18:29:23 +00:00
|
|
|
auto totgroupw = jmax(260, w) - scrollw;
|
2022-04-13 23:24:44 +00:00
|
|
|
auto groupsbounds = Rectangle<int>(0, 0, totgroupw, useh);
|
|
|
|
m_groupcontainer->setBounds(groupsbounds);
|
|
|
|
groupsbox.performLayout(groupsbounds);
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
int zscrollh = 18;
|
|
|
|
#if JUCE_IOS
|
|
|
|
zscrollh = 28;
|
|
|
|
#endif
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
m_wavecomponent.setBounds(m_wave_container->getX(), 0, m_wave_container->getWidth(),
|
2022-04-12 22:47:43 +00:00
|
|
|
m_wave_container->getHeight()-zscrollh-1);
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
if (m_recordingButton) {
|
|
|
|
m_fileRecordingLabel->setBounds(m_recordingButton->getBounds().removeFromTop(14).translated(0, -9));
|
|
|
|
}
|
2022-04-12 22:47:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
m_zs.setBounds(m_wave_container->getX(), m_wavecomponent.getBottom(), m_wave_container->getWidth(), zscrollh);
|
2018-02-27 00:33:41 +00:00
|
|
|
//m_wavecomponent.setBounds(1, m_spec_order_ed.getBottom()+1, getWidth()-2, remain_h/5*4);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
if (m_filechooser && m_filechooser->isVisible()) {
|
|
|
|
auto importbounds = getLocalArea(nullptr, m_import_button.getScreenBounds());
|
|
|
|
m_filechooser->setBounds(0, importbounds.getBottom(), getWidth()/2, getHeight() - 75);
|
|
|
|
m_filechooser->toFront(false);
|
|
|
|
}
|
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
if (m_shortMode) {
|
|
|
|
m_groupcontainer->repaint();
|
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
if (settingsCalloutBox && settingsCalloutBox->isVisible()) {
|
|
|
|
settingsCalloutBox->toFront(false);
|
|
|
|
}
|
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
}
|
2017-11-13 18:54:08 +00:00
|
|
|
|
|
|
|
void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
|
|
|
|
{
|
|
|
|
if (id == 1)
|
|
|
|
{
|
2022-04-14 07:26:26 +00:00
|
|
|
if (!tooltipWindow && getParentComponent()) {
|
|
|
|
Component* dw = this;
|
|
|
|
if (dw) {
|
|
|
|
tooltipWindow = std::make_unique<CustomTooltipWindow>(this, dw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
2022-06-14 23:11:57 +00:00
|
|
|
if (processor.isInputRecordingEnabled())
|
2017-11-15 15:52:47 +00:00
|
|
|
{
|
2022-06-14 23:11:57 +00:00
|
|
|
m_wavecomponent.setRecordingPosition(processor.getInputRecordingPositionPercent());
|
2017-11-15 15:52:47 +00:00
|
|
|
} 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;
|
2019-02-28 14:44:14 +00:00
|
|
|
String waveinfotext;
|
2018-02-13 14:51:57 +00:00
|
|
|
if (processor.m_show_technical_info)
|
|
|
|
{
|
2019-02-28 14:44:14 +00:00
|
|
|
double sr = processor.getStretchSource()->getInfileSamplerate();
|
|
|
|
if (sr>0.0)
|
|
|
|
waveinfotext += String(processor.getStretchSource()->getDiskReadSampleCount()/sr) + " seconds read from disk\n";
|
|
|
|
waveinfotext += String(processor.m_prepare_count)+" prepareToPlay calls\n";
|
|
|
|
waveinfotext += String(processor.getStretchSource()->m_param_change_count)+" parameter changes handled\n";
|
|
|
|
waveinfotext += String(m_wavecomponent.m_image_init_count) + " waveform image inits\n"
|
|
|
|
+ String(m_wavecomponent.m_image_update_count) + " waveform image updates\n";
|
|
|
|
m_wavecomponent.m_infotext = waveinfotext;
|
2018-02-13 14:51:57 +00:00
|
|
|
}
|
2019-02-28 14:44:14 +00:00
|
|
|
else
|
|
|
|
m_wavecomponent.m_infotext = {};
|
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-26 17:55:32 +00:00
|
|
|
if (processor.m_offline_render_state >= 0 && processor.m_offline_render_state <= 100)
|
|
|
|
infotext += String(processor.m_offline_render_state)+"%";
|
2018-12-19 13:16:30 +00:00
|
|
|
if (processor.m_capture_save_state == 1)
|
|
|
|
infotext += "Saving captured audio...";
|
2017-11-17 14:41:33 +00:00
|
|
|
m_info_label.setText(infotext, dontSendNotification);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
for (auto & group : m_pargroups) {
|
|
|
|
group.second->updateParameterComponents();
|
|
|
|
}
|
2022-04-12 22:47:43 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
m_stretchgroup->setToggleEnabled(!*processor.getBoolParameter(cpi_bypass_stretch));
|
|
|
|
|
2022-04-28 02:52:40 +00:00
|
|
|
m_binauralgroup->setToggleEnabled(*processor.getBoolParameter(cpi_binauralbeats));
|
|
|
|
m_binauralgroup->updateParameterComponents();
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
if (AudioParameterBool* enablepar = dynamic_cast<AudioParameterBool*>(processor.getBoolParameter(cpi_pause_enabled))) {
|
|
|
|
m_perfmeter.enabled = !enablepar->get();
|
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
if (m_recordingButton) {
|
|
|
|
m_recordingButton->setToggleState(processor.isRecordingToFile(), dontSendNotification);
|
|
|
|
}
|
|
|
|
|
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();
|
2022-04-11 22:50:55 +00:00
|
|
|
|
|
|
|
if (*processor.getBoolParameter(cpi_bypass_stretch)) {
|
|
|
|
m_stretchgroup->replaceParameterComponent(m_parcomps[cpi_stretchamount].get(), m_parcomps[cpi_dryplayrate].get());
|
|
|
|
} else {
|
|
|
|
m_stretchgroup->replaceParameterComponent(m_parcomps[cpi_dryplayrate].get(), m_parcomps[cpi_stretchamount].get());
|
|
|
|
}
|
|
|
|
|
2022-04-18 19:11:22 +00:00
|
|
|
if (auto * toggle = dynamic_cast<Button*>(m_wavefilter_tab.getTabbedButtonBar().getTabButton(1)->getExtraComponent())) {
|
|
|
|
toggle->setToggleState(isSpectrumProcGroupEnabled(RatiosGroup), dontSendNotification);
|
|
|
|
}
|
|
|
|
if (auto * toggle = dynamic_cast<Button*>(m_wavefilter_tab.getTabbedButtonBar().getTabButton(2)->getExtraComponent())) {
|
|
|
|
toggle->setToggleState(isSpectrumProcGroupEnabled(FreeFilterGroup), dontSendNotification);
|
|
|
|
}
|
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
updateAllSliders();
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
if (processor.isRecordingToFile() && m_fileRecordingLabel) {
|
|
|
|
m_fileRecordingLabel->setText(secondsToString2(processor.getElapsedRecordTime(), false), dontSendNotification);
|
|
|
|
}
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
//m_parcomps[cpi_dryplayrate]->setVisible(*processor.getBoolParameter(cpi_bypass_stretch));
|
|
|
|
//m_parcomps[cpi_stretchamount]->setVisible(!*processor.getBoolParameter(cpi_bypass_stretch));
|
|
|
|
|
|
|
|
//if (m_wavefilter_tab.getCurrentTabIndex() != processor.m_cur_tab_index)
|
2018-06-29 12:13:49 +00:00
|
|
|
// 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)
|
|
|
|
{
|
2022-04-13 17:48:09 +00:00
|
|
|
File file(files[0]);
|
|
|
|
URL url = URL(file);
|
|
|
|
processor.setAudioFile(url);
|
2017-12-27 14:56:37 +00:00
|
|
|
toFront(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::urlOpened(const URL& url)
|
|
|
|
{
|
|
|
|
DBG("Got URL: " << url.toString(false));
|
|
|
|
std::unique_ptr<InputStream> wi (url.createInputStream (false));
|
|
|
|
if (wi != nullptr)
|
|
|
|
{
|
2022-04-13 17:48:09 +00:00
|
|
|
DBG("Attempting to load after input stream create: " << url.toString(false));
|
|
|
|
processor.setAudioFile(url);
|
|
|
|
}
|
2022-04-11 22:50:55 +00:00
|
|
|
toFront(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-07 11:29:50 +00:00
|
|
|
bool PaulstretchpluginAudioProcessorEditor::keyPressed(const KeyPress & press)
|
|
|
|
{
|
2018-12-15 15:23:32 +00:00
|
|
|
std::function<bool(void)> action;
|
2018-10-07 11:29:50 +00:00
|
|
|
if (press == 'I')
|
2019-01-21 17:25:27 +00:00
|
|
|
action = [this]() { m_import_button.onClick(); ; return true; };
|
2022-04-28 02:52:40 +00:00
|
|
|
else if (press == KeyPress::spaceKey)
|
|
|
|
action = [this]() { toggleBool(processor.getBoolParameter(cpi_pause_enabled)); ; return true; };
|
2018-12-15 15:23:32 +00:00
|
|
|
return action && action();
|
2018-10-07 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 22:09:28 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::toggleFileBrowser()
|
|
|
|
{
|
2022-04-11 22:50:55 +00:00
|
|
|
#if JUCE_IOS
|
|
|
|
|
|
|
|
String curropendir = processor.m_propsfile->m_props_file->getValue("importfilefolder",
|
|
|
|
File::getSpecialLocation(File::userDocumentsDirectory).getFullPathName());
|
|
|
|
|
|
|
|
Component * parent = JUCEApplication::isStandaloneApp() ? nullptr : this;
|
|
|
|
|
|
|
|
fileChooser.reset(new FileChooser("Choose an audio file to open...",
|
|
|
|
curropendir,
|
|
|
|
"*.wav;*.mp3;*.m4a;*.aif;*.aiff;*.caf;*.ogg;*.flac",
|
|
|
|
true, false, parent));
|
|
|
|
|
|
|
|
|
|
|
|
fileChooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
|
|
|
|
[this] (const FileChooser& chooser)
|
|
|
|
{
|
|
|
|
auto results = chooser.getURLResults();
|
|
|
|
if (results.size() > 0)
|
|
|
|
{
|
|
|
|
auto url = results.getReference (0);
|
|
|
|
|
|
|
|
std::unique_ptr<InputStream> wi (url.createInputStream (false));
|
|
|
|
if (wi != nullptr)
|
|
|
|
{
|
|
|
|
File file = url.getLocalFile();
|
|
|
|
DBG("Attempting to load from: " << file.getFullPathName());
|
|
|
|
|
|
|
|
//curropendir = file.getParentDirectory();
|
2022-04-13 17:48:09 +00:00
|
|
|
processor.setAudioFile(url);
|
2022-04-11 22:50:55 +00:00
|
|
|
processor.m_propsfile->m_props_file->setValue("importfilefolder", file.getParentDirectory().getFullPathName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
if (m_filechooser == nullptr)
|
2019-01-21 22:09:28 +00:00
|
|
|
{
|
2019-01-23 12:38:48 +00:00
|
|
|
m_filechooser = std::make_unique<MyFileBrowserComponent>(processor);
|
2019-01-21 22:09:28 +00:00
|
|
|
addChildComponent(m_filechooser.get());
|
|
|
|
}
|
2022-04-22 03:04:30 +00:00
|
|
|
auto bounds = getLocalArea(nullptr, m_import_button.getScreenBounds());
|
|
|
|
m_filechooser->setBounds(0, bounds.getBottom(), getWidth()/2, getHeight() - 75);
|
2019-01-21 22:09:28 +00:00
|
|
|
m_filechooser->setVisible(!m_filechooser->isVisible());
|
|
|
|
if (m_filechooser->isVisible())
|
|
|
|
m_import_button.setButtonText("Hide browser");
|
|
|
|
else
|
|
|
|
m_import_button.setButtonText("Show browser");
|
2022-04-11 22:50:55 +00:00
|
|
|
#endif
|
2019-01-21 22:09:28 +00:00
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
|
2022-06-15 18:54:49 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::showPopTip(const String & message, int timeoutMs, Component * target, int maxwidth)
|
|
|
|
{
|
|
|
|
popTip.reset(new BubbleMessageComponent());
|
|
|
|
popTip->setAllowedPlacement(BubbleComponent::above);
|
|
|
|
|
|
|
|
if (target) {
|
|
|
|
if (auto * parent = target->findParentComponentOfClass<AudioProcessorEditor>()) {
|
|
|
|
parent->addChildComponent (popTip.get());
|
|
|
|
} else {
|
|
|
|
addChildComponent(popTip.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addChildComponent(popTip.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
AttributedString text(message);
|
|
|
|
text.setJustification (Justification::centred);
|
|
|
|
text.setColour (findColour (TextButton::textColourOffId));
|
|
|
|
text.setFont(Font(12));
|
|
|
|
if (target) {
|
|
|
|
popTip->showAt(target, text, timeoutMs);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Rectangle<int> topbox(getWidth()/2 - maxwidth/2, 0, maxwidth, 2);
|
|
|
|
popTip->showAt(topbox, text, timeoutMs);
|
|
|
|
}
|
|
|
|
popTip->toFront(false);
|
|
|
|
//AccessibilityHandler::postAnnouncement(message, AccessibilityHandler::AnnouncementPriority::high);
|
|
|
|
}
|
|
|
|
|
2022-06-14 23:11:57 +00:00
|
|
|
void PaulstretchpluginAudioProcessorEditor::toggleOutputRecording()
|
|
|
|
{
|
|
|
|
if (processor.isRecordingToFile()) {
|
|
|
|
processor.stopRecordingToFile();
|
|
|
|
|
|
|
|
m_recordingButton->setToggleState(false, dontSendNotification);
|
|
|
|
//updateServerStatusLabel("Stopped Recording");
|
|
|
|
|
|
|
|
String filepath;
|
|
|
|
#if (JUCE_IOS || JUCE_ANDROID)
|
|
|
|
filepath = m_lastRecordedFile.getRelativePathFrom(File::getSpecialLocation (File::userDocumentsDirectory));
|
|
|
|
#else
|
|
|
|
filepath = m_lastRecordedFile.getRelativePathFrom(File::getSpecialLocation (File::userHomeDirectory));
|
|
|
|
#endif
|
2022-06-15 18:54:49 +00:00
|
|
|
showPopTip(TRANS("Finished recording to ") + filepath, 4000, m_recordingButton.get(), 130);
|
2022-06-14 23:11:57 +00:00
|
|
|
|
|
|
|
m_recordingButton->setTooltip(TRANS("Last recorded file: ") + filepath);
|
|
|
|
|
|
|
|
//mFileRecordingLabel->setText("Total: " + SonoUtility::durationToString(processor.getElapsedRecordTime(), true), dontSendNotification);
|
|
|
|
m_fileRecordingLabel->setText("", dontSendNotification);
|
|
|
|
|
|
|
|
//Timer::callAfterDelay(200, []() {
|
|
|
|
// AccessibilityHandler::postAnnouncement(TRANS("Recording finished"), AccessibilityHandler::AnnouncementPriority::high);
|
|
|
|
//});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
SafePointer<PaulstretchpluginAudioProcessorEditor> safeThis (this);
|
|
|
|
|
|
|
|
if (! RuntimePermissions::isGranted (RuntimePermissions::writeExternalStorage))
|
|
|
|
{
|
|
|
|
RuntimePermissions::request (RuntimePermissions::writeExternalStorage,
|
|
|
|
[safeThis] (bool granted) mutable
|
|
|
|
{
|
|
|
|
if (granted)
|
|
|
|
safeThis->toggleOutputRecording();
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// create new timestamped filename
|
|
|
|
String filename = "PaulXStretchSession" + String("_") + Time::getCurrentTime().formatted("%Y-%m-%d_%H.%M.%S");
|
|
|
|
|
|
|
|
filename = File::createLegalFileName(filename);
|
|
|
|
|
|
|
|
auto parentDir = File(processor.getDefaultRecordingDirectory());
|
|
|
|
parentDir.createDirectory();
|
|
|
|
|
|
|
|
File file (parentDir.getNonexistentChildFile (filename, ".flac"));
|
|
|
|
|
|
|
|
if (processor.startRecordingToFile(file)) {
|
|
|
|
//updateServerStatusLabel("Started recording...");
|
|
|
|
m_lastRecordedFile = file;
|
|
|
|
String filepath;
|
|
|
|
|
|
|
|
#if (JUCE_IOS || JUCE_ANDROID)
|
|
|
|
//showPopTip(TRANS("Started recording output"), 2000, mRecordingButton.get());
|
|
|
|
#else
|
|
|
|
//Timer::callAfterDelay(200, []() {
|
|
|
|
// AccessibilityHandler::postAnnouncement(TRANS("Started recording output"), AccessibilityHandler::AnnouncementPriority::high);
|
|
|
|
//});
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if (JUCE_IOS || JUCE_ANDROID)
|
|
|
|
filepath = m_lastRecordedFile.getRelativePathFrom(File::getSpecialLocation (File::userDocumentsDirectory));
|
|
|
|
#else
|
|
|
|
filepath = m_lastRecordedFile.getRelativePathFrom(File::getSpecialLocation (File::userHomeDirectory));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_recordingButton->setTooltip(TRANS("Recording audio to: ") + filepath);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// show error starting record
|
|
|
|
String lasterr = processor.getLastErrorMessage();
|
2022-06-15 18:54:49 +00:00
|
|
|
showPopTip(lasterr, 0, m_recordingButton.get());
|
2022-06-14 23:11:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_fileRecordingLabel->setText("", dontSendNotification);
|
|
|
|
m_recordingButton->setToggleState(true, dontSendNotification);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///============================
|
|
|
|
|
2018-09-13 10:47:19 +00:00
|
|
|
WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb, StretchAudioSource* sas)
|
|
|
|
: m_sas(sas)
|
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);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
Colour selcolor(0xffccaacc);
|
|
|
|
|
2018-02-23 15:43:29 +00:00
|
|
|
if (m_is_at_selection_drag_area)
|
2022-04-11 17:23:10 +00:00
|
|
|
g.setColour(selcolor.withAlpha(0.45f));
|
2018-02-23 15:43:29 +00:00
|
|
|
else
|
2022-04-11 17:23:10 +00:00
|
|
|
g.setColour(selcolor.withAlpha(0.4f));
|
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);
|
|
|
|
}
|
2019-02-28 14:44:14 +00:00
|
|
|
if (m_file_cached.first.getLength() > 0.0 && m_infotext.isEmpty() == false)
|
2017-11-13 21:42:13 +00:00
|
|
|
{
|
|
|
|
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());
|
2019-02-28 14:04:04 +00:00
|
|
|
g.fillRect(xcorleft, 0, xcorright - xcorleft, getHeight());
|
2017-11-13 21:42:13 +00:00
|
|
|
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));
|
2019-02-28 14:04:04 +00:00
|
|
|
g.fillRect(xcorleft, m_topmargin / 2, xcorright - xcorleft, getHeight());
|
2017-11-13 21:42:13 +00:00
|
|
|
}
|
2019-02-28 14:04:04 +00:00
|
|
|
g.setColour(Colours::white);
|
2019-02-28 14:44:14 +00:00
|
|
|
//g.drawText(toString(m_file_cached.first), 0, 30, 200, 30, Justification::centredLeft);
|
|
|
|
g.drawMultiLineText(m_infotext, 0, 30, getWidth(), Justification::topLeft);
|
2017-11-13 21:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g.setColour(Colours::white);
|
|
|
|
if (CursorPosCallback)
|
|
|
|
{
|
2022-04-26 21:58:45 +00:00
|
|
|
/*
|
2018-09-13 10:47:19 +00:00
|
|
|
double timediff = (Time::getMillisecondCounterHiRes() - m_last_source_pos_update_time)*(1.0/m_sas->getRate());
|
2018-09-13 11:04:56 +00:00
|
|
|
double curpos = ((double)m_last_source_pos / m_sas->getOutputSamplerate());
|
|
|
|
double prebufoffset = (double)m_sas->m_prebuffersize / m_sas->getOutputSamplerate();
|
|
|
|
curpos -= prebufoffset;
|
|
|
|
curpos = 1.0 / m_sas->getInfileLengthSeconds()*(curpos+(timediff / 1000.0));
|
2018-09-19 23:26:11 +00:00
|
|
|
//g.fillRect(normalizedToViewX<int>(curpos), m_topmargin, 1, getHeight() - m_topmargin);
|
|
|
|
//g.drawText(String(curpos), 1, 30, 200,30, Justification::left);
|
2022-04-26 21:58:45 +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);
|
2022-04-13 17:48:09 +00:00
|
|
|
g.drawText(URL::removeEscapeChars(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()
|
|
|
|
{
|
2018-09-13 10:47:19 +00:00
|
|
|
if (m_sas->getLastSourcePosition() != m_last_source_pos)
|
|
|
|
{
|
|
|
|
m_last_source_pos = m_sas->getLastSourcePosition();
|
|
|
|
m_last_source_pos_update_time = Time::getMillisecondCounterHiRes();
|
|
|
|
}
|
2019-02-28 14:04:04 +00:00
|
|
|
m_file_cached = m_sas->getFileCachedRangesNormalized();
|
2017-11-13 21:42:13 +00:00
|
|
|
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;
|
2022-04-15 18:29:23 +00:00
|
|
|
m_timedrag_started = false;
|
|
|
|
|
2018-02-22 12:22:06 +00:00
|
|
|
double pos = viewXToNormalized(e.x);
|
2022-04-15 18:29:23 +00:00
|
|
|
if (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();
|
|
|
|
}
|
|
|
|
|
2022-04-15 18:29:23 +00:00
|
|
|
void WaveformComponent::mouseUp(const MouseEvent & e)
|
2017-11-13 21:42:13 +00:00
|
|
|
{
|
2022-04-15 18:29:23 +00:00
|
|
|
int seektopmargin = getHeight() / 2;
|
|
|
|
|
2017-11-13 21:42:13 +00:00
|
|
|
if (m_didchangetimeselection)
|
|
|
|
{
|
|
|
|
TimeSelectionChangedCallback(Range<double>(m_time_sel_start, m_time_sel_end), 1);
|
|
|
|
m_didchangetimeselection = false;
|
|
|
|
}
|
2022-04-15 18:29:23 +00:00
|
|
|
else if (e.y < seektopmargin) {
|
|
|
|
double pos = viewXToNormalized(e.x);
|
|
|
|
if (SeekCallback)
|
|
|
|
{
|
|
|
|
SeekCallback(pos);
|
|
|
|
m_last_startpos = pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_is_dragging_selection = false;
|
|
|
|
m_lock_timesel_set = false;
|
|
|
|
m_mousedown = false;
|
|
|
|
m_didseek = false;
|
|
|
|
m_timedrag_started = false;
|
2017-11-13 21:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WaveformComponent::mouseDrag(const MouseEvent & e)
|
|
|
|
{
|
|
|
|
if (m_didseek == true)
|
|
|
|
return;
|
2022-04-15 18:29:23 +00:00
|
|
|
|
|
|
|
int dragthresh = 3;
|
|
|
|
#if JUCE_IOS
|
|
|
|
dragthresh = 6;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!m_timedrag_started && abs(e.getDistanceFromDragStartX()) > dragthresh) {
|
|
|
|
m_timedrag_started = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_timedrag_started) return;
|
|
|
|
|
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)
|
|
|
|
{
|
2022-04-12 22:47:43 +00:00
|
|
|
double width = getWidth();
|
2018-03-02 20:49:32 +00:00
|
|
|
double normt = viewXToNormalized(e.x);
|
|
|
|
double curlen = m_view_range.getLength();
|
2022-04-12 22:47:43 +00:00
|
|
|
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);
|
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
if (abs(wd.deltaX) > 0.0) {
|
|
|
|
auto deltax = 0.15f * wd.deltaX;
|
|
|
|
double old_len = t1 - t0;
|
|
|
|
t0 = (jlimit(0.0, 1.0 - old_len, t0 + deltax));
|
|
|
|
t1 = (jlimit(old_len, t0 + old_len, t1 + deltax));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
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);
|
2018-03-02 20:49:32 +00:00
|
|
|
m_view_range = { t0,t1 };
|
2022-04-12 22:47:43 +00:00
|
|
|
|
2018-03-02 20:49:32 +00:00
|
|
|
//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();
|
2022-04-12 22:47:43 +00:00
|
|
|
|
2018-03-02 20:49:32 +00:00
|
|
|
}
|
|
|
|
|
2022-04-18 19:11:22 +00:00
|
|
|
void WaveformComponent::mouseMagnify (const MouseEvent& e, float scaleFactor)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
double width = getWidth();
|
|
|
|
double normt = viewXToNormalized(e.x);
|
|
|
|
double curlen = m_view_range.getLength();
|
|
|
|
double zoomFactor = 1.0 - curlen;
|
|
|
|
|
|
|
|
double newfact = jlimit(0.0, 1.0, zoomFactor + scaleFactor);
|
|
|
|
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("MAG normt: " << normt << " posratio: " << xratio << " curlen: " << curlen << " t0: " << t0 << " t1: " << t1 << " mscale: " << scaleFactor);
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (ViewRangeChangedCallback)
|
|
|
|
ViewRangeChangedCallback(m_view_range);
|
|
|
|
m_image_dirty = true;
|
|
|
|
repaint();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2022-04-15 18:29:23 +00:00
|
|
|
int touchradius = 5;
|
|
|
|
#if JUCE_IOS
|
|
|
|
touchradius = 10;
|
|
|
|
#endif
|
2017-11-13 21:42:13 +00:00
|
|
|
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());
|
2022-04-15 18:29:23 +00:00
|
|
|
if (juce::Rectangle<int>(xcorleft - touchradius, m_topmargin, 2*touchradius, getHeight() - m_topmargin).contains(x, y))
|
2017-11-13 21:42:13 +00:00
|
|
|
return 1;
|
2022-04-15 18:29:23 +00:00
|
|
|
if (juce::Rectangle<int>(xcorright - touchradius, m_topmargin, 2*touchradius, getHeight() - m_topmargin).contains(x, y))
|
2017-11-13 21:42:13 +00:00
|
|
|
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
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
SpectralChainEditor::SpectralChainEditor()
|
|
|
|
: m_bgcolor(0xff0a0a0a), m_selbgcolor(0xff141f28), m_dragbgcolor(0xff1a1a1a)
|
|
|
|
{
|
|
|
|
m_disabledImage = Drawable::createFromImageData(BinaryData::power_svg, BinaryData::power_svgSize);
|
|
|
|
m_enabledImage = Drawable::createFromImageData(BinaryData::power_sel_svg, BinaryData::power_sel_svgSize);
|
|
|
|
}
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
void SpectralChainEditor::paint(Graphics & g)
|
|
|
|
{
|
2022-04-12 22:47:43 +00:00
|
|
|
//g.fillAll(Colours::black);
|
2022-04-13 23:24:44 +00:00
|
|
|
g.setColour(Colours::black);
|
2022-04-12 22:47:43 +00:00
|
|
|
g.fillRoundedRectangle(getLocalBounds().toFloat(), 4.0f);
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
if (m_src == nullptr)
|
|
|
|
return;
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
int xoff = 3;
|
|
|
|
int yoff = 3;
|
2022-04-13 23:24:44 +00:00
|
|
|
float box_w = (getWidth() - 2*xoff) / m_order.size();
|
2017-12-13 17:55:35 +00:00
|
|
|
int box_h = getHeight();
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-13 23:24:44 +00:00
|
|
|
float box_margin = jmin( (box_w * 0.25f), 16.0f);
|
|
|
|
float arrowsize = jmin(10.0f, box_margin*0.5f);
|
|
|
|
|
2017-12-13 17:55:35 +00:00
|
|
|
for (int i = 0; i < m_order.size(); ++i)
|
|
|
|
{
|
2017-12-13 21:49:21 +00:00
|
|
|
//if (i!=m_cur_index)
|
2022-04-13 23:24:44 +00:00
|
|
|
drawBox(g, i, i*box_w + xoff, yoff, box_w - box_margin, box_h - 2*yoff);
|
2017-12-13 17:55:35 +00:00
|
|
|
if (i<m_order.size() - 1)
|
2022-04-13 23:24:44 +00:00
|
|
|
g.drawArrow(juce::Line<float>(i*box_w + (box_w - box_margin) + xoff + 1, box_h / 2, i*box_w + box_w + xoff, box_h / 2), 2.0f, arrowsize, arrowsize);
|
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)
|
2022-04-13 23:24:44 +00:00
|
|
|
drawBox(g, m_cur_index, m_drag_x - m_downoffset_x + 5, yoff, box_w - box_margin - box_margin/2, box_h - 2*yoff);
|
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;
|
2022-04-11 17:23:10 +00:00
|
|
|
int xoff = 3;
|
|
|
|
int yoff = 3;
|
2022-04-13 23:24:44 +00:00
|
|
|
float box_w = (getWidth() - 2*xoff) / (float)m_order.size();
|
2017-12-13 17:55:35 +00:00
|
|
|
int box_h = getHeight();
|
2022-04-13 23:24:44 +00:00
|
|
|
m_cur_index = (int) ((ev.x - xoff) / box_w);
|
2018-01-30 15:32:23 +00:00
|
|
|
if (m_cur_index >= 0)
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
bool done = false;
|
2022-04-13 23:24:44 +00:00
|
|
|
juce::Rectangle<float> r(box_w*m_cur_index + 3, 3, 15, 15);
|
2022-04-11 17:23:10 +00:00
|
|
|
if (r.contains(ev.x - xoff, ev.y - yoff))
|
2018-01-30 15:32:23 +00:00
|
|
|
{
|
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();
|
2022-04-11 17:23:10 +00:00
|
|
|
done = true;
|
2018-01-30 15:32:23 +00:00
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
if (ModuleSelectedCallback)
|
|
|
|
ModuleSelectedCallback(m_order[m_cur_index].m_index);
|
|
|
|
|
|
|
|
if (done) return;
|
|
|
|
}
|
|
|
|
m_drag_x = ev.x;
|
|
|
|
m_downoffset_x = ev.x - xoff - box_w*m_cur_index;
|
2017-12-13 17:55:35 +00:00
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpectralChainEditor::mouseDrag(const MouseEvent & ev)
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
int xoff = 3;
|
|
|
|
int yoff = 3;
|
2022-04-13 23:24:44 +00:00
|
|
|
float box_w = (getWidth() - 2*xoff) / (float)m_order.size();
|
|
|
|
juce::Rectangle<float> r(box_w*m_cur_index + 3, 3, 15, 15);
|
2022-04-11 17:23:10 +00:00
|
|
|
if (r.contains(ev.x - xoff, ev.y - yoff))
|
2018-01-31 22:06:32 +00:00
|
|
|
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();
|
2022-04-11 17:23:10 +00:00
|
|
|
int new_index = (ev.x - xoff) / 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;
|
2022-04-13 23:24:44 +00:00
|
|
|
bool enabled = ((bool)*m_order[index].m_enabled);
|
|
|
|
|
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";
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
Colour bgcolor = enabled ? m_selbgcolor : m_bgcolor;
|
|
|
|
|
|
|
|
if (index == m_cur_index)
|
2017-12-13 19:25:42 +00:00
|
|
|
{
|
2022-04-13 23:24:44 +00:00
|
|
|
bgcolor = bgcolor.brighter(0.1f);
|
2017-12-13 19:25:42 +00:00
|
|
|
}
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
g.setColour(bgcolor);
|
|
|
|
g.fillRoundedRectangle(x, y, w, h, 4.0f);
|
|
|
|
|
|
|
|
|
|
|
|
// outline
|
2022-04-11 17:23:10 +00:00
|
|
|
g.setColour(Colour(0xccaaaaaa));
|
|
|
|
g.drawRoundedRectangle(x, y, w, h, 4.0f, 1.0f);
|
|
|
|
|
|
|
|
g.setColour(Colour(0xffaaaaaa));
|
|
|
|
if (w > 10) {
|
|
|
|
g.drawFittedText(txt, x + 2,y,w-4,h-4, Justification::centredBottom, 3);
|
|
|
|
}
|
2022-04-13 23:24:44 +00:00
|
|
|
|
|
|
|
auto enableRect = Rectangle<float>(x + 2, y + 2, 16, 16);
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
m_enabledImage->drawWithin(g, enableRect, RectanglePlacement::centred, 1.0f);
|
|
|
|
} else {
|
|
|
|
m_disabledImage->drawWithin(g, enableRect, RectanglePlacement::centred, 0.7f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// for arrow color
|
|
|
|
g.setColour(Colours::white.withAlpha(0.8f));
|
2017-12-13 17:55:35 +00:00
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notifyOnlyOnRelease, bool useDrawableToggle)
|
|
|
|
: m_par(par)
|
2017-12-22 20:59:45 +00:00
|
|
|
{
|
|
|
|
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);
|
2022-04-11 17:23:10 +00:00
|
|
|
m_label.setJustificationType(Justification::centredRight);
|
2022-04-15 18:29:23 +00:00
|
|
|
m_label.setFont(16.0f);
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2017-12-22 20:59:45 +00:00
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
|
|
|
|
if (floatpar)
|
|
|
|
{
|
2019-02-28 21:39:39 +00:00
|
|
|
m_slider = XenUtils::makeAddAndMakeVisible<MySlider>(*this,&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);
|
2022-04-11 17:23:10 +00:00
|
|
|
m_slider->setTextBoxStyle(Slider::TextBoxLeft, false, 60, 34);
|
2017-12-22 20:59:45 +00:00
|
|
|
m_slider->addListener(this);
|
2018-02-01 18:09:12 +00:00
|
|
|
m_slider->setDoubleClickReturnValue(true, floatpar->range.convertFrom0to1(par->getDefaultValue()));
|
2022-04-11 17:23:10 +00:00
|
|
|
m_slider->setViewportIgnoreDragFlag(true);
|
2022-04-13 23:24:44 +00:00
|
|
|
m_slider->setScrollWheelEnabled(false);
|
2022-04-14 07:26:26 +00:00
|
|
|
m_slider->setTitle(floatpar->getName(50));
|
|
|
|
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
|
|
|
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(par);
|
|
|
|
if (intpar)
|
|
|
|
{
|
2019-02-28 21:39:39 +00:00
|
|
|
m_slider = XenUtils::makeAddAndMakeVisible<MySlider>(*this);
|
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);
|
2022-04-11 17:23:10 +00:00
|
|
|
m_slider->setTextBoxStyle(Slider::TextBoxLeft, false, 60, 34);
|
2017-12-22 20:59:45 +00:00
|
|
|
m_slider->addListener(this);
|
2022-04-11 17:23:10 +00:00
|
|
|
m_slider->setViewportIgnoreDragFlag(true);
|
2022-04-18 19:11:22 +00:00
|
|
|
m_slider->setDoubleClickReturnValue(true, intpar->convertFrom0to1(par->getDefaultValue()));
|
|
|
|
m_slider->setScrollWheelEnabled(false);
|
2022-04-14 07:26:26 +00:00
|
|
|
m_slider->setTitle(intpar->getName(50));
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
|
|
|
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(par);
|
|
|
|
if (choicepar)
|
|
|
|
{
|
2022-04-28 02:52:40 +00:00
|
|
|
m_combobox = XenUtils::makeAddAndMakeVisible<ComboBox>(*this);
|
|
|
|
m_combobox->addItemList(choicepar->getAllValueStrings(), 1);
|
|
|
|
m_combobox->setTitle(choicepar->getName(50));
|
|
|
|
m_combobox->addListener(this);
|
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(par);
|
|
|
|
if (boolpar)
|
|
|
|
{
|
2022-04-14 07:26:26 +00:00
|
|
|
if (useDrawableToggle) {
|
|
|
|
m_drawtogglebut = std::make_unique<DrawableButton>("but", DrawableButton::ImageFitted);
|
|
|
|
m_drawtogglebut->setToggleState(*boolpar, dontSendNotification);
|
|
|
|
m_drawtogglebut->addListener(this);
|
|
|
|
m_drawtogglebut->setTitle(par->getName(50));
|
|
|
|
m_drawtogglebut->setTooltip(par->getName(50));
|
|
|
|
m_drawtogglebut->setClickingTogglesState(true);
|
|
|
|
m_drawtogglebut->setColour(TextButton::buttonColourId, Colours::transparentBlack);
|
|
|
|
m_drawtogglebut->setColour(TextButton::buttonOnColourId, Colours::transparentBlack);
|
|
|
|
m_drawtogglebut->setColour(DrawableButton::backgroundColourId, Colours::transparentBlack);
|
|
|
|
m_drawtogglebut->setColour(DrawableButton::backgroundOnColourId, Colours::transparentBlack);
|
|
|
|
|
|
|
|
addAndMakeVisible(m_drawtogglebut.get());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
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());
|
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParameterComponent::resized()
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
int h = getHeight();
|
2017-12-22 20:59:45 +00:00
|
|
|
if (m_slider)
|
|
|
|
{
|
2022-04-18 19:11:22 +00:00
|
|
|
int smallWidthThresh = 280;
|
|
|
|
int medWidthThresh = 350;
|
|
|
|
#if JUCE_IOS
|
|
|
|
smallWidthThresh = 360;
|
|
|
|
medWidthThresh = 420;
|
|
|
|
#endif
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
//int labw = 200;
|
|
|
|
int labw = 120;
|
2022-04-18 19:11:22 +00:00
|
|
|
if (getWidth() < smallWidthThresh) {
|
2022-04-15 18:29:23 +00:00
|
|
|
labw = 60;
|
|
|
|
m_label.setFont(12.0f);
|
|
|
|
}
|
2022-04-18 19:11:22 +00:00
|
|
|
else if (getWidth() < medWidthThresh) {
|
2022-04-11 17:23:10 +00:00
|
|
|
labw = 100;
|
2022-04-15 18:29:23 +00:00
|
|
|
m_label.setFont(14.0f);
|
|
|
|
} else {
|
|
|
|
m_label.setFont(16.0f);
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
m_label.setBounds(0, 0, labw, h);
|
|
|
|
m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), h);
|
2022-04-15 23:13:55 +00:00
|
|
|
|
|
|
|
m_slider->setMouseDragSensitivity(jmax(128, m_slider->getWidth() - m_slider->getTextBoxWidth()));
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
2022-04-14 07:26:26 +00:00
|
|
|
else if (m_togglebut) {
|
2022-04-11 17:23:10 +00:00
|
|
|
m_togglebut->setBounds(1, 0, getWidth() - 1, h);
|
2022-04-14 07:26:26 +00:00
|
|
|
}
|
|
|
|
else if (m_drawtogglebut) {
|
|
|
|
m_drawtogglebut->setBounds(1, 0, getWidth() - 1, h);
|
|
|
|
}
|
2022-04-28 02:52:40 +00:00
|
|
|
else if (m_combobox) {
|
|
|
|
m_combobox->setBounds(1, 0, getWidth() - 1, h);
|
|
|
|
}
|
2022-04-14 07:26:26 +00:00
|
|
|
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-04-28 02:52:40 +00:00
|
|
|
void ParameterComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
|
|
|
|
{
|
|
|
|
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(m_par);
|
|
|
|
if (choicepar) {
|
|
|
|
choicepar->setValueNotifyingHost(choicepar->convertTo0to1(m_combobox->getSelectedItemIndex()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-22 20:59:45 +00:00
|
|
|
void ParameterComponent::buttonClicked(Button * but)
|
|
|
|
{
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
2019-02-12 12:56:37 +00:00
|
|
|
if (m_togglebut != nullptr)
|
2017-12-22 20:59:45 +00:00
|
|
|
{
|
2019-02-12 12:56:37 +00:00
|
|
|
if (m_togglebut->getToggleState()!=*boolpar)
|
|
|
|
*boolpar = m_togglebut->getToggleState();
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
2022-04-14 07:26:26 +00:00
|
|
|
else if (m_drawtogglebut != nullptr)
|
|
|
|
{
|
|
|
|
if (m_drawtogglebut->getToggleState() != *boolpar)
|
|
|
|
*boolpar = m_drawtogglebut->getToggleState();
|
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2022-04-28 02:52:40 +00:00
|
|
|
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(m_par);
|
|
|
|
if (choicepar != nullptr && m_combobox != nullptr && m_combobox->getSelectedItemIndex() != choicepar->getIndex())
|
|
|
|
{
|
|
|
|
m_combobox->setSelectedItemIndex(choicepar->getIndex(), dontSendNotification);
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
2022-04-14 07:26:26 +00:00
|
|
|
if (boolpar!=nullptr) {
|
|
|
|
if ( m_togglebut != nullptr)
|
|
|
|
{
|
|
|
|
if (m_togglebut->getToggleState() != *boolpar)
|
|
|
|
m_togglebut->setToggleState(*boolpar, dontSendNotification);
|
|
|
|
}
|
|
|
|
else if ( m_drawtogglebut != nullptr)
|
|
|
|
{
|
|
|
|
if (m_drawtogglebut->getToggleState() != *boolpar)
|
|
|
|
m_drawtogglebut->setToggleState(*boolpar, dontSendNotification);
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 20:59:45 +00:00
|
|
|
}
|
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);
|
2022-04-14 07:26:26 +00:00
|
|
|
//else if (m_drawtogglebut)
|
|
|
|
// m_drawtogglebut->setColour(ToggleButton::textColourId, m_labeldefcolor);
|
2018-02-01 13:11:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_label.setColour(Label::textColourId, Colours::yellow);
|
|
|
|
if (m_togglebut)
|
|
|
|
m_togglebut->setColour(ToggleButton::textColourId, Colours::yellow);
|
2022-04-14 07:26:26 +00:00
|
|
|
//else if (m_drawtogglebut)
|
|
|
|
// m_drawtogglebut->setColour(ToggleButton::textColourId, Colours::yellow);
|
2018-02-01 13:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
2022-04-12 22:47:43 +00:00
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
g.setColour(Colours::green.withAlpha(0.8f));
|
|
|
|
} else {
|
|
|
|
g.setColour(Colours::darkgrey.withAlpha(0.8f));
|
|
|
|
}
|
|
|
|
|
2018-02-02 10:23:57 +00:00
|
|
|
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());
|
2022-04-11 17:23:10 +00:00
|
|
|
g.setColour(Colours::white.withAlpha(0.4f));
|
2018-02-02 10:23:57 +00:00
|
|
|
g.drawRect(0, 0, getWidth(), getHeight());
|
2022-04-11 17:23:10 +00:00
|
|
|
g.setColour(Colours::white);
|
2018-02-02 10:23:57 +00:00
|
|
|
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();
|
2022-04-15 23:13:55 +00:00
|
|
|
bufferingmenu.addItem(100, "None (risky)", true, curbufamount == -1);
|
2018-02-07 13:12:10 +00:00
|
|
|
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);
|
2022-04-02 16:45:02 +00:00
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
auto opts = PopupMenu::Options().withTargetComponent(this);
|
|
|
|
if (!JUCEApplicationBase::isStandaloneApp()) {
|
|
|
|
if (auto * editor = findParentComponentOfClass<PaulstretchpluginAudioProcessorEditor>()) {
|
|
|
|
opts = opts.withParentComponent(editor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if JUCE_IOS
|
|
|
|
opts = opts.withStandardItemHeight(34);
|
|
|
|
#endif
|
2022-04-02 16:45:02 +00:00
|
|
|
|
|
|
|
bufferingmenu.showMenuAsync(opts, [this](int r) {
|
|
|
|
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)
|
|
|
|
{
|
2022-04-22 03:04:30 +00:00
|
|
|
auto ha = get_hot_area(e.x, e.y);
|
2018-02-14 13:18:35 +00:00
|
|
|
m_drag_start_x = e.x;
|
2022-04-22 03:04:30 +00:00
|
|
|
|
|
|
|
m_handle_off_x = 0;
|
|
|
|
|
|
|
|
if (ha == ha_left_edge) {
|
|
|
|
m_handle_off_x = e.x - m_therange.getStart() * getWidth();
|
|
|
|
}
|
|
|
|
else if (ha == ha_right_edge) {
|
|
|
|
m_handle_off_x = e.x - m_therange.getEnd() * getWidth();
|
|
|
|
}
|
2018-02-14 13:18:35 +00:00
|
|
|
}
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
void zoom_scrollbar::mouseDoubleClick (const MouseEvent&)
|
|
|
|
{
|
|
|
|
// reset
|
|
|
|
m_therange.setStart(0.0);
|
|
|
|
m_therange.setEnd(1.0);
|
|
|
|
repaint();
|
|
|
|
|
|
|
|
if (RangeChanged)
|
|
|
|
RangeChanged(m_therange);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-14 13:18:35 +00:00
|
|
|
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_left_edge)
|
|
|
|
{
|
2022-04-22 03:04:30 +00:00
|
|
|
double new_left_edge = 1.0 / getWidth()*(e.x - m_handle_off_x);
|
2018-02-14 13:18:35 +00:00
|
|
|
m_therange.setStart(jlimit(0.0, m_therange.getEnd() - 0.01, new_left_edge));
|
|
|
|
repaint();
|
|
|
|
}
|
2022-04-22 03:04:30 +00:00
|
|
|
else if (m_hot_area == ha_right_edge)
|
2018-02-14 13:18:35 +00:00
|
|
|
{
|
2022-04-22 03:04:30 +00:00
|
|
|
double new_right_edge = 1.0 / getWidth()*(e.x - m_handle_off_x);
|
2018-02-14 13:18:35 +00:00
|
|
|
m_therange.setEnd(jlimit(m_therange.getStart() + 0.01, 1.0, new_right_edge));
|
|
|
|
repaint();
|
|
|
|
}
|
2022-04-22 03:04:30 +00:00
|
|
|
else if (m_hot_area == ha_handle || m_hot_area == ha_none)
|
2018-02-14 13:18:35 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
void zoom_scrollbar::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wd)
|
|
|
|
{
|
|
|
|
float delta = -0.1f * wd.deltaY;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
repaint();
|
|
|
|
|
|
|
|
if (RangeChanged)
|
|
|
|
RangeChanged(m_therange);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-14 13:18:35 +00:00
|
|
|
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)
|
|
|
|
{
|
2022-04-22 03:04:30 +00:00
|
|
|
int radius = 16;
|
|
|
|
#if JUCE_IOS
|
|
|
|
radius *= 2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Colour basecolor = Colours::darkgrey;
|
|
|
|
g.setColour(basecolor);
|
|
|
|
|
|
|
|
Colour barcolor = Colours::grey;
|
|
|
|
|
2018-02-14 13:18:35 +00:00
|
|
|
g.fillRect(0, 0, getWidth(), getHeight());
|
|
|
|
int x0 = (int)(getWidth()*m_therange.getStart());
|
|
|
|
int x1 = (int)(getWidth()*m_therange.getEnd());
|
2022-04-22 03:04:30 +00:00
|
|
|
if (m_hot_area == ha_handle)
|
|
|
|
barcolor = barcolor.brighter(0.5f); //Colours::white.withAlpha(0.8f);
|
|
|
|
|
|
|
|
g.setColour(barcolor);
|
|
|
|
|
|
|
|
//g.fillRect(x0, 0, x1 - x0, getHeight());
|
2022-04-12 22:47:43 +00:00
|
|
|
g.fillRoundedRectangle(x0, 0, x1 - x0, getHeight(), 8.0f);
|
|
|
|
|
2022-04-22 03:04:30 +00:00
|
|
|
// edge handles
|
|
|
|
|
|
|
|
Colour handlecol = barcolor.brighter();
|
|
|
|
if (m_hot_area == ha_left_edge)
|
|
|
|
g.setColour(handlecol.brighter());
|
|
|
|
else g.setColour(handlecol);
|
|
|
|
|
|
|
|
g.fillRoundedRectangle(x0, 0, radius, getHeight(), 8.0f);
|
|
|
|
|
|
|
|
if (m_hot_area == ha_right_edge)
|
|
|
|
g.setColour(handlecol.brighter());
|
|
|
|
else g.setColour(handlecol);
|
|
|
|
|
|
|
|
g.fillRoundedRectangle(x1 - radius, 0, radius, getHeight(), 8.0f);
|
|
|
|
|
2018-02-14 13:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2022-04-22 03:04:30 +00:00
|
|
|
int radius = 16;
|
2022-04-13 23:24:44 +00:00
|
|
|
#if JUCE_IOS
|
|
|
|
radius *= 2;
|
|
|
|
#endif
|
2018-02-14 13:18:35 +00:00
|
|
|
int x0 = (int)(getWidth()*m_therange.getStart());
|
|
|
|
int x1 = (int)(getWidth()*m_therange.getEnd());
|
2022-04-12 22:47:43 +00:00
|
|
|
if (is_in_range(x, x0 - radius, x0 + radius))
|
2018-02-14 13:18:35 +00:00
|
|
|
return ha_left_edge;
|
2022-04-12 22:47:43 +00:00
|
|
|
if (is_in_range(x, x1 - radius, x1 + radius))
|
2018-02-14 13:18:35 +00:00
|
|
|
return ha_right_edge;
|
2022-04-12 22:47:43 +00:00
|
|
|
if (is_in_range(x, x0 + radius, x1 - radius))
|
2018-02-14 13:18:35 +00:00
|
|
|
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()); };
|
2022-04-15 18:29:23 +00:00
|
|
|
ratslid->setNumDecimalPlacesToDisplay(3);
|
|
|
|
addAndMakeVisible(ratslid.get());
|
2018-04-03 13:34:20 +00:00
|
|
|
m_ratio_sliders.emplace_back(std::move(ratslid));
|
|
|
|
|
|
|
|
auto ratlevslid = std::make_unique<Slider>();
|
|
|
|
ratlevslid->setRange(0.0, 1.0);
|
2022-04-15 18:29:23 +00:00
|
|
|
ratlevslid->setNumDecimalPlacesToDisplay(3);
|
2018-04-03 13:34:20 +00:00
|
|
|
ratlevslid->setSliderStyle(Slider::LinearVertical);
|
2022-04-18 19:11:22 +00:00
|
|
|
if (i==2) {
|
|
|
|
ratlevslid->setValue(1.0,dontSendNotification);
|
|
|
|
ratlevslid->setDoubleClickReturnValue(true, 1.0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ratlevslid->setValue(0.0,dontSendNotification);
|
|
|
|
ratlevslid->setDoubleClickReturnValue(true, 0.0);
|
|
|
|
}
|
2018-04-03 13:34:20 +00:00
|
|
|
ratlevslid->onValueChange = [this, i]() { OnRatioLevelChanged(i, m_ratio_level_sliders[i]->getValue()); };
|
|
|
|
addAndMakeVisible(ratlevslid.get());
|
|
|
|
m_ratio_level_sliders.emplace_back(std::move(ratlevslid));
|
2022-04-15 18:29:23 +00:00
|
|
|
|
|
|
|
auto ratlab = std::make_unique<Label>();
|
|
|
|
ratlab->setJustificationType(Justification::centred);
|
|
|
|
ratlab->setText(String(i+1), dontSendNotification);
|
|
|
|
addAndMakeVisible(ratlab.get());
|
|
|
|
m_labels.emplace_back(std::move(ratlab));
|
2018-04-03 13:34:20 +00:00
|
|
|
}
|
2022-04-15 18:29:23 +00:00
|
|
|
|
|
|
|
if (numratios > 0) m_ratio_sliders[0]->setDoubleClickReturnValue(true, 0.25);
|
|
|
|
if (numratios > 1) m_ratio_sliders[1]->setDoubleClickReturnValue(true, 0.5);
|
|
|
|
if (numratios > 2) m_ratio_sliders[2]->setDoubleClickReturnValue(true, 1.0);
|
|
|
|
if (numratios > 3) m_ratio_sliders[3]->setDoubleClickReturnValue(true, 2.0);
|
|
|
|
if (numratios > 4) m_ratio_sliders[4]->setDoubleClickReturnValue(true, 3.0);
|
|
|
|
if (numratios > 5) m_ratio_sliders[5]->setDoubleClickReturnValue(true, 4.0);
|
|
|
|
if (numratios > 6) m_ratio_sliders[6]->setDoubleClickReturnValue(true, 1.5);
|
|
|
|
if (numratios > 7) m_ratio_sliders[7]->setDoubleClickReturnValue(true, 2/3.0);
|
|
|
|
|
2018-04-03 13:34:20 +00:00
|
|
|
startTimer(200);
|
2018-04-03 19:04:10 +00:00
|
|
|
setOpaque(true);
|
2018-04-03 13:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RatioMixerEditor::resized()
|
|
|
|
{
|
2022-04-15 18:29:23 +00:00
|
|
|
int minslidw = 65;
|
|
|
|
int maxslidw = 120;
|
2022-04-24 22:11:57 +00:00
|
|
|
int minslidh = 45;
|
2022-04-15 18:29:23 +00:00
|
|
|
int minrslidh = 32;
|
|
|
|
int maxrslidh = 45;
|
|
|
|
FlexBox contentbox;
|
|
|
|
contentbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
contentbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
//contentbox.alignContent = FlexBox::AlignContent::flexStart;
|
|
|
|
|
|
|
|
std::vector<FlexBox> itemboxes;
|
|
|
|
itemboxes.resize(m_ratio_sliders.size());
|
|
|
|
|
|
|
|
int nsliders = (int) m_ratio_sliders.size();
|
2018-04-03 13:34:20 +00:00
|
|
|
int slidw = getWidth() / nsliders;
|
2022-04-15 18:29:23 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < nsliders; ++i)
|
2018-04-03 13:34:20 +00:00
|
|
|
{
|
2022-04-15 18:29:23 +00:00
|
|
|
itemboxes[i].flexDirection = FlexBox::Direction::column;
|
|
|
|
itemboxes[i].items.add(FlexItem(minslidw, minslidh, *m_ratio_level_sliders[i]).withFlex(1));
|
|
|
|
itemboxes[i].items.add(FlexItem(minslidw, minrslidh, *m_ratio_sliders[i]).withFlex(1).withMaxHeight(maxrslidh));
|
|
|
|
|
|
|
|
contentbox.items.add(FlexItem(minslidw, minslidh + minrslidh, itemboxes[i]).withMargin(1).withFlex(1).withMaxWidth(maxslidw));
|
2018-04-03 13:34:20 +00:00
|
|
|
}
|
2022-04-15 18:29:23 +00:00
|
|
|
|
|
|
|
contentbox.performLayout(getLocalBounds().reduced(1));
|
|
|
|
|
|
|
|
for (int i = 0; i < nsliders; ++i)
|
|
|
|
{
|
|
|
|
m_labels[i]->setBounds(m_ratio_level_sliders[i]->getX(), m_ratio_level_sliders[i]->getY() + 1, m_ratio_level_sliders[i]->getWidth() - 2 , 16);
|
2022-04-15 23:13:55 +00:00
|
|
|
m_ratio_level_sliders[i]->setMouseDragSensitivity(jmax(128, m_ratio_level_sliders[i]->getHeight()));
|
|
|
|
m_ratio_sliders[i]->setMouseDragSensitivity(jmax(128, m_ratio_sliders[i]->getWidth()));
|
2022-04-15 18:29:23 +00:00
|
|
|
}
|
2018-04-03 13:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
void RatioMixerEditor::setSlidersSnap(bool flag)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_ratio_level_sliders.size(); ++i) {
|
|
|
|
m_ratio_level_sliders[i]->setSliderSnapsToMousePosition(flag);
|
|
|
|
m_ratio_sliders[i]->setSliderSnapsToMousePosition(flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-03 19:04:10 +00:00
|
|
|
void RatioMixerEditor::paint(Graphics & g)
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
g.fillAll(Colour(0xff222222));
|
2022-04-15 18:29:23 +00:00
|
|
|
/*
|
|
|
|
g.setColour(Colours::white);
|
2018-09-19 21:58:24 +00:00
|
|
|
auto nsliders = m_ratio_sliders.size();
|
2018-05-02 10:14:02 +00:00
|
|
|
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);
|
2022-04-15 18:29:23 +00:00
|
|
|
*/
|
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
|
|
|
{
|
2022-04-14 07:26:26 +00:00
|
|
|
m_viewport = std::make_unique<Viewport>();
|
|
|
|
m_viewport->setViewedComponent(&m_container, false);
|
|
|
|
addAndMakeVisible(m_viewport.get());
|
|
|
|
|
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));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_shifty], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_scaley], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_tilty], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_numbands], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_rate], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:49:11 +00:00
|
|
|
m_parcomps.emplace_back(std::make_unique<ParameterComponent>(pars[cpi_freefilter_randomy_amount], false));
|
2022-04-14 07:26:26 +00:00
|
|
|
m_container.addAndMakeVisible(m_parcomps.back().get());
|
2018-06-29 11:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeFilterComponent::resized()
|
|
|
|
{
|
2022-04-11 17:23:10 +00:00
|
|
|
int minslidwidth = 230;
|
|
|
|
int slidh = 24;
|
|
|
|
int margin = 1;
|
|
|
|
|
|
|
|
#if JUCE_IOS
|
|
|
|
slidh = 28;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FlexBox mainbox;
|
|
|
|
|
|
|
|
FlexBox slidbox;
|
|
|
|
slidbox.flexDirection = FlexBox::Direction::column;
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
slidbox.items.add(FlexItem(3, 2).withMargin(0));
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
2022-04-14 07:26:26 +00:00
|
|
|
{
|
|
|
|
//m_parcomps[i]->setBounds(1, 1+25*i, m_slidwidth - 2, 24);
|
2022-04-11 17:23:10 +00:00
|
|
|
slidbox.items.add(FlexItem(minslidwidth, slidh, *m_parcomps[i]).withMargin(margin).withFlex(0));
|
|
|
|
}
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
int minh = 0;
|
|
|
|
for (auto & item : slidbox.items ) {
|
|
|
|
minh += item.minHeight + item.margin.top + item.margin.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
int vpminh = 3*slidh + 3*margin;
|
|
|
|
|
|
|
|
if (minslidwidth < getWidth() * 0.4) {
|
|
|
|
|
|
|
|
mainbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
|
|
|
|
//m_env.setBounds(m_slidwidth, 0, getWidth() - m_slidwidth, getHeight());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(minslidwidth, vpminh, *m_viewport).withMargin(0).withFlex(1).withMaxWidth(m_slidwidth));
|
|
|
|
mainbox.items.add(FlexItem(100, 50, m_env).withMargin(0).withFlex(3));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mainbox.flexDirection = FlexBox::Direction::column;
|
|
|
|
|
|
|
|
//m_env.setBounds(m_slidwidth, 0, getWidth() - m_slidwidth, getHeight());
|
|
|
|
|
|
|
|
slidbox.flexDirection = FlexBox::Direction::column;
|
|
|
|
slidbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
|
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(minslidwidth, vpminh, *m_viewport).withMargin(0).withFlex(0));
|
|
|
|
mainbox.items.add(FlexItem(100, 3).withMargin(0));
|
|
|
|
mainbox.items.add(FlexItem(100, 50, m_env).withMargin(0).withFlex(3));
|
|
|
|
}
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
mainbox.performLayout(getLocalBounds());
|
2022-04-14 07:26:26 +00:00
|
|
|
|
|
|
|
auto contw = m_viewport->getWidth() - (minh > m_viewport->getHeight() ? m_viewport->getScrollBarThickness() : 0);
|
|
|
|
auto contbounds = Rectangle<int>(0, 0, contw, minh);
|
|
|
|
m_container.setBounds(contbounds);
|
|
|
|
slidbox.performLayout(contbounds);
|
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
{
|
|
|
|
if (auto * slid = m_parcomps[i]->getSlider()) {
|
|
|
|
slid->setMouseDragSensitivity(jmax(128, slid->getWidth() - slid->getTextBoxWidth()));
|
|
|
|
}
|
|
|
|
}
|
2018-06-29 11:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeFilterComponent::paint(Graphics & g)
|
|
|
|
{
|
2022-04-15 23:42:43 +00:00
|
|
|
g.setColour(Colour(0xff222222));
|
2022-04-11 17:23:10 +00:00
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
g.fillRect(0, 0, getWidth(), getHeight());
|
2018-06-29 11:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeFilterComponent::updateParameterComponents()
|
|
|
|
{
|
|
|
|
for (auto& e : m_parcomps)
|
|
|
|
e->updateComponent();
|
2018-06-29 11:23:48 +00:00
|
|
|
}
|
2018-09-26 16:19:10 +00:00
|
|
|
|
2022-04-15 23:13:55 +00:00
|
|
|
void FreeFilterComponent::setSlidersSnap(bool flag)
|
|
|
|
{
|
|
|
|
for (auto& e : m_parcomps) {
|
|
|
|
if (auto * slid = e->getSlider())
|
|
|
|
slid->setSliderSnapsToMousePosition(flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
ParameterGroupComponent::ParameterGroupComponent(const String & name_, int groupid, PaulstretchpluginAudioProcessor* proc, bool showtoggle)
|
2022-04-12 23:20:28 +00:00
|
|
|
:name(name_), groupId(groupid), m_proc(proc), m_bgcolor(0xff1a1a1a), m_selbgcolor(0xff141f28)
|
2022-04-11 17:23:10 +00:00
|
|
|
{
|
|
|
|
if (name_.isNotEmpty()) {
|
|
|
|
m_namelabel = std::make_unique<Label>("name", name);
|
|
|
|
addAndMakeVisible(m_namelabel.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (showtoggle) {
|
|
|
|
//m_enableButton = std::make_unique<DrawableButton>("ena", DrawableButton::ImageFitted);
|
2022-04-12 22:47:43 +00:00
|
|
|
//m_enableButton = std::make_unique<ToggleButton>();
|
2022-04-11 17:23:10 +00:00
|
|
|
//m_enableButton->setColour(DrawableButton::backgroundOnColourId, Colours::blue);
|
2022-04-12 22:47:43 +00:00
|
|
|
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());
|
2022-04-11 17:23:10 +00:00
|
|
|
m_enableButton->setClickingTogglesState(true);
|
2022-04-12 22:47:43 +00:00
|
|
|
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);
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
m_enableButton->onClick = [this]() {
|
2022-04-14 07:26:26 +00:00
|
|
|
if (groupId < 0) {
|
|
|
|
if (EnabledChangedCallback)
|
|
|
|
EnabledChangedCallback();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
auto order = m_proc->getStretchSource()->getSpectrumProcessOrder();
|
|
|
|
for (int i=0; i < order.size(); ++i) {
|
|
|
|
if (order[i].m_index == groupId) {
|
|
|
|
toggleBool(order[i].m_enabled);
|
|
|
|
m_enableButton->setToggleState(order[i].m_enabled->get(), dontSendNotification);
|
|
|
|
if (EnabledChangedCallback)
|
|
|
|
EnabledChangedCallback();
|
|
|
|
break;
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
addAndMakeVisible(m_enableButton.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ParameterGroupComponent::getMinimumHeight(int forWidth)
|
|
|
|
{
|
|
|
|
if (m_lastForWidth != forWidth || m_lastCompSize != m_parcomps.size()) {
|
|
|
|
m_minHeight = doLayout(Rectangle<int>(0,0, forWidth, 2000));
|
|
|
|
|
|
|
|
m_lastForWidth = forWidth;
|
|
|
|
m_lastCompSize = (int) m_parcomps.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_minHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParameterGroupComponent::addParameterComponent(ParameterComponent * pcomp)
|
|
|
|
{
|
|
|
|
if (pcomp) {
|
|
|
|
addAndMakeVisible(pcomp);
|
|
|
|
m_parcomps.push_back(pcomp);
|
|
|
|
//m_parcomps.emplace_back(pcomp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-11 22:50:55 +00:00
|
|
|
void ParameterGroupComponent::replaceParameterComponent(ParameterComponent * oldcomp, ParameterComponent * newcomp)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_parcomps[i] == oldcomp) {
|
|
|
|
removeChildComponent(oldcomp);
|
|
|
|
addAndMakeVisible(newcomp);
|
|
|
|
m_parcomps[i] = newcomp;
|
|
|
|
resized();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-11 17:23:10 +00:00
|
|
|
int ParameterGroupComponent::doLayout(Rectangle<int> bounds)
|
|
|
|
{
|
|
|
|
int titlew = m_namelabel ? 100 : m_enableButton ? 40 : 0;
|
|
|
|
int enablew = m_enableButton ? 40 : 0;
|
2022-04-12 22:47:43 +00:00
|
|
|
int enablemaxh = 34;
|
2022-04-15 18:29:23 +00:00
|
|
|
int minitemw = 260;
|
2022-04-28 02:52:40 +00:00
|
|
|
int choiceminitemw = 110;
|
2022-04-12 22:47:43 +00:00
|
|
|
int minitemh = 26;
|
|
|
|
int margin = 1;
|
2022-04-11 17:23:10 +00:00
|
|
|
int outsidemargin = 4;
|
|
|
|
|
|
|
|
#if JUCE_IOS
|
2022-04-12 22:47:43 +00:00
|
|
|
minitemh = 34;
|
|
|
|
outsidemargin = 4;
|
2022-04-11 17:23:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
FlexBox mainbox;
|
|
|
|
mainbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
|
|
|
|
|
|
|
|
FlexBox contentbox;
|
|
|
|
contentbox.flexDirection = FlexBox::Direction::row;
|
|
|
|
contentbox.flexWrap = FlexBox::Wrap::wrap;
|
|
|
|
contentbox.alignContent = FlexBox::AlignContent::flexStart;
|
|
|
|
|
|
|
|
FlexBox titlebox;
|
|
|
|
|
|
|
|
if (titlew > 0) {
|
|
|
|
titlebox.flexDirection = FlexBox::Direction::row;
|
|
|
|
//titlebox.items.add(FlexItem(4, minitemh));
|
|
|
|
|
|
|
|
if (m_enableButton) {
|
2022-04-12 22:47:43 +00:00
|
|
|
titlebox.items.add(FlexItem(enablew, minitemh, *m_enableButton).withMargin(margin).withMaxHeight(enablemaxh));
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_namelabel) {
|
|
|
|
titlebox.items.add(FlexItem(titlew-enablew, minitemh, *m_namelabel).withMargin(margin).withFlex(1));
|
|
|
|
}
|
|
|
|
|
2022-04-12 22:47:43 +00:00
|
|
|
mainbox.items.add(FlexItem(titlew, enablemaxh, titlebox).withMargin(1)/*.withAlignSelf(FlexItem::AlignSelf::center)*/);
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_parcomps.size(); ++i)
|
|
|
|
{
|
2022-04-28 02:52:40 +00:00
|
|
|
if (m_parcomps[i]->getComboBox()) {
|
|
|
|
contentbox.items.add(FlexItem(choiceminitemw, minitemh, *m_parcomps[i]).withMargin(margin).withFlex(0.1));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
contentbox.items.add(FlexItem(minitemw, minitemh, *m_parcomps[i]).withMargin(margin).withFlex(1));
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mainbox.items.add(FlexItem(minitemw, minitemh, contentbox).withFlex(1).withMargin(outsidemargin));
|
|
|
|
|
|
|
|
|
|
|
|
mainbox.performLayout(bounds);
|
|
|
|
|
|
|
|
int minh = contentbox.items.size() > 0 ? contentbox.items.getLast().currentBounds.getBottom() + margin + outsidemargin : minitemh;
|
|
|
|
|
|
|
|
return minh;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParameterGroupComponent::resized()
|
|
|
|
{
|
|
|
|
|
|
|
|
doLayout(getLocalBounds());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParameterGroupComponent::paint(Graphics & g)
|
|
|
|
{
|
2022-04-28 02:52:40 +00:00
|
|
|
if (m_enableButton && m_enableButton->getToggleState()) {
|
2022-04-12 22:47:43 +00:00
|
|
|
g.setColour(m_selbgcolor);
|
|
|
|
} else {
|
|
|
|
g.setColour(m_bgcolor);
|
|
|
|
}
|
|
|
|
g.fillRoundedRectangle(getLocalBounds().toFloat(), 4.0f);
|
2022-04-11 17:23:10 +00:00
|
|
|
//g.fillRect(0, 0, getWidth(), getHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParameterGroupComponent::updateParameterComponents()
|
|
|
|
{
|
|
|
|
bool enabled = true;
|
|
|
|
|
2022-04-14 07:26:26 +00:00
|
|
|
if (m_enableButton && groupId >= 0) {
|
2022-04-11 17:23:10 +00:00
|
|
|
auto order = m_proc->getStretchSource()->getSpectrumProcessOrder();
|
|
|
|
for (int i=0; i < order.size(); ++i) {
|
|
|
|
if (order[i].m_index == groupId) {
|
|
|
|
enabled = order[i].m_enabled->get();
|
|
|
|
m_enableButton->setToggleState(enabled, dontSendNotification);
|
2022-04-12 23:20:28 +00:00
|
|
|
m_enableButton->setAlpha(enabled ? 1.0f : 0.75f);
|
2022-04-11 17:23:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-28 02:52:40 +00:00
|
|
|
else if (m_enableButton) {
|
|
|
|
enabled = m_enableButton->getToggleState();
|
|
|
|
}
|
2022-04-11 17:23:10 +00:00
|
|
|
|
|
|
|
for (auto& e : m_parcomps) {
|
|
|
|
e->updateComponent();
|
2022-04-28 02:52:40 +00:00
|
|
|
e->setAlpha((enabled || !allowDisableFade) ? 1.0f : 0.5f);
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
2022-04-12 22:47:43 +00:00
|
|
|
repaint();
|
2022-04-11 17:23:10 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 16:19:10 +00:00
|
|
|
void AudioFilePreviewComponent::processBlock(double sr, AudioBuffer<float>& buf)
|
|
|
|
{
|
|
|
|
if (m_reader != nullptr)
|
|
|
|
{
|
|
|
|
m_reader->read(&buf, 0, buf.getNumSamples(), m_playpos, true, true);
|
|
|
|
m_playpos += buf.getNumSamples();
|
|
|
|
if (m_playpos >= m_reader->lengthInSamples)
|
|
|
|
m_playpos = 0;
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 12:38:48 +00:00
|
|
|
|
|
|
|
MyFileBrowserComponent::MyFileBrowserComponent(PaulstretchpluginAudioProcessor & p) :
|
2022-04-12 22:47:43 +00:00
|
|
|
m_filefilter(p.m_afm->getWildcardForAllFormats(),String(),String()), m_proc(p)
|
2019-01-23 12:38:48 +00:00
|
|
|
{
|
|
|
|
String initiallocfn = m_proc.m_propsfile->m_props_file->getValue("importfilefolder",
|
|
|
|
File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
|
|
|
|
File initialloc(initiallocfn);
|
2022-04-11 22:50:55 +00:00
|
|
|
m_fbcomp = std::make_unique<FileBrowserComponent>(FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
|
2019-01-23 12:38:48 +00:00
|
|
|
initialloc, &m_filefilter, nullptr);
|
|
|
|
m_fbcomp->addListener(this);
|
|
|
|
addAndMakeVisible(m_fbcomp.get());
|
2022-04-11 22:50:55 +00:00
|
|
|
//setLookAndFeel(&m_filebwlookandfeel);
|
2019-02-19 18:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MyFileBrowserComponent::~MyFileBrowserComponent()
|
|
|
|
{
|
|
|
|
setLookAndFeel(nullptr);
|
2019-01-23 12:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::resized()
|
|
|
|
{
|
|
|
|
m_fbcomp->setBounds(0, 0, getWidth(), getHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::paint(Graphics & g)
|
|
|
|
{
|
2022-04-11 22:50:55 +00:00
|
|
|
g.fillAll(Colours::black.withAlpha(0.9f));
|
2019-01-23 12:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::selectionChanged()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::fileClicked(const File & file, const MouseEvent & e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::fileDoubleClicked(const File & file)
|
|
|
|
{
|
2022-04-13 17:48:09 +00:00
|
|
|
m_proc.setAudioFile(URL(file));
|
2019-01-23 12:38:48 +00:00
|
|
|
m_proc.m_propsfile->m_props_file->setValue("importfilefolder", file.getParentDirectory().getFullPathName());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileBrowserComponent::browserRootChanged(const File & newRoot)
|
|
|
|
{
|
2019-02-19 18:28:13 +00:00
|
|
|
m_proc.m_propsfile->m_props_file->setValue("importfilefolder", newRoot.getFullPathName());
|
2019-01-23 12:38:48 +00:00
|
|
|
}
|