Audacity  2.3.1
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 880 of file MixerBoard.cpp.

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

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

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

Definition at line 1384 of file MixerBoard.cpp.

References mMixerTrackClusters.

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

1386 {
1387  *hMixerTrackCluster = NULL;
1388  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1389  {
1390  if (mMixerTrackClusters[i]->mTrack.get() == pTrack)
1391  {
1392  *hMixerTrackCluster = mMixerTrackClusters[i];
1393  return i;
1394  }
1395  }
1396  return -1;
1397 }
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:369
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:125
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:136
const int kInset
Definition: MixerBoard.cpp:124
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
bool MixerBoard::HasSolo ( )

Definition at line 1162 of file MixerBoard.cpp.

References TrackList::Any(), PlayableTrack::GetSolo(), and mTracks.

Referenced by MixerTrackCluster::UpdateMeter().

1163 {
1164  return !(( mTracks->Any<PlayableTrack>() + &PlayableTrack::GetSolo ).empty());
1165 }
bool GetSolo() const
Definition: Track.h:765
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1195
An AudioTrack that can be played and stopped.
Definition: Track.h:757
TrackList * mTracks
Definition: MixerBoard.h:272
void MixerBoard::LoadMusicalInstruments ( )
private

Definition at line 1399 of file MixerBoard.cpp.

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

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

Definition at line 1317 of file MixerBoard.cpp.

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

Referenced by CreateMuteSoloImages().

1318 {
1319 
1320  int textWidth, textHeight;
1321 
1322  int fontSize = 10;
1323  #ifdef __WXMSW__
1324  fontSize = 8;
1325  #endif
1326  wxFont font(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1327  GetTextExtent(str, &textWidth, &textHeight, NULL, NULL, &font);
1328 
1329  AColor::UseThemeColour( &dc, clrMedium );
1330  dc.DrawRectangle(bev);
1331 
1332  AColor::Bevel2( dc, up, bev, false );
1333 
1334  wxCoord x = bev.x + (bev.width - textWidth) / 2;
1335  wxCoord y = bev.y + (bev.height - textHeight) / 2;
1336  dc.SetFont(font);
1337  dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
1338  dc.SetBackgroundMode(wxTRANSPARENT);
1339  dc.DrawText(str, x, y);
1340 // dc.DrawText(str, 0, 0);
1341 }
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().

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:136
const int kInset
Definition: MixerBoard.cpp:124
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 1443 of file MixerBoard.cpp.

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

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

Definition at line 1452 of file MixerBoard.cpp.

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

Referenced by MixerBoard().

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

Definition at line 1167 of file MixerBoard.cpp.

References FindMixerTrackCluster().

Referenced by SelectionState::SelectTrack().

1168 {
1169  MixerTrackCluster* pMixerTrackCluster;
1170  this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1171  if (pMixerTrackCluster)
1172  pMixerTrackCluster->Refresh(bEraseBackground);
1173 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::RefreshTrackClusters ( bool  bEraseBackground = true)

Definition at line 1175 of file MixerBoard.cpp.

References mMixerTrackClusters.

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

1176 {
1177  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1178  mMixerTrackClusters[i]->Refresh(bEraseBackground);
1179 }
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::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:136
const int kInset
Definition: MixerBoard.cpp:124
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:266
void UpdateWidth()
void MixerBoard::ResetMeters ( const bool  bResetClipping)

Definition at line 1187 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

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

1188 {
1190 
1191  if (!this->IsShown())
1192  return;
1193 
1194  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1195  mMixerTrackClusters[i]->ResetMeter(bResetClipping);
1196 }
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 1181 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnSize(), and UpdateTrackClusters().

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

Definition at line 1254 of file MixerBoard.cpp.

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

Referenced by GainSliderHandle::SetValue().

1255 {
1256  MixerTrackCluster* pMixerTrackCluster;
1257  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1258  if (pMixerTrackCluster)
1259  pMixerTrackCluster->UpdateGain();
1260 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdateMeters ( const double  t1,
const bool  bLoopedPlay 
)

Definition at line 1272 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by OnTimer().

1273 {
1274  if (!this->IsShown() || (t1 == BAD_STREAM_TIME))
1275  return;
1276 
1277  if (mPrevT1 == BAD_STREAM_TIME)
1278  {
1279  mPrevT1 = t1;
1280  return;
1281  }
1282 
1283  // In loopedPlay mode, at the end of the loop, mPrevT1 is set to
1284  // selection end, so the next t1 will be less, but we do want to
1285  // keep updating the meters.
1286  if (t1 <= mPrevT1)
1287  {
1288  if (bLoopedPlay)
1289  mPrevT1 = t1;
1290  return;
1291  }
1292 
1293  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1294  mMixerTrackClusters[i]->UpdateMeter(mPrevT1, t1);
1295 
1296  mPrevT1 = t1;
1297 }
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 1206 of file MixerBoard.cpp.

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

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

1207 {
1208  if (pTrack == NULL)
1209  {
1210  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1212  }
1213  else
1214  {
1215  MixerTrackCluster* pMixerTrackCluster;
1216  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1217  if (pMixerTrackCluster)
1218  pMixerTrackCluster->UpdateMute();
1219  }
1220 }
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 1198 of file MixerBoard.cpp.

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

Referenced by TrackMenuTable::OnSetName().

1199 {
1200  MixerTrackCluster* pMixerTrackCluster;
1201  this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1202  if (pMixerTrackCluster)
1203  pMixerTrackCluster->UpdateName();
1204 }
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::UpdatePan ( const PlayableTrack pTrack = NULL)

Definition at line 1238 of file MixerBoard.cpp.

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

Referenced by PanSliderHandle::SetValue().

1239 {
1240  if (pTrack == NULL)
1241  {
1242  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1244  }
1245  else
1246  {
1247  MixerTrackCluster* pMixerTrackCluster;
1248  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1249  if (pMixerTrackCluster)
1250  pMixerTrackCluster->UpdatePan();
1251  }
1252 }
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 948 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().

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

Definition at line 1222 of file MixerBoard.cpp.

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

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

1223 {
1224  if (pTrack == NULL)
1225  {
1226  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1228  }
1229  else
1230  {
1231  MixerTrackCluster* pMixerTrackCluster;
1232  FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
1233  if (pMixerTrackCluster)
1234  pMixerTrackCluster->UpdateSolo();
1235  }
1236 }
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 981 of file MixerBoard.cpp.

References CreateMuteSoloImages(), kDoubleInset, kMixerTrackClusterWidth, TrackList::Leaders(), mImageMuteUp, mMixerTrackClusters, mProject, mScrolledWindow, mTracks, RemoveTrackCluster(), ResizeTrackClusters(), safenew, and UpdateWidth().

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

982 {
983  if (!mImageMuteUp)
984  this->CreateMuteSoloImages();
985 
986  const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset;
987  size_t nClusterCount = mMixerTrackClusters.size();
988  unsigned int nClusterIndex = 0;
989  MixerTrackCluster* pMixerTrackCluster = NULL;
990 
991  for (auto pPlayableTrack: mTracks->Leaders<PlayableTrack>()) {
992  // TODO: more-than-two-channels
993  auto spTrack = Track::Pointer<PlayableTrack>( pPlayableTrack );
994  if (nClusterIndex < nClusterCount)
995  {
996  // Already showing it.
997  // Track clusters are maintained in the same order as the WaveTracks.
998  // Track pointers can change for the "same" track for different states
999  // on the undo stack, so update the pointers and display name.
1000  mMixerTrackClusters[nClusterIndex]->mTrack = spTrack;
1001  // Assume linked track is wave or null
1002  mMixerTrackClusters[nClusterIndex]->UpdateForStateChange();
1003  }
1004  else
1005  {
1006  // Not already showing it. Add a NEW MixerTrackCluster.
1007  wxPoint clusterPos(
1008  kInset + nClusterIndex * kMixerTrackClusterWidth,
1009  kInset);
1010  wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight);
1011  pMixerTrackCluster =
1013  spTrack,
1014  clusterPos, clusterSize);
1015  if (pMixerTrackCluster)
1016  mMixerTrackClusters.push_back(pMixerTrackCluster);
1017  }
1018  nClusterIndex++;
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:125
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:136
void ResizeTrackClusters()
auto Leaders() -> TrackIterRange< TrackType >
Definition: Track.h:1229
AudacityProject * mProject
Definition: MixerBoard.h:269
const int kInset
Definition: MixerBoard.cpp:124
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
void UpdateWidth()
An AudioTrack that can be played and stopped.
Definition: Track.h:757
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:258
TrackList * mTracks
Definition: MixerBoard.h:272
void MixerBoard::UpdateWidth ( )

Definition at line 1300 of file MixerBoard.cpp.

References GetTrackClustersWidth(), MIXER_BOARD_MIN_WIDTH, and mScrolledWindow.

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

1301 {
1302  int newWidth = this->GetTrackClustersWidth();
1303 
1304  // Min width is one cluster wide, plus margins.
1305  if (newWidth < MIXER_BOARD_MIN_WIDTH)
1306  newWidth = MIXER_BOARD_MIN_WIDTH;
1307 
1308  mScrolledWindow->SetVirtualSize(newWidth, -1);
1309  this->GetParent()->SetSize(newWidth + kDoubleInset, -1);
1310 }
const int kDoubleInset
Definition: MixerBoard.cpp:125
#define MIXER_BOARD_MIN_WIDTH
Definition: MixerBoard.cpp:873
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: