Rename member. Attempt clearing buffers more thoroughly but old audio still appears to be present when restarting playback...

This commit is contained in:
xenakios 2017-12-27 17:35:30 +02:00
parent f9cce79f49
commit a6ec40904c
6 changed files with 40 additions and 25 deletions

View File

@ -41,7 +41,10 @@ void ProcessedStretch::set_parameters(ProcessParameters *ppar)
}
void ProcessedStretch::setBufferSize(int sz)
{
jassert(sz > 0);
Stretch::setBufferSize(sz);
//if (nfreq != sz)
{
nfreq = bufsize;
infreq = floatvector(nfreq);
sumfreq = floatvector(nfreq);
@ -54,6 +57,7 @@ void ProcessedStretch::setBufferSize(int sz)
// fbfreq[i]=0.0;
};
}
}
/*

View File

@ -237,14 +237,15 @@ void Stretch::setBufferSize(int bufsize_)
outfft = std::make_unique<FFT>(bufsize * 2);
}
jassert(infft != nullptr && fft != nullptr && outfft != nullptr);
fill_container(outfft->smp, 0.0f);
for (int i = 0; i<bufsize * 2; i++) {
old_out_smps[i] = 0.0;
};
for (int i = 0; i<bufsize; i++) {
old_freq[i] = 0.0;
new_smps[i] = 0.0;
old_smps[i] = 0.0;
very_old_smps[i] = 0.0;
old_freq[i] = 0.0f;
new_smps[i] = 0.0f;
old_smps[i] = 0.0f;
very_old_smps[i] = 0.0f;
};
}

View File

@ -439,6 +439,7 @@ void StretchAudioSource::initObjects()
m_stretchers[i]->set_onset_detection_sensitivity(onsetsens);
m_stretchers[i]->set_parameters(&m_ppar);
m_stretchers[i]->set_freezing(m_freezing);
fill_container(m_stretchers[i]->out_buf, 0.0f);
m_stretchers[i]->m_spectrum_processes = m_specproc_order;
}
m_inbufs.resize(m_num_outchans);

View File

@ -187,3 +187,9 @@ private:
int m_avail = 0;
std::vector<T> m_buf;
};
template<typename Cont,typename T>
inline void fill_container(Cont& c, const T& x)
{
std::fill(std::begin(c), std::end(c), x);
}

View File

@ -192,13 +192,13 @@ void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
m_prebuffer_amount = temp;
m_recreate_buffering_source = true;
ScopedLock locker(m_cs);
m_ready_to_play = false;
m_prebuffering_inited = 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, m_curmaxblocksize, err);
m_ready_to_play = true;
m_prebuffering_inited = true;
}
}
@ -321,7 +321,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
m_input_buffer.setSize(2, samplesPerBlock);
int numoutchans = *m_outchansparam;
if (numoutchans != m_cur_num_out_chans)
m_ready_to_play = false;
m_prebuffering_inited = false;
if (m_using_memory_buffer == true)
{
int len = jlimit(100,m_recbuffer.getNumSamples(),
@ -331,7 +331,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
len);
callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRateChecked(), len); },false);
}
if (m_ready_to_play == false)
if (m_prebuffering_inited == false)
{
setFFTSize(*getFloatParameter(cpi_fftsize));
m_stretch_source->setProcessParameters(&m_ppar);
@ -340,9 +340,12 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
numoutchans, samplesPerBlock, err);
m_cur_num_out_chans = numoutchans;
m_ready_to_play = true;
m_prebuffering_inited = true;
}
else
{
m_buffering_source->prepareToPlay(samplesPerBlock, getSampleRateChecked());
}
}
void PaulstretchpluginAudioProcessor::releaseResources()
@ -412,7 +415,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples());
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
if (m_ready_to_play == false)
if (m_prebuffering_inited == false)
return;
if (m_is_recording == true)
{
@ -698,13 +701,13 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id)
{
jassert(m_curmaxblocksize > 0);
ScopedLock locker(m_cs);
m_ready_to_play = false;
m_prebuffering_inited = 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, m_curmaxblocksize, err);
m_ready_to_play = true;
m_prebuffering_inited = true;
}
}
}

View File

@ -148,7 +148,7 @@ public:
private:
bool m_ready_to_play = false;
bool m_prebuffering_inited = false;
AudioBuffer<float> m_recbuffer;
double m_max_reclen = 10.0;
bool m_is_recording = false;