1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 08:39:46 +02:00

Bug2214: Mix and Render should insert new tracks after old tracks...

... or where the old tracks were, if replacing them

This puts the new track in the sync-lock group of the old tracks.
This commit is contained in:
Paul Licameli 2019-12-30 11:01:44 -05:00
parent dbdfb26e4a
commit 28e19e3e03

View File

@ -66,6 +66,11 @@ void DoMixAndRender
// Remove originals, get stats on what tracks were mixed
auto trackRange = tracks.Selected< WaveTrack >();
// But before removing, determine the first track after the removal
auto last = *trackRange.rbegin();
auto insertionPoint = * ++ tracks.Find( last );
auto selectedCount = (trackRange + &Track::IsLeader).size();
wxString firstName;
if (selectedCount > 0)
@ -93,6 +98,29 @@ void DoMixAndRender
pNewRight->SetName(firstName);
}
// Permute the tracks as needed
// The new track appears after the old tracks (or where the old tracks
// had been) so that they are in the same sync-lock group
if (insertionPoint)
{
std::vector<TrackNodePointer> arr;
arr.reserve( tracks.size() );
size_t begin = 0, ii = 0;
for (auto iter = tracks.ListOfTracks::begin(),
end = tracks.ListOfTracks::end(); iter != end; ++iter) {
arr.push_back( {iter, &tracks} );
if ( iter->get() == insertionPoint )
begin = ii;
++ii;
}
auto mid = arr.end();
--mid;
if (pNewRight)
--mid;
std::rotate( arr.begin() + begin, mid, arr.end() );
tracks.Permute( arr );
}
// Smart history/undo message
if (selectedCount==1) {
auto msg = XO("Rendered all audio in track '%s'").Format( firstName );