-
Notifications
You must be signed in to change notification settings - Fork 1
/
PeakMeter.h
121 lines (105 loc) · 3.49 KB
/
PeakMeter.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
#ifndef _PEAKMETER_H_
#define _PEAKMETER_H_
#define HORZ_DEFAULT 8
#define VERT_DEFAULT 8
#define BAND_DEFAULT 8
#define LEDS_DEFAULT 8
#define BAND_PERCENT 10 // 10% of Max Range (Auto Decrease)
#define GRID_INCREASEBY 5 // Increase Grid color based on Background color
#define FALL_INCREASEBY 60 // Increase Falloff color based on Background
#define DELAY_10MS 10
#define DEFAULT_SPEED 10
// Peak Meter Control styles
#define PM_HORIZONTAL 0x0000 // Horizontal band
#define PM_VERTICAL 0x0001 // Vertical band
class GButton;
struct PeakMeterData {
public:
int value;
int fallOff;
int peak;
PeakMeterData() :
value(0), fallOff(0), peak(0)
{
}
~PeakMeterData() { }
PeakMeterData& Copy(const PeakMeterData& pm);
PeakMeterData& operator=(const PeakMeterData& pm)
{ return Copy( pm ); }
bool IsEqual(const PeakMeterData& pm);
bool IsGreater(const PeakMeterData& pm);
bool IsLower(const PeakMeterData& pm);
bool operator==(const PeakMeterData& pm)
{ return IsEqual( pm ); }
bool operator!=(const PeakMeterData& pm)
{ return !IsEqual( pm ); }
bool operator<(const PeakMeterData& pm)
{ return IsLower( pm ); }
bool operator>(const PeakMeterData& pm)
{ return IsGreater( pm ); }
bool operator<=(const PeakMeterData& pm)
{ return !IsGreater( pm ); }
bool operator>=(const PeakMeterData& pm)
{ return !IsLower( pm ); }
};
typedef std::vector<PeakMeterData> Vector_MeterData;
class PeakMeter: public wxPanel
{
public:
PeakMeter(wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style = wxBORDER_RAISED);
~PeakMeter();
void InitData();
void ResetControl();
void DoTimerProcessing();
bool IsStarted();
bool Stop();
bool Start(int delay);
void SetBackgroundColor(wxColour colorBgnd);
void SetBandsColor(wxColour colorNormal,
wxColour colorMedium,
wxColour colorHigh);
void SetBandWidth(int width);
void SetMeterBands(int nNumBands, int nLedBands);
void SetRangeValue(int nMin, int nMed, int nMax);
void GetRangeValue(int* lpiMin, int* lpiMed, int* lpiMax);
void SetFalloffDelay(int nSpeed);
void SetFalloffEffect(bool bFalloffEffect);
bool GetFalloffEffect();
bool SetData(const int ArrayValue[], int nOffset, int nSize);
void DrawBand(wxAutoBufferedPaintDC &dc, int x, int y);
void Draw();
void SetMeters(double data[], int length);
protected:
wxColour m_colorBack; // Control background color
wxColour m_colorNorm; // Normal-range value band color
wxColour m_colorMedium; // Medium-range value band color
wxColour m_colorHigh; // High-range value band color
int m_minValue; // Minimum value
int m_medValue; // Medium value
int m_maxValue; // Maximum value
int m_numBand; // number of bands
int m_ledBand; // number of leds per band
int m_speed; // Falloff Speed
bool m_showFallOff; // Show Falloff
int m_meterBitmapX;
int m_meterBitmapY;
unsigned int m_delay; // Saved delay value
GButton *m_playModeButton;
GButton *m_repeatButton;
GButton *m_convertButton;
Vector_MeterData m_meterData;
wxMenu *m_menu;
wxTimer *m_timer;
private:
void OnRepeat(wxCommandEvent& WXUNUSED(event));
void OnRepeatNo(wxCommandEvent& WXUNUSED(event));
void OnRepeatAll(wxCommandEvent& WXUNUSED(event));
void OnRepeatThis(wxCommandEvent& WXUNUSED(event));
void OnPaint(wxPaintEvent &WXUNUSED(event));
void OnSize(wxSizeEvent& event);
void OnTimer(wxTimerEvent &event);
DECLARE_EVENT_TABLE();
};
#endif