forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMixerBoard.h
294 lines (215 loc) · 7.61 KB
/
MixerBoard.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/**********************************************************************
Sneedacity: A Digital Audio Editor
MixerBoard.h
Vaughan Johnson, January 2007
**********************************************************************/
#ifndef __SNEEDACITY_MIXER_BOARD__
#define __SNEEDACITY_MIXER_BOARD__
#include <wx/frame.h> // to inherit
#include <wx/scrolwin.h> // to inherit
#include "widgets/ASlider.h" // to inherit
#include "commands/CommandManagerWindowClasses.h"
#include "Prefs.h"
class wxArrayString;
class wxBitmapButton;
class wxImage;
class wxMemoryDC;
class AButton;
struct TrackListEvent;
// containment hierarchy:
// MixerBoardFrame -> MixerBoard -> MixerBoardScrolledWindow -> MixerTrackCluster(s)
// MixerTrackSlider is a subclass just to override OnMouseEvent,
// so we can know when adjustment ends, so we can PushState only then.
class MixerTrackSlider final : public ASlider
{
public:
MixerTrackSlider(wxWindow * parent,
wxWindowID id,
const TranslatableString &name,
const wxPoint & pos,
const wxSize & size,
const ASlider::Options &options = ASlider::Options{});
virtual ~MixerTrackSlider() {}
void OnMouseEvent(wxMouseEvent & event);
void OnFocus(wxFocusEvent &event);
void OnCaptureKey(wxCommandEvent& event);
protected:
bool mIsPan;
public:
DECLARE_EVENT_TABLE()
};
class SneedacityProject;
class MeterPanel;
class MixerBoard;
class Track;
#ifdef USE_MIDI
class NoteTrack;
#endif
class PlayableTrack;
class WaveTrack;
class auStaticText;
class MixerTrackCluster final : public wxPanelWrapper
{
public:
MixerTrackCluster(wxWindow* parent,
MixerBoard* grandParent, SneedacityProject* project,
const std::shared_ptr<PlayableTrack> &pTrack,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
virtual ~MixerTrackCluster() {}
WaveTrack *GetWave() const;
WaveTrack *GetRight() const;
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrack *GetNote() const;
#endif
//void UpdatePrefs();
void HandleResize(); // For wxSizeEvents, update gain slider and meter.
void HandleSliderGain(const bool bWantPushState = false);
#ifdef EXPERIMENTAL_MIDI_OUT
void HandleSliderVelocity(const bool bWantPushState = false);
#endif
void HandleSliderPan(const bool bWantPushState = false);
void ResetMeter(const bool bResetClipping);
void UpdateForStateChange();
void UpdateMeter(const double t0, const double t1);
private:
wxColour GetTrackColor();
// event handlers
void HandleSelect(bool bShiftDown, bool bControlDown);
void OnKeyEvent(wxKeyEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& evt);
void OnButton_MusicalInstrument(wxCommandEvent& event);
void OnSlider_Gain(wxCommandEvent& event);
#ifdef EXPERIMENTAL_MIDI_OUT
void OnSlider_Velocity(wxCommandEvent& event);
#endif
void OnSlider_Pan(wxCommandEvent& event);
void OnButton_Mute(wxCommandEvent& event);
void OnButton_Solo(wxCommandEvent& event);
//v void OnSliderScroll_Gain(wxScrollEvent& event);
public:
std::shared_ptr<PlayableTrack> mTrack;
private:
MixerBoard* mMixerBoard;
SneedacityProject* mProject;
// controls
auStaticText* mStaticText_TrackName;
wxBitmapButton* mBitmapButton_MusicalInstrument;
AButton* mToggleButton_Mute;
AButton* mToggleButton_Solo;
MixerTrackSlider* mSlider_Pan;
MixerTrackSlider* mSlider_Gain;
#ifdef EXPERIMENTAL_MIDI_OUT
MixerTrackSlider* mSlider_Velocity;
#endif
wxWeakRef<MeterPanel> mMeter;
public:
DECLARE_EVENT_TABLE()
};
class MusicalInstrument
{
public:
MusicalInstrument(std::unique_ptr<wxBitmap> &&pBitmap, const wxString & strXPMfilename);
virtual ~MusicalInstrument();
std::unique_ptr<wxBitmap> mBitmap;
wxArrayString mKeywords;
};
using MusicalInstrumentArray = std::vector<std::unique_ptr<MusicalInstrument>>;
// wxScrolledWindow ignores mouse clicks in client area,
// but they don't get passed to Mixerboard.
// We need to catch them to deselect all track clusters.
class MixerBoardScrolledWindow final : public wxScrolledWindow
{
public:
MixerBoardScrolledWindow(SneedacityProject* project,
MixerBoard* parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHSCROLL | wxVSCROLL);
virtual ~MixerBoardScrolledWindow();
private:
void OnMouseEvent(wxMouseEvent& event);
private:
MixerBoard* mMixerBoard;
SneedacityProject* mProject;
public:
DECLARE_EVENT_TABLE()
};
class MixerBoardFrame;
class TrackList;
class MixerBoard final : public wxWindow, private PrefsListener
{
friend class MixerBoardFrame;
public:
MixerBoard(SneedacityProject* pProject,
wxFrame* parent,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
void UpdatePrefs() override;
// Add clusters for any tracks we're not yet showing.
// Update pointers for tracks we're already showing.
void UpdateTrackClusters();
int GetTrackClustersWidth();
wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);
bool HasSolo();
void RefreshTrackClusters(bool bEraseBackground = true);
void ResizeTrackClusters();
void UpdateMeters(const double t1, const bool bLoopedPlay);
void UpdateWidth();
private:
void ResetMeters(const bool bResetClipping);
void RemoveTrackCluster(size_t nIndex);
void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
wxRect & bev, const TranslatableString & str, bool up );
void CreateMuteSoloImages();
int FindMixerTrackCluster(const PlayableTrack* pTrack,
MixerTrackCluster** hMixerTrackCluster) const;
void LoadMusicalInstruments();
// event handlers
void OnPaint(wxPaintEvent& evt);
void OnSize(wxSizeEvent &evt);
void OnTimer(wxCommandEvent &event);
void OnTrackSetChanged(wxEvent &event);
void OnTrackChanged(TrackListEvent &event);
void OnStartStop(wxCommandEvent &event);
public:
// mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,
mImageMuteDownWhileSolo, // the one actually alternate image
mImageMuteDisabled, mImageSoloUp, mImageSoloOver, mImageSoloDown, mImageSoloDisabled;
int mMuteSoloWidth;
private:
// Track clusters are maintained in the same order as the WaveTracks.
std::vector<MixerTrackCluster*> mMixerTrackClusters;
MusicalInstrumentArray mMusicalInstruments;
SneedacityProject* mProject;
MixerBoardScrolledWindow* mScrolledWindow; // Holds the MixerTrackClusters and handles scrolling.
double mPrevT1;
TrackList* mTracks;
bool mUpToDate{ false };
public:
DECLARE_EVENT_TABLE()
};
class MixerBoardFrame final
: public wxFrame
, public TopLevelKeystrokeHandlingWindow
{
public:
MixerBoardFrame(SneedacityProject* parent);
virtual ~MixerBoardFrame();
void Recreate(SneedacityProject *pProject);
private:
// event handlers
void OnCloseWindow(wxCloseEvent &WXUNUSED(event));
void OnMaximize(wxMaximizeEvent &event);
void OnSize(wxSizeEvent &evt);
void OnKeyEvent(wxKeyEvent &evt);
void SetWindowTitle();
SneedacityProject *mProject;
public:
MixerBoard* mMixerBoard;
public:
DECLARE_EVENT_TABLE()
};
#endif // __SNEEDACITY_MIXER_BOARD__