From 612868405517979c691d44d9649a00341ebf3dac Mon Sep 17 00:00:00 2001 From: richardash1981 Date: Sun, 28 Aug 2011 19:30:17 +0000 Subject: [PATCH] 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. --- src/Mix.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Mix.cpp b/src/Mix.cpp index 0d0b9b7b4..627c261ef 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -56,9 +56,11 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory, WaveTrack **waveArray; Track *t; - int numWaves = 0; - int numMono = 0; - bool mono = false; + int numWaves = 0; /* number of wave tracks in the selection */ + int numMono = 0; /* number of mono, centre-panned wave tracks in selection*/ + 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; TrackListIterator iter(tracks); @@ -91,15 +93,27 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory, 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); - mixLeft->SetName(_("Mix")); + 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")); WaveTrack *mixRight = 0; if (mono) { mixLeft->SetChannel(Track::MonoChannel); } else { mixRight = trackFactory->NewWaveTrack(format, rate); - mixRight->SetName(_("Mix")); + if (oneinput) + mixLeft->SetName(iter.First()->GetLink()->GetName()); /* set name to match input track's right channel!*/ + else + mixRight->SetName(_("Mix")); mixLeft->SetChannel(Track::LeftChannel); mixRight->SetChannel(Track::RightChannel); mixLeft->SetLinked(true);