mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Merge: Less shimmer and maybe less CPU in display updates for scroll-scrub
This commit is contained in:
commit
c5f9d94a84
@ -325,7 +325,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Matches(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
bool Matches(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
||||||
const SpectrogramSettings &settings) const;
|
const SpectrogramSettings &settings, double rate) const;
|
||||||
|
|
||||||
void CalculateOneSpectrum
|
void CalculateOneSpectrum
|
||||||
(const SpectrogramSettings &settings,
|
(const SpectrogramSettings &settings,
|
||||||
@ -602,11 +602,20 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
|||||||
|
|
||||||
ODLocker locker(mWaveCacheMutex);
|
ODLocker locker(mWaveCacheMutex);
|
||||||
|
|
||||||
|
const double tstep = 1.0 / pixelsPerSecond;
|
||||||
|
const double samplesPerPixel = mRate * tstep;
|
||||||
|
|
||||||
|
// Make a tolerant comparison of the pps values in this wise:
|
||||||
|
// accumulated difference of times over the number of pixels is less than
|
||||||
|
// a sample period.
|
||||||
|
const bool ppsMatch = mWaveCache &&
|
||||||
|
(fabs(tstep - 1.0 / mWaveCache->pps) * numPixels < (1.0 / mRate));
|
||||||
|
|
||||||
const bool match =
|
const bool match =
|
||||||
mWaveCache &&
|
mWaveCache &&
|
||||||
|
ppsMatch &&
|
||||||
mWaveCache->len > 0 &&
|
mWaveCache->len > 0 &&
|
||||||
mWaveCache->dirty == mDirty &&
|
mWaveCache->dirty == mDirty;
|
||||||
mWaveCache->pps == pixelsPerSecond;
|
|
||||||
|
|
||||||
if (match &&
|
if (match &&
|
||||||
mWaveCache->start == t0 &&
|
mWaveCache->start == t0 &&
|
||||||
@ -627,9 +636,6 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
|||||||
std::auto_ptr<WaveCache> oldCache(mWaveCache);
|
std::auto_ptr<WaveCache> oldCache(mWaveCache);
|
||||||
mWaveCache = 0;
|
mWaveCache = 0;
|
||||||
|
|
||||||
const double tstep = 1.0 / pixelsPerSecond;
|
|
||||||
const double samplesPerPixel = mRate * tstep;
|
|
||||||
|
|
||||||
int oldX0 = 0;
|
int oldX0 = 0;
|
||||||
double correction = 0.0;
|
double correction = 0.0;
|
||||||
|
|
||||||
@ -811,9 +817,17 @@ void ComputeSpectrogramGainFactors
|
|||||||
|
|
||||||
bool SpecCache::Matches
|
bool SpecCache::Matches
|
||||||
(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
||||||
const SpectrogramSettings &settings) const
|
const SpectrogramSettings &settings, double rate) const
|
||||||
{
|
{
|
||||||
|
// Make a tolerant comparison of the pps values in this wise:
|
||||||
|
// accumulated difference of times over the number of pixels is less than
|
||||||
|
// a sample period.
|
||||||
|
const double tstep = 1.0 / pixelsPerSecond;
|
||||||
|
const bool ppsMatch =
|
||||||
|
(fabs(tstep - 1.0 / pps) * len < (1.0 / rate));
|
||||||
|
|
||||||
return
|
return
|
||||||
|
ppsMatch &&
|
||||||
dirty == dirty_ &&
|
dirty == dirty_ &&
|
||||||
windowType == settings.windowType &&
|
windowType == settings.windowType &&
|
||||||
windowSize == settings.windowSize &&
|
windowSize == settings.windowSize &&
|
||||||
@ -822,8 +836,7 @@ bool SpecCache::Matches
|
|||||||
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
|
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
|
||||||
fftSkipPoints == settings.fftSkipPoints &&
|
fftSkipPoints == settings.fftSkipPoints &&
|
||||||
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
|
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
|
||||||
ac == autocorrelation &&
|
ac == autocorrelation;
|
||||||
pps == pixelsPerSecond;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecCache::CalculateOneSpectrum
|
void SpecCache::CalculateOneSpectrum
|
||||||
@ -1017,7 +1030,8 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
|
|||||||
const bool match =
|
const bool match =
|
||||||
mSpecCache &&
|
mSpecCache &&
|
||||||
mSpecCache->len > 0 &&
|
mSpecCache->len > 0 &&
|
||||||
mSpecCache->Matches(mDirty, autocorrelation, pixelsPerSecond, settings);
|
mSpecCache->Matches
|
||||||
|
(mDirty, autocorrelation, pixelsPerSecond, settings, mRate);
|
||||||
|
|
||||||
if (match &&
|
if (match &&
|
||||||
mSpecCache->start == t0 &&
|
mSpecCache->start == t0 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user