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 ()
 
wxBitmap * GetMusicalInstrumentBitmap (const Track *pTrack)
 
bool HasSolo ()
 
void RefreshTrackClusters (bool bEraseBackground=true)
 
void ResizeTrackClusters ()
 
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 ResetMeters (const bool bResetClipping)
 
void RemoveTrackCluster (size_t nIndex)
 
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 OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void OnTimer (wxCommandEvent &event)
 
void OnTrackSetChanged (wxEvent &event)
 
void OnTrackChanged (TrackListEvent &event)
 
void OnStartStop (wxCommandEvent &event)
 

Private Attributes

std::vector< MixerTrackCluster * > mMixerTrackClusters
 
MusicalInstrumentArray mMusicalInstruments
 
AudacityProjectmProject
 
MixerBoardScrolledWindowmScrolledWindow
 
double mPrevT1
 
TrackListmTracks
 
bool mUpToDate { false }
 

Friends

class MixerBoardFrame
 

Detailed Description

Definition at line 191 of file MixerBoard.h.

Constructor & Destructor Documentation

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

Definition at line 853 of file MixerBoard.cpp.

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

857 : wxWindow(parent, -1, pos, size)
858 {
859  // public data members
860 
861  // mute & solo button images
862  // Create once and store on MixerBoard for use in all MixerTrackClusters.
863  mImageMuteUp = NULL;
864  mImageMuteOver = NULL;
865  mImageMuteDown = NULL;
867  mImageMuteDisabled = NULL;
868  mImageSoloUp = NULL;
869  mImageSoloOver = NULL;
870  mImageSoloDown = NULL;
871  mImageSoloDisabled = NULL;
872 
873  mMuteSoloWidth = kRightSideStackWidth - kInset; // correct for max width, but really set in MixerBoard::CreateMuteSoloImages
874 
875  // private data members
876  this->LoadMusicalInstruments(); // Set up mMusicalInstruments.
877  mProject = pProject;
878 
879  wxASSERT(pProject); // to justify safenew
882  pProject, // AudacityProject* project,
883  this, -1, // wxWindow* parent, wxWindowID id = -1,
884  this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition,
885  size, // const wxSize& size = wxDefaultSize,
886  wxHSCROLL); // long style = wxHSCROLL | wxVSCROLL, const wxString& name = "scrolledWindow")
887 
888  // Set background color to same as TrackPanel background.
889 // #ifdef EXPERIMENTAL_THEMING
890 // mScrolledWindow->SetBackgroundColour(this->GetParent()->GetBackgroundColour());
891 // #else
892 // mScrolledWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
893 // #endif
894  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
896 
897  mScrolledWindow->SetScrollRate(10, 0); // no vertical scroll
898  mScrolledWindow->SetVirtualSize(size);
899 
900  /* This doesn't work to make the mScrolledWindow automatically resize, so do it explicitly in OnSize.
901  auto pBoxSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
902  pBoxSizer->Add(mScrolledWindow, 0, wxExpand, 0);
903  this->SetAutoLayout(true);
904  this->SetSizer(pBoxSizer);
905  pBoxSizer->Fit(this);
906  pBoxSizer->SetSizeHints(this);
907  */
908 
909  mPrevT1 = 0.0;
911 
912  // Events from the project don't propagate directly to this other frame, so...
913  mProject->Bind(EVT_TRACK_PANEL_TIMER,
915  this);
916 
917  mProject->GetTracks()->Bind(EVT_TRACKLIST_SELECTION_CHANGE,
919  this);
920 
921  mProject->GetTracks()->Bind(EVT_TRACKLIST_PERMUTED,
923  this);
924 
925  mProject->GetTracks()->Bind(EVT_TRACKLIST_ADDITION,
927  this);
928 
929  mProject->GetTracks()->Bind(EVT_TRACKLIST_DELETION,
931  this);
932 
933  mProject->GetTracks()->Bind(EVT_TRACKLIST_TRACK_DATA_CHANGE,
935  this);
936 
937  wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK,
938  wxCommandEventHandler(MixerBoard::OnStartStop),
939  NULL,
940  this);
941 }
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:241
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:241
AudacityProject * mProject
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:241
const int kInset
Definition: MixerBoard.cpp:125
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:241
int mMuteSoloWidth
Definition: MixerBoard.h:245
void LoadMusicalInstruments()
void OnTrackSetChanged(wxEvent &event)
void OnTrackChanged(TrackListEvent &event)
#define safenew
Definition: Audacity.h:230
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:241
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:253
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:241
void OnTimer(wxCommandEvent &event)
const int kRightSideStackWidth
Definition: MixerBoard.cpp:136
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:241
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
double mPrevT1
Definition: MixerBoard.h:254
TrackList * GetTracks()
Definition: Project.h:209
TrackList * mTracks
Definition: MixerBoard.h:255
void OnStartStop(wxCommandEvent &event)

Member Function Documentation

void MixerBoard::CreateMuteSoloImages ( )
private

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

1214 {
1215  // Much of this is similar to TrackInfo::MuteOrSoloDrawFunction.
1216  wxMemoryDC dc;
1217  wxString str = _("Mute");
1218 
1219  //mMuteSoloWidth = textWidth + kQuadrupleInset;
1220  //if (mMuteSoloWidth < kRightSideStackWidth - kInset)
1222 
1223  wxBitmap bitmap(mMuteSoloWidth, MUTE_SOLO_HEIGHT,24);
1224  dc.SelectObject(bitmap);
1225  wxRect bev(0, 0, mMuteSoloWidth, MUTE_SOLO_HEIGHT);
1226 
1227  const bool up=true;
1228  const bool down=false;
1229 
1230  MakeButtonBitmap( dc, bitmap, bev, str, up );
1231  mImageMuteUp = std::make_unique<wxImage>(bitmap.ConvertToImage());
1232  mImageMuteOver = std::make_unique<wxImage>(bitmap.ConvertToImage()); // Same as up, for now.
1233 
1234  MakeButtonBitmap( dc, bitmap, bev, str, down );
1235  //AColor::Bevel(dc, false, bev);
1236  mImageMuteDown = std::make_unique<wxImage>(bitmap.ConvertToImage());
1237 
1238  MakeButtonBitmap( dc, bitmap, bev, str, down );
1239  mImageMuteDownWhileSolo = std::make_unique<wxImage>(bitmap.ConvertToImage());
1240 
1241  mImageMuteDisabled = std::make_unique<wxImage>(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused.
1242 
1243  str = _("Solo");
1244  MakeButtonBitmap( dc, bitmap, bev, str, up );
1245  mImageSoloUp = std::make_unique<wxImage>(bitmap.ConvertToImage());
1246  mImageSoloOver = std::make_unique<wxImage>(bitmap.ConvertToImage()); // Same as up, for now.
1247 
1248  MakeButtonBitmap( dc, bitmap, bev, str, down );
1249  mImageSoloDown = std::make_unique<wxImage>(bitmap.ConvertToImage());
1250 
1251  mImageSoloDisabled = std::make_unique<wxImage>(mMuteSoloWidth, MUTE_SOLO_HEIGHT); // Leave empty because unused.
1252 }
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:241
const int kInset
Definition: MixerBoard.cpp:125
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:241
int mMuteSoloWidth
Definition: MixerBoard.h:245
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:132
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:241
_("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:241
void MakeButtonBitmap(wxMemoryDC &dc, wxBitmap &bitmap, wxRect &bev, const wxString &str, bool up)
const int kRightSideStackWidth
Definition: MixerBoard.cpp:136
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:241
int MixerBoard::FindMixerTrackCluster ( const PlayableTrack pTrack,
MixerTrackCluster **  hMixerTrackCluster 
) const
private

Definition at line 1254 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnTrackChanged().

1256 {
1257  *hMixerTrackCluster = NULL;
1258  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1259  {
1260  if (mMixerTrackClusters[i]->mTrack.get() == pTrack)
1261  {
1262  *hMixerTrackCluster = mMixerTrackClusters[i];
1263  return i;
1264  }
1265  }
1266  return -1;
1267 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
wxBitmap * MixerBoard::GetMusicalInstrumentBitmap ( const Track pTrack)

Definition at line 1070 of file MixerBoard.cpp.

References Track::GetName(), and mMusicalInstruments.

Referenced by MixerTrackCluster::UpdateForStateChange().

1071 {
1072  if (mMusicalInstruments.empty())
1073  return NULL;
1074 
1075  // random choice: return mMusicalInstruments[(int)pTrack % mMusicalInstruments.GetCount()].mBitmap;
1076 
1077  const wxString strTrackName(pTrack->GetName().MakeLower());
1078  size_t nBestItemIndex = 0;
1079  unsigned int nBestScore = 0;
1080  unsigned int nInstrIndex = 0;
1081  unsigned int nKeywordIndex;
1082  unsigned int nNumKeywords;
1083  unsigned int nPointsPerMatch;
1084  unsigned int nScore;
1085  for (nInstrIndex = 0; nInstrIndex < mMusicalInstruments.size(); nInstrIndex++)
1086  {
1087  nScore = 0;
1088 
1089  nNumKeywords = mMusicalInstruments[nInstrIndex]->mKeywords.GetCount();
1090  if (nNumKeywords > 0)
1091  {
1092  nPointsPerMatch = 10 / nNumKeywords;
1093  for (nKeywordIndex = 0; nKeywordIndex < nNumKeywords; nKeywordIndex++)
1094  if (strTrackName.Contains(mMusicalInstruments[nInstrIndex]->mKeywords[nKeywordIndex]))
1095  {
1096  nScore +=
1097  nPointsPerMatch +
1098  // Longer keywords get more points.
1099  (2 * mMusicalInstruments[nInstrIndex]->mKeywords[nKeywordIndex].Length());
1100  }
1101  }
1102 
1103  // Choose later one if just matching nBestScore, for better variety,
1104  // and so default works as last element.
1105  if (nScore >= nBestScore)
1106  {
1107  nBestScore = nScore;
1108  nBestItemIndex = nInstrIndex;
1109  }
1110  }
1111  return mMusicalInstruments[nBestItemIndex]->mBitmap.get();
1112 }
wxString GetName() const
Definition: Track.h:376
MusicalInstrumentArray mMusicalInstruments
Definition: MixerBoard.h:251
int MixerBoard::GetTrackClustersWidth ( )

Definition at line 1037 of file MixerBoard.cpp.

References kDoubleInset, kMixerTrackClusterWidth, and mMixerTrackClusters.

Referenced by UpdateWidth().

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

Definition at line 1114 of file MixerBoard.cpp.

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

Referenced by MixerTrackCluster::UpdateMeter().

1115 {
1116  return !(( mTracks->Any<PlayableTrack>() + &PlayableTrack::GetSolo ).empty());
1117 }
bool GetSolo() const
Definition: Track.h:777
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1246
An AudioTrack that can be played and stopped.
Definition: Track.h:769
TrackList * mTracks
Definition: MixerBoard.h:255
void MixerBoard::LoadMusicalInstruments ( )
private

Definition at line 1269 of file MixerBoard.cpp.

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

1270 {
1271  const struct Data { const char * const *bitmap; wxString name; } table[] = {
1272  {acoustic_guitar_gtr_xpm, wxT("acoustic_guitar_gtr")},
1273  {acoustic_piano_pno_xpm, wxT("acoustic_piano_pno")},
1274  {back_vocal_bg_vox_xpm, wxT("back_vocal_bg_vox")},
1275  {clap_xpm, wxT("clap")},
1276  {drums_dr_xpm, wxT("drums_dr")},
1277  {electric_bass_guitar_bs_gtr_xpm, wxT("electric_bass_guitar_bs_gtr")},
1278  {electric_guitar_gtr_xpm, wxT("electric_guitar_gtr")},
1279  {electric_piano_pno_key_xpm, wxT("electric_piano_pno_key")},
1280  {kick_xpm, wxT("kick")},
1281  {loop_xpm, wxT("loop")},
1282  {organ_org_xpm, wxT("organ_org")},
1283  {perc_xpm, wxT("perc")},
1284  {sax_xpm, wxT("sax")},
1285  {snare_xpm, wxT("snare")},
1286  {string_violin_cello_xpm, wxT("string_violin_cello")},
1287  {synth_xpm, wxT("synth")},
1288  {tambo_xpm, wxT("tambo")},
1289  {trumpet_horn_xpm, wxT("trumpet_horn")},
1290  {turntable_xpm, wxT("turntable")},
1291  {vibraphone_vibes_xpm, wxT("vibraphone_vibes")},
1292  {vocal_vox_xpm, wxT("vocal_vox")},
1293 
1294  // This one must be last, so it wins when best score is 0.
1295  {_default_instrument_xpm, wxEmptyString},
1296  };
1297 
1299  wxMemoryDC dc;
1300 
1301  for (const auto &data : table) {
1302  auto bmp = std::make_unique<wxBitmap>(data.bitmap,24);
1303  dc.SelectObject(*bmp);
1304  AColor::Bevel(dc, false, bev);
1305  mMusicalInstruments.push_back(std::make_unique<MusicalInstrument>(
1306  std::move(bmp), data.name
1307  ));
1308  };
1309 }
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:251
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:131
void MixerBoard::MakeButtonBitmap ( wxMemoryDC &  dc,
wxBitmap &  bitmap,
wxRect &  bev,
const wxString &  str,
bool  up 
)
private

Definition at line 1187 of file MixerBoard.cpp.

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

Referenced by CreateMuteSoloImages().

1188 {
1189 
1190  int textWidth, textHeight;
1191 
1192  int fontSize = 10;
1193  #ifdef __WXMSW__
1194  fontSize = 8;
1195  #endif
1196  wxFont font(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1197  GetTextExtent(str, &textWidth, &textHeight, NULL, NULL, &font);
1198 
1199  AColor::UseThemeColour( &dc, clrMedium );
1200  dc.DrawRectangle(bev);
1201 
1202  AColor::Bevel2( dc, up, bev, false );
1203 
1204  wxCoord x = bev.x + (bev.width - textWidth) / 2;
1205  wxCoord y = bev.y + (bev.height - textHeight) / 2;
1206  dc.SetFont(font);
1207  dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
1208  dc.SetBackgroundMode(wxTRANSPARENT);
1209  dc.DrawText(str, x, y);
1210 // dc.DrawText(str, 0, 0);
1211 }
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::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 1313 of file MixerBoard.cpp.

References mUpToDate, and UpdateTrackClusters().

1314 {
1315  if (!mUpToDate) {
1316  mUpToDate = true;
1318  Refresh();
1319  }
1320  // Does the base class do anything for repainting?
1321  evt.Skip();
1322 }
bool mUpToDate
Definition: MixerBoard.h:256
void UpdateTrackClusters()
Definition: MixerBoard.cpp:980
void MixerBoard::OnSize ( wxSizeEvent &  evt)
private

Definition at line 1324 of file MixerBoard.cpp.

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

1325 {
1326  // this->FitInside() doesn't work, and it doesn't happen automatically. Is wxScrolledWindow wrong?
1327  mScrolledWindow->SetSize(evt.GetSize());
1328 
1329  this->ResizeTrackClusters();
1330  this->RefreshTrackClusters(true);
1331 }
void RefreshTrackClusters(bool bEraseBackground=true)
void ResizeTrackClusters()
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:253
void MixerBoard::OnStartStop ( wxCommandEvent &  event)
private

Definition at line 1379 of file MixerBoard.cpp.

References ResetMeters().

Referenced by MixerBoard().

1380 {
1381  evt.Skip();
1382  bool start = evt.GetInt();
1383  ResetMeters( start );
1384 }
void ResetMeters(const bool bResetClipping)
void MixerBoard::OnTimer ( wxCommandEvent &  event)
private

Definition at line 1333 of file MixerBoard.cpp.

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

Referenced by MixerBoard().

1334 {
1335  // PRL 12 Jul 2015: Moved the below (with comments) out of TrackPanel::OnTimer.
1336 
1337  // Vaughan, 2011-01-28: No longer doing this on timer.
1338  // Now it's in AudioIO::SetMeters() and AudioIO::StopStream(), as with Meter Toolbar meters.
1339  //if (pMixerBoard)
1340  // pMixerBoard->ResetMeters(false);
1341 
1342  //v Vaughan, 2011-02-25: Moved this update back here from audacityAudioCallback.
1343  // See note there.
1344  // Vaughan, 2010-01-30:
1345  // Since all we're doing here is updating the meters, I moved it to
1346  // audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
1347  if (mProject->IsAudioActive())
1348  {
1351  }
1352 
1353  // Let other listeners get the notification
1354  event.Skip();
1355 }
double GetStreamTime()
During playback, the track time most recently played.
Definition: AudioIO.cpp:2895
AudacityProject * mProject
Definition: MixerBoard.h:252
bool IsAudioActive() const
Definition: Project.cpp:1533
PlayMode mLastPlayMode
Definition: Project.h:554
void UpdateMeters(const double t1, const bool bLoopedPlay)
AudioIO * gAudioIO
Definition: AudioIO.cpp:491
void MixerBoard::OnTrackChanged ( TrackListEvent event)
private

Definition at line 1357 of file MixerBoard.cpp.

References FindMixerTrackCluster(), and TrackListEvent::mpTrack.

Referenced by MixerBoard().

1358 {
1359  evt.Skip();
1360 
1361  auto pTrack = evt.mpTrack.lock();
1362  auto pPlayable = dynamic_cast<PlayableTrack*>( pTrack.get() );
1363  if ( pPlayable ) {
1364  MixerTrackCluster *pMixerTrackCluster;
1365  FindMixerTrackCluster( pPlayable, &pMixerTrackCluster );
1366  if ( pMixerTrackCluster )
1367  pMixerTrackCluster->Refresh();
1368  }
1369 }
An AudioTrack that can be played and stopped.
Definition: Track.h:769
int FindMixerTrackCluster(const PlayableTrack *pTrack, MixerTrackCluster **hMixerTrackCluster) const
void MixerBoard::OnTrackSetChanged ( wxEvent &  event)
private

Definition at line 1371 of file MixerBoard.cpp.

References mUpToDate, and UpdateTrackClusters().

Referenced by MixerBoard().

1372 {
1373  evt.Skip();
1374  mUpToDate = false;
1376  Refresh();
1377 }
bool mUpToDate
Definition: MixerBoard.h:256
void UpdateTrackClusters()
Definition: MixerBoard.cpp:980
void MixerBoard::RefreshTrackClusters ( bool  bEraseBackground = true)

Definition at line 1119 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnSize().

1120 {
1121  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1122  mMixerTrackClusters[i]->Refresh(bEraseBackground);
1123 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
void MixerBoard::RemoveTrackCluster ( size_t  nIndex)
private

Definition at line 1046 of file MixerBoard.cpp.

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

Referenced by UpdateTrackClusters().

1047 {
1048  auto pMixerTrackCluster = mMixerTrackClusters[nIndex];
1049  mMixerTrackClusters.erase(mMixerTrackClusters.begin() + nIndex);
1050  pMixerTrackCluster->Destroy(); // DELETE is unsafe on wxWindow.
1051 
1052  // Close the gap, if any.
1053  wxPoint pos;
1054  int targetX;
1055  for (unsigned int i = nIndex; i < mMixerTrackClusters.size(); i++)
1056  {
1057  pos = mMixerTrackClusters[i]->GetPosition();
1058  targetX =
1059  kInset + // extra inset to left for first one, so it's double
1060  (i * (kInset + kMixerTrackClusterWidth)) + // left margin and width for each
1061  kInset; // plus left margin for this cluster
1062  if (pos.x != targetX)
1063  mMixerTrackClusters[i]->Move(targetX, pos.y);
1064  }
1065 
1066  this->UpdateWidth();
1067 }
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:137
const int kInset
Definition: MixerBoard.cpp:125
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
void UpdateWidth()
void MixerBoard::ResetMeters ( const bool  bResetClipping)
private

Definition at line 1131 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by OnStartStop().

1132 {
1134 
1135  if (!this->IsShown())
1136  return;
1137 
1138  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1139  mMixerTrackClusters[i]->ResetMeter(bResetClipping);
1140 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
#define BAD_STREAM_TIME
Definition: AudioIO.h:81
double mPrevT1
Definition: MixerBoard.h:254
void MixerBoard::ResizeTrackClusters ( )

Definition at line 1125 of file MixerBoard.cpp.

References mMixerTrackClusters.

Referenced by OnSize(), and UpdateTrackClusters().

1126 {
1127  for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.size(); nClusterIndex++)
1128  mMixerTrackClusters[nClusterIndex]->HandleResize();
1129 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
void MixerBoard::UpdateMeters ( const double  t1,
const bool  bLoopedPlay 
)

Definition at line 1142 of file MixerBoard.cpp.

References BAD_STREAM_TIME, mMixerTrackClusters, and mPrevT1.

Referenced by OnTimer().

1143 {
1144  if (!this->IsShown() || (t1 == BAD_STREAM_TIME))
1145  return;
1146 
1147  if (mPrevT1 == BAD_STREAM_TIME)
1148  {
1149  mPrevT1 = t1;
1150  return;
1151  }
1152 
1153  // In loopedPlay mode, at the end of the loop, mPrevT1 is set to
1154  // selection end, so the next t1 will be less, but we do want to
1155  // keep updating the meters.
1156  if (t1 <= mPrevT1)
1157  {
1158  if (bLoopedPlay)
1159  mPrevT1 = t1;
1160  return;
1161  }
1162 
1163  for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
1164  mMixerTrackClusters[i]->UpdateMeter(mPrevT1, t1);
1165 
1166  mPrevT1 = t1;
1167 }
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
#define BAD_STREAM_TIME
Definition: AudioIO.h:81
double mPrevT1
Definition: MixerBoard.h:254
void MixerBoard::UpdatePrefs ( )

Definition at line 946 of file MixerBoard.cpp.

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

Referenced by AudacityProject::UpdatePrefs().

947 {
948  // Destroys this:
949  static_cast<MixerBoardFrame*>(GetParent())->Recreate( mProject );
950 
951 // Old approach modified things in situ.
952 // However with a theme change there is so much to modify, it is easier
953 // to recreate.
954 #if 0
955  mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
956  if( mImageMuteUp ){
957  mImageMuteUp.reset();
958  mImageMuteOver.reset();
959  mImageMuteDown.reset();
960  mImageMuteDownWhileSolo.reset();
961  mImageMuteDisabled.reset();
962  mImageSoloUp.reset();
963  mImageSoloOver.reset();
964  mImageSoloDown.reset();
965  mImageSoloDisabled.reset();
966  }
967  for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.GetCount(); nClusterIndex++)
968  mMixerTrackClusters[nClusterIndex]->UpdatePrefs();
969  Refresh();
970 #endif
971 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:241
AudacityProject * mProject
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:241
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
std::unique_ptr< wxImage > mImageMuteDownWhileSolo
Definition: MixerBoard.h:241
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:253
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:241
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:241
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void UpdatePrefs()
Definition: MixerBoard.cpp:946
void MixerBoard::UpdateTrackClusters ( )

Definition at line 980 of file MixerBoard.cpp.

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

Referenced by OnPaint(), OnTrackSetChanged(), and MixerBoardFrame::Recreate().

981 {
982  if (!mImageMuteUp)
983  this->CreateMuteSoloImages();
984 
985  const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset;
986  size_t nClusterCount = mMixerTrackClusters.size();
987  unsigned int nClusterIndex = 0;
988  MixerTrackCluster* pMixerTrackCluster = NULL;
989 
990  for (auto pPlayableTrack: mTracks->Leaders<PlayableTrack>()) {
991  // TODO: more-than-two-channels
992  auto spTrack = Track::Pointer<PlayableTrack>( pPlayableTrack );
993  if (nClusterIndex < nClusterCount)
994  {
995  // Already showing it.
996  // Track clusters are maintained in the same order as the WaveTracks.
997  // Track pointers can change for the "same" track for different states
998  // on the undo stack, so update the pointers and display name.
999  mMixerTrackClusters[nClusterIndex]->mTrack = spTrack;
1000  // Assume linked track is wave or null
1001  mMixerTrackClusters[nClusterIndex]->UpdateForStateChange();
1002  }
1003  else
1004  {
1005  // Not already showing it. Add a NEW MixerTrackCluster.
1006  wxPoint clusterPos(
1007  kInset + nClusterIndex * kMixerTrackClusterWidth,
1008  kInset);
1009  wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight);
1010  pMixerTrackCluster =
1012  spTrack,
1013  clusterPos, clusterSize);
1014  if (pMixerTrackCluster)
1015  mMixerTrackClusters.push_back(pMixerTrackCluster);
1016  }
1017  nClusterIndex++;
1018  }
1019 
1020  if (pMixerTrackCluster)
1021  {
1022  // Added at least one MixerTrackCluster.
1023  this->UpdateWidth();
1024  this->ResizeTrackClusters();
1025  }
1026  else while (nClusterIndex < nClusterCount)
1027  {
1028  // We've got too many clusters.
1029  // This can happen only on things like Undo New Audio Track or Undo Import
1030  // that don't call RemoveTrackCluster explicitly.
1031  // We've already updated the track pointers for the clusters to the left, so just remove all the rest.
1032  // Successively DELETE from right to left.
1033  RemoveTrackCluster(--nClusterCount);
1034  }
1035 }
const int kDoubleInset
Definition: MixerBoard.cpp:126
const int kMixerTrackClusterWidth
Definition: MixerBoard.cpp:137
void ResizeTrackClusters()
auto Leaders() -> TrackIterRange< TrackType >
Definition: Track.h:1280
AudacityProject * mProject
Definition: MixerBoard.h:252
const int kInset
Definition: MixerBoard.cpp:125
std::vector< MixerTrackCluster * > mMixerTrackClusters
Definition: MixerBoard.h:249
#define safenew
Definition: Audacity.h:230
void CreateMuteSoloImages()
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:253
void UpdateWidth()
An AudioTrack that can be played and stopped.
Definition: Track.h:769
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:241
void RemoveTrackCluster(size_t nIndex)
TrackList * mTracks
Definition: MixerBoard.h:255
void MixerBoard::UpdateWidth ( )

Definition at line 1170 of file MixerBoard.cpp.

References GetTrackClustersWidth(), MIXER_BOARD_MIN_WIDTH, and mScrolledWindow.

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

1171 {
1172  int newWidth = this->GetTrackClustersWidth();
1173 
1174  // Min width is one cluster wide, plus margins.
1175  if (newWidth < MIXER_BOARD_MIN_WIDTH)
1176  newWidth = MIXER_BOARD_MIN_WIDTH;
1177 
1178  mScrolledWindow->SetVirtualSize(newWidth, -1);
1179  this->GetParent()->SetSize(newWidth + kDoubleInset, -1);
1180 }
const int kDoubleInset
Definition: MixerBoard.cpp:126
#define MIXER_BOARD_MIN_WIDTH
Definition: MixerBoard.cpp:845
MixerBoardScrolledWindow * mScrolledWindow
Definition: MixerBoard.h:253
int GetTrackClustersWidth()

Friends And Related Function Documentation

friend class MixerBoardFrame
friend

Definition at line 193 of file MixerBoard.h.

Member Data Documentation

std::unique_ptr<wxImage> MixerBoard::mImageMuteDisabled

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteDown

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteDownWhileSolo

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteOver

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageMuteUp

Definition at line 241 of file MixerBoard.h.

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

std::unique_ptr<wxImage> MixerBoard::mImageSoloDisabled

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloDown

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloOver

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

std::unique_ptr<wxImage> MixerBoard::mImageSoloUp

Definition at line 241 of file MixerBoard.h.

Referenced by CreateMuteSoloImages(), and UpdatePrefs().

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

Definition at line 251 of file MixerBoard.h.

Referenced by GetMusicalInstrumentBitmap(), and LoadMusicalInstruments().

int MixerBoard::mMuteSoloWidth

Definition at line 245 of file MixerBoard.h.

Referenced by CreateMuteSoloImages().

double MixerBoard::mPrevT1
private

Definition at line 254 of file MixerBoard.h.

Referenced by ResetMeters(), and UpdateMeters().

AudacityProject* MixerBoard::mProject
private

Definition at line 252 of file MixerBoard.h.

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

MixerBoardScrolledWindow* MixerBoard::mScrolledWindow
private

Definition at line 253 of file MixerBoard.h.

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

TrackList* MixerBoard::mTracks
private

Definition at line 255 of file MixerBoard.h.

Referenced by HasSolo(), and UpdateTrackClusters().

bool MixerBoard::mUpToDate { false }
private

Definition at line 256 of file MixerBoard.h.

Referenced by OnPaint(), and OnTrackSetChanged().


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