Support resampled playrate changes for non stretched playback

This commit is contained in:
xenakios
2018-08-20 15:49:51 +03:00
parent d0f912ba1f
commit 8d008e5d2e
6 changed files with 29 additions and 3 deletions

View File

@ -269,6 +269,23 @@ bool StretchAudioSource::isPreviewingDry() const
return m_preview_dry;
}
void StretchAudioSource::setDryPlayrate(double rate)
{
if (rate == m_dryplayrate)
return;
if (m_cs.tryEnter())
{
m_dryplayrate = rate;
++m_param_change_count;
m_cs.exit();
}
}
double StretchAudioSource::getDryPlayrate() const
{
return m_dryplayrate;
}
void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill)
{
ScopedLock locker(m_cs);
@ -568,7 +585,7 @@ void StretchAudioSource::playDrySound(const AudioSourceChannelInfo & bufferToFil
double maingain = Decibels::decibelsToGain(m_main_volume);
m_inputfile->setXFadeLenSeconds(m_loopxfadelen);
double* rsinbuf = nullptr;
m_resampler->SetRates(m_inputfile->info.samplerate, m_outsr);
m_resampler->SetRates(m_inputfile->info.samplerate*m_dryplayrate, m_outsr);
int wanted = m_resampler->ResamplePrepare(bufferToFill.numSamples, m_num_outchans, &rsinbuf);
m_inputfile->readNextBlock(m_drypreviewbuf, wanted, m_num_outchans);
for (int i = 0; i < wanted; ++i)