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 873 of file MixerBoard.cpp.

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

877 : wxWindow(parent, -1, pos, size)
878 {
879  // public data members
880 
881  // mute & solo button images
882  // Create once and store on MixerBoard for use in all MixerTrackClusters.
883  mImageMuteUp = NULL;
884  mImageMuteOver = NULL;
885  mImageMuteDown = NULL;
887  mImageMuteDisabled = NULL;
888  mImageSoloUp = NULL;
889  mImageSoloOver = NULL;
890  mImageSoloDown = NULL;
891  mImageSoloDisabled = NULL;
892 
893  mMuteSoloWidth = kRightSideStackWidth - kInset; // correct for max width, but really set in MixerBoard::CreateMuteSoloImages
894 
895  // private data members
896  this->LoadMusicalInstruments(); // Set up mMusicalInstruments.
897  mProject = pProject;
898 
899  wxASSERT(pProject); // to justify safenew
902  pProject, // AudacityProject* project,
903  this, -1, // wxWindow* parent, wxWindowID id = -1,
904  this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition,
905  size, // const wxSize& size = wxDefaultSize,
906  wxHSCROLL); // long style = wxHSCROLL | wxVSCROLL, const wxString& name = "scrolledWindow")
907 
908  // Set background color to same as TrackPanel background.
909 // #ifdef EXPERIMENTAL_THEMING
910 // mScrolledWindow->SetBackgroundColour(this->GetParent()->GetBackgroundColour());
911 // #else
912 // mScrolledWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
913 // #endif
914  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
915 
916  mScrolledWindow->SetScrollRate(10, 0); // no vertical scroll
917  mScrolledWindow->SetVirtualSize(size);
918 
919  /* This doesn't work to make the mScrolledWindow automatically resize, so do it explicitly in OnSize.
920  auto pBoxSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
921  pBoxSizer->Add(mScrolledWindow, 0, wxExpand, 0);
922  this->SetAutoLayout(true);
923  this->SetSizer(pBoxSizer);
924  pBoxSizer->Fit(this);
925  pBoxSizer->SetSizeHints(this);
926  */
927 
928  mPrevT1 = 0.0;
930 
931  // Events from the project don't propagate directly to this other frame, so...
932  mProject->Bind(EVT_TRACK_PANEL_TIMER,
934  this);
935 }
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
const int kInset
Definition: MixerBoard.cpp:120
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:131
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 1348 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().

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

Definition at line 1389 of file MixerBoard.cpp.

References mMixerTrackClusters.

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

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

Definition at line 1116 of file MixerBoard.cpp.

References Track::GetName(), and mMusicalInstruments.

Referenced by MixerTrackCluster::UpdateName().

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

Definition at line 1036 of file MixerBoard.cpp.

References kDoubleInset, kMixerTrackClusterWidth, and mMixerTrackClusters.

Referenced by UpdateWidth().

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

Definition at line 1160 of file MixerBoard.cpp.

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

Referenced by MixerTrackCluster::UpdateMeter().

1161 {
1162  TrackListIterator iterTracks(mTracks);
1163  Track* pTrack;
1164  for (pTrack = iterTracks.First(); pTrack; pTrack = iterTracks.Next()) {
1165  auto pPlayable = dynamic_cast<PlayableTrack *>( pTrack );
1166  if (pPlayable && pPlayable->GetSolo())
1167  return true;
1168  }
1169  return false;
1170 }
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:376
An iterator for a TrackList.
Definition: Track.h:402
TrackList * mTracks
Definition: MixerBoard.h:272
void MixerBoard::LoadMusicalInstruments ( )
private

Definition at line 1404 of file MixerBoard.cpp.

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

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

Definition at line 1322 of file MixerBoard.cpp.

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

Referenced by CreateMuteSoloImages().

1323 {
1324 
1325  int textWidth, textHeight;
1326 
1327  int fontSize = 10;
1328  #ifdef __WXMSW__
1329  fontSize = 8;
1330  #endif
1331  wxFont font(fontSize, wxSWISS, wxNORMAL, wxNORMAL);
1332  GetTextExtent(str, &textWidth, &textHeight, NULL, NULL, &font);
1333 
1334  AColor::UseThemeColour( &dc, clrMedium );
1335  dc.DrawRectangle(bev);
1336 
1337  AColor::Bevel2( dc, up, bev, false );
1338 
1339  wxCoord x = bev.x + (bev.width - textWidth) / 2;
1340  wxCoord y = bev.y + (bev.height - textHeight) / 2;
1341  dc.SetFont(font);
1342  dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
1343  dc.SetBackgroundMode(wxTRANSPARENT);
1344  dc.DrawText(str, x, y);
1345 // dc.DrawText(str, 0, 0);
1346 }
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 1045 of file MixerBoard.cpp.

References FindMixerTrackCluster(), kMixerTrackClusterWidth, and mMixerTrackClusters.

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

1047 {
1048  MixerTrackCluster* pMixerTrackCluster;
1049  int nIndex = FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1050  if (pMixerTrackCluster == NULL)
1051  return; // Couldn't find it.
1052 
1053  wxPoint pos;
1054  if (bUp)
1055  { // Move it up (left).
1056  if (nIndex <= 0)
1057  return; // It's already first (0), or not found (-1).
1058 
1059  pos = pMixerTrackCluster->GetPosition();
1060  mMixerTrackClusters[nIndex] = mMixerTrackClusters[nIndex - 1];
1061  mMixerTrackClusters[nIndex]->Move(pos);
1062 
1063  mMixerTrackClusters[nIndex - 1] = pMixerTrackCluster;
1064  pMixerTrackCluster->Move(pos.x - (kInset + kMixerTrackClusterWidth), pos.y);
1065  }
1066  else
1067  { // Move it down (right).
1068  if (((unsigned int)nIndex + 1) >= mMixerTrackClusters.size())
1069  return; // It's already last.
1070 
1071  pos = pMixerTrackCluster->GetPosition();
1072  mMixerTrackClusters[nIndex] = mMixerTrackClusters[nIndex + 1];
1073  mMixerTrackClusters[nIndex]->Move(pos);
1074 
1075  mMixerTrackClusters[nIndex + 1] = pMixerTrackCluster;
1076  pMixerTrackCluster->Move(pos.x + (kInset + kMixerTrackClusterWidth), pos.y);
1077  }
1078 }
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:132
const int kInset
Definition: MixerBoard.cpp:120
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 1448 of file MixerBoard.cpp.

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

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

Definition at line 1457 of file MixerBoard.cpp.

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

Referenced by MixerBoard().

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

Definition at line 1172 of file MixerBoard.cpp.

References FindMixerTrackCluster().

Referenced by SelectionState::SelectTrack().

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

Definition at line 1180 of file MixerBoard.cpp.

References mMixerTrackClusters.

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

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

Definition at line 1080 of file MixerBoard.cpp.

References FindMixerTrackCluster().

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

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

Definition at line 1092 of file MixerBoard.cpp.

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

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

Definition at line 1192 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

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

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

Definition at line 1186 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnSize(), and UpdateTrackClusters().

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

Definition at line 1259 of file MixerBoard.cpp.

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

Referenced by GainSliderHandle::SetValue().

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

Definition at line 1277 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by OnTimer().

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

Definition at line 1211 of file MixerBoard.cpp.

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

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

1212 {
1213  if (pTrack == NULL)
1214  {
1215  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1217  }
1218  else
1219  {
1220  MixerTrackCluster* pMixerTrackCluster;
1221  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1222  if (pMixerTrackCluster)
1223  pMixerTrackCluster->UpdateMute();
1224  }
1225 }
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 1203 of file MixerBoard.cpp.

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

Referenced by TrackMenuTable::OnSetName().

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

Definition at line 1243 of file MixerBoard.cpp.

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

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

1244 {
1245  if (pTrack == NULL)
1246  {
1247  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1249  }
1250  else
1251  {
1252  MixerTrackCluster* pMixerTrackCluster;
1253  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1254  if (pMixerTrackCluster)
1255  pMixerTrackCluster->UpdatePan();
1256  }
1257 }
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 940 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().

941 {
943 
944 // Old approach modified things in situ.
945 // However with a theme change there is so much to modify, it is easier
946 // to recreate.
947 #if 0
948  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
949  if( mImageMuteUp ){
950  mImageMuteUp.reset();
951  mImageMuteOver.reset();
952  mImageMuteDown.reset();
953  mImageMuteDownWhileSolo.reset();
954  mImageMuteDisabled.reset();
955  mImageSoloUp.reset();
956  mImageSoloOver.reset();
957  mImageSoloDown.reset();
958  mImageSoloDisabled.reset();
959  }
960  for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.GetCount(); nClusterIndex++)
961  mMixerTrackClusters[nClusterIndex]->UpdatePrefs();
962  Refresh();
963 #endif
964 }
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:940
void RecreateMixerBoard()
Definition: Project.cpp:4866
void MixerBoard::UpdateSolo ( const PlayableTrack pTrack = NULL)

Definition at line 1227 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().

1228 {
1229  if (pTrack == NULL)
1230  {
1231  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1233  }
1234  else
1235  {
1236  MixerTrackCluster* pMixerTrackCluster;
1237  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1238  if (pMixerTrackCluster)
1239  pMixerTrackCluster->UpdateSolo();
1240  }
1241 }
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 973 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().

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

Definition at line 1305 of file MixerBoard.cpp.

References GetTrackClustersWidth(), MIXER_BOARD_MIN_WIDTH, and mScrolledWindow.

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

1306 {
1307  int newWidth = this->GetTrackClustersWidth();
1308 
1309  // Min width is one cluster wide, plus margins.
1310  if (newWidth < MIXER_BOARD_MIN_WIDTH)
1311  newWidth = MIXER_BOARD_MIN_WIDTH;
1312 
1313  mScrolledWindow->SetVirtualSize(newWidth, -1);
1314  this->GetParent()->SetSize(newWidth + kDoubleInset, -1);
1315 }
const int kDoubleInset
Definition: MixerBoard.cpp:121
#define MIXER_BOARD_MIN_WIDTH
Definition: MixerBoard.cpp:866
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: