2017-11-13 15:06:08 +00:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
This file was auto-generated!
|
|
|
|
|
|
|
|
It contains the basic framework code for a JUCE plugin editor.
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../JuceLibraryCode/JuceHeader.h"
|
|
|
|
#include "PluginProcessor.h"
|
2017-11-13 18:45:23 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2017-11-13 15:06:08 +00:00
|
|
|
|
2017-11-13 18:45:23 +00:00
|
|
|
class ParameterComponent : public Component,
|
|
|
|
public Slider::Listener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ParameterComponent(AudioProcessorParameter* par) : m_par(par)
|
|
|
|
{
|
|
|
|
addAndMakeVisible(&m_label);
|
|
|
|
m_label.setText(par->getName(50),dontSendNotification);
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
|
|
|
|
if (floatpar)
|
|
|
|
{
|
|
|
|
m_slider = std::make_unique<Slider>();
|
|
|
|
m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval);
|
|
|
|
m_slider->setValue(*floatpar, dontSendNotification);
|
|
|
|
m_slider->addListener(this);
|
|
|
|
addAndMakeVisible(m_slider.get());
|
|
|
|
}
|
|
|
|
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(par);
|
|
|
|
if (choicepar)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(par);
|
|
|
|
if (boolpar)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void resized() override
|
|
|
|
{
|
|
|
|
m_label.setBounds(0, 0, 200, 24);
|
|
|
|
if (m_slider)
|
|
|
|
m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), 24);
|
|
|
|
}
|
|
|
|
void sliderValueChanged(Slider* slid) override
|
|
|
|
{
|
2017-11-13 18:54:08 +00:00
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
|
|
|
*floatpar = slid->getValue();
|
|
|
|
}
|
|
|
|
void updateComponent()
|
|
|
|
{
|
|
|
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
|
|
|
if (m_slider != nullptr && (float)m_slider->getValue() != *floatpar)
|
|
|
|
{
|
|
|
|
m_slider->setValue(*floatpar, dontSendNotification);
|
|
|
|
}
|
2017-11-13 18:45:23 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
Label m_label;
|
|
|
|
AudioProcessorParameter* m_par = nullptr;
|
|
|
|
std::unique_ptr<Slider> m_slider;
|
|
|
|
std::unique_ptr<ComboBox> m_combobox;
|
|
|
|
std::unique_ptr<ToggleButton> m_togglebut;
|
|
|
|
};
|
2017-11-13 15:06:08 +00:00
|
|
|
|
2017-11-13 21:42:13 +00:00
|
|
|
class WaveformComponent : public Component, public ChangeListener, public Timer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WaveformComponent(AudioFormatManager* afm);
|
|
|
|
~WaveformComponent();
|
|
|
|
void changeListenerCallback(ChangeBroadcaster* cb) override;
|
|
|
|
void paint(Graphics& g) override;
|
|
|
|
void setAudioFile(File f);
|
|
|
|
void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len);
|
2017-11-15 15:52:47 +00:00
|
|
|
void beginAddingAudioBlocks(int channels, int samplerate, int totalllen);
|
|
|
|
void addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos);
|
2017-11-13 21:42:13 +00:00
|
|
|
void timerCallback() override;
|
|
|
|
std::function<double()> CursorPosCallback;
|
|
|
|
std::function<void(double)> SeekCallback;
|
|
|
|
std::function<void(Range<double>, int)> TimeSelectionChangedCallback;
|
|
|
|
void mouseDown(const MouseEvent& e) override;
|
|
|
|
void mouseUp(const MouseEvent& e) override;
|
|
|
|
void mouseDrag(const MouseEvent& e) override;
|
|
|
|
void mouseMove(const MouseEvent& e) override;
|
|
|
|
Range<double> 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 setTimeSelection(Range<double> rng)
|
|
|
|
{
|
|
|
|
if (rng.isEmpty())
|
|
|
|
rng = { -1.0,1.0 };
|
|
|
|
m_time_sel_start = rng.getStart();
|
|
|
|
m_time_sel_end = rng.getEnd();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
void setFileCachedRange(std::pair<Range<double>, Range<double>> rng);
|
|
|
|
void setTimerEnabled(bool b);
|
|
|
|
void setViewRange(Range<double> rng);
|
|
|
|
Value ShowFileCacheRange;
|
2017-11-15 15:52:47 +00:00
|
|
|
void setRecordingPosition(double pos) { m_rec_pos = pos; }
|
2017-11-13 21:42:13 +00:00
|
|
|
private:
|
|
|
|
AudioThumbnailCache m_thumbcache;
|
|
|
|
|
|
|
|
std::unique_ptr<AudioThumbnail> m_thumb;
|
|
|
|
Range<double> m_view_range{ 0.0,1.0 };
|
|
|
|
int m_time_sel_drag_target = 0;
|
|
|
|
double m_time_sel_start = -1.0;
|
|
|
|
double m_time_sel_end = -1.0;
|
|
|
|
double m_drag_time_start = 0.0;
|
|
|
|
bool m_mousedown = false;
|
|
|
|
bool m_didseek = false;
|
|
|
|
bool m_didchangetimeselection = false;
|
|
|
|
int m_topmargin = 0;
|
|
|
|
int getTimeSelectionEdge(int x, int y);
|
|
|
|
std::pair<Range<double>, Range<double>> m_file_cached;
|
|
|
|
File m_curfile;
|
|
|
|
Image m_waveimage;
|
|
|
|
OpenGLContext m_ogl;
|
|
|
|
bool m_use_opengl = false;
|
2017-11-15 15:52:47 +00:00
|
|
|
double m_rec_pos = 0.0;
|
2017-11-13 21:42:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-11-13 18:54:08 +00:00
|
|
|
class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor,
|
2017-11-13 19:21:30 +00:00
|
|
|
public MultiTimer, public Button::Listener
|
2017-11-13 15:06:08 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor&);
|
|
|
|
~PaulstretchpluginAudioProcessorEditor();
|
2017-11-13 19:21:30 +00:00
|
|
|
void buttonClicked(Button* but) override;
|
2017-11-13 15:06:08 +00:00
|
|
|
//==============================================================================
|
|
|
|
void paint (Graphics&) override;
|
|
|
|
void resized() override;
|
2017-11-13 18:54:08 +00:00
|
|
|
void timerCallback(int id) override;
|
2017-11-13 21:42:13 +00:00
|
|
|
void setAudioFile(File f);
|
|
|
|
void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len);
|
2017-11-15 15:52:47 +00:00
|
|
|
void beginAddingAudioBlocks(int channels, int samplerate, int totalllen);
|
|
|
|
void addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos);
|
2017-11-15 19:47:26 +00:00
|
|
|
WaveformComponent m_wavecomponent;
|
2017-11-13 15:06:08 +00:00
|
|
|
private:
|
|
|
|
PaulstretchpluginAudioProcessor& processor;
|
2017-11-13 18:45:23 +00:00
|
|
|
std::vector<std::shared_ptr<ParameterComponent>> m_parcomps;
|
2017-11-13 19:21:30 +00:00
|
|
|
ToggleButton m_rec_enable;
|
2017-11-14 16:14:14 +00:00
|
|
|
TextButton m_import_button;
|
2017-11-13 20:35:36 +00:00
|
|
|
Label m_info_label;
|
2017-11-15 19:47:26 +00:00
|
|
|
|
2017-11-13 15:06:08 +00:00
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
|
|
|
};
|