Parameter and slider stuff. Added spread parameter. Mutex locking fixes. This had went unnoticed because VS for some reason didn't break into the debugger on entering a non recursive multiple times.
This commit is contained in:
parent
73ef79509c
commit
8bd4468603
@ -43,6 +43,24 @@ inline void attachCallback(Button& button, std::function<void()> callback)
|
|||||||
new ButtonCallback(button, callback);
|
new ButtonCallback(button, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MySlider : public Slider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MySlider(NormalisableRange<float>* range) : m_range(range)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
double proportionOfLengthToValue(double x) override
|
||||||
|
{
|
||||||
|
return m_range->convertFrom0to1(x);
|
||||||
|
}
|
||||||
|
double valueToProportionOfLength(double x) override
|
||||||
|
{
|
||||||
|
return m_range->convertTo0to1(x);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
NormalisableRange<float>* m_range = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
class ParameterComponent : public Component,
|
class ParameterComponent : public Component,
|
||||||
public Slider::Listener, public Button::Listener
|
public Slider::Listener, public Button::Listener
|
||||||
{
|
{
|
||||||
@ -54,7 +72,7 @@ public:
|
|||||||
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
|
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(par);
|
||||||
if (floatpar)
|
if (floatpar)
|
||||||
{
|
{
|
||||||
m_slider = std::make_unique<Slider>();
|
m_slider = std::make_unique<MySlider>(&floatpar->range);
|
||||||
m_notify_only_on_release = notifyOnlyOnRelease;
|
m_notify_only_on_release = notifyOnlyOnRelease;
|
||||||
m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval);
|
m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval);
|
||||||
m_slider->setValue(*floatpar, dontSendNotification);
|
m_slider->setValue(*floatpar, dontSendNotification);
|
||||||
@ -126,7 +144,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Label m_label;
|
Label m_label;
|
||||||
AudioProcessorParameter* m_par = nullptr;
|
AudioProcessorParameter* m_par = nullptr;
|
||||||
std::unique_ptr<Slider> m_slider;
|
std::unique_ptr<MySlider> m_slider;
|
||||||
std::unique_ptr<ComboBox> m_combobox;
|
std::unique_ptr<ComboBox> m_combobox;
|
||||||
std::unique_ptr<ToggleButton> m_togglebut;
|
std::unique_ptr<ToggleButton> m_togglebut;
|
||||||
bool m_notify_only_on_release = false;
|
bool m_notify_only_on_release = false;
|
||||||
@ -136,8 +154,8 @@ private:
|
|||||||
class MyThumbCache : public AudioThumbnailCache
|
class MyThumbCache : public AudioThumbnailCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyThumbCache() : AudioThumbnailCache(100) { Logger::writeToLog("Constructed AudioThumbNailCache"); }
|
MyThumbCache() : AudioThumbnailCache(100) { /*Logger::writeToLog("Constructed AudioThumbNailCache");*/ }
|
||||||
~MyThumbCache() { Logger::writeToLog("Destructed AudioThumbNailCache"); }
|
~MyThumbCache() { /*Logger::writeToLog("Destructed AudioThumbNailCache");*/ }
|
||||||
};
|
};
|
||||||
|
|
||||||
class WaveformComponent : public Component, public ChangeListener, public Timer
|
class WaveformComponent : public Component, public ChangeListener, public Timer
|
||||||
|
@ -83,13 +83,15 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
|||||||
m_stretch_source->setOnsetDetection(0.0);
|
m_stretch_source->setOnsetDetection(0.0);
|
||||||
m_stretch_source->setLoopingEnabled(true);
|
m_stretch_source->setLoopingEnabled(true);
|
||||||
addParameter(new AudioParameterFloat("mainvolume0", "Main volume", -24.0f, 12.0f, -3.0f)); // 0
|
addParameter(new AudioParameterFloat("mainvolume0", "Main volume", -24.0f, 12.0f, -3.0f)); // 0
|
||||||
addParameter(new AudioParameterFloat("stretchamount0", "Stretch amount", 0.1f, 128.0f, 1.0f)); // 1
|
addParameter(new AudioParameterFloat("stretchamount0", "Stretch amount",
|
||||||
|
NormalisableRange<float>(0.1f, 128.0f, 0.01f, 0.5),1.0f)); // 1
|
||||||
addParameter(new AudioParameterFloat("fftsize0", "FFT size", 0.0f, 1.0f, 0.7f)); // 2
|
addParameter(new AudioParameterFloat("fftsize0", "FFT size", 0.0f, 1.0f, 0.7f)); // 2
|
||||||
addParameter(new AudioParameterFloat("pitchshift0", "Pitch shift", -24.0f, 24.0f, 0.0f)); // 3
|
addParameter(new AudioParameterFloat("pitchshift0", "Pitch shift", -24.0f, 24.0f, 0.0f)); // 3
|
||||||
addParameter(new AudioParameterFloat("freqshift0", "Frequency shift", -1000.0f, 1000.0f, 0.0f)); // 4
|
addParameter(new AudioParameterFloat("freqshift0", "Frequency shift", -1000.0f, 1000.0f, 0.0f)); // 4
|
||||||
addParameter(new AudioParameterFloat("playrange_start0", "Sound start", 0.0f, 1.0f, 0.0f)); // 5
|
addParameter(new AudioParameterFloat("playrange_start0", "Sound start", 0.0f, 1.0f, 0.0f)); // 5
|
||||||
addParameter(new AudioParameterFloat("playrange_end0", "Sound end", 0.0f, 1.0f, 1.0f)); // 6
|
addParameter(new AudioParameterFloat("playrange_end0", "Sound end", 0.0f, 1.0f, 1.0f)); // 6
|
||||||
addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7
|
addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7
|
||||||
|
addParameter(new AudioParameterFloat("spread0", "Frequency spread", 0.0f, 1.0f, 0.0f)); // 8
|
||||||
}
|
}
|
||||||
|
|
||||||
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
||||||
@ -183,7 +185,7 @@ void PaulstretchpluginAudioProcessor::setFFTSize(double size)
|
|||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int numoutchans, String& err)
|
void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int numoutchans, String& err)
|
||||||
{
|
{
|
||||||
m_stretch_source->setPlayRange(playrange, m_stretch_source->isLoopingEnabled());
|
m_stretch_source->setPlayRange(playrange, true);
|
||||||
|
|
||||||
int bufamt = m_bufamounts[m_prebuffer_amount];
|
int bufamt = m_bufamounts[m_prebuffer_amount];
|
||||||
|
|
||||||
@ -207,6 +209,7 @@ void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int num
|
|||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> locker(m_mutex);
|
||||||
if (getNumOutputChannels() != m_cur_num_out_chans)
|
if (getNumOutputChannels() != m_cur_num_out_chans)
|
||||||
m_ready_to_play = false;
|
m_ready_to_play = false;
|
||||||
if (m_using_memory_buffer == true)
|
if (m_using_memory_buffer == true)
|
||||||
@ -309,6 +312,8 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
setFFTSize(*getFloatParameter(2));
|
setFFTSize(*getFloatParameter(2));
|
||||||
m_ppar.pitch_shift.cents = *getFloatParameter(3) * 100.0;
|
m_ppar.pitch_shift.cents = *getFloatParameter(3) * 100.0;
|
||||||
m_ppar.freq_shift.Hz = *getFloatParameter(4);
|
m_ppar.freq_shift.Hz = *getFloatParameter(4);
|
||||||
|
m_ppar.spread.enabled = *getFloatParameter(8) > 0.0f;
|
||||||
|
m_ppar.spread.bandwidth = *getFloatParameter(8);
|
||||||
double t0 = *getFloatParameter(5);
|
double t0 = *getFloatParameter(5);
|
||||||
double t1 = *getFloatParameter(6);
|
double t1 = *getFloatParameter(6);
|
||||||
if (t0 > t1)
|
if (t0 > t1)
|
||||||
@ -358,9 +363,10 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
|||||||
{
|
{
|
||||||
ValueTree tree = ValueTree::readFromData(data, sizeInBytes);
|
ValueTree tree = ValueTree::readFromData(data, sizeInBytes);
|
||||||
if (tree.isValid())
|
if (tree.isValid())
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
std::lock_guard<std::mutex> locker(m_mutex);
|
||||||
for (int i = 0; i<getNumParameters(); ++i)
|
for (int i = 0; i < getNumParameters(); ++i)
|
||||||
{
|
{
|
||||||
auto par = getFloatParameter(i);
|
auto par = getFloatParameter(i);
|
||||||
if (par != nullptr)
|
if (par != nullptr)
|
||||||
@ -369,10 +375,10 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
|||||||
*par = parval;
|
*par = parval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String fn = tree.getProperty("importedfile");
|
String fn = tree.getProperty("importedfile");
|
||||||
if (fn.isEmpty() == false)
|
if (fn.isEmpty() == false)
|
||||||
{
|
{
|
||||||
m_using_memory_buffer = false;
|
|
||||||
File f(fn);
|
File f(fn);
|
||||||
setAudioFile(f);
|
setAudioFile(f);
|
||||||
}
|
}
|
||||||
@ -414,7 +420,6 @@ double PaulstretchpluginAudioProcessor::getRecordingPositionPercent()
|
|||||||
|
|
||||||
String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
|
||||||
auto ai = unique_from_raw(m_afm->createReaderFor(f));
|
auto ai = unique_from_raw(m_afm->createReaderFor(f));
|
||||||
if (ai != nullptr)
|
if (ai != nullptr)
|
||||||
{
|
{
|
||||||
@ -428,9 +433,10 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
|||||||
//MessageManager::callAsync([cb, file]() { cb("Too high bit depth in file " + file.getFullPathName()); });
|
//MessageManager::callAsync([cb, file]() { cb("Too high bit depth in file " + file.getFullPathName()); });
|
||||||
return "Too high bit depth in file " + f.getFullPathName();
|
return "Too high bit depth in file " + f.getFullPathName();
|
||||||
}
|
}
|
||||||
|
std::lock_guard<std::mutex> locker(m_mutex);
|
||||||
|
m_stretch_source->setAudioFile(f);
|
||||||
m_current_file = f;
|
m_current_file = f;
|
||||||
m_using_memory_buffer = false;
|
m_using_memory_buffer = false;
|
||||||
m_stretch_source->setAudioFile(f);
|
|
||||||
return String();
|
return String();
|
||||||
//MessageManager::callAsync([cb, file]() { cb(String()); });
|
//MessageManager::callAsync([cb, file]() { cb(String()); });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user