Preliminary work to enable multichannel output again with a parameter to determine the output channels to render
This commit is contained in:
parent
71a9419e51
commit
d05a5d41a8
@ -61,16 +61,21 @@ inline void attachCallback(Button& button, std::function<void()> callback)
|
||||
class MySlider : public Slider
|
||||
{
|
||||
public:
|
||||
MySlider() {}
|
||||
MySlider(NormalisableRange<float>* range) : m_range(range)
|
||||
{
|
||||
}
|
||||
double proportionOfLengthToValue(double x) override
|
||||
{
|
||||
return m_range->convertFrom0to1(x);
|
||||
if (m_range)
|
||||
return m_range->convertFrom0to1(x);
|
||||
return Slider::proportionOfLengthToValue(x);
|
||||
}
|
||||
double valueToProportionOfLength(double x) override
|
||||
{
|
||||
return m_range->convertTo0to1(x);
|
||||
if (m_range)
|
||||
return m_range->convertTo0to1(x);
|
||||
return Slider::valueToProportionOfLength(x);
|
||||
}
|
||||
private:
|
||||
NormalisableRange<float>* m_range = nullptr;
|
||||
@ -94,6 +99,16 @@ public:
|
||||
m_slider->addListener(this);
|
||||
addAndMakeVisible(m_slider.get());
|
||||
}
|
||||
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(par);
|
||||
if (intpar)
|
||||
{
|
||||
m_slider = std::make_unique<MySlider>();
|
||||
m_notify_only_on_release = notifyOnlyOnRelease;
|
||||
m_slider->setRange(intpar->getRange().getStart(), intpar->getRange().getEnd(), 1.0);
|
||||
m_slider->setValue(*intpar, dontSendNotification);
|
||||
m_slider->addListener(this);
|
||||
addAndMakeVisible(m_slider.get());
|
||||
}
|
||||
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(par);
|
||||
if (choicepar)
|
||||
{
|
||||
@ -121,7 +136,11 @@ public:
|
||||
if (m_notify_only_on_release == true)
|
||||
return;
|
||||
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
||||
*floatpar = slid->getValue();
|
||||
if (floatpar!=nullptr)
|
||||
*floatpar = slid->getValue();
|
||||
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
||||
if (intpar != nullptr)
|
||||
*intpar = slid->getValue();
|
||||
}
|
||||
void sliderDragStarted(Slider* slid) override
|
||||
{
|
||||
@ -133,7 +152,11 @@ public:
|
||||
if (m_notify_only_on_release == false)
|
||||
return;
|
||||
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
||||
*floatpar = slid->getValue();
|
||||
if (floatpar!=nullptr)
|
||||
*floatpar = slid->getValue();
|
||||
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
||||
if (intpar != nullptr)
|
||||
*intpar = slid->getValue();
|
||||
}
|
||||
void buttonClicked(Button* but) override
|
||||
{
|
||||
@ -146,10 +169,15 @@ public:
|
||||
void updateComponent()
|
||||
{
|
||||
AudioParameterFloat* floatpar = dynamic_cast<AudioParameterFloat*>(m_par);
|
||||
if (m_slider != nullptr && m_dragging == false && (float)m_slider->getValue() != *floatpar)
|
||||
if (floatpar!=nullptr && m_slider != nullptr && m_dragging == false && (float)m_slider->getValue() != *floatpar)
|
||||
{
|
||||
m_slider->setValue(*floatpar, dontSendNotification);
|
||||
}
|
||||
AudioParameterInt* intpar = dynamic_cast<AudioParameterInt*>(m_par);
|
||||
if (intpar != nullptr && m_slider != nullptr && m_dragging == false && (int)m_slider->getValue() != *intpar)
|
||||
{
|
||||
m_slider->setValue(*intpar, dontSendNotification);
|
||||
}
|
||||
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
||||
if (m_togglebut != nullptr && m_togglebut->getToggleState() != *boolpar)
|
||||
{
|
||||
|
@ -115,6 +115,8 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
addParameter(new AudioParameterFloat("filter_high_0", "Filter high", 20.0f, 20000.0f, 20000.0f)); // 24
|
||||
addParameter(new AudioParameterFloat("onsetdetect_0", "Onset detection", 0.0f, 1.0f, 0.0f)); // 25
|
||||
addParameter(new AudioParameterBool("capture_enabled0", "Capture", false)); // 26
|
||||
m_outchansparam = new AudioParameterInt("numoutchans0", "Num output channels", 1, 8, 2);
|
||||
addParameter(m_outchansparam); // 27
|
||||
startTimer(1, 50);
|
||||
}
|
||||
|
||||
@ -234,7 +236,8 @@ void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int num
|
||||
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
||||
{
|
||||
ScopedLock locker(m_cs);
|
||||
if (getNumOutputChannels() != m_cur_num_out_chans)
|
||||
int numoutchans = *m_outchansparam;
|
||||
if (numoutchans != m_cur_num_out_chans)
|
||||
m_ready_to_play = false;
|
||||
if (m_using_memory_buffer == true)
|
||||
{
|
||||
@ -251,8 +254,8 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
|
||||
String err;
|
||||
startplay({ *getFloatParameter(5),*getFloatParameter(6) },
|
||||
2, err);
|
||||
m_cur_num_out_chans = getNumOutputChannels();
|
||||
numoutchans, err);
|
||||
m_cur_num_out_chans = numoutchans;
|
||||
m_ready_to_play = true;
|
||||
}
|
||||
}
|
||||
@ -393,6 +396,7 @@ void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData
|
||||
paramtree.setProperty(par->paramID, (double)*par, nullptr);
|
||||
}
|
||||
}
|
||||
paramtree.setProperty(m_outchansparam->paramID, (int)*m_outchansparam, nullptr);
|
||||
if (m_current_file != File())
|
||||
{
|
||||
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
|
||||
@ -417,6 +421,9 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
||||
*par = parval;
|
||||
}
|
||||
}
|
||||
if (tree.hasProperty(m_outchansparam->paramID))
|
||||
*m_outchansparam = tree.getProperty(m_outchansparam->paramID, 2);
|
||||
|
||||
}
|
||||
String fn = tree.getProperty("importedfile");
|
||||
if (fn.isEmpty() == false)
|
||||
|
@ -42,6 +42,7 @@ const int cpi_filter_low = 23;
|
||||
const int cpi_filter_high = 24;
|
||||
const int cpi_onsetdetection = 25;
|
||||
const int cpi_capture_enabled = 26;
|
||||
const int cpi_num_outchans = 27;
|
||||
|
||||
class PaulstretchpluginAudioProcessor : public AudioProcessor, public MultiTimer
|
||||
{
|
||||
@ -126,6 +127,7 @@ private:
|
||||
void setFFTSize(double size);
|
||||
void startplay(Range<double> playrange, int numoutchans, String& err);
|
||||
SharedResourcePointer<MyThumbCache> m_thumbcache;
|
||||
AudioParameterInt* m_outchansparam = nullptr;
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user