Audacity  2.2.0
MixerBoard.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  MixerBoard.h
6 
7  Vaughan Johnson, January 2007
8 
9 **********************************************************************/
10 
11 #include "Experimental.h"
12 
13 #ifndef __AUDACITY_MIXER_BOARD__
14 #define __AUDACITY_MIXER_BOARD__
15 
16 #include <wx/frame.h>
17 #include <wx/bmpbuttn.h>
18 #include <wx/hashmap.h>
19 #include <wx/image.h>
20 #include <wx/scrolwin.h>
21 #include <wx/statbmp.h>
22 #include <wx/stattext.h>
23 
24 #include "widgets/AButton.h"
25 #include "widgets/ASlider.h"
26 #include "widgets/wxPanelWrapper.h"
27 
28 // containment hierarchy:
29 // MixerBoardFrame -> MixerBoard -> MixerBoardScrolledWindow -> MixerTrackCluster(s)
30 
31 
32 // MixerTrackSlider is a subclass just to override OnMouseEvent,
33 // so we can know when adjustment ends, so we can PushState only then.
34 class MixerTrackSlider final : public ASlider
35 {
36 public:
37  MixerTrackSlider(wxWindow * parent,
38  wxWindowID id,
39  const wxString &name,
40  const wxPoint & pos,
41  const wxSize & size,
42  int style = FRAC_SLIDER,
43  bool popup = true,
44  bool canUseShift = true,
45  float stepValue = STEP_CONTINUOUS,
46  int orientation = wxHORIZONTAL);
47  virtual ~MixerTrackSlider() {}
48 
49  void OnMouseEvent(wxMouseEvent & event);
50 
51  void OnFocus(wxFocusEvent &event);
52  void OnCaptureKey(wxCommandEvent& event);
53 
54 protected:
55  bool mIsPan;
56 
57 public:
58  DECLARE_EVENT_TABLE()
59 };
60 
61 
62 class AudacityProject;
63 class Meter;
64 class MixerBoard;
65 
66 class Track;
67 #ifdef USE_MIDI
68 class NoteTrack;
69 #endif
70 class PlayableTrack;
71 
72 class WaveTrack;
73 class auStaticText;
74 
75 class MixerTrackCluster final : public wxPanelWrapper
76 {
77 public:
78  MixerTrackCluster(wxWindow* parent,
79  MixerBoard* grandParent, AudacityProject* project,
80  PlayableTrack* pTrack,
81  const wxPoint& pos = wxDefaultPosition,
82  const wxSize& size = wxDefaultSize);
83  virtual ~MixerTrackCluster() {}
84 
85  WaveTrack *GetWave() const;
86  WaveTrack *GetRight() const;
87 #ifdef EXPERIMENTAL_MIDI_OUT
88  NoteTrack *GetNote() const;
89 #endif
90 
91  void UpdatePrefs();
92 
93  void HandleResize(); // For wxSizeEvents, update gain slider and meter.
94 
95  void HandleSliderGain(const bool bWantPushState = false);
96 #ifdef EXPERIMENTAL_MIDI_OUT
97  void HandleSliderVelocity(const bool bWantPushState = false);
98 #endif
99  void HandleSliderPan(const bool bWantPushState = false);
100 
101  void ResetMeter(const bool bResetClipping);
102 
103  // These are used by TrackPanel for synchronizing control states.
104  void UpdateForStateChange(); // Update the controls that can be affected by state change.
105  void UpdateName();
106  void UpdateMute();
107  void UpdateSolo();
108  void UpdatePan();
109  void UpdateGain();
110 #ifdef EXPERIMENTAL_MIDI_OUT
111  void UpdateVelocity();
112 #endif
113  void UpdateMeter(const double t0, const double t1);
114 
115 private:
116  wxColour GetTrackColor();
117 
118  // event handlers
119  void HandleSelect(bool bShiftDown, bool bControlDown);
120 
121  void OnKeyEvent(wxKeyEvent& event);
122  void OnMouseEvent(wxMouseEvent& event);
123  void OnPaint(wxPaintEvent& evt);
124 
125  void OnButton_MusicalInstrument(wxCommandEvent& event);
126  void OnSlider_Gain(wxCommandEvent& event);
127 #ifdef EXPERIMENTAL_MIDI_OUT
128  void OnSlider_Velocity(wxCommandEvent& event);
129 #endif
130  void OnSlider_Pan(wxCommandEvent& event);
131  void OnButton_Mute(wxCommandEvent& event);
132  void OnButton_Solo(wxCommandEvent& event);
133  //v void OnSliderScroll_Gain(wxScrollEvent& event);
134 
135 
136 public:
138 
139 private:
142 
143  // controls
150 #ifdef EXPERIMENTAL_MIDI_OUT
151  MixerTrackSlider* mSlider_Velocity;
152 #endif
154 
155 public:
156  DECLARE_EVENT_TABLE()
157 };
158 
159 WX_DEFINE_ARRAY(MixerTrackCluster*, MixerTrackClusterArray);
160 
161 
163 {
164 public:
165  MusicalInstrument(std::unique_ptr<wxBitmap> &&pBitmap, const wxString & strXPMfilename);
166  virtual ~MusicalInstrument();
167 
168  std::unique_ptr<wxBitmap> mBitmap;
169  wxArrayString mKeywords;
170 };
171 
172 using MusicalInstrumentArray = std::vector<movable_ptr<MusicalInstrument>>;
173 
174 
175 
176 // wxScrolledWindow ignores mouse clicks in client area,
177 // but they don't get passed to Mixerboard.
178 // We need to catch them to deselect all track clusters.
179 class MixerBoardScrolledWindow final : public wxScrolledWindow
180 {
181 public:
183  MixerBoard* parent, wxWindowID id = -1,
184  const wxPoint& pos = wxDefaultPosition,
185  const wxSize& size = wxDefaultSize,
186  long style = wxHSCROLL | wxVSCROLL);
187  virtual ~MixerBoardScrolledWindow();
188 
189 private:
190  void OnMouseEvent(wxMouseEvent& event);
191 
192 private:
195 
196 public:
197  DECLARE_EVENT_TABLE()
198 };
199 
200 
201 class MixerBoardFrame;
202 class TrackList;
203 
204 class MixerBoard final : public wxWindow
205 {
206  friend class MixerBoardFrame;
207 
208 public:
209  MixerBoard(AudacityProject* pProject,
210  wxFrame* parent,
211  const wxPoint& pos = wxDefaultPosition,
212  const wxSize& size = wxDefaultSize);
213  virtual ~MixerBoard();
214 
215  void UpdatePrefs();
216 
217  // Add clusters for any tracks we're not yet showing.
218  // Update pointers for tracks we're aleady showing.
219  void UpdateTrackClusters();
220 
221  int GetTrackClustersWidth();
222  void MoveTrackCluster(const PlayableTrack* pTrack, bool bUp); // Up in TrackPanel is left in MixerBoard.
223  void RemoveTrackCluster(const PlayableTrack* pTrack);
224  void RemoveTrackCluster(size_t nIndex);
225 
226 
227  wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);
228 
229  bool HasSolo();
230 
231  void RefreshTrackCluster(const PlayableTrack* pTrack, bool bEraseBackground = true);
232  void RefreshTrackClusters(bool bEraseBackground = true);
233  void ResizeTrackClusters();
234 
235  void ResetMeters(const bool bResetClipping);
236 
237  void UpdateName(const PlayableTrack* pTrack);
238  void UpdateMute(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
239  void UpdateSolo(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
240  void UpdatePan(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
241  void UpdateGain(const PlayableTrack* pTrack);
242 #ifdef EXPERIMENTAL_MIDI_OUT
243  void UpdateVelocity(const PlayableTrack* pTrack);
244 #endif
245 
246  void UpdateMeters(const double t1, const bool bLoopedPlay);
247 
248  void UpdateWidth();
249 
250 private:
251  void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
252  wxRect & bev, const wxString & str, bool up );
253  void CreateMuteSoloImages();
254  int FindMixerTrackCluster(const PlayableTrack* pTrack,
255  MixerTrackCluster** hMixerTrackCluster) const;
256  void LoadMusicalInstruments();
257 
258  // event handlers
259  void OnSize(wxSizeEvent &evt);
260  void OnTimer(wxCommandEvent &event);
261 
262 
263 public:
264  // mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
265  std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,
266  mImageMuteDownWhileSolo, // the one actually alternate image
268 
270 
271 private:
272  // Track clusters are maintained in the same order as the WaveTracks.
273  MixerTrackClusterArray mMixerTrackClusters;
274 
277  MixerBoardScrolledWindow* mScrolledWindow; // Holds the MixerTrackClusters and handles scrolling.
278  double mPrevT1;
280 
281 public:
282  DECLARE_EVENT_TABLE()
283 };
284 
285 
286 class MixerBoardFrame final : public wxFrame
287 {
288 public:
290  virtual ~MixerBoardFrame();
291 
292 private:
293  // event handlers
294  void OnCloseWindow(wxCloseEvent &WXUNUSED(event));
295  void OnMaximize(wxMaximizeEvent &event);
296  void OnSize(wxSizeEvent &evt);
297  void OnKeyEvent(wxKeyEvent &evt);
298 
299 public:
301 
302 public:
303  DECLARE_EVENT_TABLE()
304 };
305 
306 #endif // __AUDACITY_MIXER_BOARD__
307 
308 
void RefreshTrackClusters(bool bEraseBackground=true)
Definition: MixerBoard.cpp:1189
Definition: MixerBoard.h:162
void OnKeyEvent(wxKeyEvent &evt)
Definition: MixerBoard.cpp:1562
A list of TrackListNode items.
Definition: Track.h:532
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:681
void OnPaint(wxPaintEvent &evt)
Definition: MixerBoard.cpp:695
void OnButton_Solo(wxCommandEvent &event)
Definition: MixerBoard.cpp:773
WX_DEFINE_ARRAY(MixerTrackCluster *, MixerTrackClusterArray)
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:265
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:148
std::vector< movable_ptr< MusicalInstrument >> MusicalInstrumentArray
Definition: MixerBoard.h:172
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:842
#define STEP_CONTINUOUS
Definition: ASlider.h:63
MixerBoard(AudacityProject *pProject, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:868
void OnSlider_Gain(wxCommandEvent &event)
Definition: MixerBoard.cpp:724
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:144
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:265
void ResizeTrackClusters()
Definition: MixerBoard.cpp:1195
VU Meter, for displaying recording/playback level.
Definition: Meter.h:88
Definition: MixerBoard.h:179
AudacityProject * mProject
Definition: MixerBoard.h:276
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:687
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:265
void OnKeyEvent(wxKeyEvent &event)
Definition: MixerBoard.h:286
Definition: Theme.h:184
void OnMaximize(wxMaximizeEvent &event)
Definition: MixerBoard.cpp:1550
void UpdateSolo()
Definition: MixerBoard.cpp:477
void OnFocus(wxFocusEvent &event)
Definition: MixerBoard.cpp:91
void RefreshTrackCluster(const PlayableTrack *pTrack, bool bEraseBackground=true)
Definition: MixerBoard.cpp:1181
void RemoveTrackCluster(const PlayableTrack *pTrack)
Definition: MixerBoard.cpp:1089
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:265
MixerBoard * mMixerBoard
Definition: MixerBoard.h:193
void UpdateForStateChange()
Definition: MixerBoard.cpp:449
Definition: wxPanelWrapper.h:19
int mMuteSoloWidth
Definition: MixerBoard.h:269
void LoadMusicalInstruments()
Definition: MixerBoard.cpp:1413
virtual ~MixerBoardScrolledWindow()
Definition: MixerBoard.cpp:838
void UpdatePan(const PlayableTrack *pTrack=NULL)
Definition: MixerBoard.cpp:1252
wxColour GetTrackColor()
Definition: MixerBoard.cpp:673
std::unique_ptr< wxBitmap > mBitmap
Definition: MixerBoard.h:168
Definition: MixerBoard.h:34
void UpdateMeter(const double t0, const double t1)
Definition: MixerBoard.cpp:516
void OnButton_MusicalInstrument(wxCommandEvent &event)
Definition: MixerBoard.cpp:718
void UpdateName()
Definition: MixerBoard.cpp:456
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:424
void CreateMuteSoloImages()
Definition: MixerBoard.cpp:1357
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:265
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:439
void UpdatePrefs()
Definition: MixerBoard.cpp:348
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:145
virtual ~MixerTrackCluster()
Definition: MixerBoard.h:83
virtual ~MusicalInstrument()
Definition: MixerBoard.cpp:811
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
Definition: MixerBoard.cpp:1125
void UpdateSolo(const PlayableTrack *pTrack=NULL)
Definition: MixerBoard.cpp:1236
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:277
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:75
void UpdateMute()
Definition: MixerBoard.cpp:468
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:265
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:265
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:85
MixerTrackSlider(wxWindow *parent, wxWindowID id, const wxString &name, const wxPoint &pos, const wxSize &size, int style=FRAC_SLIDER, bool popup=true, bool canUseShift=true, float stepValue=STEP_CONTINUOUS, int orientation=wxHORIZONTAL)
Definition: MixerBoard.cpp:60
void UpdateWidth()
Definition: MixerBoard.cpp:1314
AudacityProject * mProject
Definition: MixerBoard.h:194
virtual ~MixerBoardFrame()
Definition: MixerBoard.cpp:1539
void UpdateGain(const PlayableTrack *pTrack)
Definition: MixerBoard.cpp:1268
void MoveTrackCluster(const PlayableTrack *pTrack, bool bUp)
Definition: MixerBoard.cpp:1054
void OnCaptureKey(wxCommandEvent &event)
Definition: MixerBoard.cpp:105
MixerTrackCluster(wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, PlayableTrack *pTrack, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:166
Definition: MixerBoard.h:204
Definition: Track.h:351
AButton * mToggleButton_Solo
Definition: MixerBoard.h:147
void OnSlider_Pan(wxCommandEvent &event)
Definition: MixerBoard.cpp:751
void UpdateMeters(const double t1, const bool bLoopedPlay)
Definition: MixerBoard.cpp:1286
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
Definition: MixerBoard.cpp:1398
void UpdateName(const PlayableTrack *pTrack)
Definition: MixerBoard.cpp:1212
virtual ~MixerTrackSlider()
Definition: MixerBoard.h:47
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:265
void OnTimer(wxCommandEvent &event)
Definition: MixerBoard.cpp:1466
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:242
const wxChar * name
Definition: Distortion.cpp:93
virtual ~MixerBoard()
Definition: MixerBoard.cpp:933
AButton * mToggleButton_Mute
Definition: MixerBoard.h:146
void OnSize(wxSizeEvent &evt)
Definition: MixerBoard.cpp:1557
MixerBoardFrame(AudacityProject *parent)
Definition: MixerBoard.cpp:1504
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const wxString &str, bool up)
Definition: MixerBoard.cpp:1331
void OnSize(wxSizeEvent &evt)
Definition: MixerBoard.cpp:1457
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:332
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:275
void OnButton_Mute(wxCommandEvent &event)
Definition: MixerBoard.cpp:756
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:149
void OnCloseWindow(wxCloseEvent &WXUNUSED(event))
Definition: MixerBoard.cpp:1545
wxArrayString mKeywords
Definition: MixerBoard.h:169
void UpdatePan()
Definition: MixerBoard.cpp:487
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:327
MixerBoardScrolledWindow(AudacityProject *project, MixerBoard *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL)
Definition: MixerBoard.cpp:827
PlayableTrack * mTrack
Definition: MixerBoard.h:137
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:265
Meter * mMeter
Definition: MixerBoard.h:153
int GetTrackClustersWidth()
Definition: MixerBoard.cpp:1045
MixerBoard * mMixerBoard
Definition: MixerBoard.h:140
MusicalInstrument(std::unique_ptr< wxBitmap > &&pBitmap, const wxString &strXPMfilename)
Definition: MixerBoard.cpp:793
Definition: MixerBoard.h:75
void UpdatePrefs()
Definition: MixerBoard.cpp:947
AudacityProject * mProject
Definition: MixerBoard.h:141
double mPrevT1
Definition: MixerBoard.h:278
MixerTrackClusterArray mMixerTrackClusters
Definition: MixerBoard.h:273
void ResetMeters(const bool bResetClipping)
Definition: MixerBoard.cpp:1201
void HandleResize()
Definition: MixerBoard.cpp:357
TrackList * mTracks
Definition: MixerBoard.h:279
MixerBoard * mMixerBoard
Definition: MixerBoard.h:300
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:396
void UpdateGain()
Definition: MixerBoard.cpp:496
bool mIsPan
Definition: MixerBoard.h:55
bool HasSolo()
Definition: MixerBoard.cpp:1169
#define FRAC_SLIDER
Definition: ASlider.h:43
void UpdateMute(const PlayableTrack *pTrack=NULL)
Definition: MixerBoard.cpp:1220
A wxButton with mouse-over behaviour.
Definition: AButton.h:27
A Track that is used for Midi notes. (Somewhat old code).
void UpdateTrackClusters()
Definition: MixerBoard.cpp:980