MCPcopy Create free account
hub / github.com/audacity/audacity / UpdateTrackClusters

Method UpdateTrackClusters

src/MixerBoard.cpp:970–1027  ·  view source on GitHub ↗

Reassign mixer input strips (MixerTrackClusters) to Track Clusters both have the same order. Note Tracks appear in the mixer, and we must be able to convert and reuse a MixerTrackCluster from audio to midi or midi to audio. This task is handled by UpdateForStateChange().

Source from the content-addressed store, hash-verified

968// UpdateForStateChange().
969//
970void MixerBoard::UpdateTrackClusters()
971{
972 if (!mImageMuteUp)
973 this->CreateMuteSoloImages();
974
975 const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset;
976 size_t nClusterCount = mMixerTrackClusters.size();
977 unsigned int nClusterIndex = 0;
978 MixerTrackCluster* pMixerTrackCluster = NULL;
979
980 for (auto pPlayableTrack: mTracks->Any<PlayableTrack>()) {
981 // TODO: more-than-two-channels
982 auto spTrack = pPlayableTrack->SharedPointer<PlayableTrack>();
983 // Track iterations always yield non-null pointers; maintain invariant
984 // when reassigning
985 assert(spTrack);
986 if (nClusterIndex < nClusterCount)
987 {
988 // Already showing it.
989 // Track clusters are maintained in the same order as the WaveTracks.
990 // Track pointers can change for the "same" track for different states
991 // on the undo stack, so update the pointers and display name.
992 mMixerTrackClusters[nClusterIndex]->mTrack = spTrack;
993 // Assume linked track is wave or null
994 mMixerTrackClusters[nClusterIndex]->UpdateForStateChange();
995 }
996 else
997 {
998 // Not already showing it. Add a NEW MixerTrackCluster.
999 wxPoint clusterPos(
1000 kInset + nClusterIndex * kMixerTrackClusterWidth,
1001 kInset);
1002 wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight);
1003 pMixerTrackCluster =
1004 safenew MixerTrackCluster(mScrolledWindow, this, mProject,
1005 *spTrack, clusterPos, clusterSize);
1006 if (pMixerTrackCluster)
1007 mMixerTrackClusters.push_back(pMixerTrackCluster);
1008 }
1009 nClusterIndex++;
1010 }
1011
1012 if (pMixerTrackCluster)
1013 {
1014 // Added at least one MixerTrackCluster.
1015 this->UpdateWidth();
1016 this->ResizeTrackClusters();
1017 }
1018 else while (nClusterIndex < nClusterCount)
1019 {
1020 // We've got too many clusters.
1021 // This can happen only on things like Undo New Audio Track or Undo Import
1022 // that don't call RemoveTrackCluster explicitly.
1023 // We've already updated the track pointers for the clusters to the left, so just remove all the rest.
1024 // Successively DELETE from right to left.
1025 RemoveTrackCluster(--nClusterCount);
1026 }
1027}

Callers 2

MixerBoardFrameMethod · 0.80
RecreateMethod · 0.80

Calls 7

CreateMuteSoloImagesMethod · 0.95
UpdateWidthMethod · 0.95
ResizeTrackClustersMethod · 0.95
GetHeightMethod · 0.80
UpdateForStateChangeMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected