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;
34
35using ChannelGroupSampleView = std::vector<std::vector<AudioSegmentSampleView>>;
36
37// containment hierarchy:
38// MixerBoardFrame -> MixerBoard -> MixerBoardScrolledWindow -> MixerTrackCluster(s)
39
40
41// MixerTrackSlider is a subclass just to override OnMouseEvent,
42// so we can know when adjustment ends, so we can PushState only then.
43class MixerTrackSlider final : public ASlider
44{
45public:
46 MixerTrackSlider(wxWindow * parent,
47 wxWindowID id,
49 const wxPoint & pos,
50 const wxSize & size,
51 const ASlider::Options &options = ASlider::Options{});
52 virtual ~MixerTrackSlider() {}
53
54 void OnMouseEvent(wxMouseEvent & event);
55
56 void OnFocus(wxFocusEvent &event);
57 void OnCaptureKey(wxCommandEvent& event);
58
59protected:
60 bool mIsPan;
61
62public:
63 DECLARE_EVENT_TABLE()
64};
65
66
67class AudacityProject;
68class MeterPanel;
69class MixerBoard;
70
71class Track;
72#ifdef USE_MIDI
73class NoteTrack;
74#endif
75class PlayableTrack;
76
77class WaveChannel;
78class WaveTrack;
79class auStaticText;
80
82{
83public:
84 MixerTrackCluster(wxWindow* parent,
85 MixerBoard* grandParent, AudacityProject* project,
86 PlayableTrack &track,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize);
89 virtual ~MixerTrackCluster() {}
90
91 WaveTrack *GetWave() const;
92 WaveChannel *GetRight() const;
93 NoteTrack *GetNote() const;
94
95 //void UpdatePrefs();
96
97 void HandleResize(); // For wxSizeEvents, update volume slider and meter.
98
99 void HandleSliderGain(const bool bWantPushState = false);
100 void HandleSliderVelocity(const bool bWantPushState = false);
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 void OnSlider_Velocity(wxCommandEvent& event);
121 void OnSlider_Pan(wxCommandEvent& event);
122 void OnButton_Mute(wxCommandEvent& event);
123 void OnButton_Solo(wxCommandEvent& event);
124
125public:
127 std::shared_ptr<PlayableTrack> mTrack;
128
129private:
132
133 // controls
141 wxWeakRef<MeterPanel> mMeter;
143
144public:
145 DECLARE_EVENT_TABLE()
146};
147
148
150{
151public:
152 MusicalInstrument(std::unique_ptr<wxBitmap> &&pBitmap, const wxString & strXPMfilename);
153 virtual ~MusicalInstrument();
154
155 std::unique_ptr<wxBitmap> mBitmap;
156 wxArrayString mKeywords;
157};
158
159using MusicalInstrumentArray = std::vector<std::unique_ptr<MusicalInstrument>>;
160
161
162
163// wxScrolledWindow ignores mouse clicks in client area,
164// but they don't get passed to Mixerboard.
165// We need to catch them to deselect all track clusters.
166class MixerBoardScrolledWindow final : public wxScrolledWindow
167{
168public:
170 MixerBoard* parent, wxWindowID id = -1,
171 const wxPoint& pos = wxDefaultPosition,
172 const wxSize& size = wxDefaultSize,
173 long style = wxHSCROLL | wxVSCROLL);
175
176private:
177 void OnMouseEvent(wxMouseEvent& event);
178
179private:
182
183public:
184 DECLARE_EVENT_TABLE()
185};
186
187
188class MixerBoardFrame;
189class TrackList;
190
191class MixerBoard final : public wxWindow, private PrefsListener
192{
193 friend class MixerBoardFrame;
194
195public:
196 MixerBoard(AudacityProject* pProject,
197 wxFrame* parent,
198 const wxPoint& pos = wxDefaultPosition,
199 const wxSize& size = wxDefaultSize);
200
201 void UpdatePrefs() override;
202
203 // Add clusters for any tracks we're not yet showing.
204 // Update pointers for tracks we're already showing.
205 void UpdateTrackClusters();
206
208
209
210 wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);
211
212 bool HasSolo();
213
214 void RefreshTrackClusters(bool bEraseBackground = true);
215 void ResizeTrackClusters();
216
217 void UpdateMeters(const double t1, const bool bLoopedPlay);
218
219 void UpdateWidth();
220
221private:
222 void ResetMeters(const bool bResetClipping);
223 void RemoveTrackCluster(size_t nIndex);
224 void MakeButtonBitmap( wxMemoryDC & dc, wxBitmap & bitmap,
225 wxRect & bev, const TranslatableString & str, bool up );
227 int FindMixerTrackCluster(const PlayableTrack* pTrack,
228 MixerTrackCluster** hMixerTrackCluster) const;
230
231 // event handlers
232 void OnPaint(wxPaintEvent& evt);
233 void OnSize(wxSizeEvent &evt);
235 void OnTrackSetChanged();
236 void OnTrackChanged(const TrackListEvent &event);
238
239public:
240 // mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
241 std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,
242 mImageMuteDownWhileSolo, // the one actually alternate image
244
246
247private:
251
252 // Track clusters are maintained in the same order as the WaveTracks.
253 std::vector<MixerTrackCluster*> mMixerTrackClusters;
254
257 MixerBoardScrolledWindow* mScrolledWindow; // Holds the MixerTrackClusters and handles scrolling.
258 double mPrevT1;
260 bool mUpToDate{ false };
261
262public:
263 DECLARE_EVENT_TABLE()
264};
265
266
268 : public wxFrame
270{
271public:
273 virtual ~MixerBoardFrame();
274
275 void Recreate(AudacityProject *pProject);
276
277private:
278 // event handlers
279 void OnCloseWindow(wxCloseEvent &WXUNUSED(event));
280 void OnMaximize(wxMaximizeEvent &event);
281 void OnSize(wxSizeEvent &evt);
282 void OnKeyEvent(wxKeyEvent &evt);
283
284 void SetWindowTitle();
285
288public:
290
291public:
292 DECLARE_EVENT_TABLE()
293};
294
295#endif // __AUDACITY_MIXER_BOARD__
296
297
wxImage(22, 22)
#define str(a)
std::vector< std::unique_ptr< MusicalInstrument > > MusicalInstrumentArray
Definition: MixerBoard.h:159
std::vector< std::vector< AudioSegmentSampleView > > ChannelGroupSampleView
Definition: MixerBoard.h:35
wxString name
Definition: TagsEditor.cpp:166
const auto project
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:91
void OnKeyEvent(wxKeyEvent &evt)
void OnMaximize(wxMaximizeEvent &event)
Observer::Subscription mTitleChangeSubscription
Definition: MixerBoard.h:286
void OnCloseWindow(wxCloseEvent &WXUNUSED(event))
AudacityProject * mProject
Definition: MixerBoard.h:287
MixerBoardFrame(AudacityProject *parent)
void OnSize(wxSizeEvent &evt)
MixerBoard * mMixerBoard
Definition: MixerBoard.h:289
virtual ~MixerBoardFrame()
void Recreate(AudacityProject *pProject)
bool mUpToDate
Definition: MixerBoard.h:260
void OnSize(wxSizeEvent &evt)
void OnStartStop(AudioIOEvent)
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:242
void UpdateWidth()
void ResizeTrackClusters()
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:255
void UpdateMeters(const double t1, const bool bLoopedPlay)
void OnPaint(wxPaintEvent &evt)
void OnTrackSetChanged()
TrackList * mTracks
Definition: MixerBoard.h:259
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:243
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:243
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const TranslatableString &str, bool up)
void UpdatePrefs() override
Definition: MixerBoard.cpp:936
void OnTimer(Observer::Message)
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:257
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:241
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
void OnTrackChanged(const TrackListEvent &event)
void UpdateTrackClusters()
Definition: MixerBoard.cpp:970
bool HasSolo()
Observer::Subscription mTrackPanelSubscription
Definition: MixerBoard.h:249
Observer::Subscription mAudioIOSubscription
Definition: MixerBoard.h:250
void ResetMeters(const bool bResetClipping)
MixerBoard(AudacityProject *pProject, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:854
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:243
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:243
int GetTrackClustersWidth()
void RemoveTrackCluster(size_t nIndex)
void CreateMuteSoloImages()
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:243
void LoadMusicalInstruments()
AudacityProject * mProject
Definition: MixerBoard.h:256
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:253
void RefreshTrackClusters(bool bEraseBackground=true)
int mMuteSoloWidth
Definition: MixerBoard.h:245
Observer::Subscription mPlaybackScrollerSubscription
Definition: MixerBoard.h:248
double mPrevT1
Definition: MixerBoard.h:258
AudacityProject * mProject
Definition: MixerBoard.h:181
MixerBoard * mMixerBoard
Definition: MixerBoard.h:180
virtual ~MixerBoardScrolledWindow()
Definition: MixerBoard.cpp:823
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:827
MixerBoardScrolledWindow(AudacityProject *project, MixerBoard *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL)
Definition: MixerBoard.cpp:812
void HandleSliderVelocity(const bool bWantPushState=false)
Definition: MixerBoard.cpp:414
MixerTrackCluster(wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, PlayableTrack &track, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: MixerBoard.cpp:173
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:135
void OnSlider_Gain(wxCommandEvent &event)
Definition: MixerBoard.cpp:734
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:401
void UpdateForStateChange()
Definition: MixerBoard.cpp:453
void OnButton_MusicalInstrument(wxCommandEvent &event)
Definition: MixerBoard.cpp:728
std::shared_ptr< PlayableTrack > mTrack
Invariant not null.
Definition: MixerBoard.h:127
AudacityProject * mProject
Definition: MixerBoard.h:131
NoteTrack * GetNote() const
Definition: MixerBoard.cpp:351
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:443
void OnSlider_Pan(wxCommandEvent &event)
Definition: MixerBoard.cpp:744
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:334
AButton * mToggleButton_Mute
Definition: MixerBoard.h:136
ChannelGroupSampleView mSampleView
Definition: MixerBoard.h:142
MixerBoard * mMixerBoard
Definition: MixerBoard.h:130
wxWeakRef< MeterPanel > mMeter
Definition: MixerBoard.h:141
MixerTrackSlider * mSlider_Volume
Definition: MixerBoard.h:139
void UpdateMeter(const double t0, const double t1)
Definition: MixerBoard.cpp:519
void OnPaint(wxPaintEvent &evt)
Definition: MixerBoard.cpp:701
void OnButton_Mute(wxCommandEvent &event)
Definition: MixerBoard.cpp:749
WaveChannel * GetRight() const
Definition: MixerBoard.cpp:339
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:687
void OnKeyEvent(wxKeyEvent &event)
wxColour GetTrackColor()
Definition: MixerBoard.cpp:679
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:693
void OnSlider_Velocity(wxCommandEvent &event)
Definition: MixerBoard.cpp:739
virtual ~MixerTrackCluster()
Definition: MixerBoard.h:89
MixerTrackSlider * mSlider_Velocity
Definition: MixerBoard.h:140
void OnButton_Solo(wxCommandEvent &event)
Definition: MixerBoard.cpp:763
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:138
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:428
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:134
AButton * mToggleButton_Solo
Definition: MixerBoard.h:137
void OnCaptureKey(wxCommandEvent &event)
Definition: MixerBoard.cpp:116
void OnFocus(wxFocusEvent &event)
Definition: MixerBoard.cpp:111
void OnMouseEvent(wxMouseEvent &event)
Definition: MixerBoard.cpp:95
virtual ~MixerTrackSlider()
Definition: MixerBoard.h:52
MixerTrackSlider(wxWindow *parent, wxWindowID id, const TranslatableString &name, const wxPoint &pos, const wxSize &size, const ASlider::Options &options=ASlider::Options{})
Definition: MixerBoard.cpp:85
MusicalInstrument(std::unique_ptr< wxBitmap > &&pBitmap, const wxString &strXPMfilename)
Definition: MixerBoard.cpp:778
virtual ~MusicalInstrument()
Definition: MixerBoard.cpp:796
std::unique_ptr< wxBitmap > mBitmap
Definition: MixerBoard.h:155
wxArrayString mKeywords
Definition: MixerBoard.h:156
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
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: PlayableTrack.h:40
A listener notified of changes in preferences.
Definition: Prefs.h:652
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
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:803