Rename member. Attempt clearing buffers more thoroughly but old audio still appears to be present when restarting playback...
This commit is contained in:
parent
f9cce79f49
commit
a6ec40904c
@ -41,18 +41,22 @@ void ProcessedStretch::set_parameters(ProcessParameters *ppar)
|
|||||||
}
|
}
|
||||||
void ProcessedStretch::setBufferSize(int sz)
|
void ProcessedStretch::setBufferSize(int sz)
|
||||||
{
|
{
|
||||||
|
jassert(sz > 0);
|
||||||
Stretch::setBufferSize(sz);
|
Stretch::setBufferSize(sz);
|
||||||
nfreq = bufsize;
|
//if (nfreq != sz)
|
||||||
infreq = floatvector(nfreq);
|
{
|
||||||
sumfreq = floatvector(nfreq);
|
nfreq = bufsize;
|
||||||
tmpfreq1 = floatvector(nfreq);
|
infreq = floatvector(nfreq);
|
||||||
tmpfreq2 = floatvector(nfreq);
|
sumfreq = floatvector(nfreq);
|
||||||
//fbfreq=new REALTYPE[nfreq];
|
tmpfreq1 = floatvector(nfreq);
|
||||||
free_filter_freqs = floatvector(nfreq);
|
tmpfreq2 = floatvector(nfreq);
|
||||||
for (int i = 0; i<nfreq; i++) {
|
//fbfreq=new REALTYPE[nfreq];
|
||||||
free_filter_freqs[i] = 1.0;
|
free_filter_freqs = floatvector(nfreq);
|
||||||
// fbfreq[i]=0.0;
|
for (int i = 0; i < nfreq; i++) {
|
||||||
};
|
free_filter_freqs[i] = 1.0;
|
||||||
|
// fbfreq[i]=0.0;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,14 +237,15 @@ void Stretch::setBufferSize(int bufsize_)
|
|||||||
outfft = std::make_unique<FFT>(bufsize * 2);
|
outfft = std::make_unique<FFT>(bufsize * 2);
|
||||||
}
|
}
|
||||||
jassert(infft != nullptr && fft != nullptr && outfft != nullptr);
|
jassert(infft != nullptr && fft != nullptr && outfft != nullptr);
|
||||||
|
fill_container(outfft->smp, 0.0f);
|
||||||
for (int i = 0; i<bufsize * 2; i++) {
|
for (int i = 0; i<bufsize * 2; i++) {
|
||||||
old_out_smps[i] = 0.0;
|
old_out_smps[i] = 0.0;
|
||||||
};
|
};
|
||||||
for (int i = 0; i<bufsize; i++) {
|
for (int i = 0; i<bufsize; i++) {
|
||||||
old_freq[i] = 0.0;
|
old_freq[i] = 0.0f;
|
||||||
new_smps[i] = 0.0;
|
new_smps[i] = 0.0f;
|
||||||
old_smps[i] = 0.0;
|
old_smps[i] = 0.0f;
|
||||||
very_old_smps[i] = 0.0;
|
very_old_smps[i] = 0.0f;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,6 +439,7 @@ void StretchAudioSource::initObjects()
|
|||||||
m_stretchers[i]->set_onset_detection_sensitivity(onsetsens);
|
m_stretchers[i]->set_onset_detection_sensitivity(onsetsens);
|
||||||
m_stretchers[i]->set_parameters(&m_ppar);
|
m_stretchers[i]->set_parameters(&m_ppar);
|
||||||
m_stretchers[i]->set_freezing(m_freezing);
|
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_stretchers[i]->m_spectrum_processes = m_specproc_order;
|
||||||
}
|
}
|
||||||
m_inbufs.resize(m_num_outchans);
|
m_inbufs.resize(m_num_outchans);
|
||||||
|
@ -187,3 +187,9 @@ private:
|
|||||||
int m_avail = 0;
|
int m_avail = 0;
|
||||||
std::vector<T> m_buf;
|
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);
|
||||||
|
}
|
||||||
|
@ -192,13 +192,13 @@ void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
|
|||||||
m_prebuffer_amount = temp;
|
m_prebuffer_amount = temp;
|
||||||
m_recreate_buffering_source = true;
|
m_recreate_buffering_source = true;
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
m_ready_to_play = false;
|
m_prebuffering_inited = false;
|
||||||
m_cur_num_out_chans = *m_outchansparam;
|
m_cur_num_out_chans = *m_outchansparam;
|
||||||
//Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels");
|
//Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels");
|
||||||
String err;
|
String err;
|
||||||
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
||||||
m_cur_num_out_chans, m_curmaxblocksize, err);
|
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);
|
m_input_buffer.setSize(2, samplesPerBlock);
|
||||||
int numoutchans = *m_outchansparam;
|
int numoutchans = *m_outchansparam;
|
||||||
if (numoutchans != m_cur_num_out_chans)
|
if (numoutchans != m_cur_num_out_chans)
|
||||||
m_ready_to_play = false;
|
m_prebuffering_inited = false;
|
||||||
if (m_using_memory_buffer == true)
|
if (m_using_memory_buffer == true)
|
||||||
{
|
{
|
||||||
int len = jlimit(100,m_recbuffer.getNumSamples(),
|
int len = jlimit(100,m_recbuffer.getNumSamples(),
|
||||||
@ -331,7 +331,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
|||||||
len);
|
len);
|
||||||
callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRateChecked(), len); },false);
|
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));
|
setFFTSize(*getFloatParameter(cpi_fftsize));
|
||||||
m_stretch_source->setProcessParameters(&m_ppar);
|
m_stretch_source->setProcessParameters(&m_ppar);
|
||||||
@ -340,9 +340,12 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
|||||||
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
||||||
numoutchans, samplesPerBlock, err);
|
numoutchans, samplesPerBlock, err);
|
||||||
m_cur_num_out_chans = numoutchans;
|
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()
|
void PaulstretchpluginAudioProcessor::releaseResources()
|
||||||
@ -412,7 +415,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples());
|
m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples());
|
||||||
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
|
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
|
||||||
buffer.clear (i, 0, buffer.getNumSamples());
|
buffer.clear (i, 0, buffer.getNumSamples());
|
||||||
if (m_ready_to_play == false)
|
if (m_prebuffering_inited == false)
|
||||||
return;
|
return;
|
||||||
if (m_is_recording == true)
|
if (m_is_recording == true)
|
||||||
{
|
{
|
||||||
@ -698,13 +701,13 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id)
|
|||||||
{
|
{
|
||||||
jassert(m_curmaxblocksize > 0);
|
jassert(m_curmaxblocksize > 0);
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
m_ready_to_play = false;
|
m_prebuffering_inited = false;
|
||||||
m_cur_num_out_chans = *m_outchansparam;
|
m_cur_num_out_chans = *m_outchansparam;
|
||||||
//Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels");
|
//Logger::writeToLog("Switching to use " + String(m_cur_num_out_chans) + " out channels");
|
||||||
String err;
|
String err;
|
||||||
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) },
|
||||||
m_cur_num_out_chans, m_curmaxblocksize, err);
|
m_cur_num_out_chans, m_curmaxblocksize, err);
|
||||||
m_ready_to_play = true;
|
m_prebuffering_inited = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
bool m_ready_to_play = false;
|
bool m_prebuffering_inited = false;
|
||||||
AudioBuffer<float> m_recbuffer;
|
AudioBuffer<float> m_recbuffer;
|
||||||
double m_max_reclen = 10.0;
|
double m_max_reclen = 10.0;
|
||||||
bool m_is_recording = false;
|
bool m_is_recording = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user