From 40096fc87d1fc4539f13dec7c22d9bb784213286 Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 14 Dec 2017 19:06:26 +0200 Subject: [PATCH] Propagate host provided maximum block size to buffering audio source --- Source/PluginProcessor.cpp | 10 ++++++---- Source/PluginProcessor.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 63c892b..98d9cd0 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -210,7 +210,7 @@ void PaulstretchpluginAudioProcessor::setFFTSize(double size) //Logger::writeToLog(String(m_fft_size_to_use)); } -void PaulstretchpluginAudioProcessor::startplay(Range playrange, int numoutchans, String& err) +void PaulstretchpluginAudioProcessor::startplay(Range playrange, int numoutchans, int maxBlockSize, String& err) { m_stretch_source->setPlayRange(playrange, true); @@ -231,12 +231,13 @@ 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, getSampleRate()); + m_buffering_source->prepareToPlay(maxBlockSize, getSampleRate()); }; void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) { ScopedLock locker(m_cs); + m_curmaxblocksize = samplesPerBlock; int numoutchans = *m_outchansparam; if (numoutchans != m_cur_num_out_chans) m_ready_to_play = false; @@ -255,7 +256,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl String err; startplay({ *getFloatParameter(5),*getFloatParameter(6) }, - numoutchans, err); + numoutchans, samplesPerBlock, err); m_cur_num_out_chans = numoutchans; m_ready_to_play = true; } @@ -527,13 +528,14 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id) } if (m_cur_num_out_chans != *m_outchansparam) { + jassert(m_curmaxblocksize > 0); 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_cur_num_out_chans, m_curmaxblocksize, err); m_ready_to_play = true; } } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index af2a47d..4a78b9c 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -125,9 +125,10 @@ private: ProcessParameters m_ppar; void setPreBufferAmount(int x); void setFFTSize(double size); - void startplay(Range playrange, int numoutchans, String& err); + void startplay(Range playrange, int numoutchans, int maxBlockSize, String& err); SharedResourcePointer m_thumbcache; AudioParameterInt* m_outchansparam = nullptr; + int m_curmaxblocksize = 0; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) };