From 76880a8d5f12a49060eff54c09818757a3c882df Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 14 Dec 2017 00:44:46 +0200 Subject: [PATCH] Update output channel count on the fly. Somewhat hacky... --- Source/PluginEditor.cpp | 2 ++ Source/PluginProcessor.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index ee9cd55..c00a5f0 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -35,6 +35,8 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (Pa bool notifyonlyonrelease = false; if (parid->paramID.startsWith("fftsize")) notifyonlyonrelease = true; + if (parid->paramID.startsWith("numoutchans")) + notifyonlyonrelease = true; m_parcomps.push_back(std::make_shared(pars[i],notifyonlyonrelease)); addAndMakeVisible(m_parcomps.back().get()); } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 2c2566e..18dbf1e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -230,7 +230,7 @@ void PaulstretchpluginAudioProcessor::startplay(Range playrange, int num m_stretch_source->setProcessParameters(&m_ppar); m_last_outpos_pos = 0.0; m_last_in_pos = playrange.getStart()*m_stretch_source->getInfileLengthSeconds(); - m_buffering_source->prepareToPlay(1024, 44100.0); + m_buffering_source->prepareToPlay(1024, getSampleRate()); }; void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) @@ -521,7 +521,17 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id) setRecordingEnabled(false); return; } - + if (m_cur_num_out_chans != *m_outchansparam) + { + ScopedLock locker(m_cs); + m_ready_to_play = false; + m_cur_num_out_chans = *m_outchansparam; + //Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels"); + String err; + startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) }, + m_cur_num_out_chans, err); + m_ready_to_play = true; + } } }