Audacity  3.0.3
SpectrumAnalyst.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  SpectrumAnalyst.h
6 
7  Dominic Mazzoni
8  Paul Licameli split from FreqWindow.h
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_SPECTRUM_ANALYST__
13 #define __AUDACITY_SPECTRUM_ANALYST__
14 
15 #include <vector>
16 #include <wx/statusbr.h>
17 
18 class FreqGauge;
19 
20 class AUDACITY_DLL_API SpectrumAnalyst
21 {
22 public:
23 
24  enum Algorithm {
30 
31  NumAlgorithms
32  };
33 
35  ~SpectrumAnalyst();
36 
37  // Return true iff successful
38  bool Calculate(Algorithm alg,
39  int windowFunc, // see FFT.h for values
40  size_t windowSize, double rate,
41  const float *data, size_t dataLen,
42  float *pYMin = NULL, float *pYMax = NULL, // outputs
43  FreqGauge *progress = NULL);
44 
45  const float *GetProcessed() const;
46  int GetProcessedSize() const;
47 
48  float GetProcessedValue(float freq0, float freq1) const;
49  float FindPeak(float xPos, float *pY) const;
50 
51 private:
52  float CubicInterpolate(float y0, float y1, float y2, float y3, float x) const;
53  float CubicMaximize(float y0, float y1, float y2, float y3, float * max) const;
54 
55 private:
57  double mRate;
58  size_t mWindowSize;
59  std::vector<float> mProcessed;
60 };
61 
62 class AUDACITY_DLL_API FreqGauge final : public wxStatusBar
63 {
64 public:
65  FreqGauge(wxWindow * parent, wxWindowID winid);
66 
67  void SetRange(int range, int bar = 12, int gap = 3);
68  void SetValue(int value);
69  void Reset();
70 
71 private:
72  wxRect mRect;
73  int mRange;
74  int mCur;
75  int mLast;
76  int mInterval;
77  int mBar;
78  int mGap;
79  int mMargin;
80 };
81 
82 #endif
SpectrumAnalyst::Spectrum
@ Spectrum
Definition: SpectrumAnalyst.h:25
FreqGauge::mRect
wxRect mRect
Definition: SpectrumAnalyst.h:72
FreqGauge::mMargin
int mMargin
Definition: SpectrumAnalyst.h:79
FreqGauge::mInterval
int mInterval
Definition: SpectrumAnalyst.h:76
gap
static const int gap
Definition: MeterPanel.cpp:257
FreqGauge::mRange
int mRange
Definition: SpectrumAnalyst.h:73
SpectrumAnalyst::EnhancedAutocorrelation
@ EnhancedAutocorrelation
Definition: SpectrumAnalyst.h:28
SpectrumAnalyst
Used for finding the peaks, for snapping to peaks.
Definition: SpectrumAnalyst.h:21
SpectrumAnalyst::mWindowSize
size_t mWindowSize
Definition: SpectrumAnalyst.h:58
FreqGauge::mGap
int mGap
Definition: SpectrumAnalyst.h:78
FreqGauge
Definition: SpectrumAnalyst.h:63
SpectrumAnalyst::Cepstrum
@ Cepstrum
Definition: SpectrumAnalyst.h:29
FreqGauge::mCur
int mCur
Definition: SpectrumAnalyst.h:74
FreqGauge::mBar
int mBar
Definition: SpectrumAnalyst.h:77
SpectrumAnalyst::mProcessed
std::vector< float > mProcessed
Definition: SpectrumAnalyst.h:59
SpectrumAnalyst::Autocorrelation
@ Autocorrelation
Definition: SpectrumAnalyst.h:26
SpectrumAnalyst::CubeRootAutocorrelation
@ CubeRootAutocorrelation
Definition: SpectrumAnalyst.h:27
SpectrumAnalyst::mAlg
Algorithm mAlg
Definition: SpectrumAnalyst.h:56
SpectrumAnalyst::Algorithm
Algorithm
Definition: SpectrumAnalyst.h:24
SpectrumAnalyst::mRate
double mRate
Definition: SpectrumAnalyst.h:57
FreqGauge::mLast
int mLast
Definition: SpectrumAnalyst.h:75