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