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

#include <MixerBoard.h>

Inheritance diagram for MixerBoard:

Public Member Functions

 MixerBoard (AudacityProject *pProject, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
void UpdatePrefs ()
 
void UpdateTrackClusters ()
 
int GetTrackClustersWidth ()
 
void MoveTrackCluster (const PlayableTrack *pTrack, bool bUp)
 
void RemoveTrackCluster (const PlayableTrack *pTrack)
 
void RemoveTrackCluster (size_t nIndex)
 
wxBitmap * GetMusicalInstrumentBitmap (const Track *pTrack)
 
bool HasSolo ()
 
void RefreshTrackCluster (const PlayableTrack *pTrack, bool bEraseBackground=true)
 
void RefreshTrackClusters (bool bEraseBackground=true)
 
void ResizeTrackClusters ()
 
void ResetMeters (const bool bResetClipping)
 
void UpdateName (const PlayableTrack *pTrack)
 
void UpdateMute (const PlayableTrack *pTrack=NULL)
 
void UpdateSolo (const PlayableTrack *pTrack=NULL)
 
void UpdatePan (const PlayableTrack *pTrack=NULL)
 
void UpdateGain (const PlayableTrack *pTrack)
 
void UpdateMeters (const double t1, const bool bLoopedPlay)
 
void UpdateWidth ()
 

Public Attributes

std::unique_ptr< wxImage > mImageMuteUp
 
std::unique_ptr< wxImage > mImageMuteOver
 
std::unique_ptr< wxImage > mImageMuteDown
 
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
 
std::unique_ptr< wxImage > mImageMuteDisabled
 
std::unique_ptr< wxImage > mImageSoloUp
 
std::unique_ptr< wxImage > mImageSoloOver
 
std::unique_ptr< wxImage > mImageSoloDown
 
std::unique_ptr< wxImage > mImageSoloDisabled
 
int mMuteSoloWidth
 

Private Member Functions

void MakeButtonBitmap (wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const wxString &str, bool up)
 
void CreateMuteSoloImages ()
 
int FindMixerTrackCluster (const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
 
void LoadMusicalInstruments ()
 
void OnSize (wxSizeEvent &evt)
 
void OnTimer (wxCommandEvent &event)
 

Private Attributes

std::vector< MixerTrackCluster * > mMixerTrackClusters
 
MusicalInstrumentArray mMusicalInstruments
 
AudacityProjectmProject
 
MixerBoardScrolledWindowmScrolledWindow
 
double mPrevT1
 
TrackListmTracks
 

Friends

class MixerBoardFrame
 

Detailed Description

Definition at line 198 of file MixerBoard.h.

Constructor & Destructor Documentation

MixerBoard::MixerBoard ( AudacityProject pProject,
wxFrame *  parent,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)

Definition at line 874 of file MixerBoard.cpp.

References ThemeBase::Colour(), kInset, kRightSideStackWidth, OnTimer(), RTL_WORKAROUND, safenew, and theTheme.

878 : wxWindow(parent, -1, pos, size)
879 {
880  // public data members
881 
882  // mute & solo button images
883  // Create once and store on MixerBoard for use in all MixerTrackClusters.
884  mImageMuteUp = NULL;
885  mImageMuteOver = NULL;
886  mImageMuteDown = NULL;
888  mImageMuteDisabled = NULL;
889  mImageSoloUp = NULL;
890  mImageSoloOver = NULL;
891  mImageSoloDown = NULL;
892  mImageSoloDisabled = NULL;
893 
894  mMuteSoloWidth = kRightSideStackWidth - kInset; // correct for max width, but really set in MixerBoard::CreateMuteSoloImages
895 
896  // private data members
897  this->LoadMusicalInstruments(); // Set up mMusicalInstruments.
898  mProject = pProject;
899 
900  wxASSERT(pProject); // to justify safenew
903  pProject, // AudacityProject* project,
904  this, -1, // wxWindow* parent, wxWindowID id = -1,
905  this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition,
906  size, // const wxSize& size = wxDefaultSize,
907  wxHSCROLL); // long style = wxHSCROLL | wxVSCROLL, const wxString& name = "scrolledWindow")
908 
909  // Set background color to same as TrackPanel background.
910 // #ifdef EXPERIMENTAL_THEMING
911 // mScrolledWindow->SetBackgroundColour(this->GetParent()->GetBackgroundColour());
912 // #else
913 // mScrolledWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
914 // #endif
915  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
917 
918  mScrolledWindow->SetScrollRate(10, 0); // no vertical scroll
919  mScrolledWindow->SetVirtualSize(size);
920 
921  /* This doesn't work to make the mScrolledWindow automatically resize, so do it explicitly in OnSize.
922  auto pBoxSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
923  pBoxSizer->Add(mScrolledWindow, 0, wxExpand, 0);
924  this->SetAutoLayout(true);
925  this->SetSizer(pBoxSizer);
926  pBoxSizer->Fit(this);
927  pBoxSizer->SetSizeHints(this);
928  */
929 
930  mPrevT1 = 0.0;
932 
933  // Events from the project don't propagate directly to this other frame, so...
934  mProject->Bind(EVT_TRACK_PANEL_TIMER,
936  this);
937 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
#define RTL_WORKAROUND(pWnd)
Definition: Audacity.h:235
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:258
AudacityProject * mProject
Definition: MixerBoard.h:269
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:258
const int kInset
Definition: MixerBoard.cpp:121
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:258
int mMuteSoloWidth
Definition: MixerBoard.h:262
void LoadMusicalInstruments()
#define safenew
Definition: Audacity.h:230
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:258
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:270
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:258
void OnTimer(wxCommandEvent &event)
const int kRightSideStackWidth
Definition: MixerBoard.cpp:132
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:258
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
double mPrevT1
Definition: MixerBoard.h:271
TrackList * GetTracks()
Definition: Project.h:192
TrackList * mTracks
Definition: MixerBoard.h:272

Member Function Documentation

void MixerBoard::CreateMuteSoloImages ( )
private

Definition at line 1350 of file MixerBoard.cpp.

References _(), kInset, kRightSideStackWidth, MakeButtonBitmap(), mImageMuteDisabled, mImageMuteDown, mImageMuteDownWhileSolo, mImageMuteOver, mImageMuteUp, mImageSoloDisabled, mImageSoloDown, mImageSoloOver, mImageSoloUp, mMuteSoloWidth, and MUTE_SOLO_HEIGHT.

Referenced by UpdateTrackClusters().

1351 {
1352  // Much of this is similar to TrackInfo::MuteOrSoloDrawFunction.
1353  wxMemoryDC dc;
1354  wxString str = _("Mute");
1355 
1356  //mMuteSoloWidth = textWidth + kQuadrupleInset;
1357  //if (mMuteSoloWidth < kRightSideStackWidth - kInset)
1359 
1360  wxBitmap bitmap(mMuteSoloWidth, MUTE_SOLO_HEIGHT,24);
1361  dc.SelectObject(bitmap);
1362  wxRect bev(0, 0, mMuteSoloWidth, MUTE_SOLO_HEIGHT);
1363 
1364  const bool up=true;
1365  const bool down=false;
1366 
1367  MakeButtonBitmap( dc, bitmap, bev, str, up );
1368  mImageMuteUp = std::make_unique<wxImage>(bitmap.ConvertToImage());
1369  mImageMuteOver = std::make_unique<wxImage>(bitmap.ConvertToImage()); // Same as up, for now.
1370 
1371  MakeButtonBitmap( dc, bitmap, bev, str, down );
1372  //AColor::Bevel(dc, false, bev);
1373  mImageMuteDown = std::make_unique<wxImage>(bitmap.ConvertToImage());
1374 
1375  MakeButtonBitmap( dc, bitmap, bev, str, down );
1376  mImageMuteDownWhileSolo = std::make_unique<wxImage>(bitmap.ConvertToImage());
1377 
1378  mImageMuteDisabled = std::make_unique<wxImage>(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused.
1379 
1380  str = _("Solo");
1381  MakeButtonBitmap( dc, bitmap, bev, str, up );
1382  mImageSoloUp = std::make_unique<wxImage>(bitmap.ConvertToImage());
1383  mImageSoloOver = std::make_unique<wxImage>(bitmap.ConvertToImage()); // Same as up, for now.
1384 
1385  MakeButtonBitmap( dc, bitmap, bev, str, down );
1386  mImageSoloDown = std::make_unique<wxImage>(bitmap.ConvertToImage());
1387 
1388  mImageSoloDisabled = std::make_unique<wxImage>(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused.
1389 }
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:258
const int kInset
Definition: MixerBoard.cpp:121
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:258
int mMuteSoloWidth
Definition: MixerBoard.h:262
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:128
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:258
_("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
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const wxString &str, bool up)
const int kRightSideStackWidth
Definition: MixerBoard.cpp:132
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:258
int MixerBoard::FindMixerTrackCluster ( const PlayableTrack pTrack,
MixerTrackCluster **  hMixerTrackCluster 
) const
private

Definition at line 1391 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by MoveTrackCluster(), RefreshTrackCluster(), RemoveTrackCluster(), UpdateGain(), UpdateMute(), UpdateName(), UpdatePan(), and UpdateSolo().

1393 {
1394  *hMixerTrackCluster = NULL;
1395  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1396  {
1397  if (mMixerTrackClusters[i]->mTrack.get() == pTrack)
1398  {
1399  *hMixerTrackCluster = mMixerTrackClusters[i];
1400  return i;
1401  }
1402  }
1403  return -1;
1404 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
wxBitmap * MixerBoard::GetMusicalInstrumentBitmap ( const Track pTrack)

Definition at line 1118 of file MixerBoard.cpp.

References Track::GetName(), and mMusicalInstruments.

Referenced by MixerTrackCluster::UpdateName().

1119 {
1120  if (mMusicalInstruments.empty())
1121  return NULL;
1122 
1123  // random choice: return mMusicalInstruments[(int)pTrack % mMusicalInstruments.GetCount()].mBitmap;
1124 
1125  const wxString strTrackName(pTrack->GetName().MakeLower());
1126  size_t nBestItemIndex = 0;
1127  unsigned int nBestScore = 0;
1128  unsigned int nInstrIndex = 0;
1129  unsigned int nKeywordIndex;
1130  unsigned int nNumKeywords;
1131  unsigned int nPointsPerMatch;
1132  unsigned int nScore;
1133  for (nInstrIndex = 0; nInstrIndex < mMusicalInstruments.size(); nInstrIndex++)
1134  {
1135  nScore = 0;
1136 
1137  nNumKeywords = mMusicalInstruments[nInstrIndex]->mKeywords.GetCount();
1138  if (nNumKeywords > 0)
1139  {
1140  nPointsPerMatch = 10 / nNumKeywords;
1141  for (nKeywordIndex = 0; nKeywordIndex < nNumKeywords; nKeywordIndex++)
1142  if (strTrackName.Contains(mMusicalInstruments[nInstrIndex]->mKeywords[nKeywordIndex]))
1143  {
1144  nScore +=
1145  nPointsPerMatch +
1146  // Longer keywords get more points.
1147  (2 * mMusicalInstruments[nInstrIndex]->mKeywords[nKeywordIndex].Length());
1148  }
1149  }
1150 
1151  // Choose later one if just matching nBestScore, for better variety,
1152  // and so default works as last element.
1153  if (nScore >= nBestScore)
1154  {
1155  nBestScore = nScore;
1156  nBestItemIndex = nInstrIndex;
1157  }
1158  }
1159  return mMusicalInstruments[nBestItemIndex]->mBitmap.get();
1160 }
wxString GetName() const
Definition: Track.h:275
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:268
int MixerBoard::GetTrackClustersWidth ( )

Definition at line 1038 of file MixerBoard.cpp.

References kDoubleInset, kMixerTrackClusterWidth, and mMixerTrackClusters.

Referenced by UpdateWidth().

1039 {
1040  return
1041  kInset + // extra margin at left for first one
1042  (mMixerTrackClusters.size() * // number of tracks times
1043  (kInset + kMixerTrackClusterWidth)) + // left margin and width for each
1044  kDoubleInset; // plus final right margin
1045 }
const int kDoubleInset
Definition: MixerBoard.cpp:122
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:133
const int kInset
Definition: MixerBoard.cpp:121
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
bool MixerBoard::HasSolo ( )

Definition at line 1162 of file MixerBoard.cpp.

References TrackListIterator::First(), mTracks, and TrackListIterator::Next().

Referenced by MixerTrackCluster::UpdateMeter().

1163 {
1164  TrackListIterator iterTracks(mTracks);
1165  Track* pTrack;
1166  for (pTrack = iterTracks.First(); pTrack; pTrack = iterTracks.Next()) {
1167  auto pPlayable = dynamic_cast<PlayableTrack *>( pTrack );
1168  if (pPlayable && pPlayable->GetSolo())
1169  return true;
1170  }
1171  return false;
1172 }
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An AudioTrack that can be played and stopped.
Definition: Track.h:380
An iterator for a TrackList.
Definition: Track.h:406
TrackList * mTracks
Definition: MixerBoard.h:272
void MixerBoard::LoadMusicalInstruments ( )
private

Definition at line 1406 of file MixerBoard.cpp.

References AColor::Bevel(), mMusicalInstruments, MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH, and name.

1407 {
1408  const struct Data { const char * const *bitmap; wxString name; } table[] = {
1409  {acoustic_guitar_gtr_xpm, wxT("acoustic_guitar_gtr")},
1410  {acoustic_piano_pno_xpm, wxT("acoustic_piano_pno")},
1411  {back_vocal_bg_vox_xpm, wxT("back_vocal_bg_vox")},
1412  {clap_xpm, wxT("clap")},
1413  {drums_dr_xpm, wxT("drums_dr")},
1414  {electric_bass_guitar_bs_gtr_xpm, wxT("electric_bass_guitar_bs_gtr")},
1415  {electric_guitar_gtr_xpm, wxT("electric_guitar_gtr")},
1416  {electric_piano_pno_key_xpm, wxT("electric_piano_pno_key")},
1417  {kick_xpm, wxT("kick")},
1418  {loop_xpm, wxT("loop")},
1419  {organ_org_xpm, wxT("organ_org")},
1420  {perc_xpm, wxT("perc")},
1421  {sax_xpm, wxT("sax")},
1422  {snare_xpm, wxT("snare")},
1423  {string_violin_cello_xpm, wxT("string_violin_cello")},
1424  {synth_xpm, wxT("synth")},
1425  {tambo_xpm, wxT("tambo")},
1426  {trumpet_horn_xpm, wxT("trumpet_horn")},
1427  {turntable_xpm, wxT("turntable")},
1428  {vibraphone_vibes_xpm, wxT("vibraphone_vibes")},
1429  {vocal_vox_xpm, wxT("vocal_vox")},
1430 
1431  // This one must be last, so it wins when best score is 0.
1432  {_default_instrument_xpm, wxEmptyString},
1433  };
1434 
1436  wxMemoryDC dc;
1437 
1438  for (const auto &data : table) {
1439  auto bmp = std::make_unique<wxBitmap>(data.bitmap,24);
1440  dc.SelectObject(*bmp);
1441  AColor::Bevel(dc, false, bev);
1442  mMusicalInstruments.push_back(std::make_unique<MusicalInstrument>(
1443  std::move(bmp), data.name
1444  ));
1445  };
1446 }
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:202
const wxChar * name
Definition: Distortion.cpp:94
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:268
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:127
void MixerBoard::MakeButtonBitmap ( wxMemoryDC &  dc,
wxBitmap &  bitmap,
wxRect &  bev,
const wxString &  str,
bool  up 
)
private

Definition at line 1324 of file MixerBoard.cpp.

References AColor::Bevel2(), ThemeBase::Colour(), theTheme, and AColor::UseThemeColour().

Referenced by CreateMuteSoloImages().

1325 {
1326 
1327  int textWidth, textHeight;
1328 
1329  int fontSize = 10;
1330  #ifdef __WXMSW__
1331  fontSize = 8;
1332  #endif
1333  wxFont font(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1334  GetTextExtent(str, &textWidth, &textHeight, NULL, NULL, &font);
1335 
1336  AColor::UseThemeColour( &dc, clrMedium );
1337  dc.DrawRectangle(bev);
1338 
1339  AColor::Bevel2( dc, up, bev, false );
1340 
1341  wxCoord x = bev.x + (bev.width - textWidth) / 2;
1342  wxCoord y = bev.y + (bev.height - textHeight) / 2;
1343  dc.SetFont(font);
1344  dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
1345  dc.SetBackgroundMode(wxTRANSPARENT);
1346  dc.DrawText(str, x, y);
1347 // dc.DrawText(str, 0, 0);
1348 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
static void Bevel2(wxDC &dc, bool up, const wxRect &r, bool bSel=false, bool bHighlight=false)
Definition: AColor.cpp:222
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1)
Definition: AColor.cpp:289
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void MixerBoard::MoveTrackCluster ( const PlayableTrack pTrack,
bool  bUp 
)

Definition at line 1047 of file MixerBoard.cpp.

References FindMixerTrackCluster(), kMixerTrackClusterWidth, and mMixerTrackClusters.

Referenced by TrackSelectHandle::Drag(), and AudacityProject::MoveTrack().

1049 {
1050  MixerTrackCluster* pMixerTrackCluster;
1051  int nIndex = FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1052  if (pMixerTrackCluster == NULL)
1053  return; // Couldn't find it.
1054 
1055  wxPoint pos;
1056  if (bUp)
1057  { // Move it up (left).
1058  if (nIndex <= 0)
1059  return; // It's already first (0), or not found (-1).
1060 
1061  pos = pMixerTrackCluster->GetPosition();
1062  mMixerTrackClusters[nIndex] = mMixerTrackClusters[nIndex - 1];
1063  mMixerTrackClusters[nIndex]->Move(pos);
1064 
1065  mMixerTrackClusters[nIndex - 1] = pMixerTrackCluster;
1066  pMixerTrackCluster->Move(pos.x - (kInset + kMixerTrackClusterWidth), pos.y);
1067  }
1068  else
1069  { // Move it down (right).
1070  if (((unsigned int)nIndex + 1) >= mMixerTrackClusters.size())
1071  return; // It's already last.
1072 
1073  pos = pMixerTrackCluster->GetPosition();
1074  mMixerTrackClusters[nIndex] = mMixerTrackClusters[nIndex + 1];
1075  mMixerTrackClusters[nIndex]->Move(pos);
1076 
1077  mMixerTrackClusters[nIndex + 1] = pMixerTrackCluster;
1078  pMixerTrackCluster->Move(pos.x + (kInset + kMixerTrackClusterWidth), pos.y);
1079  }
1080 }
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:133
const int kInset
Definition: MixerBoard.cpp:121
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::OnSize ( wxSizeEvent &  evt)
private

Definition at line 1450 of file MixerBoard.cpp.

References mScrolledWindow, RefreshTrackClusters(), and ResizeTrackClusters().

1451 {
1452  // this->FitInside() doesn't work, and it doesn't happen automatically. Is wxScrolledWindow wrong?
1453  mScrolledWindow->SetSize(evt.GetSize());
1454 
1455  this->ResizeTrackClusters();
1456  this->RefreshTrackClusters(true);
1457 }
void RefreshTrackClusters(bool bEraseBackground=true)
void ResizeTrackClusters()
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:270
void MixerBoard::OnTimer ( wxCommandEvent &  event)
private

Definition at line 1459 of file MixerBoard.cpp.

References gAudioIO, AudioIO::GetStreamTime(), AudacityProject::IsAudioActive(), loopedPlay, AudacityProject::mLastPlayMode, mProject, and UpdateMeters().

Referenced by MixerBoard().

1460 {
1461  // PRL 12 Jul 2015: Moved the below (with comments) out of TrackPanel::OnTimer.
1462 
1463  // Vaughan, 2011-01-28: No longer doing this on timer.
1464  // Now it's in AudioIO::SetMeters() and AudioIO::StopStream(), as with Meter Toolbar meters.
1465  //if (pMixerBoard)
1466  // pMixerBoard->ResetMeters(false);
1467 
1468  //v Vaughan, 2011-02-25: Moved this update back here from audacityAudioCallback.
1469  // See note there.
1470  // Vaughan, 2010-01-30:
1471  // Since all we're doing here is updating the meters, I moved it to
1472  // audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
1473  if (mProject->IsAudioActive())
1474  {
1477  }
1478 
1479  // Let other listeners get the notification
1480  event.Skip();
1481 }
double GetStreamTime()
During playback, the track time most recently played.
Definition: AudioIO.cpp:3006
AudacityProject * mProject
Definition: MixerBoard.h:269
bool IsAudioActive() const
Definition: Project.cpp:1457
PlayMode mLastPlayMode
Definition: Project.h:558
void UpdateMeters(const double t1, const bool bLoopedPlay)
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
void MixerBoard::RefreshTrackCluster ( const PlayableTrack pTrack,
bool  bEraseBackground = true 
)

Definition at line 1174 of file MixerBoard.cpp.

References FindMixerTrackCluster().

Referenced by SelectionState::SelectTrack().

1175 {
1176  MixerTrackCluster* pMixerTrackCluster;
1177  this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1178  if (pMixerTrackCluster)
1179  pMixerTrackCluster->Refresh(bEraseBackground);
1180 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::RefreshTrackClusters ( bool  bEraseBackground = true)

Definition at line 1182 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by SelectionState::HandleListSelection(), and OnSize().

1183 {
1184  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1185  mMixerTrackClusters[i]->Refresh(bEraseBackground);
1186 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void MixerBoard::RemoveTrackCluster ( const PlayableTrack pTrack)

Definition at line 1082 of file MixerBoard.cpp.

References FindMixerTrackCluster().

Referenced by AudacityProject::OnRemoveTracks(), AudacityProject::RemoveTrack(), and UpdateTrackClusters().

1083 {
1084  // Find and destroy.
1085  MixerTrackCluster* pMixerTrackCluster;
1086  int nIndex = this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1087 
1088  if (pMixerTrackCluster == NULL)
1089  return; // Couldn't find it.
1090 
1091  RemoveTrackCluster(nIndex);
1092 }
void RemoveTrackCluster(const PlayableTrack *pTrack)
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::RemoveTrackCluster ( size_t  nIndex)

Definition at line 1094 of file MixerBoard.cpp.

References kInset, kMixerTrackClusterWidth, mMixerTrackClusters, and UpdateWidth().

1095 {
1096  auto pMixerTrackCluster = mMixerTrackClusters[nIndex];
1097  mMixerTrackClusters.erase(mMixerTrackClusters.begin() + nIndex);
1098  pMixerTrackCluster->Destroy(); // DELETE is unsafe on wxWindow.
1099 
1100  // Close the gap, if any.
1101  wxPoint pos;
1102  int targetX;
1103  for (unsigned int i = nIndex; i < mMixerTrackClusters.size(); i++)
1104  {
1105  pos = mMixerTrackClusters[i]->GetPosition();
1106  targetX =
1107  kInset + // extra inset to left for first one, so it's double
1108  (i * (kInset + kMixerTrackClusterWidth)) + // left margin and width for each
1109  kInset; // plus left margin for this cluster
1110  if (pos.x != targetX)
1111  mMixerTrackClusters[i]->Move(targetX, pos.y);
1112  }
1113 
1114  this->UpdateWidth();
1115 }
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:133
const int kInset
Definition: MixerBoard.cpp:121
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void UpdateWidth()
void MixerBoard::ResetMeters ( const bool  bResetClipping)

Definition at line 1194 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by AudioIO::SetMeters(), and AudioIO::StopStream().

1195 {
1197 
1198  if (!this->IsShown())
1199  return;
1200 
1201  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1202  mMixerTrackClusters[i]->ResetMeter(bResetClipping);
1203 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
#define BAD_STREAM_TIME
Definition: AudioIO.h:81
double mPrevT1
Definition: MixerBoard.h:271
void MixerBoard::ResizeTrackClusters ( )

Definition at line 1188 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnSize(), and UpdateTrackClusters().

1189 {
1190  for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.size(); nClusterIndex++)
1191  mMixerTrackClusters[nClusterIndex]->HandleResize();
1192 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void MixerBoard::UpdateGain ( const PlayableTrack pTrack)

Definition at line 1261 of file MixerBoard.cpp.

References FindMixerTrackCluster(), and MixerTrackCluster::UpdateGain().

Referenced by GainSliderHandle::SetValue().

1262 {
1263  MixerTrackCluster* pMixerTrackCluster;
1264  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1265  if (pMixerTrackCluster)
1266  pMixerTrackCluster->UpdateGain();
1267 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdateMeters ( const double  t1,
const bool  bLoopedPlay 
)

Definition at line 1279 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by OnTimer().

1280 {
1281  if (!this->IsShown() || (t1 == BAD_STREAM_TIME))
1282  return;
1283 
1284  if (mPrevT1 == BAD_STREAM_TIME)
1285  {
1286  mPrevT1 = t1;
1287  return;
1288  }
1289 
1290  // In loopedPlay mode, at the end of the loop, mPrevT1 is set to
1291  // selection end, so the next t1 will be less, but we do want to
1292  // keep updating the meters.
1293  if (t1 <= mPrevT1)
1294  {
1295  if (bLoopedPlay)
1296  mPrevT1 = t1;
1297  return;
1298  }
1299 
1300  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1301  mMixerTrackClusters[i]->UpdateMeter(mPrevT1, t1);
1302 
1303  mPrevT1 = t1;
1304 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
#define BAD_STREAM_TIME
Definition: AudioIO.h:81
double mPrevT1
Definition: MixerBoard.h:271
void MixerBoard::UpdateMute ( const PlayableTrack pTrack = NULL)

Definition at line 1213 of file MixerBoard.cpp.

References FindMixerTrackCluster(), mMixerTrackClusters, and MixerTrackCluster::UpdateMute().

Referenced by AudacityProject::DoTrackMute(), AudacityProject::DoTrackSolo(), MixerTrackCluster::OnButton_Solo(), AudacityProject::OnMuteAllTracks(), and AudacityProject::OnUnmuteAllTracks().

1214 {
1215  if (pTrack == NULL)
1216  {
1217  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1219  }
1220  else
1221  {
1222  MixerTrackCluster* pMixerTrackCluster;
1223  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1224  if (pMixerTrackCluster)
1225  pMixerTrackCluster->UpdateMute();
1226  }
1227 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void UpdateMute(const PlayableTrack *pTrack=NULL)
void MixerBoard::UpdateName ( const PlayableTrack pTrack)

Definition at line 1205 of file MixerBoard.cpp.

References FindMixerTrackCluster(), and MixerTrackCluster::UpdateName().

Referenced by TrackMenuTable::OnSetName().

1206 {
1207  MixerTrackCluster* pMixerTrackCluster;
1208  this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1209  if (pMixerTrackCluster)
1210  pMixerTrackCluster->UpdateName();
1211 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdatePan ( const PlayableTrack pTrack = NULL)

Definition at line 1245 of file MixerBoard.cpp.

References FindMixerTrackCluster(), mMixerTrackClusters, and MixerTrackCluster::UpdatePan().

Referenced by AudacityProject::OnPanTracks(), and PanSliderHandle::SetValue().

1246 {
1247  if (pTrack == NULL)
1248  {
1249  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1251  }
1252  else
1253  {
1254  MixerTrackCluster* pMixerTrackCluster;
1255  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1256  if (pMixerTrackCluster)
1257  pMixerTrackCluster->UpdatePan();
1258  }
1259 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void UpdatePan(const PlayableTrack *pTrack=NULL)
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdatePrefs ( )

Definition at line 942 of file MixerBoard.cpp.

References ThemeBase::Colour(), mImageMuteDisabled, mImageMuteDown, mImageMuteDownWhileSolo, mImageMuteOver, mImageMuteUp, mImageSoloDisabled, mImageSoloDown, mImageSoloOver, mImageSoloUp, mMixerTrackClusters, mProject, mScrolledWindow, AudacityProject::RecreateMixerBoard(), and theTheme.

Referenced by AudacityProject::UpdatePrefs().

943 {
945 
946 // Old approach modified things in situ.
947 // However with a theme change there is so much to modify, it is easier
948 // to recreate.
949 #if 0
950  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
951  if( mImageMuteUp ){
952  mImageMuteUp.reset();
953  mImageMuteOver.reset();
954  mImageMuteDown.reset();
955  mImageMuteDownWhileSolo.reset();
956  mImageMuteDisabled.reset();
957  mImageSoloUp.reset();
958  mImageSoloOver.reset();
959  mImageSoloDown.reset();
960  mImageSoloDisabled.reset();
961  }
962  for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.GetCount(); nClusterIndex++)
963  mMixerTrackClusters[nClusterIndex]->UpdatePrefs();
964  Refresh();
965 #endif
966 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:258
AudacityProject * mProject
Definition: MixerBoard.h:269
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:258
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:258
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:270
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:258
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:258
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void UpdatePrefs()
Definition: MixerBoard.cpp:942
void RecreateMixerBoard()
Definition: Project.cpp:4878
void MixerBoard::UpdateSolo ( const PlayableTrack pTrack = NULL)

Definition at line 1229 of file MixerBoard.cpp.

References FindMixerTrackCluster(), mMixerTrackClusters, and MixerTrackCluster::UpdateSolo().

Referenced by AudacityProject::DoTrackMute(), AudacityProject::DoTrackSolo(), MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), AudacityProject::OnMuteAllTracks(), and AudacityProject::OnUnmuteAllTracks().

1230 {
1231  if (pTrack == NULL)
1232  {
1233  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1235  }
1236  else
1237  {
1238  MixerTrackCluster* pMixerTrackCluster;
1239  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1240  if (pMixerTrackCluster)
1241  pMixerTrackCluster->UpdateSolo();
1242  }
1243 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void UpdateSolo(const PlayableTrack *pTrack=NULL)
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdateTrackClusters ( )

Definition at line 975 of file MixerBoard.cpp.

References CreateMuteSoloImages(), TrackListIterator::First(), kDoubleInset, kMixerTrackClusterWidth, mImageMuteUp, mMixerTrackClusters, mProject, mScrolledWindow, mTracks, TrackListIterator::Next(), RemoveTrackCluster(), ResizeTrackClusters(), safenew, and UpdateWidth().

Referenced by WaveTrackMenuTable::OnSwapChannels(), AudacityProject::RecreateMixerBoard(), and AudacityProject::UpdateMixerBoard().

976 {
977  if (!mImageMuteUp)
978  this->CreateMuteSoloImages();
979 
980  const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset;
981  size_t nClusterCount = mMixerTrackClusters.size();
982  unsigned int nClusterIndex = 0;
983  TrackListIterator iterTracks(mTracks);
984  MixerTrackCluster* pMixerTrackCluster = NULL;
985  Track* pTrack;
986 
987  pTrack = iterTracks.First();
988  while (pTrack) {
989  if (auto pPlayableTrack = dynamic_cast<PlayableTrack*>(pTrack))
990  {
991  auto spTrack = Track::Pointer<PlayableTrack>( pPlayableTrack );
992  if (nClusterIndex < nClusterCount)
993  {
994  // Already showing it.
995  // Track clusters are maintained in the same order as the WaveTracks.
996  // Track pointers can change for the "same" track for different states
997  // on the undo stack, so update the pointers and display name.
998  mMixerTrackClusters[nClusterIndex]->mTrack = spTrack;
999  // Assume linked track is wave or null
1000  mMixerTrackClusters[nClusterIndex]->UpdateForStateChange();
1001  }
1002  else
1003  {
1004  // Not already showing it. Add a NEW MixerTrackCluster.
1005  wxPoint clusterPos(
1006  kInset + nClusterIndex * kMixerTrackClusterWidth,
1007  kInset);
1008  wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight);
1009  pMixerTrackCluster =
1011  spTrack,
1012  clusterPos, clusterSize);
1013  if (pMixerTrackCluster)
1014  mMixerTrackClusters.push_back(pMixerTrackCluster);
1015  }
1016  nClusterIndex++;
1017  }
1018  pTrack = iterTracks.Next(true);
1019  }
1020 
1021  if (pMixerTrackCluster)
1022  {
1023  // Added at least one MixerTrackCluster.
1024  this->UpdateWidth();
1025  this->ResizeTrackClusters();
1026  }
1027  else while (nClusterIndex < nClusterCount)
1028  {
1029  // We've got too many clusters.
1030  // This can happen only on things like Undo New Audio Track or Undo Import
1031  // that don't call RemoveTrackCluster explicitly.
1032  // We've already updated the track pointers for the clusters to the left, so just remove all the rest.
1033  // Successively DELETE from right to left.
1034  RemoveTrackCluster(--nClusterCount);
1035  }
1036 }
const int kDoubleInset
Definition: MixerBoard.cpp:122
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:133
void ResizeTrackClusters()
AudacityProject * mProject
Definition: MixerBoard.h:269
const int kInset
Definition: MixerBoard.cpp:121
void RemoveTrackCluster(const PlayableTrack *pTrack)
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
#define safenew
Definition: Audacity.h:230
void CreateMuteSoloImages()
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:270
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void UpdateWidth()
An iterator for a TrackList.
Definition: Track.h:406
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:258
TrackList * mTracks
Definition: MixerBoard.h:272
void MixerBoard::UpdateWidth ( )

Definition at line 1307 of file MixerBoard.cpp.

References GetTrackClustersWidth(), MIXER_BOARD_MIN_WIDTH, and mScrolledWindow.

Referenced by MixerBoardFrame::OnMaximize(), RemoveTrackCluster(), and UpdateTrackClusters().

1308 {
1309  int newWidth = this->GetTrackClustersWidth();
1310 
1311  // Min width is one cluster wide, plus margins.
1312  if (newWidth < MIXER_BOARD_MIN_WIDTH)
1313  newWidth = MIXER_BOARD_MIN_WIDTH;
1314 
1315  mScrolledWindow->SetVirtualSize(newWidth, -1);
1316  this->GetParent()->SetSize(newWidth + kDoubleInset, -1);
1317 }
const int kDoubleInset
Definition: MixerBoard.cpp:122
#define MIXER_BOARD_MIN_WIDTH
Definition: MixerBoard.cpp:867
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:270
int GetTrackClustersWidth()

Friends And Related Function Documentation

friend class MixerBoardFrame
friend

Definition at line 200 of file MixerBoard.h.

Member Data Documentation

std::unique_ptr<wxImage> MixerBoard::mImageMuteDisabled

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteDown

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteDownWhileSolo

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteOver

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteUp

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), UpdatePrefs(), and UpdateTrackClusters().

std::unique_ptr<wxImage> MixerBoard::mImageSoloDisabled

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloDown

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloOver

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloUp

Definition at line 258 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::vector<MixerTrackCluster*> MixerBoard::mMixerTrackClusters
private
MusicalInstrumentArray MixerBoard::mMusicalInstruments
private

Definition at line 268 of file MixerBoard.h.

Referenced by GetMusicalInstrumentBitmap(), and LoadMusicalInstruments().

int MixerBoard::mMuteSoloWidth

Definition at line 262 of file MixerBoard.h.

Referenced by CreateMuteSoloImages().

double MixerBoard::mPrevT1
private

Definition at line 271 of file MixerBoard.h.

Referenced by ResetMeters(), and UpdateMeters().

AudacityProject* MixerBoard::mProject
private

Definition at line 269 of file MixerBoard.h.

Referenced by OnTimer(), UpdatePrefs(), and UpdateTrackClusters().

MixerBoardScrolledWindow* MixerBoard::mScrolledWindow
private

Definition at line 270 of file MixerBoard.h.

Referenced by OnSize(), UpdatePrefs(), UpdateTrackClusters(), and UpdateWidth().

TrackList* MixerBoard::mTracks
private

Definition at line 272 of file MixerBoard.h.

Referenced by HasSolo(), and UpdateTrackClusters().


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