mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-24 16:20:05 +02:00
simplify argument passing for drawing pitch views
This commit is contained in:
parent
b2e04909dc
commit
5aba06a8a2
@ -2065,7 +2065,6 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
|
||||
const WaveTrack *const track = waveTrackCache.GetTrack();
|
||||
const SpectrogramSettings &settings = track->GetSpectrogramSettings();
|
||||
|
||||
const bool autocorrelation = (settings.algorithm == SpectrogramSettings::algPitchEAC);
|
||||
|
||||
enum { DASH_LENGTH = 10 /* pixels */ };
|
||||
@ -2131,7 +2130,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
{
|
||||
const double pps = averagePixelsPerSample * rate;
|
||||
updated = clip->GetSpectrogram(waveTrackCache, freq, where, hiddenMid.width,
|
||||
t0, pps, autocorrelation);
|
||||
t0, pps);
|
||||
}
|
||||
|
||||
// Legacy special-case treatment of log scale
|
||||
@ -2364,7 +2363,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
const int numPixels = std::max(0, end - begin);
|
||||
const int zeroPaddingFactor = autocorrelation ? 1 : settings.zeroPaddingFactor;
|
||||
SpecCache specCache
|
||||
(numPixels, autocorrelation, -1,
|
||||
(numPixels, settings.algorithm, -1,
|
||||
t0, settings.windowType,
|
||||
settings.windowSize, zeroPaddingFactor, settings.frequencyGain);
|
||||
if (numPixels > 0) {
|
||||
@ -2376,8 +2375,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
(settings, waveTrackCache,
|
||||
0, 0, numPixels,
|
||||
clip->GetNumSamples(),
|
||||
tOffset, rate,
|
||||
autocorrelation);
|
||||
tOffset, rate);
|
||||
}
|
||||
|
||||
int correctedX = leftOffset - hiddenLeftOffset;
|
||||
|
@ -764,7 +764,7 @@ void ComputeSpectrogramGainFactors
|
||||
}
|
||||
|
||||
bool SpecCache::Matches
|
||||
(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
||||
(int dirty_, double pixelsPerSecond,
|
||||
const SpectrogramSettings &settings, double rate) const
|
||||
{
|
||||
// Make a tolerant comparison of the pps values in this wise:
|
||||
@ -781,7 +781,7 @@ bool SpecCache::Matches
|
||||
windowSize == settings.windowSize &&
|
||||
zeroPaddingFactor == settings.zeroPaddingFactor &&
|
||||
frequencyGain == settings.frequencyGain &&
|
||||
ac == autocorrelation;
|
||||
algorithm == settings.algorithm;
|
||||
}
|
||||
|
||||
void SpecCache::CalculateOneSpectrum
|
||||
@ -871,8 +871,7 @@ void SpecCache::Populate
|
||||
(const SpectrogramSettings &settings, WaveTrackCache &waveTrackCache,
|
||||
int copyBegin, int copyEnd, int numPixels,
|
||||
sampleCount numSamples,
|
||||
double offset, double rate,
|
||||
bool autocorrelation)
|
||||
double offset, double rate)
|
||||
{
|
||||
#ifdef EXPERIMENTAL_USE_REALFFTF
|
||||
settings.CacheWindows();
|
||||
@ -880,6 +879,8 @@ void SpecCache::Populate
|
||||
|
||||
const int &frequencyGain = settings.frequencyGain;
|
||||
const int &windowSize = settings.windowSize;
|
||||
const bool autocorrelation =
|
||||
settings.algorithm == SpectrogramSettings::algPitchEAC;
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
const int &zeroPaddingFactor = autocorrelation ? 1 : settings.zeroPaddingFactor;
|
||||
#else
|
||||
@ -912,11 +913,12 @@ void SpecCache::Populate
|
||||
bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
|
||||
const float *& spectrogram, const sampleCount *& where,
|
||||
int numPixels,
|
||||
double t0, double pixelsPerSecond,
|
||||
bool autocorrelation)
|
||||
double t0, double pixelsPerSecond)
|
||||
{
|
||||
const WaveTrack *const track = waveTrackCache.GetTrack();
|
||||
const SpectrogramSettings &settings = track->GetSpectrogramSettings();
|
||||
const bool autocorrelation =
|
||||
settings.algorithm == SpectrogramSettings::algPitchEAC;
|
||||
const int &frequencyGain = settings.frequencyGain;
|
||||
const int &windowSize = settings.windowSize;
|
||||
const int &windowType = settings.windowType;
|
||||
@ -935,7 +937,7 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
|
||||
mSpecCache &&
|
||||
mSpecCache->len > 0 &&
|
||||
mSpecCache->Matches
|
||||
(mDirty, autocorrelation, pixelsPerSecond, settings, mRate);
|
||||
(mDirty, pixelsPerSecond, settings, mRate);
|
||||
|
||||
if (match &&
|
||||
mSpecCache->start == t0 &&
|
||||
@ -972,9 +974,8 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
|
||||
oldCache.reset(0);
|
||||
|
||||
mSpecCache = new SpecCache(
|
||||
numPixels, autocorrelation, pixelsPerSecond, t0,
|
||||
windowType, windowSize, zeroPaddingFactor, frequencyGain
|
||||
);
|
||||
numPixels, settings.algorithm, pixelsPerSecond, t0,
|
||||
windowType, windowSize, zeroPaddingFactor, frequencyGain);
|
||||
|
||||
fillWhere(mSpecCache->where, numPixels, 0.5, correction,
|
||||
t0, mRate, samplesPerPixel);
|
||||
@ -990,7 +991,7 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
|
||||
|
||||
mSpecCache->Populate
|
||||
(settings, waveTrackCache, copyBegin, copyEnd, numPixels,
|
||||
mSequence->GetNumSamples(), mOffset, mRate, autocorrelation);
|
||||
mSequence->GetNumSamples(), mOffset, mRate);
|
||||
|
||||
mSpecCache->dirty = mDirty;
|
||||
spectrogram = &mSpecCache->freq[0];
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
// Make invalid cache
|
||||
SpecCache()
|
||||
: len(-1)
|
||||
, ac(false)
|
||||
, algorithm(-1)
|
||||
, pps(-1.0)
|
||||
, start(-1.0)
|
||||
, windowType(-1)
|
||||
@ -60,12 +60,11 @@ public:
|
||||
}
|
||||
|
||||
// Make valid cache, to be filled in
|
||||
SpecCache(int cacheLen, bool autocorrelation,
|
||||
SpecCache(int cacheLen, int algorithm_,
|
||||
double pps_, double start_, int windowType_, int windowSize_,
|
||||
int zeroPaddingFactor_, int frequencyGain_
|
||||
)
|
||||
int zeroPaddingFactor_, int frequencyGain_)
|
||||
: len(cacheLen)
|
||||
, ac(autocorrelation)
|
||||
, algorithm(algorithm_)
|
||||
, pps(pps_)
|
||||
, start(start_)
|
||||
, windowType(windowType_)
|
||||
@ -90,7 +89,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Matches(int dirty_, bool autocorrelation, double pixelsPerSecond,
|
||||
bool Matches(int dirty_, double pixelsPerSecond,
|
||||
const SpectrogramSettings &settings, double rate) const;
|
||||
|
||||
void CalculateOneSpectrum
|
||||
@ -105,11 +104,10 @@ public:
|
||||
(const SpectrogramSettings &settings, WaveTrackCache &waveTrackCache,
|
||||
int copyBegin, int copyEnd, int numPixels,
|
||||
sampleCount numSamples,
|
||||
double offset, double rate,
|
||||
bool autocorrelation);
|
||||
double offset, double rate);
|
||||
|
||||
const int len; // counts pixels, not samples
|
||||
const bool ac;
|
||||
const int algorithm;
|
||||
const double pps;
|
||||
const double start;
|
||||
const int windowType;
|
||||
@ -288,8 +286,7 @@ public:
|
||||
bool GetSpectrogram(WaveTrackCache &cache,
|
||||
const float *& spectrogram, const sampleCount *& where,
|
||||
int numPixels,
|
||||
double t0, double pixelsPerSecond,
|
||||
bool autocorrelation);
|
||||
double t0, double pixelsPerSecond);
|
||||
bool GetMinMax(float *min, float *max, double t0, double t1);
|
||||
bool GetRMS(float *rms, double t0, double t1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user