Audacity  3.0.3
Classes | Namespaces | Functions
WaveClip.cpp File Reference
#include "WaveClip.h"
#include <math.h>
#include <vector>
#include <wx/log.h>
#include "Sequence.h"
#include "Spectrum.h"
#include "Prefs.h"
#include "Envelope.h"
#include "Resample.h"
#include "WaveTrack.h"
#include "Profiler.h"
#include "InconsistencyException.h"
#include "UserException.h"
#include "prefs/SpectrogramSettings.h"
#include "widgets/ProgressDialog.h"
Include dependency graph for WaveClip.cpp:

Go to the source code of this file.

Classes

class  WaveCache
 Cache used with WaveClip to cache wave information (for drawing). More...
 

Namespaces

 anonymous_namespace{WaveClip.cpp}
 

Functions

static void ComputeSpectrumUsingRealFFTf (float *__restrict buffer, const FFTParam *hFFT, const float *__restrict window, size_t len, float *__restrict out)
 
void anonymous_namespace{WaveClip.cpp}::findCorrection (const std::vector< sampleCount > &oldWhere, size_t oldLen, size_t newLen, double t0, double rate, double samplesPerPixel, int &oldX0, double &correction)
 
void anonymous_namespace{WaveClip.cpp}::fillWhere (std::vector< sampleCount > &where, size_t len, double bias, double correction, double t0, double rate, double samplesPerPixel)
 
void anonymous_namespace{WaveClip.cpp}::ComputeSpectrogramGainFactors (size_t fftLen, double rate, int frequencyGain, std::vector< float > &gainFactors)
 

Function Documentation

◆ ComputeSpectrumUsingRealFFTf()

static void ComputeSpectrumUsingRealFFTf ( float *__restrict  buffer,
const FFTParam hFFT,
const float *__restrict  window,
size_t  len,
float *__restrict  out 
)
static

Definition at line 92 of file WaveClip.cpp.

95 {
96  size_t i;
97  if(len > hFFT->Points * 2)
98  len = hFFT->Points * 2;
99  for(i = 0; i < len; i++)
100  buffer[i] *= window[i];
101  for( ; i < (hFFT->Points * 2); i++)
102  buffer[i] = 0; // zero pad as needed
103  RealFFTf(buffer, hFFT);
104  // Handle the (real-only) DC
105  float power = buffer[0] * buffer[0];
106  if(power <= 0)
107  out[0] = -160.0;
108  else
109  out[0] = 10.0 * log10f(power);
110  for(i = 1; i < hFFT->Points; i++) {
111  const int index = hFFT->BitReversed[i];
112  const float re = buffer[index], im = buffer[index + 1];
113  power = re * re + im * im;
114  if(power <= 0)
115  out[i] = -160.0;
116  else
117  out[i] = 10.0*log10f(power);
118  }
119 }

References FFTParam::BitReversed, FFTParam::Points, and RealFFTf().

Referenced by SpecCache::CalculateOneSpectrum().

Here is the call graph for this function:
Here is the caller graph for this function:
RealFFTf
void RealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:162
FFTParam::Points
size_t Points
Definition: RealFFTf.h:10
FFTParam::BitReversed
ArrayOf< int > BitReversed
Definition: RealFFTf.h:8