forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreqWindow.h
161 lines (123 loc) · 3.54 KB
/
FreqWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**********************************************************************
Sneedacity: A Digital Audio Editor
FreqWindow.h
Dominic Mazzoni
**********************************************************************/
#ifndef __SNEEDACITY_FREQ_WINDOW__
#define __SNEEDACITY_FREQ_WINDOW__
#include <vector>
#include <wx/font.h> // member variable
#include <wx/statusbr.h> // to inherit
#include "Prefs.h"
#include "SampleFormat.h"
#include "SpectrumAnalyst.h"
#include "widgets/wxPanelWrapper.h" // to inherit
class wxMemoryDC;
class wxScrollBar;
class wxSlider;
class wxTextCtrl;
class wxButton;
class wxCheckBox;
class wxChoice;
class SneedacityProject;
class FrequencyPlotDialog;
class FreqGauge;
class RulerPanel;
DECLARE_EXPORTED_EVENT_TYPE(SNEEDACITY_DLL_API, EVT_FREQWINDOW_RECALC, -1);
class FreqPlot final : public wxWindow
{
public:
FreqPlot(wxWindow *parent, wxWindowID winid);
// We don't need or want to accept focus.
bool AcceptsFocus() const;
private:
void OnPaint(wxPaintEvent & event);
void OnErase(wxEraseEvent & event);
void OnMouseEvent(wxMouseEvent & event);
private:
FrequencyPlotDialog *freqWindow;
DECLARE_EVENT_TABLE()
};
class FrequencyPlotDialog final : public wxDialogWrapper,
public PrefsListener
{
public:
FrequencyPlotDialog(wxWindow *parent, wxWindowID id,
SneedacityProject &project,
const TranslatableString & title, const wxPoint & pos);
virtual ~ FrequencyPlotDialog();
bool Show( bool show = true ) override;
private:
void Populate();
void GetAudio();
void PlotMouseEvent(wxMouseEvent & event);
void PlotPaint(wxPaintEvent & event);
void OnCloseWindow(wxCloseEvent & event);
void OnCloseButton(wxCommandEvent & event);
void OnGetURL(wxCommandEvent & event);
void OnSize(wxSizeEvent & event);
void OnPanScroller(wxScrollEvent & event);
void OnZoomSlider(wxCommandEvent & event);
void OnAlgChoice(wxCommandEvent & event);
void OnSizeChoice(wxCommandEvent & event);
void OnFuncChoice(wxCommandEvent & event);
void OnAxisChoice(wxCommandEvent & event);
void OnExport(wxCommandEvent & event);
void OnReplot(wxCommandEvent & event);
void OnGridOnOff(wxCommandEvent & event);
void OnRecalc(wxCommandEvent & event);
void SendRecalcEvent();
void Recalc();
void DrawPlot();
void DrawBackground(wxMemoryDC & dc);
// PrefsListener implementation
void UpdatePrefs() override;
private:
bool mDrawGrid;
int mSize;
SpectrumAnalyst::Algorithm mAlg;
int mFunc;
int mAxis;
int dBRange;
SneedacityProject *mProject;
#ifdef __WXMSW__
static const int fontSize = 8;
#else
static const int fontSize = 10;
#endif
RulerPanel *vRuler;
RulerPanel *hRuler;
FreqPlot *mFreqPlot;
FreqGauge *mProgress;
wxRect mPlotRect;
wxFont mFreqFont;
std::unique_ptr<wxCursor> mArrowCursor;
std::unique_ptr<wxCursor> mCrossCursor;
wxButton *mCloseButton;
wxButton *mExportButton;
wxButton *mReplotButton;
wxCheckBox *mGridOnOff;
wxChoice *mAlgChoice;
wxChoice *mSizeChoice;
wxChoice *mFuncChoice;
wxChoice *mAxisChoice;
wxScrollBar *mPanScroller;
wxSlider *mZoomSlider;
wxTextCtrl *mCursorText;
wxTextCtrl *mPeakText;
double mRate;
size_t mDataLen;
Floats mData;
size_t mWindowSize;
bool mLogAxis;
float mYMin;
float mYMax;
float mYStep;
std::unique_ptr<wxBitmap> mBitmap;
int mMouseX;
int mMouseY;
std::unique_ptr<SpectrumAnalyst> mAnalyst;
DECLARE_EVENT_TABLE()
friend class FreqPlot;
};
#endif