Support resampled playrate changes for non stretched playback
This commit is contained in:
@ -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)
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
double getLoopXFadeLengtj() const { return m_loopxfadelen; }
|
||||
void setPreviewDry(bool b);
|
||||
bool isPreviewingDry() const;
|
||||
void setDryPlayrate(double rate);
|
||||
double getDryPlayrate() const;
|
||||
int m_param_change_count = 0;
|
||||
double getLastSeekPos() const { return m_seekpos; }
|
||||
CriticalSection* getMutex() { return &m_cs; }
|
||||
@ -163,6 +165,7 @@ private:
|
||||
} m_xfadetask;
|
||||
int m_pause_fade_counter = 0;
|
||||
bool m_preview_dry = false;
|
||||
double m_dryplayrate = 1.0;
|
||||
AudioBuffer<float> m_drypreviewbuf;
|
||||
void playDrySound(const AudioSourceChannelInfo & bufferToFill);
|
||||
};
|
||||
|
Reference in New Issue
Block a user