1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-11 17:41:15 +02:00

If only mix and rendering one track, make the new track have the same name.

This saves a lot of typing if it is necessary to render a lot tracks in-place whilst preserving their names.
It is currently impossible to test that the two channels of stereo tracks get the correct name, as making stereo tracks always results in tracks with the same name for both channels ... This code would be much simpler if stereo tracks were objects.
This function (Mix and Render) could be made simpler if it used the TrackList functions like GetNumExportChannels() and made better use of conditional iterators rather than working it out for itself.
This commit is contained in:
richardash1981 2011-08-28 19:30:17 +00:00
parent ea1bc0f5a3
commit 6128684055

View File

@ -56,9 +56,11 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
WaveTrack **waveArray; WaveTrack **waveArray;
Track *t; Track *t;
int numWaves = 0; int numWaves = 0; /* number of wave tracks in the selection */
int numMono = 0; int numMono = 0; /* number of mono, centre-panned wave tracks in selection*/
bool mono = false; bool mono = false; /* flag if output can be mono without loosing anything*/
bool oneinput = false; /* flag set to true if there is only one input track
(mono or stereo) */
int w; int w;
TrackListIterator iter(tracks); TrackListIterator iter(tracks);
@ -91,7 +93,16 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
t = iter.Next(); t = iter.Next();
} }
/* create the destination track (new track) */
if ((numWaves == 1) || ((numWaves == 2) && (iter.First()->GetLink() != NULL)))
oneinput = true;
// only one input track (either 1 mono or one linked stereo pair)
WaveTrack *mixLeft = trackFactory->NewWaveTrack(format, rate); WaveTrack *mixLeft = trackFactory->NewWaveTrack(format, rate);
if (oneinput)
mixLeft->SetName(iter.First()->GetName()); /* set name of output track to be the same as the sole input track */
else
mixLeft->SetName(_("Mix")); mixLeft->SetName(_("Mix"));
WaveTrack *mixRight = 0; WaveTrack *mixRight = 0;
if (mono) { if (mono) {
@ -99,6 +110,9 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
} }
else { else {
mixRight = trackFactory->NewWaveTrack(format, rate); mixRight = trackFactory->NewWaveTrack(format, rate);
if (oneinput)
mixLeft->SetName(iter.First()->GetLink()->GetName()); /* set name to match input track's right channel!*/
else
mixRight->SetName(_("Mix")); mixRight->SetName(_("Mix"));
mixLeft->SetChannel(Track::LeftChannel); mixLeft->SetChannel(Track::LeftChannel);
mixRight->SetChannel(Track::RightChannel); mixRight->SetChannel(Track::RightChannel);