1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-23 07:58:05 +02:00

Publicize class SpecCache. TrackArtist will re-use it.

This commit is contained in:
Paul Licameli 2015-06-09 14:01:44 -04:00
parent e0f4595485
commit c14b326913
2 changed files with 85 additions and 91 deletions

View File

@ -17,12 +17,6 @@
\class WaveCache
\brief Cache used with WaveClip to cache wave information (for drawing).
*//****************************************************************//**
\class SpecCache
\brief Cache used with WaveClip to cache spectrum information (for
drawing). Cache's the Spectrogram frequency samples.
*//*******************************************************************/
#include "WaveClip.h"
@ -263,90 +257,6 @@ protected:
};
class SpecCache {
public:
// Make invalid cache
SpecCache()
: len(-1)
, ac(false)
, pps(-1.0)
, start(-1.0)
, windowType(-1)
, windowSize(-1)
, zeroPaddingFactor(-1)
, frequencyGain(-1)
, freq(NULL)
, where(NULL)
, dirty(-1)
{
}
// Make valid cache, to be filled in
SpecCache(int cacheLen, bool autocorrelation,
double pps_, double start_, int windowType_, int windowSize_,
int zeroPaddingFactor_, int frequencyGain_
)
: len(cacheLen)
, ac(autocorrelation)
, pps(pps_)
, start(start_)
, windowType(windowType_)
, windowSize(windowSize_)
, zeroPaddingFactor(zeroPaddingFactor_)
, frequencyGain(frequencyGain_)
// len columns, and so many rows, column-major.
// Don't take column literally -- this isn't pixel data yet, it's the
// raw data to be mapped onto the display.
, freq(len * ((windowSize * zeroPaddingFactor) / 2))
// Sample counts corresponding to the columns, and to one past the end.
, where(len + 1)
, dirty(-1)
{
where[0] = 0;
}
~SpecCache()
{
}
bool Matches(int dirty_, bool autocorrelation, double pixelsPerSecond,
const SpectrogramSettings &settings, double rate) const;
void CalculateOneSpectrum
(const SpectrogramSettings &settings,
WaveTrackCache &waveTrackCache,
int xx, sampleCount numSamples,
double offset, double rate,
bool autocorrelation, const std::vector<float> &gainFactors,
float *scratch);
void Populate
(const SpectrogramSettings &settings, WaveTrackCache &waveTrackCache,
int copyBegin, int copyEnd, int numPixels,
sampleCount numSamples,
double offset, double rate,
bool autocorrelation);
const int len; // counts pixels, not samples
const bool ac;
const double pps;
const double start;
const int windowType;
const int windowSize;
const int zeroPaddingFactor;
const int frequencyGain;
std::vector<float> freq;
std::vector<sampleCount> where;
int dirty;
};
#ifdef EXPERIMENTAL_USE_REALFFTF
#include "FFT.h"
static void ComputeSpectrumUsingRealFFTf

View File

@ -32,9 +32,93 @@
#include <vector>
class Envelope;
class SpectrogramSettings;
class WaveCache;
class WaveTrackCache;
class SpecCache;
class SpecCache {
public:
// Make invalid cache
SpecCache()
: len(-1)
, ac(false)
, pps(-1.0)
, start(-1.0)
, windowType(-1)
, windowSize(-1)
, zeroPaddingFactor(-1)
, frequencyGain(-1)
, freq(NULL)
, where(NULL)
, dirty(-1)
{
}
// Make valid cache, to be filled in
SpecCache(int cacheLen, bool autocorrelation,
double pps_, double start_, int windowType_, int windowSize_,
int zeroPaddingFactor_, int frequencyGain_
)
: len(cacheLen)
, ac(autocorrelation)
, pps(pps_)
, start(start_)
, windowType(windowType_)
, windowSize(windowSize_)
, zeroPaddingFactor(zeroPaddingFactor_)
, frequencyGain(frequencyGain_)
// len columns, and so many rows, column-major.
// Don't take column literally -- this isn't pixel data yet, it's the
// raw data to be mapped onto the display.
, freq(len * ((windowSize * zeroPaddingFactor) / 2))
// Sample counts corresponding to the columns, and to one past the end.
, where(len + 1)
, dirty(-1)
{
where[0] = 0;
}
~SpecCache()
{
}
bool Matches(int dirty_, bool autocorrelation, double pixelsPerSecond,
const SpectrogramSettings &settings, double rate) const;
void CalculateOneSpectrum
(const SpectrogramSettings &settings,
WaveTrackCache &waveTrackCache,
int xx, sampleCount numSamples,
double offset, double rate,
bool autocorrelation, const std::vector<float> &gainFactors,
float *scratch);
void Populate
(const SpectrogramSettings &settings, WaveTrackCache &waveTrackCache,
int copyBegin, int copyEnd, int numPixels,
sampleCount numSamples,
double offset, double rate,
bool autocorrelation);
const int len; // counts pixels, not samples
const bool ac;
const double pps;
const double start;
const int windowType;
const int windowSize;
const int zeroPaddingFactor;
const int frequencyGain;
std::vector<float> freq;
std::vector<sampleCount> where;
int dirty;
};
class SpecPxCache {
public: