1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 00:03:52 +02:00

MixAndRender returns unique_ptr results (in a std::pair)

This commit is contained in:
Paul Licameli
2016-03-13 03:14:46 -04:00
parent 3015a9c8d9
commit c4fc7e2bf0
4 changed files with 34 additions and 32 deletions

View File

@@ -43,10 +43,10 @@
#include "float_cast.h"
//TODO-MB: wouldn't it make more sense to DELETE the time track after 'mix and render'?
bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
std::pair<WaveTrack::Holder, WaveTrack::Holder>
MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
double rate, sampleFormat format,
double startTime, double endTime,
WaveTrack **newLeft, WaveTrack **newRight)
double startTime, double endTime)
{
// This function was formerly known as "Quick Mix".
Track *t;
@@ -121,18 +121,18 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
oneinput = true;
// only one input track (either 1 mono or one linked stereo pair)
WaveTrack *mixLeft = trackFactory->NewWaveTrack(format, rate).release();
auto mixLeft = trackFactory->NewWaveTrack(format, rate);
if (oneinput)
mixLeft->SetName(usefulIter.First()->GetName()); /* set name of output track to be the same as the sole input track */
else
mixLeft->SetName(_("Mix"));
mixLeft->SetOffset(mixStartTime);
WaveTrack *mixRight = 0;
decltype(mixLeft) mixRight{};
if (mono) {
mixLeft->SetChannel(Track::MonoChannel);
}
else {
mixRight = trackFactory->NewWaveTrack(format, rate).release();
mixRight = trackFactory->NewWaveTrack(format, rate);
if (oneinput) {
if (usefulIter.First()->GetLink() != NULL) // we have linked track
mixLeft->SetName(usefulIter.First()->GetLink()->GetName()); /* set name to match input track's right channel!*/
@@ -197,14 +197,13 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
mixRight->Flush();
if (updateResult == eProgressCancelled || updateResult == eProgressFailed)
{
delete mixLeft;
if (!mono)
delete mixRight;
} else {
*newLeft = mixLeft;
if (!mono)
*newRight = mixRight;
return{};
}
else {
return std::make_pair(
std::move(mixLeft),
std::move(mixRight)
);
#if 0
int elapsedMS = wxGetElapsedTime();
double elapsedTime = elapsedMS * 0.001;
@@ -218,7 +217,6 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
printf("Max number of tracks to mix in real time: %f\n", maxTracks);
#endif
}
return (updateResult == eProgressSuccess || updateResult == eProgressStopped);
}
Mixer::WarpOptions::WarpOptions(double min, double max)