Audacity 3.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
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 "Observer.h"
24#include "Prefs.h"
25
26class wxArrayString;
27class wxBitmapButton;
28class wxImage;
29class wxMemoryDC;
30class AButton;
31struct AudioIOEvent;
32struct TrackListEvent;
33
34// containment hierarchy:
35// MixerBoardFrame -> MixerBoard -> MixerBoardScrolledWindow -> MixerTrackCluster(s)
36
37
38// MixerTrackSlider is a subclass just to override OnMouseEvent,
39// so we can know when adjustment ends, so we can PushState only then.
40class MixerTrackSlider final : public ASlider
41{
42public:
43 MixerTrackSlider(wxWindow * parent,
44 wxWindowID id,
46 const wxPoint & pos,
47 const wxSize & size,
48 const ASlider::Options &options = ASlider::Options{});
49 virtual ~MixerTrackSlider() {}
50
51 void OnMouseEvent(wxMouseEvent & event);
52
53 void OnFocus(wxFocusEvent &event);
54 void OnCaptureKey(wxCommandEvent& event);
55
56protected:
57 bool mIsPan;
58
59public:
60 DECLARE_EVENT_TABLE()
61};
62
63
64class AudacityProject;
65class MeterPanel;
66class MixerBoard;
67
68class Track;
69#ifdef USE_MIDI
70class NoteTrack;
71#endif
72class PlayableTrack;
73
74class WaveTrack;
75class auStaticText;
76
78{
79public:
80 MixerTrackCluster(wxWindow* parent,
81 MixerBoard* grandParent, AudacityProject* project,
82 const std::shared_ptr<PlayableTrack> &pTrack,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize);
85 virtual ~MixerTrackCluster() {}
86
87 WaveTrack *GetWave() const;
88 WaveTrack *GetRight() const;
89#ifdef EXPERIMENTAL_MIDI_OUT
90 NoteTrack *GetNote() const;
91#endif
92
93 //void UpdatePrefs();
94
95 void HandleResize(); // For wxSizeEvents, update gain slider and meter.
96
97 void HandleSliderGain(const bool bWantPushState = false);
98#ifdef EXPERIMENTAL_MIDI_OUT
99 void HandleSliderVelocity(const bool bWantPushState = false);
100#endif
101 void HandleSliderPan(const bool bWantPushState = false);
102
103 void ResetMeter(const bool bResetClipping);
104
106 void UpdateMeter(const double t0, const double t1);
107
108private:
109 wxColour GetTrackColor();
110
111 // event handlers
112 void HandleSelect(bool bShiftDown, bool bControlDown);
113
114 void OnKeyEvent(wxKeyEvent& event);
115 void OnMouseEvent(wxMouseEvent& event);
116 void OnPaint(wxPaintEvent& evt);
117
118 void OnButton_MusicalInstrument(wxCommandEvent& event);
119 void OnSlider_Gain(wxCommandEvent& event);
120#ifdef EXPERIMENTAL_MIDI_OUT
121 void OnSlider_Velocity(wxCommandEvent& event);
122#endif
123 void OnSlider_Pan(wxCommandEvent& event);
124 void OnButton_Mute(wxCommandEvent& event);
125 void OnButton_Solo(wxCommandEvent& event);
126 //v void OnSliderScroll_Gain(wxScrollEvent& event);
127
128
129public:
130 std::shared_ptr<PlayableTrack> mTrack;
131
132private:
135
136 // controls
143#ifdef EXPERIMENTAL_MIDI_OUT
144 MixerTrackSlider* mSlider_Velocity;
145#endif
146 wxWeakRef<MeterPanel> mMeter;
147
148public:
149 DECLARE_EVENT_TABLE()
150};
151
152
154{
155public:
156 MusicalInstrument(std::unique_ptr<wxBitmap> &&pBitmap, const wxString & strXPMfilename);
157 virtual ~MusicalInstrument();
158
159 std::unique_ptr<wxBitmap> mBitmap;
160 wxArrayString mKeywords;
161};
162
163using MusicalInstrumentArray = std::vector<std::unique_ptr<MusicalInstrument>>;
164
165
166
167// wxScrolledWindow ignores mouse clicks in client area,
168// but they don't get passed to Mixerboard.
169// We need to catch them to deselect all track clusters.
170class MixerBoardScrolledWindow final : public wxScrolledWindow
171{
172public:
174 MixerBoard* parent, wxWindowID id = -1,
175 const wxPoint& pos = wxDefaultPosition,
176 const wxSize& size = wxDefaultSize,
177 long style = wxHSCROLL | wxVSCROLL);
179
180private:
181 void OnMouseEvent(wxMouseEvent& event);
182
183private:
186
187public:
188 DECLARE_EVENT_TABLE()
189};
190
191
192class MixerBoardFrame;
193class TrackList;
194
195class MixerBoard final : public wxWindow, private PrefsListener
196{
197 friend class MixerBoardFrame;
198
199public:
200 MixerBoard(AudacityProject* pProject,
201 wxFrame* parent,
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize);
204
205 void UpdatePrefs() override;
206
207 // Add clusters for any tracks we're not yet showing.
208 // Update pointers for tracks we're already showing.
209 void UpdateTrackClusters();
210
212
213
214 wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);
215
216 bool HasSolo();
217
218 void RefreshTrackClusters(bool bEraseBackground = true);
219 void ResizeTrackClusters();
220
221 void UpdateMeters(const double t1, const bool bLoopedPlay);
222
223 void UpdateWidth();
224
225private:
226 void ResetMeters(const bool bResetClipping);
227 void RemoveTrackCluster(size_t nIndex);
228 void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
229 wxRect & bev, const TranslatableString & str, bool up );
231 int FindMixerTrackCluster(const PlayableTrack* pTrack,
232 MixerTrackCluster** hMixerTrackCluster) const;
234
235 // event handlers
236 void OnPaint(wxPaintEvent& evt);
237 void OnSize(wxSizeEvent &evt);
239 void OnTrackSetChanged();
240 void OnTrackChanged(const TrackListEvent &event);
242
243public:
244 // mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
245 std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,
246 mImageMuteDownWhileSolo, // the one actually alternate image
248
250
251private:
255
256 // Track clusters are maintained in the same order as the WaveTracks.
257 std::vector<MixerTrackCluster*> mMixerTrackClusters;
258
261 MixerBoardScrolledWindow* mScrolledWindow; // Holds the MixerTrackClusters and handles scrolling.
262 double mPrevT1;
264 bool mUpToDate{ false };
265
266public:
267 DECLARE_EVENT_TABLE()
268};
269
270
272 : public wxFrame
274{
275public:
277 virtual ~MixerBoardFrame();
278
279 void Recreate(AudacityProject *pProject);
280
281private:
282 // event handlers
283 void OnCloseWindow(wxCloseEvent &WXUNUSED(event));
284 void OnMaximize(wxMaximizeEvent &event);
285 void OnSize(wxSizeEvent &evt);
286 void OnKeyEvent(wxKeyEvent &evt);
287
288 void SetWindowTitle();
289
292public:
294
295public:
296 DECLARE_EVENT_TABLE()
297};
298
299#endif // __AUDACITY_MIXER_BOARD__
300
301
wxImage(22, 22)
#define str(a)
const TranslatableString name
Definition: Distortion.cpp:74
std::vector< std::unique_ptr< MusicalInstrument > > MusicalInstrumentArray
Definition: MixerBoard.h:163
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:260
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: MeterPanel.h:104
void OnKeyEvent(wxKeyEvent &evt)
void OnMaximize(wxMaximizeEvent &event)
Observer::Subscription mTitleChangeSubscription
Definition: MixerBoard.h:290
void OnCloseWindow(wxCloseEvent &WXUNUSED(event))
AudacityProject * mProject
Definition: MixerBoard.h:291
MixerBoardFrame(AudacityProject *parent)
void OnSize(wxSizeEvent &evt)
MixerBoard * mMixerBoard
Definition: MixerBoard.h:293
virtual ~MixerBoardFrame()
void Recreate(AudacityProject *pProject)
bool mUpToDate
Definition: MixerBoard.h:264
void OnSize(wxSizeEvent &evt)
void OnStartStop(AudioIOEvent)
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:246
void UpdateWidth()
void ResizeTrackClusters()
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:259
void UpdateMeters(const double t1, const bool bLoopedPlay)
void OnPaint(wxPaintEvent &evt)
void OnTrackSetChanged()
TrackList * mTracks
Definition: MixerBoard.h:263
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:245
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:245
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:247
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const TranslatableString &str, bool up)
void UpdatePrefs() override
Definition: MixerBoard.cpp:951
void OnTimer(Observer::Message)
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:261
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:245
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
void OnTrackChanged(const TrackListEvent &event)
void UpdateTrackClusters()
Definition: MixerBoard.cpp:985
bool HasSolo()
Observer::Subscription mTrackPanelSubscription
Definition: MixerBoard.h:253
Observer::Subscription mAudioIOSubscription
Definition: MixerBoard.h:254
void ResetMeters(const bool bResetClipping)
MixerBoard(AudacityProject *pProject, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:865
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:247
int GetTrackClustersWidth()
void RemoveTrackCluster(size_t nIndex)
void CreateMuteSoloImages()
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:247
void LoadMusicalInstruments()
AudacityProject * mProject
Definition: MixerBoard.h:260
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:257
void RefreshTrackClusters(bool bEraseBackground=true)
int mMuteSoloWidth
Definition: MixerBoard.h:249
Observer::Subscription mPlaybackScrollerSubscription
Definition: MixerBoard.h:252
double mPrevT1
Definition: MixerBoard.h:262
AudacityProject * mProject
Definition: MixerBoard.h:185
MixerBoard * mMixerBoard
Definition: MixerBoard.h:184
virtual ~MixerBoardScrolledWindow()
Definition: MixerBoard.cpp:834
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:838
MixerBoardScrolledWindow(AudacityProject *project, MixerBoard *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL)
Definition: MixerBoard.cpp:823
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:138
void OnSlider_Gain(wxCommandEvent &event)
Definition: MixerBoard.cpp:728
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:413
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:142
void UpdateForStateChange()
Definition: MixerBoard.cpp:469
void OnButton_MusicalInstrument(wxCommandEvent &event)
Definition: MixerBoard.cpp:722
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:130
AudacityProject * mProject
Definition: MixerBoard.h:134
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:461
void OnSlider_Pan(wxCommandEvent &event)
Definition: MixerBoard.cpp:755
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:338
AButton * mToggleButton_Mute
Definition: MixerBoard.h:139
MixerBoard * mMixerBoard
Definition: MixerBoard.h:133
wxWeakRef< MeterPanel > mMeter
Definition: MixerBoard.h:146
void UpdateMeter(const double t0, const double t1)
Definition: MixerBoard.cpp:514
void OnPaint(wxPaintEvent &evt)
Definition: MixerBoard.cpp:695
void OnButton_Mute(wxCommandEvent &event)
Definition: MixerBoard.cpp:760
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:681
void OnKeyEvent(wxKeyEvent &event)
wxColour GetTrackColor()
Definition: MixerBoard.cpp:673
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:687
MixerTrackCluster(wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, const std::shared_ptr< PlayableTrack > &pTrack, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:173
virtual ~MixerTrackCluster()
Definition: MixerBoard.h:85
void OnButton_Solo(wxCommandEvent &event)
Definition: MixerBoard.cpp:774
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:141
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:343
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:444
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:137
AButton * mToggleButton_Solo
Definition: MixerBoard.h:140
void OnCaptureKey(wxCommandEvent &event)
Definition: MixerBoard.cpp:112
void OnFocus(wxFocusEvent &event)
Definition: MixerBoard.cpp:107
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:91
virtual ~MixerTrackSlider()
Definition: MixerBoard.h:49
MixerTrackSlider(wxWindow *parent, wxWindowID id, const TranslatableString &name, const wxPoint &pos, const wxSize &size, const ASlider::Options &options=ASlider::Options{})
Definition: MixerBoard.cpp:81
MusicalInstrument(std::unique_ptr< wxBitmap > &&pBitmap, const wxString &strXPMfilename)
Definition: MixerBoard.cpp:789
virtual ~MusicalInstrument()
Definition: MixerBoard.cpp:807
std::unique_ptr< wxBitmap > mBitmap
Definition: MixerBoard.h:159
wxArrayString mKeywords
Definition: MixerBoard.h:160
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:63
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
AudioTrack subclass that can also be audibly replayed by the program.
Definition: Track.h:916
A listener notified of changes in preferences.
Definition: Prefs.h:556
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1338
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: auStaticText.h:20
Default message type for Publisher.
Definition: Observer.h:26
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:1288