Finally support changing FFT size. This however doesn't now use the double stretch source thing, so glitches will probably happen... Parameter component was changed to support changing the parameter value only on mouse releasee etc

This commit is contained in:
xenakios 2017-11-17 16:41:33 +02:00
parent 3cdc6eabd6
commit 6aa514f52b
4 changed files with 35 additions and 10 deletions

View File

@ -437,10 +437,11 @@ void StretchAudioSource::setFFTWindowingType(int windowtype)
void StretchAudioSource::setFFTSize(int size)
{
jassert(size>0);
if (size != m_process_fftsize)
if (m_process_fftsize == 0 || size != m_process_fftsize)
{
m_process_fftsize = size;
initObjects();
++m_param_change_count;
}
}

View File

@ -28,8 +28,16 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (Pa
const auto& pars = processor.getParameters();
for (int i=0;i<pars.size();++i)
{
m_parcomps.push_back(std::make_shared<ParameterComponent>(pars[i]));
addAndMakeVisible(m_parcomps.back().get());
AudioProcessorParameterWithID* parid = dynamic_cast<AudioProcessorParameterWithID*>(pars[i]);
jassert(parid);
if (parid)
{
bool notifyonlyonrelease = false;
if (parid->paramID.startsWith("fftsize"))
notifyonlyonrelease = true;
m_parcomps.push_back(std::make_shared<ParameterComponent>(pars[i],notifyonlyonrelease));
addAndMakeVisible(m_parcomps.back().get());
}
}
addAndMakeVisible(&m_rec_enable);
m_rec_enable.setButtonText("Capture");
@ -90,9 +98,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent());
} else
m_wavecomponent.setRecordingPosition(-1.0);
//m_info_label.setText(String(processor.m_control->getStretchAudioSource()->m_param_change_count), dontSendNotification);
double prebufavail=processor.m_control->getPreBufferingPercent();
m_info_label.setText(String(prebufavail,1), dontSendNotification);
String infotext = String(processor.m_control->getPreBufferingPercent(), 1) + " " + String(processor.m_control->getStretchAudioSource()->m_param_change_count);
m_info_label.setText(infotext, dontSendNotification);
}
if (id == 2)
{

View File

@ -47,7 +47,7 @@ class ParameterComponent : public Component,
public Slider::Listener, public Button::Listener
{
public:
ParameterComponent(AudioProcessorParameter* par) : m_par(par)
ParameterComponent(AudioProcessorParameter* par, bool notifyOnlyOnRelease) : m_par(par)
{
addAndMakeVisible(&m_label);
m_label.setText(par->getName(50),dontSendNotification);
@ -55,6 +55,7 @@ public:
if (floatpar)
{
m_slider = std::make_unique<Slider>();
m_notify_only_on_release = notifyOnlyOnRelease;
m_slider->setRange(floatpar->range.start, floatpar->range.end, floatpar->range.interval);
m_slider->setValue(*floatpar, dontSendNotification);
m_slider->addListener(this);
@ -84,6 +85,20 @@ public:
}
void sliderValueChanged(Slider* slid) override
{
if (m_notify_only_on_release == true)
return;
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
*floatpar = slid->getValue();
}
void sliderDragStarted(Slider* slid) override
{
m_dragging = true;
}
void sliderDragEnded(Slider* slid) override
{
m_dragging = false;
if (m_notify_only_on_release == false)
return;
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
*floatpar = slid->getValue();
}
@ -98,7 +113,7 @@ public:
void updateComponent()
{
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
if (m_slider != nullptr && (float)m_slider->getValue() != *floatpar)
if (m_slider != nullptr && m_dragging == false && (float)m_slider->getValue() != *floatpar)
{
m_slider->setValue(*floatpar, dontSendNotification);
}
@ -114,6 +129,8 @@ private:
std::unique_ptr<Slider> m_slider;
std::unique_ptr<ComboBox> m_combobox;
std::unique_ptr<ToggleButton> m_togglebut;
bool m_notify_only_on_release = false;
bool m_dragging = false;
};
class WaveformComponent : public Component, public ChangeListener, public Timer

View File

@ -235,7 +235,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
m_control->getStretchAudioSource()->val_MainVolume = (float)*getFloatParameter(0);
m_control->getStretchAudioSource()->setRate(*getFloatParameter(1));
m_control->getStretchAudioSource()->val_XFadeLen = 0.1;
//m_control->setFFTSize(*getFloatParameter(2));
m_control->setFFTSize(*getFloatParameter(2));
m_control->ppar.pitch_shift.cents = *getFloatParameter(3) * 100.0;
m_control->ppar.freq_shift.Hz = *getFloatParameter(4);
double t0 = *getFloatParameter(5);