mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-14 07:37:43 +02:00
Rewrite iterations over sync-lock groups
This commit is contained in:
parent
bb3aa00f50
commit
b6a6b8e73e
@ -16,43 +16,25 @@
|
|||||||
// on, use the largest possible selection in the sync-lock group.
|
// on, use the largest possible selection in the sync-lock group.
|
||||||
// If it's a stereo track, do the same for the stereo channels.
|
// If it's a stereo track, do the same for the stereo channels.
|
||||||
void SelectionState::SelectTrackLength
|
void SelectionState::SelectTrackLength
|
||||||
( TrackList &tracks, ViewInfo &viewInfo, Track &track, bool syncLocked )
|
( ViewInfo &viewInfo, Track &track, bool syncLocked )
|
||||||
{
|
{
|
||||||
SyncLockedTracksIterator it( &tracks );
|
auto trackRange = syncLocked
|
||||||
Track *t1 = it.StartWith( &track );
|
|
||||||
double minOffset = track.GetOffset();
|
|
||||||
double maxEnd = track.GetEndTime();
|
|
||||||
|
|
||||||
// If we have a sync-lock group and sync-lock linking is on,
|
// If we have a sync-lock group and sync-lock linking is on,
|
||||||
// check the sync-lock group tracks.
|
// check the sync-lock group tracks.
|
||||||
if ( syncLocked && t1 != NULL )
|
? TrackList::SyncLockGroup(&track)
|
||||||
{
|
|
||||||
for ( ; t1; t1 = it.Next())
|
|
||||||
{
|
|
||||||
if (t1->GetOffset() < minOffset)
|
|
||||||
minOffset = t1->GetOffset();
|
|
||||||
if (t1->GetEndTime() > maxEnd)
|
|
||||||
maxEnd = t1->GetEndTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Otherwise, check for a stereo pair
|
// Otherwise, check for a stereo pair
|
||||||
t1 = track.GetLink();
|
: TrackList::Channels(&track);
|
||||||
if (t1)
|
|
||||||
{
|
auto minOffset = trackRange.min( &Track::GetOffset );
|
||||||
if (t1->GetOffset() < minOffset)
|
auto maxEnd = trackRange.max( &Track::GetEndTime );
|
||||||
minOffset = t1->GetOffset();
|
|
||||||
if (t1->GetEndTime() > maxEnd)
|
|
||||||
maxEnd = t1->GetEndTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PRL: double click or click on track control.
|
// PRL: double click or click on track control.
|
||||||
// should this select all frequencies too? I think not.
|
// should this select all frequencies too? I think not.
|
||||||
viewInfo.selectedRegion.setTimes(minOffset, maxEnd);
|
viewInfo.selectedRegion.setTimes(minOffset, maxEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionState::SelectTrack
|
void SelectionState::SelectTrack
|
||||||
( Track &track, bool selected, bool updateLastPicked,
|
( Track &track, bool selected, bool updateLastPicked,
|
||||||
MixerBoard *pMixerBoard )
|
MixerBoard *pMixerBoard )
|
||||||
@ -175,7 +157,7 @@ void SelectionState::HandleListSelection
|
|||||||
else {
|
else {
|
||||||
SelectNone( tracks, pMixerBoard );
|
SelectNone( tracks, pMixerBoard );
|
||||||
SelectTrack( track, true, true, pMixerBoard );
|
SelectTrack( track, true, true, pMixerBoard );
|
||||||
SelectTrackLength( tracks, viewInfo, track, syncLocked );
|
SelectTrackLength( viewInfo, track, syncLocked );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMixerBoard)
|
if (pMixerBoard)
|
||||||
|
@ -21,7 +21,7 @@ class SelectionState
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void SelectTrackLength
|
static void SelectTrackLength
|
||||||
( TrackList &tracks, ViewInfo &viewInfo, Track &track, bool syncLocked );
|
( ViewInfo &viewInfo, Track &track, bool syncLocked );
|
||||||
|
|
||||||
void SelectTrack
|
void SelectTrack
|
||||||
( Track &track,
|
( Track &track,
|
||||||
|
@ -371,9 +371,9 @@ bool EffectTruncSilence::ProcessIndependently()
|
|||||||
// Treat tracks in the sync lock group only
|
// Treat tracks in the sync lock group only
|
||||||
Track *groupFirst, *groupLast;
|
Track *groupFirst, *groupLast;
|
||||||
if (syncLock) {
|
if (syncLock) {
|
||||||
SyncLockedTracksIterator syncIter(mOutputTracks.get());
|
auto trackRange = TrackList::SyncLockGroup(track);
|
||||||
groupFirst = syncIter.StartWith(track);
|
groupFirst = *trackRange.begin();
|
||||||
groupLast = syncIter.Last();
|
groupLast = *trackRange.rbegin();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
groupFirst = track;
|
groupFirst = track;
|
||||||
|
@ -818,8 +818,7 @@ bool NyquistEffect::Process()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we're in the same group as the last selected track
|
// Check whether we're in the same group as the last selected track
|
||||||
SyncLockedTracksIterator gIter(mOutputTracks.get());
|
Track *gt = *TrackList::SyncLockGroup(mCurTrack[0]).first;
|
||||||
Track *gt = gIter.StartWith(mCurTrack[0]);
|
|
||||||
mFirstInGroup = !gtLast || (gtLast != gt);
|
mFirstInGroup = !gtLast || (gtLast != gt);
|
||||||
gtLast = gt;
|
gtLast = gt;
|
||||||
|
|
||||||
@ -1530,9 +1529,7 @@ bool NyquistEffect::ProcessOne()
|
|||||||
|
|
||||||
// If we were first in the group adjust non-selected group tracks
|
// If we were first in the group adjust non-selected group tracks
|
||||||
if (mFirstInGroup) {
|
if (mFirstInGroup) {
|
||||||
SyncLockedTracksIterator git(mOutputTracks.get());
|
for (auto t : TrackList::SyncLockGroup(mCurTrack[i]))
|
||||||
Track *t;
|
|
||||||
for (t = git.StartWith(mCurTrack[i]); t; t = git.Next())
|
|
||||||
{
|
{
|
||||||
if (!t->GetSelected() && t->IsSyncLockSelected()) {
|
if (!t->GetSelected() && t->IsSyncLockSelected()) {
|
||||||
t->SyncLockAdjust(mT1, mT0 + out->GetEndTime());
|
t->SyncLockAdjust(mT1, mT0 + out->GetEndTime());
|
||||||
|
@ -226,9 +226,8 @@ UIHandle::Result StretchHandle::Release
|
|||||||
bool right = mStretchState.mMode == stretchRight;
|
bool right = mStretchState.mMode == stretchRight;
|
||||||
ViewInfo &viewInfo = pProject->GetViewInfo();
|
ViewInfo &viewInfo = pProject->GetViewInfo();
|
||||||
if ( pProject->IsSyncLocked() && ( left || right ) ) {
|
if ( pProject->IsSyncLocked() && ( left || right ) ) {
|
||||||
SyncLockedTracksIterator syncIter( pProject->GetTracks() );
|
for ( auto track :
|
||||||
for ( auto track = syncIter.StartWith( mpTrack.get() ); track != nullptr;
|
TrackList::SyncLockGroup( mpTrack.get() ) ) {
|
||||||
track = syncIter.Next() ) {
|
|
||||||
if ( track != mpTrack.get() ) {
|
if ( track != mpTrack.get() ) {
|
||||||
if ( left ) {
|
if ( left ) {
|
||||||
auto origT0 = mStretchState.mOrigSel0Quantized;
|
auto origT0 = mStretchState.mOrigSel0Quantized;
|
||||||
|
@ -566,7 +566,7 @@ UIHandle::Result SelectHandle::Click
|
|||||||
|
|
||||||
// Default behavior: select whole track
|
// Default behavior: select whole track
|
||||||
SelectionState::SelectTrackLength
|
SelectionState::SelectTrackLength
|
||||||
( *trackList, viewInfo, *pTrack, pProject->IsSyncLocked() );
|
( viewInfo, *pTrack, pProject->IsSyncLocked() );
|
||||||
|
|
||||||
// Special case: if we're over a clip in a WaveTrack,
|
// Special case: if we're over a clip in a WaveTrack,
|
||||||
// select just that clip
|
// select just that clip
|
||||||
|
@ -267,9 +267,7 @@ void TimeShiftHandle::CreateListOfCapturedClips
|
|||||||
// we can treat individual labels as clips)
|
// we can treat individual labels as clips)
|
||||||
if ( trackClip.clip ) {
|
if ( trackClip.clip ) {
|
||||||
// Iterate over sync-lock group tracks.
|
// Iterate over sync-lock group tracks.
|
||||||
SyncLockedTracksIterator git( &trackList );
|
for (auto t : TrackList::SyncLockGroup( trackClip.track ))
|
||||||
for (Track *t = git.StartWith( trackClip.track );
|
|
||||||
t; t = git.Next() )
|
|
||||||
AddClipsToCaptured(state, t,
|
AddClipsToCaptured(state, t,
|
||||||
trackClip.clip->GetStartTime(),
|
trackClip.clip->GetStartTime(),
|
||||||
trackClip.clip->GetEndTime() );
|
trackClip.clip->GetEndTime() );
|
||||||
@ -278,8 +276,7 @@ void TimeShiftHandle::CreateListOfCapturedClips
|
|||||||
// Capture additional clips from NoteTracks
|
// Capture additional clips from NoteTracks
|
||||||
trackClip.track->TypeSwitch( [&](NoteTrack *nt) {
|
trackClip.track->TypeSwitch( [&](NoteTrack *nt) {
|
||||||
// Iterate over sync-lock group tracks.
|
// Iterate over sync-lock group tracks.
|
||||||
SyncLockedTracksIterator git( &trackList );
|
for (auto t : TrackList::SyncLockGroup(nt))
|
||||||
for (Track *t = git.StartWith(nt); t; t = git.Next())
|
|
||||||
AddClipsToCaptured
|
AddClipsToCaptured
|
||||||
( state, t, nt->GetStartTime(), nt->GetEndTime() );
|
( state, t, nt->GetStartTime(), nt->GetEndTime() );
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user