Audacity  2.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
MixerTrackCluster Class Referencefinal

#include <MixerBoard.h>

Inheritance diagram for MixerTrackCluster:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 MixerTrackCluster (wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, const std::shared_ptr< PlayableTrack > &pTrack, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
virtual ~MixerTrackCluster ()
 
WaveTrackGetWave () const
 
WaveTrackGetRight () const
 
void UpdatePrefs ()
 
void HandleResize ()
 
void HandleSliderGain (const bool bWantPushState=false)
 
void HandleSliderPan (const bool bWantPushState=false)
 
void ResetMeter (const bool bResetClipping)
 
void UpdateForStateChange ()
 
void UpdateName ()
 
void UpdateMute ()
 
void UpdateSolo ()
 
void UpdatePan ()
 
void UpdateGain ()
 
void UpdateMeter (const double t0, const double t1)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Public Attributes

std::shared_ptr< PlayableTrackmTrack
 

Private Member Functions

wxColour GetTrackColor ()
 
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)
 
void OnSlider_Pan (wxCommandEvent &event)
 
void OnButton_Mute (wxCommandEvent &event)
 
void OnButton_Solo (wxCommandEvent &event)
 

Private Attributes

MixerBoardmMixerBoard
 
AudacityProjectmProject
 
auStaticTextmStaticText_TrackName
 
wxBitmapButton * mBitmapButton_MusicalInstrument
 
AButtonmToggleButton_Mute
 
AButtonmToggleButton_Solo
 
MixerTrackSlidermSlider_Pan
 
MixerTrackSlidermSlider_Gain
 
MeterPanelmMeter
 

Detailed Description

Definition at line 71 of file MixerBoard.h.

Constructor & Destructor Documentation

MixerTrackCluster::MixerTrackCluster ( wxWindow *  parent,
MixerBoard grandParent,
AudacityProject project,
const std::shared_ptr< PlayableTrack > &  pTrack,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)

Definition at line 160 of file MixerBoard.cpp.

165 : wxPanelWrapper(parent, -1, pos, size)
166 , mTrack{ pTrack }
167 {
168  mMixerBoard = grandParent;
169  mProject = project;
170  wxASSERT( pTrack );
171 
172  SetName(mTrack->GetName());
173 
174  //this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
175  this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
176  // Not sure why, but sizers weren't getting offset vertically,
177  // probably because not using wxDefaultPosition,
178  // so positions are calculated explicitly below, and sizers code was removed.
179  // (Still available in Audacity_UmixIt branch off 1.2.6.)
180 
181  // track name
182  wxPoint ctrlPos(kDoubleInset, kDoubleInset);
183  wxSize ctrlSize(size.GetWidth() - kQuadrupleInset, TRACK_NAME_HEIGHT);
185  safenew auStaticText(this, mTrack->GetName());
186  //v Useful when different tracks are different colors, but not now.
187  // mStaticText_TrackName->SetBackgroundColour(this->GetTrackColor());
188  mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrMedium));
189  mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
190  mStaticText_TrackName->SetSize( ctrlSize );
191  mStaticText_TrackName->SetPosition( ctrlPos );
192 
193 
194  // gain and velocity sliders at left (both in same place)
195  ctrlPos.x = kDoubleInset;
196  ctrlPos.y += TRACK_NAME_HEIGHT + kDoubleInset;
197  const int nGainSliderHeight =
198  size.GetHeight() - ctrlPos.y - kQuadrupleInset;
199  ctrlSize.Set(kLeftSideStackWidth - kQuadrupleInset, nGainSliderHeight);
200 
201  mSlider_Gain =
203  this, ID_SLIDER_GAIN,
204  /* i18n-hint: title of the Gain slider, used to adjust the volume */
205  _("Gain"),
206  ctrlPos, ctrlSize,
208  .Style( DB_SLIDER )
209  .Orientation( wxVERTICAL ));
210  mSlider_Gain->SetName(_("Gain"));
211  this->UpdateGain();
212 #ifdef EXPERIMENTAL_MIDI_OUT
213  mSlider_Velocity =
215  this, ID_SLIDER_VELOCITY,
216  /* i18n-hint: title of the MIDI Velocity slider */
217  _("Velocity"),
218  ctrlPos, ctrlSize,
220  .Style( VEL_SLIDER )
221  .Orientation( wxVERTICAL ));
222  mSlider_Velocity->SetName(_("Velocity"));
223  this->UpdateVelocity();
224 #endif
225 
226  // other controls and meter at right
227 
228  // musical instrument image
229  ctrlPos.x += kLeftSideStackWidth + kInset; // + kInset to center it in right side stack
231  wxBitmap* bitmap = mMixerBoard->GetMusicalInstrumentBitmap(mTrack.get());
232  wxASSERT(bitmap);
234  safenew wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap,
235  ctrlPos, ctrlSize,
236  wxBU_AUTODRAW, wxDefaultValidator,
237  _("Musical Instrument"));
238  mBitmapButton_MusicalInstrument->SetName(_("Musical Instrument"));
239 
240 
241  // pan slider
242  ctrlPos.x -= kInset; // Remove inset for instrument, so Pan is at leftmost of left side stack.
244  ctrlSize.Set(kRightSideStackWidth, PAN_HEIGHT);
245 
246  // The width of the pan slider must be odd (don't ask).
247  if (!(ctrlSize.x & 1))
248  ctrlSize.x--;
249 
250  mSlider_Pan =
252  this, ID_SLIDER_PAN,
253  /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
254  _("Pan"),
255  ctrlPos, ctrlSize,
257  mSlider_Pan->SetName(_("Pan"));
258 
259  this->UpdatePan();
260 
261  // mute/solo buttons stacked below Pan slider
262  ctrlPos.y += PAN_HEIGHT + kDoubleInset;
266  ctrlPos, ctrlSize,
270  true); // toggle button
271  mToggleButton_Mute->SetName(_("Mute"));
273  1,
277  this->UpdateMute();
278 
279  ctrlPos.y += MUTE_SOLO_HEIGHT;
282  ctrlPos, ctrlSize,
286  true); // toggle button
287  mToggleButton_Solo->SetName(_("Solo"));
288  this->UpdateSolo();
289  bool bSoloNone = mProject->IsSoloNone();
290  mToggleButton_Solo->Show(!bSoloNone);
291 
292 
293  // meter
294  ctrlPos.y += (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset;
295  const int nMeterHeight =
296  nGainSliderHeight -
298  (PAN_HEIGHT + kDoubleInset) -
299  (MUTE_SOLO_HEIGHT + (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset);
300  ctrlSize.Set(kRightSideStackWidth, nMeterHeight);
301 
302  mMeter = NULL;
303  if (GetWave()) {
304  mMeter =
305  safenew MeterPanel(GetActiveProject(), // AudacityProject* project,
306  this, -1, // wxWindow* parent, wxWindowID id,
307  false, // bool isInput
308  ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
309  MeterPanel::MixerTrackCluster); // Style style = HorizontalStereo,
310  mMeter->SetName(_("Signal Level Meter"));
311  }
312 
313  #if wxUSE_TOOLTIPS
314  mStaticText_TrackName->SetToolTip(mTrack->GetName());
315  mToggleButton_Mute->SetToolTip(_("Mute"));
316  mToggleButton_Solo->SetToolTip(_("Solo"));
317  if (GetWave())
318  mMeter->SetToolTip(_("Signal Level Meter"));
319  #endif // wxUSE_TOOLTIPS
320 
321  #ifdef __WXMAC__
322  wxSizeEvent event(GetSize(), GetId());
323  event.SetEventObject(this);
324  GetEventHandler()->ProcessEvent(event);
325  UpdateGain();
326  #endif
327 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
const int TRACK_NAME_HEIGHT
Definition: MixerBoard.cpp:125
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:258
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:144
void SetAlternateImages(unsigned idx, ImageRoll up, ImageRoll over, ImageRoll down, ImageRoll overDown, ImageRoll dis)
Definition: AButton.cpp:232
const int kDoubleInset
Definition: MixerBoard.cpp:121
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:140
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:258
const int kInset
Definition: MixerBoard.cpp:120
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: Theme.h:177
Options & Orientation(wxOrientation o)
Definition: ASlider.h:261
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:258
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: Meter.h:97
int mMuteSoloWidth
Definition: MixerBoard.h:262
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:127
#define safenew
Definition: Audacity.h:230
#define PAN_SLIDER
Definition: ASlider.h:46
const int PAN_HEIGHT
Definition: MixerBoard.cpp:128
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:141
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:258
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:258
const int kQuadrupleInset
Definition: MixerBoard.cpp:123
AButton * mToggleButton_Solo
Definition: MixerBoard.h:143
bool IsSoloNone() const
Definition: Project.h:607
#define DB_SLIDER
Definition: ASlider.h:45
#define VEL_SLIDER
Definition: ASlider.h:49
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:258
AButton * mToggleButton_Mute
Definition: MixerBoard.h:142
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:145
const int kRightSideStackWidth
Definition: MixerBoard.cpp:131
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
const int kLeftSideStackWidth
Definition: MixerBoard.cpp:130
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:258
MeterPanel * mMeter
Definition: MixerBoard.h:149
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
MixerBoard * mMixerBoard
Definition: MixerBoard.h:136
AudacityProject * mProject
Definition: MixerBoard.h:137
Options & Style(int s)
Definition: ASlider.h:260
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:126
virtual MixerTrackCluster::~MixerTrackCluster ( )
inlinevirtual

Definition at line 79 of file MixerBoard.h.

79 {}

Member Function Documentation

WaveTrack * MixerTrackCluster::GetRight ( ) const

Definition at line 334 of file MixerBoard.cpp.

References GetWave().

Referenced by HandleSliderGain(), HandleSliderPan(), and UpdateMeter().

335 {
336  auto left = GetWave();
337  if (left)
338  return static_cast<WaveTrack*>(left->GetLink());
339  else
340  return nullptr;
341 }
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
wxColour MixerTrackCluster::GetTrackColor ( )
private

Definition at line 677 of file MixerBoard.cpp.

678 {
679  return wxColour(102, 255, 102); // same as Meter playback color
680 }
WaveTrack * MixerTrackCluster::GetWave ( ) const

Definition at line 329 of file MixerBoard.cpp.

References mTrack.

Referenced by GetRight(), HandleSliderGain(), HandleSliderPan(), ResetMeter(), UpdateGain(), UpdateMeter(), and UpdatePan().

330 {
331  return dynamic_cast< WaveTrack * >( mTrack.get() );
332 }
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void MixerTrackCluster::HandleResize ( )

Definition at line 359 of file MixerBoard.cpp.

References AudacityProject::IsSoloNone(), kDoubleInset, kQuadrupleInset, mMeter, mProject, mSlider_Gain, mToggleButton_Solo, MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH, MUTE_SOLO_HEIGHT, PAN_HEIGHT, and TRACK_NAME_HEIGHT.

Referenced by UpdatePrefs().

360 {
361  wxSize scrolledWindowClientSize = this->GetParent()->GetClientSize();
362  const int newClusterHeight =
363  scrolledWindowClientSize.GetHeight() - kDoubleInset - // nClusterHeight from MixerBoard::UpdateTrackClusters
364  wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y) + // wxScrolledWindow::GetClientSize doesn't account for its scrollbar size.
365  kDoubleInset;
366 
367  this->SetSize(-1, newClusterHeight);
368 
369  // Change only the heights of mSlider_Gain and mMeter.
370  // But update shown status of mToggleButton_Solo, which affects top of mMeter.
371  const int nGainSliderHeight =
372  newClusterHeight -
373  (kInset + // margin above mStaticText_TrackName
374  TRACK_NAME_HEIGHT + kDoubleInset) - // mStaticText_TrackName + margin
375  kQuadrupleInset; // margin below gain slider
376  mSlider_Gain->SetSize(-1, nGainSliderHeight);
377 #ifdef EXPERIMENTAL_MIDI_OUT
378  mSlider_Velocity->SetSize(-1, nGainSliderHeight);
379 #endif
380 
381  bool bSoloNone = mProject->IsSoloNone();
382 
383  mToggleButton_Solo->Show(!bSoloNone);
384 
385  const int nRequiredHeightAboveMeter =
386  MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH + kDoubleInset +
387  PAN_HEIGHT + kDoubleInset +
388  MUTE_SOLO_HEIGHT + (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset;
389  const int nMeterY =
390  kDoubleInset + // margin at top
391  TRACK_NAME_HEIGHT + kDoubleInset +
392  nRequiredHeightAboveMeter;
393  const int nMeterHeight = nGainSliderHeight - nRequiredHeightAboveMeter;
394  if (mMeter)
395  mMeter->SetSize(-1, nMeterY, -1, nMeterHeight);
396 }
const int TRACK_NAME_HEIGHT
Definition: MixerBoard.cpp:125
const int kDoubleInset
Definition: MixerBoard.cpp:121
const int kInset
Definition: MixerBoard.cpp:120
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:127
const int PAN_HEIGHT
Definition: MixerBoard.cpp:128
const int kQuadrupleInset
Definition: MixerBoard.cpp:123
AButton * mToggleButton_Solo
Definition: MixerBoard.h:143
bool IsSoloNone() const
Definition: Project.h:607
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:145
MeterPanel * mMeter
Definition: MixerBoard.h:149
AudacityProject * mProject
Definition: MixerBoard.h:137
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:126
void MixerTrackCluster::HandleSelect ( bool  bShiftDown,
bool  bControlDown 
)
private

Definition at line 685 of file MixerBoard.cpp.

References AudacityProject::HandleListSelection(), mProject, and mTrack.

Referenced by OnButton_MusicalInstrument(), and OnMouseEvent().

686 {
687  mProject->HandleListSelection( mTrack.get(), bShiftDown, bControlDown, true
688  );
689 }
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
AudacityProject * mProject
Definition: MixerBoard.h:137
void HandleListSelection(Track *t, bool shift, bool ctrl, bool modifyState)
Definition: Menus.cpp:3578
void MixerTrackCluster::HandleSliderGain ( const bool  bWantPushState = false)

Definition at line 398 of file MixerBoard.cpp.

References _(), CONSOLIDATE, ASlider::Get(), GetRight(), GetWave(), mProject, mSlider_Gain, mTrack, AudacityProject::RefreshTPTrack(), WaveTrack::SetGain(), and AudacityProject::TP_PushState().

Referenced by MixerTrackSlider::OnMouseEvent(), and OnSlider_Gain().

399 {
400  float fValue = mSlider_Gain->Get();
401  if (GetWave())
402  GetWave()->SetGain(fValue);
403  if (GetRight())
404  GetRight()->SetGain(fValue);
405 
406  // Update the TrackPanel correspondingly.
408  if (bWantPushState)
409  mProject->TP_PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE );
410 }
void TP_PushState(const wxString &longDesc, const wxString &shortDesc, UndoPush flags) override
Definition: Project.cpp:5413
float Get(bool convert=true)
Definition: ASlider.cpp:1567
void RefreshTPTrack(Track *pTrk, bool refreshbacking=true)
Definition: Project.cpp:5406
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
void SetGain(float newGain)
Definition: WaveTrack.cpp:420
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:334
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:145
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
AudacityProject * mProject
Definition: MixerBoard.h:137
void MixerTrackCluster::HandleSliderPan ( const bool  bWantPushState = false)

Definition at line 426 of file MixerBoard.cpp.

References _(), CONSOLIDATE, ASlider::Get(), GetRight(), GetWave(), mProject, mSlider_Pan, mTrack, AudacityProject::RefreshTPTrack(), WaveTrack::SetPan(), and AudacityProject::TP_PushState().

Referenced by MixerTrackSlider::OnMouseEvent(), and OnSlider_Pan().

427 {
428  float fValue = mSlider_Pan->Get();
429  if (GetWave()) // test in case track is a NoteTrack
430  GetWave()->SetPan(fValue);
431  if (GetRight())
432  GetRight()->SetPan(fValue);
433 
434  // Update the TrackPanel correspondingly.
436 
437  if (bWantPushState)
438  mProject->TP_PushState(_("Moved pan slider"), _("Pan"), UndoPush::CONSOLIDATE );
439 }
void TP_PushState(const wxString &longDesc, const wxString &shortDesc, UndoPush flags) override
Definition: Project.cpp:5413
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:144
float Get(bool convert=true)
Definition: ASlider.cpp:1567
void RefreshTPTrack(Track *pTrk, bool refreshbacking=true)
Definition: Project.cpp:5406
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:334
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
AudacityProject * mProject
Definition: MixerBoard.h:137
void SetPan(float newPan) override
Definition: WaveTrack.cpp:430
void MixerTrackCluster::OnButton_MusicalInstrument ( wxCommandEvent &  event)
private

Definition at line 723 of file MixerBoard.cpp.

References HandleSelect().

724 {
725  const auto &state = ::wxGetMouseState();
726  this->HandleSelect(state.ShiftDown(), state.ControlDown());
727 }
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:685
void MixerTrackCluster::OnButton_Mute ( wxCommandEvent &  event)
private

Definition at line 761 of file MixerBoard.cpp.

References AudacityProject::HandleTrackMute(), AudacityProject::IsSoloSimple(), mMixerBoard, mProject, mToggleButton_Mute, mTrack, AudacityProject::RedrawProject(), AudacityProject::RefreshTPTrack(), AButton::SetAlternateIdx(), MixerBoard::UpdateSolo(), and AButton::WasShiftDown().

762 {
764  mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
765 
766  // Update the TrackPanel correspondingly.
767  if (mProject->IsSoloSimple())
768  {
769  // Have to refresh all tracks.
772  }
773  else
774  // Update only the changed track.
776 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void RedrawProject(const bool bForceWaveTracks=false)
Definition: Project.cpp:1378
bool WasShiftDown()
Definition: AButton.cpp:485
void HandleTrackMute(Track *t, const bool exclusive)
Definition: Project.cpp:5786
void RefreshTPTrack(Track *pTrk, bool refreshbacking=true)
Definition: Project.cpp:5406
void UpdateSolo(const PlayableTrack *pTrack=NULL)
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
bool IsSoloSimple() const
Definition: Project.h:606
AButton * mToggleButton_Mute
Definition: MixerBoard.h:142
MixerBoard * mMixerBoard
Definition: MixerBoard.h:136
AudacityProject * mProject
Definition: MixerBoard.h:137
void MixerTrackCluster::OnButton_Solo ( wxCommandEvent &  event)
private

Definition at line 778 of file MixerBoard.cpp.

References AudacityProject::HandleTrackSolo(), AudacityProject::IsSoloSimple(), mMixerBoard, mProject, mToggleButton_Mute, mToggleButton_Solo, mTrack, AudacityProject::RedrawProject(), AButton::SetAlternateIdx(), MixerBoard::UpdateMute(), MixerBoard::UpdateSolo(), and AButton::WasShiftDown().

779 {
781  bool bIsSolo = mTrack->GetSolo();
782  mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
783 
784  // Update the TrackPanel correspondingly.
785  if (mProject->IsSoloSimple())
786  {
787  // Have to refresh all tracks.
790  }
791  // Bug 509: Must repaint all, as many tracks can change with one Solo change.
793 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void RedrawProject(const bool bForceWaveTracks=false)
Definition: Project.cpp:1378
bool WasShiftDown()
Definition: AButton.cpp:485
void UpdateSolo(const PlayableTrack *pTrack=NULL)
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
AButton * mToggleButton_Solo
Definition: MixerBoard.h:143
bool IsSoloSimple() const
Definition: Project.h:606
AButton * mToggleButton_Mute
Definition: MixerBoard.h:142
MixerBoard * mMixerBoard
Definition: MixerBoard.h:136
AudacityProject * mProject
Definition: MixerBoard.h:137
void HandleTrackSolo(Track *t, const bool alternate)
Definition: Project.cpp:5871
void UpdateMute(const PlayableTrack *pTrack=NULL)
void MixerTrackCluster::OnKeyEvent ( wxKeyEvent &  event)
private
void MixerTrackCluster::OnMouseEvent ( wxMouseEvent &  event)
private

Definition at line 691 of file MixerBoard.cpp.

References HandleSelect().

692 {
693  if (event.ButtonUp())
694  this->HandleSelect(event.ShiftDown(), event.ControlDown());
695  else
696  event.Skip();
697 }
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:685
void MixerTrackCluster::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 699 of file MixerBoard.cpp.

References AColor::Bevel(), ThemeBase::Colour(), AColor::MediumTrackInfo(), mMeter, mSlider_Gain, mSlider_Pan, mTrack, and theTheme.

700 {
701  auto selected = mTrack->GetSelected();
702 
703  wxColour col = theTheme.Colour(selected ? clrTrackInfoSelected : clrTrackInfo) ;
704  SetBackgroundColour( col );
705  mMeter->SetBackgroundColour( col );
706  mStaticText_TrackName->SetBackgroundColour( col );
707  mSlider_Gain->SetBackgroundColour( col );
708  mSlider_Pan->SetBackgroundColour( col );
709 
710  wxPaintDC dc(this);
711 
712  AColor::MediumTrackInfo(&dc, selected);
713  dc.DrawRectangle(this->GetClientRect());
714 
715  wxSize clusterSize = this->GetSize();
716  wxRect bev(0, 0, clusterSize.GetWidth() - 1, clusterSize.GetHeight() - 1);
717 
718  //bev.Inflate(-1, -1);
719  AColor::Bevel(dc, true, bev);// same bevel whether selected or not.
720 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:144
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:140
static void MediumTrackInfo(wxDC *dc, bool selected)
Definition: AColor.cpp:328
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:202
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:145
MeterPanel * mMeter
Definition: MixerBoard.h:149
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void MixerTrackCluster::OnSlider_Gain ( wxCommandEvent &  event)
private

Definition at line 729 of file MixerBoard.cpp.

References HandleSliderGain().

730 {
731  this->HandleSliderGain();
732 }
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:398
void MixerTrackCluster::OnSlider_Pan ( wxCommandEvent &  event)
private

Definition at line 756 of file MixerBoard.cpp.

References HandleSliderPan().

757 {
758  this->HandleSliderPan();
759 }
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:426
void MixerTrackCluster::ResetMeter ( const bool  bResetClipping)

Definition at line 441 of file MixerBoard.cpp.

References GetWave(), mMeter, and MeterPanel::Reset().

Referenced by UpdateMeter().

442 {
443  if (mMeter)
444  mMeter->Reset(GetWave()->GetRate(), bResetClipping);
445 }
void Reset(double sampleRate, bool resetClipping)
This method is thread-safe! Feel free to call from a different thread (like from an audio I/O callbac...
Definition: Meter.cpp:826
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
MeterPanel * mMeter
Definition: MixerBoard.h:149
void MixerTrackCluster::UpdateForStateChange ( )

Definition at line 451 of file MixerBoard.cpp.

References UpdateGain(), UpdateName(), and UpdatePan().

452 {
453  this->UpdateName();
454  this->UpdatePan();
455  this->UpdateGain();
456 }
void MixerTrackCluster::UpdateGain ( )

Definition at line 500 of file MixerBoard.cpp.

References GetWave(), mSlider_Gain, and ASlider::Set().

Referenced by UpdateForStateChange(), and MixerBoard::UpdateGain().

501 {
502  if (!GetWave()) {
503  mSlider_Gain->Hide();
504  return;
505  }
506  mSlider_Gain->Set(GetWave()->GetGain());
507 }
void Set(float value)
Definition: ASlider.cpp:1572
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:145
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
void MixerTrackCluster::UpdateMeter ( const double  t0,
const double  t1 
)

Definition at line 520 of file MixerBoard.cpp.

References fillZero, floatSample, WaveTrack::Get(), WaveTrack::GetChannelGain(), GetRight(), GetWave(), MixerBoard::HasSolo(), mMeter, mMixerBoard, mTrack, ResetMeter(), and MeterPanel::UpdateDisplay().

521 {
522  // NoteTracks do not (currently) register on meters. It would probably be
523  // a good idea to display 16 channel "active" lights rather than a meter
524  if (!GetWave())
525  return;
526 
527  if ((t0 < 0.0) || (t1 < 0.0) || (t0 >= t1) || // bad time value or nothing to show
528  ((mMixerBoard->HasSolo() || mTrack->GetMute()) && !mTrack->GetSolo())
529  )
530  {
531  //v Vaughan, 2011-02-25: Moved the update back to TrackPanel::OnTimer() as it helps with
532  // playback issues reported by Bill and noted on Bug 258, so no assert.
533  // Vaughan, 2011-02-04: Now that we're updating all meters from audacityAudioCallback,
534  // this causes an assert if you click Mute while playing, because ResetMeter() resets
535  // the timer, and wxTimerbase says that can only be done from main thread --
536  // but it seems to work fine.
537  this->ResetMeter(false);
538  return;
539  }
540 
541  // Vaughan, 2010-11-27:
542  // This commented out code is flawed. Mistaken understanding of "frame" vs "window".
543  // Caused me to override MeterPanel::UpdateDisplay().
544  // But I think it's got a good idea, of calling WaveTracks' GetMinMax and GetRMS
545  // instead of passing in all the data and asking the meter to derive peak and rms.
546  // May be worth revisiting as I think it should perform better, because it uses the min/max/rms
547  // stored in blockfiles, rather than calculating them, but for now, changing it to use the
548  // original MeterPanel::UpdateDisplay(). New code is below the previous (now commented out).
549  //
550  //const size_t kFramesPerBuffer = 4;
551  //float min; // dummy, since it's not shown in meters
552  //Floats maxLeft{kFramesPerBuffer};
553  //Floats rmsLeft{kFramesPerBuffer};
554  //Floats maxRight{kFramesPerBuffer};
555  //Floats rmsRight{kFramesPerBuffer};
556  //
557  //#ifdef EXPERIMENTAL_MIDI_OUT
558  // bool bSuccess = (GetWave() != nullptr);
559  //#else
560  // bool bSuccess = true;
561  //#endif
562 
563  //const double dFrameInterval = (t1 - t0) / (double)kFramesPerBuffer;
564  //double dFrameT0 = t0;
565  //double dFrameT1 = t0 + dFrameInterval;
566  //int i = 0;
567  //while (bSuccess && (i < kFramesPerBuffer))
568  //{
569  // bSuccess &=
570  // mTrack->GetMinMax(&min, &(maxLeft[i]), dFrameT0, dFrameT1) &&
571  // mTrack->GetRMS(&(rmsLeft[i]), dFrameT0, dFrameT1);
572  // if (bSuccess && mRightTrack)
573  // bSuccess &=
574  // mRightTrack->GetMinMax(&min, &(maxRight[i]), dFrameT0, dFrameT1) &&
575  // mRightTrack->GetRMS(&(rmsRight[i]), dFrameT0, dFrameT1);
576  // else
577  // {
578  // // Mono: Start with raw values same as left.
579  // // To be modified by bWantPostFadeValues and channel pan/gain.
580  // maxRight[i] = maxLeft[i];
581  // rmsRight[i] = rmsLeft[i];
582  // }
583  // dFrameT0 += dFrameInterval;
584  // dFrameT1 += dFrameInterval;
585  // i++;
586  //}
587  //
588  //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
589  //if (bSuccess && bWantPostFadeValues)
590  //if (bSuccess)
591  //{
592  // for (i = 0; i < kFramesPerBuffer; i++)
593  // {
594  // float gain = mTrack->GetChannelGain(0);
595  // maxLeft[i] *= gain;
596  // rmsLeft[i] *= gain;
597  // if (mRightTrack)
598  // gain = mRightTrack->GetChannelGain(1);
599  // maxRight[i] *= gain;
600  // rmsRight[i] *= gain;
601  // }
602  // if ( mMeter ) mMeter->UpdateDisplay(
603  // 2, // If mono, show left track values in both meters, as in MeterToolBar, rather than nChannels.
604  // kFramesPerBuffer,
605  // maxLeft, rmsLeft,
606  // maxRight, rmsRight,
607  // mTrack->TimeToLongSamples(t1 - t0));
608  //}
609  //
610 
611  const auto pTrack = GetWave();
612  auto startSample = (sampleCount)((pTrack->GetRate() * t0) + 0.5);
613  auto scnFrames = (sampleCount)((pTrack->GetRate() * (t1 - t0)) + 0.5);
614 
615  // Expect that the difference of t1 and t0 is the part of a track played
616  // in about 1/20 second (ticks of TrackPanel timer), so this won't overflow
617  auto nFrames = scnFrames.as_size_t();
618 
619  Floats tempFloatsArray{ nFrames };
620  decltype(tempFloatsArray) meterFloatsArray;
621  // Don't throw on read error in this drawing update routine
622  bool bSuccess = pTrack->Get((samplePtr)tempFloatsArray.get(),
623  floatSample, startSample, nFrames, fillZero, false);
624  if (bSuccess)
625  {
626  // We always pass a stereo sample array to the meter, as it shows 2 channels.
627  // Mono shows same in both meters.
628  // Since we're not mixing, need to duplicate same signal for "right" channel in mono case.
629  meterFloatsArray = Floats{ 2 * nFrames };
630 
631  // Interleave for stereo. Left/mono first.
632  for (unsigned int index = 0; index < nFrames; index++)
633  meterFloatsArray[2 * index] = tempFloatsArray[index];
634 
635  if (GetRight())
636  // Again, don't throw
637  bSuccess = GetRight()->Get((samplePtr)tempFloatsArray.get(),
638  floatSample, startSample, nFrames, fillZero, false);
639 
640  if (bSuccess)
641  // Interleave right channel, or duplicate same signal for "right" channel in mono case.
642  for (unsigned int index = 0; index < nFrames; index++)
643  meterFloatsArray[(2 * index) + 1] = tempFloatsArray[index];
644  }
645 
646  //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
647  //if (bSuccess && bWantPostFadeValues)
648  if (bSuccess)
649  {
650  //vvv Need to apply envelope, too? See Mixer::MixSameRate.
651  float gain = pTrack->GetChannelGain(0);
652  if (gain < 1.0)
653  for (unsigned int index = 0; index < nFrames; index++)
654  meterFloatsArray[2 * index] *= gain;
655  if (GetRight())
656  gain = GetRight()->GetChannelGain(1);
657  else
658  gain = pTrack->GetChannelGain(1);
659  if (gain < 1.0)
660  for (unsigned int index = 0; index < nFrames; index++)
661  meterFloatsArray[(2 * index) + 1] *= gain;
662  // Clip to [-1.0, 1.0] range.
663  for (unsigned int index = 0; index < 2 * nFrames; index++)
664  if (meterFloatsArray[index] < -1.0)
665  meterFloatsArray[index] = -1.0;
666  else if (meterFloatsArray[index] > 1.0)
667  meterFloatsArray[index] = 1.0;
668 
669  mMeter->UpdateDisplay(2, nFrames, meterFloatsArray.get());
670  }
671  else
672  this->ResetMeter(false);
673 }
float GetChannelGain(int channel) const
Definition: WaveTrack.cpp:440
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:441
void UpdateDisplay(unsigned numChannels, int numFrames, float *sampleData)
Update the meters with a block of audio data.
Definition: Meter.cpp:886
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
char * samplePtr
Definition: Types.h:203
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:334
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
MeterPanel * mMeter
Definition: MixerBoard.h:149
MixerBoard * mMixerBoard
Definition: MixerBoard.h:136
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumCopied=nullptr) const
Definition: WaveTrack.cpp:1971
bool HasSolo()
void MixerTrackCluster::UpdateMute ( )

Definition at line 472 of file MixerBoard.cpp.

References mToggleButton_Mute, mTrack, AButton::PopUp(), AButton::PushDown(), and AButton::SetAlternateIdx().

Referenced by MixerBoard::UpdateMute().

473 {
474  mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
475  if (mTrack->GetMute())
477  else
479 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
AButton * mToggleButton_Mute
Definition: MixerBoard.h:142
void PushDown()
Definition: AButton.cpp:517
void MixerTrackCluster::UpdateName ( )

Definition at line 458 of file MixerBoard.cpp.

References MixerBoard::GetMusicalInstrumentBitmap(), mBitmapButton_MusicalInstrument, mMixerBoard, and mTrack.

Referenced by UpdateForStateChange(), and MixerBoard::UpdateName().

459 {
460  const wxString newName = mTrack->GetName();
461  SetName(newName);
462  mStaticText_TrackName->SetLabel(newName);
463  mStaticText_TrackName->SetName(newName);
464  #if wxUSE_TOOLTIPS
465  mStaticText_TrackName->SetToolTip(newName);
466  #endif
467  mBitmapButton_MusicalInstrument->SetBitmapLabel(
469  Refresh();
470 }
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:140
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:141
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
MixerBoard * mMixerBoard
Definition: MixerBoard.h:136
void MixerTrackCluster::UpdatePan ( )

Definition at line 491 of file MixerBoard.cpp.

References GetWave(), mSlider_Pan, and ASlider::Set().

Referenced by UpdateForStateChange(), and MixerBoard::UpdatePan().

492 {
493  if (!GetWave()) {
494  mSlider_Pan->Hide();
495  return;
496  }
497  mSlider_Pan->Set(GetWave()->GetPan());
498 }
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:144
void Set(float value)
Definition: ASlider.cpp:1572
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:329
void MixerTrackCluster::UpdatePrefs ( )

Definition at line 350 of file MixerBoard.cpp.

References ThemeBase::Colour(), HandleResize(), mMeter, theTheme, and MeterPanel::UpdatePrefs().

351 {
352  this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
353  mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
354  if (mMeter)
355  mMeter->UpdatePrefs(); // in case meter range has changed
356  HandleResize(); // in case prefs "/GUI/Solo" changed
357 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:140
void UpdatePrefs()
Definition: Meter.cpp:340
MeterPanel * mMeter
Definition: MixerBoard.h:149
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void MixerTrackCluster::UpdateSolo ( )

Definition at line 481 of file MixerBoard.cpp.

References mToggleButton_Mute, mToggleButton_Solo, mTrack, AButton::PopUp(), AButton::PushDown(), and AButton::SetAlternateIdx().

Referenced by MixerBoard::UpdateSolo().

482 {
483  bool bIsSolo = mTrack->GetSolo();
484  if (bIsSolo)
486  else
488  mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
489 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:133
AButton * mToggleButton_Solo
Definition: MixerBoard.h:143
AButton * mToggleButton_Mute
Definition: MixerBoard.h:142
void PushDown()
Definition: AButton.cpp:517

Member Data Documentation

wxBitmapButton* MixerTrackCluster::mBitmapButton_MusicalInstrument
private

Definition at line 141 of file MixerBoard.h.

Referenced by UpdateName().

MeterPanel* MixerTrackCluster::mMeter
private

Definition at line 149 of file MixerBoard.h.

Referenced by HandleResize(), OnPaint(), ResetMeter(), UpdateMeter(), and UpdatePrefs().

MixerBoard* MixerTrackCluster::mMixerBoard
private

Definition at line 136 of file MixerBoard.h.

Referenced by OnButton_Mute(), OnButton_Solo(), UpdateMeter(), and UpdateName().

AudacityProject* MixerTrackCluster::mProject
private
MixerTrackSlider* MixerTrackCluster::mSlider_Gain
private

Definition at line 145 of file MixerBoard.h.

Referenced by HandleResize(), HandleSliderGain(), OnPaint(), and UpdateGain().

MixerTrackSlider* MixerTrackCluster::mSlider_Pan
private

Definition at line 144 of file MixerBoard.h.

Referenced by HandleSliderPan(), OnPaint(), and UpdatePan().

auStaticText* MixerTrackCluster::mStaticText_TrackName
private

Definition at line 140 of file MixerBoard.h.

AButton* MixerTrackCluster::mToggleButton_Mute
private

Definition at line 142 of file MixerBoard.h.

Referenced by OnButton_Mute(), OnButton_Solo(), UpdateMute(), and UpdateSolo().

AButton* MixerTrackCluster::mToggleButton_Solo
private

Definition at line 143 of file MixerBoard.h.

Referenced by HandleResize(), OnButton_Solo(), and UpdateSolo().

std::shared_ptr<PlayableTrack> MixerTrackCluster::mTrack

The documentation for this class was generated from the following files: