Audacity  3.0.3
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 
12 
13 
14 #ifndef __AUDACITY_MIXER_BOARD__
15 #define __AUDACITY_MIXER_BOARD__
16 
17 #include <wx/frame.h> // to inherit
18 #include <wx/scrolwin.h> // to inherit
19 
20 #include "widgets/ASlider.h" // to inherit
22 
23 #include "Prefs.h"
24 
25 class wxArrayString;
26 class wxBitmapButton;
27 class wxImage;
28 class wxMemoryDC;
29 class AButton;
30 struct TrackListEvent;
31 
32 // containment hierarchy:
33 // MixerBoardFrame -> MixerBoard -> MixerBoardScrolledWindow -> MixerTrackCluster(s)
34 
35 
36 // MixerTrackSlider is a subclass just to override OnMouseEvent,
37 // so we can know when adjustment ends, so we can PushState only then.
38 class MixerTrackSlider final : public ASlider
39 {
40 public:
41  MixerTrackSlider(wxWindow * parent,
42  wxWindowID id,
43  const TranslatableString &name,
44  const wxPoint & pos,
45  const wxSize & size,
46  const ASlider::Options &options = ASlider::Options{});
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 MeterPanel;
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  const std::shared_ptr<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  void UpdateForStateChange();
104  void UpdateMeter(const double t0, const double t1);
105 
106 private:
107  wxColour GetTrackColor();
108 
109  // event handlers
110  void HandleSelect(bool bShiftDown, bool bControlDown);
111 
112  void OnKeyEvent(wxKeyEvent& event);
113  void OnMouseEvent(wxMouseEvent& event);
114  void OnPaint(wxPaintEvent& evt);
115 
116  void OnButton_MusicalInstrument(wxCommandEvent& event);
117  void OnSlider_Gain(wxCommandEvent& event);
118 #ifdef EXPERIMENTAL_MIDI_OUT
119  void OnSlider_Velocity(wxCommandEvent& event);
120 #endif
121  void OnSlider_Pan(wxCommandEvent& event);
122  void OnButton_Mute(wxCommandEvent& event);
123  void OnButton_Solo(wxCommandEvent& event);
124  //v void OnSliderScroll_Gain(wxScrollEvent& event);
125 
126 
127 public:
128  std::shared_ptr<PlayableTrack> mTrack;
129 
130 private:
133 
134  // controls
141 #ifdef EXPERIMENTAL_MIDI_OUT
142  MixerTrackSlider* mSlider_Velocity;
143 #endif
144  wxWeakRef<MeterPanel> mMeter;
145 
146 public:
147  DECLARE_EVENT_TABLE()
148 };
149 
150 
152 {
153 public:
154  MusicalInstrument(std::unique_ptr<wxBitmap> &&pBitmap, const wxString & strXPMfilename);
155  virtual ~MusicalInstrument();
156 
157  std::unique_ptr<wxBitmap> mBitmap;
158  wxArrayString mKeywords;
159 };
160 
161 using MusicalInstrumentArray = std::vector<std::unique_ptr<MusicalInstrument>>;
162 
163 
164 
165 // wxScrolledWindow ignores mouse clicks in client area,
166 // but they don't get passed to Mixerboard.
167 // We need to catch them to deselect all track clusters.
168 class MixerBoardScrolledWindow final : public wxScrolledWindow
169 {
170 public:
172  MixerBoard* parent, wxWindowID id = -1,
173  const wxPoint& pos = wxDefaultPosition,
174  const wxSize& size = wxDefaultSize,
175  long style = wxHSCROLL | wxVSCROLL);
176  virtual ~MixerBoardScrolledWindow();
177 
178 private:
179  void OnMouseEvent(wxMouseEvent& event);
180 
181 private:
184 
185 public:
186  DECLARE_EVENT_TABLE()
187 };
188 
189 
190 class MixerBoardFrame;
191 class TrackList;
192 
193 class MixerBoard final : public wxWindow, private PrefsListener
194 {
195  friend class MixerBoardFrame;
196 
197 public:
198  MixerBoard(AudacityProject* pProject,
199  wxFrame* parent,
200  const wxPoint& pos = wxDefaultPosition,
201  const wxSize& size = wxDefaultSize);
202 
203  void UpdatePrefs() override;
204 
205  // Add clusters for any tracks we're not yet showing.
206  // Update pointers for tracks we're already showing.
207  void UpdateTrackClusters();
208 
209  int GetTrackClustersWidth();
210 
211 
212  wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);
213 
214  bool HasSolo();
215 
216  void RefreshTrackClusters(bool bEraseBackground = true);
217  void ResizeTrackClusters();
218 
219  void UpdateMeters(const double t1, const bool bLoopedPlay);
220 
221  void UpdateWidth();
222 
223 private:
224  void ResetMeters(const bool bResetClipping);
225  void RemoveTrackCluster(size_t nIndex);
226  void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
227  wxRect & bev, const TranslatableString & str, bool up );
228  void CreateMuteSoloImages();
229  int FindMixerTrackCluster(const PlayableTrack* pTrack,
230  MixerTrackCluster** hMixerTrackCluster) const;
231  void LoadMusicalInstruments();
232 
233  // event handlers
234  void OnPaint(wxPaintEvent& evt);
235  void OnSize(wxSizeEvent &evt);
236  void OnTimer(wxCommandEvent &event);
237  void OnTrackSetChanged(wxEvent &event);
238  void OnTrackChanged(TrackListEvent &event);
239  void OnStartStop(wxCommandEvent &event);
240 
241 public:
242  // mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
243  std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,
244  mImageMuteDownWhileSolo, // the one actually alternate image
246 
248 
249 private:
250  // Track clusters are maintained in the same order as the WaveTracks.
251  std::vector<MixerTrackCluster*> mMixerTrackClusters;
252 
255  MixerBoardScrolledWindow* mScrolledWindow; // Holds the MixerTrackClusters and handles scrolling.
256  double mPrevT1;
258  bool mUpToDate{ false };
259 
260 public:
261  DECLARE_EVENT_TABLE()
262 };
263 
264 
265 class MixerBoardFrame final
266  : public wxFrame
268 {
269 public:
271  virtual ~MixerBoardFrame();
272 
273  void Recreate(AudacityProject *pProject);
274 
275 private:
276  // event handlers
277  void OnCloseWindow(wxCloseEvent &WXUNUSED(event));
278  void OnMaximize(wxMaximizeEvent &event);
279  void OnSize(wxSizeEvent &evt);
280  void OnKeyEvent(wxKeyEvent &evt);
281 
282  void SetWindowTitle();
283 
285 public:
287 
288 public:
289  DECLARE_EVENT_TABLE()
290 };
291 
292 #endif // __AUDACITY_MIXER_BOARD__
293 
294 
MixerTrackCluster::GetRight
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:342
MixerBoard::mImageMuteDownWhileSolo
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:244
MixerBoard::mImageMuteOver
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:243
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
MixerBoardScrolledWindow::mProject
AudacityProject * mProject
Definition: MixerBoard.h:183
MixerTrackCluster::HandleSliderPan
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:443
MixerTrackSlider::OnMouseEvent
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:90
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
MixerBoard::OnTrackSetChanged
void OnTrackSetChanged(wxEvent &event)
Definition: MixerBoard.cpp:1384
MixerTrackSlider::~MixerTrackSlider
virtual ~MixerTrackSlider()
Definition: MixerBoard.h:47
MixerBoard::mImageMuteDisabled
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:245
MixerTrackCluster::OnButton_Mute
void OnButton_Mute(wxCommandEvent &event)
Definition: MixerBoard.cpp:756
MixerBoard::mMusicalInstruments
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:253
MixerBoard::UpdateTrackClusters
void UpdateTrackClusters()
Definition: MixerBoard.cpp:988
MixerBoard::mImageSoloDown
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:245
MixerBoardFrame::SetWindowTitle
void SetWindowTitle()
Definition: MixerBoard.cpp:1502
MixerTrackCluster::ResetMeter
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:460
MixerBoard::mPrevT1
double mPrevT1
Definition: MixerBoard.h:256
MixerTrackCluster::mProject
AudacityProject * mProject
Definition: MixerBoard.h:132
AButton
A wxButton with mouse-over behaviour.
Definition: AButton.h:25
MixerBoard::GetMusicalInstrumentBitmap
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
Definition: MixerBoard.cpp:1078
MixerTrackSlider::MixerTrackSlider
MixerTrackSlider(wxWindow *parent, wxWindowID id, const TranslatableString &name, const wxPoint &pos, const wxSize &size, const ASlider::Options &options=ASlider::Options{})
Definition: MixerBoard.cpp:80
wxPanelWrapper
Definition: wxPanelWrapper.h:41
MixerTrackCluster::OnPaint
void OnPaint(wxPaintEvent &evt)
Definition: MixerBoard.cpp:691
MixerBoard::ResetMeters
void ResetMeters(const bool bResetClipping)
Definition: MixerBoard.cpp:1139
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1280
MixerBoard::mScrolledWindow
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:255
MixerBoard::mImageSoloUp
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:245
MixerTrackCluster::mStaticText_TrackName
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:135
MixerBoard::UpdateMeters
void UpdateMeters(const double t1, const bool bLoopedPlay)
Definition: MixerBoard.cpp:1150
MixerTrackCluster::OnSlider_Gain
void OnSlider_Gain(wxCommandEvent &event)
Definition: MixerBoard.cpp:724
ASlider::Options
Definition: ASlider.h:238
MixerBoardScrolledWindow::MixerBoardScrolledWindow
MixerBoardScrolledWindow(AudacityProject *project, MixerBoard *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL)
Definition: MixerBoard.cpp:819
MixerTrackCluster::mSlider_Gain
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:140
MixerBoard::UpdateWidth
void UpdateWidth()
Definition: MixerBoard.cpp:1178
MixerTrackCluster::mToggleButton_Mute
AButton * mToggleButton_Mute
Definition: MixerBoard.h:137
MusicalInstrumentArray
std::vector< std::unique_ptr< MusicalInstrument > > MusicalInstrumentArray
Definition: MixerBoard.h:161
MixerBoard::OnPaint
void OnPaint(wxPaintEvent &evt)
Definition: MixerBoard.cpp:1322
MixerTrackCluster::~MixerTrackCluster
virtual ~MixerTrackCluster()
Definition: MixerBoard.h:83
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:389
MixerBoardFrame::Recreate
void Recreate(AudacityProject *pProject)
Definition: MixerBoard.cpp:1484
MixerTrackCluster::mMixerBoard
MixerBoard * mMixerBoard
Definition: MixerBoard.h:131
MixerTrackCluster
Definition: MixerBoard.h:76
MixerBoard::mMuteSoloWidth
int mMuteSoloWidth
Definition: MixerBoard.h:247
MusicalInstrument
Definition: MixerBoard.h:152
MusicalInstrument::mKeywords
wxArrayString mKeywords
Definition: MixerBoard.h:158
MixerBoard
Definition: MixerBoard.h:194
MixerBoardScrolledWindow
Definition: MixerBoard.h:169
MixerBoardFrame
Definition: MixerBoard.h:268
MixerTrackCluster::mMeter
wxWeakRef< MeterPanel > mMeter
Definition: MixerBoard.h:144
TrackListEvent
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:1222
MixerBoardFrame::MixerBoardFrame
MixerBoardFrame(AudacityProject *parent)
Definition: MixerBoard.cpp:1412
MixerTrackCluster::MixerTrackCluster
MixerTrackCluster(wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, const std::shared_ptr< PlayableTrack > &pTrack, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:172
MixerBoard::UpdatePrefs
void UpdatePrefs() override
Definition: MixerBoard.cpp:954
MixerTrackCluster::OnMouseEvent
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:683
TopLevelKeystrokeHandlingWindow
Definition: CommandManagerWindowClasses.h:29
MixerTrackCluster::OnKeyEvent
void OnKeyEvent(wxKeyEvent &event)
MixerTrackCluster::GetWave
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:337
MixerBoard::mImageSoloDisabled
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:245
name
const TranslatableString name
Definition: Distortion.cpp:98
MixerTrackCluster::OnButton_Solo
void OnButton_Solo(wxCommandEvent &event)
Definition: MixerBoard.cpp:770
MixerBoard::ResizeTrackClusters
void ResizeTrackClusters()
Definition: MixerBoard.cpp:1133
MusicalInstrument::~MusicalInstrument
virtual ~MusicalInstrument()
Definition: MixerBoard.cpp:803
ASlider.h
MixerBoardFrame::mProject
AudacityProject * mProject
Definition: MixerBoard.h:284
MusicalInstrument::mBitmap
std::unique_ptr< wxBitmap > mBitmap
Definition: MixerBoard.h:157
MixerTrackCluster::UpdateForStateChange
void UpdateForStateChange()
Definition: MixerBoard.cpp:468
PlayableTrack
AudioTrack subclass that can also be audibly replayed by the program.
Definition: Track.h:854
MixerBoardFrame::OnMaximize
void OnMaximize(wxMaximizeEvent &event)
Definition: MixerBoard.cpp:1465
MixerBoardScrolledWindow::OnMouseEvent
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:834
MixerBoard::MakeButtonBitmap
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const TranslatableString &str, bool up)
Definition: MixerBoard.cpp:1195
MusicalInstrument::MusicalInstrument
MusicalInstrument(std::unique_ptr< wxBitmap > &&pBitmap, const wxString &strXPMfilename)
Definition: MixerBoard.cpp:785
MixerBoard::mImageMuteUp
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:243
MixerTrackCluster::OnSlider_Pan
void OnSlider_Pan(wxCommandEvent &event)
Definition: MixerBoard.cpp:751
MixerBoard::GetTrackClustersWidth
int GetTrackClustersWidth()
Definition: MixerBoard.cpp:1045
auStaticText
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: Theme.h:183
MixerBoard::mImageMuteDown
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:243
ASlider
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:234
MixerTrackSlider::OnCaptureKey
void OnCaptureKey(wxCommandEvent &event)
Definition: MixerBoard.cpp:111
MixerBoard::OnSize
void OnSize(wxSizeEvent &evt)
Definition: MixerBoard.cpp:1333
MixerTrackCluster::mBitmapButton_MusicalInstrument
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:136
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
MixerBoardFrame::mMixerBoard
MixerBoard * mMixerBoard
Definition: MixerBoard.h:286
MixerBoard::mMixerTrackClusters
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:251
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
MixerBoard::mImageSoloOver
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:245
MixerBoard::MixerBoard
MixerBoard(AudacityProject *pProject, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:861
MixerTrackCluster::mSlider_Pan
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:139
MeterPanel
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: MeterPanel.h:97
MixerBoard::mProject
AudacityProject * mProject
Definition: MixerBoard.h:254
MixerBoardFrame::OnKeyEvent
void OnKeyEvent(wxKeyEvent &evt)
Definition: MixerBoard.cpp:1477
CommandManagerWindowClasses.h
MixerTrackCluster::UpdateMeter
void UpdateMeter(const double t0, const double t1)
Definition: MixerBoard.cpp:513
MixerBoard::RemoveTrackCluster
void RemoveTrackCluster(size_t nIndex)
Definition: MixerBoard.cpp:1054
MixerTrackSlider::OnFocus
void OnFocus(wxFocusEvent &event)
Definition: MixerBoard.cpp:106
MixerBoard::RefreshTrackClusters
void RefreshTrackClusters(bool bEraseBackground=true)
Definition: MixerBoard.cpp:1127
MixerTrackCluster::HandleSelect
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:677
MixerBoardFrame::OnSize
void OnSize(wxSizeEvent &evt)
Definition: MixerBoard.cpp:1472
MixerTrackCluster::OnButton_MusicalInstrument
void OnButton_MusicalInstrument(wxCommandEvent &event)
Definition: MixerBoard.cpp:718
Prefs.h
MixerBoard::mTracks
TrackList * mTracks
Definition: MixerBoard.h:257
MixerTrackSlider::mIsPan
bool mIsPan
Definition: MixerBoard.h:55
MixerTrackCluster::HandleSliderGain
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:412
MixerTrackSlider
Definition: MixerBoard.h:39
MixerBoard::OnTimer
void OnTimer(wxCommandEvent &event)
Definition: MixerBoard.cpp:1342
MixerBoard::HasSolo
bool HasSolo()
Definition: MixerBoard.cpp:1122
MixerBoard::OnTrackChanged
void OnTrackChanged(TrackListEvent &event)
Definition: MixerBoard.cpp:1370
MixerTrackCluster::HandleResize
void HandleResize()
Definition: MixerBoard.cpp:373
MixerBoard::FindMixerTrackCluster
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
Definition: MixerBoard.cpp:1263
MixerBoard::CreateMuteSoloImages
void CreateMuteSoloImages()
Definition: MixerBoard.cpp:1222
MixerBoardScrolledWindow::mMixerBoard
MixerBoard * mMixerBoard
Definition: MixerBoard.h:182
MixerBoard::mUpToDate
bool mUpToDate
Definition: MixerBoard.h:258
MixerTrackCluster::mToggleButton_Solo
AButton * mToggleButton_Solo
Definition: MixerBoard.h:138
MixerBoardFrame::OnCloseWindow
void OnCloseWindow(wxCloseEvent &WXUNUSED(event))
Definition: MixerBoard.cpp:1452
MixerBoardFrame::~MixerBoardFrame
virtual ~MixerBoardFrame()
Definition: MixerBoard.cpp:1446
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:66
MixerTrackCluster::mTrack
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:128
MixerBoardScrolledWindow::~MixerBoardScrolledWindow
virtual ~MixerBoardScrolledWindow()
Definition: MixerBoard.cpp:830
MixerBoard::LoadMusicalInstruments
void LoadMusicalInstruments()
Definition: MixerBoard.cpp:1278
MixerTrackCluster::GetTrackColor
wxColour GetTrackColor()
Definition: MixerBoard.cpp:669
MixerBoard::OnStartStop
void OnStartStop(wxCommandEvent &event)
Definition: MixerBoard.cpp:1392