From 1dce507aaf532e26b6865d2249cc087cde9d42d2 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 24 May 2019 10:11:52 -0400 Subject: [PATCH] Avoid repetition in computing arguments for export mixers --- src/export/Export.cpp | 7 +++++-- src/export/Export.h | 4 ++-- src/export/ExportCL.cpp | 6 ++---- src/export/ExportFFmpeg.cpp | 5 +---- src/export/ExportFLAC.cpp | 5 +---- src/export/ExportMP2.cpp | 5 +---- src/export/ExportMP3.cpp | 5 +---- src/export/ExportOGG.cpp | 5 +---- src/export/ExportPCM.cpp | 5 +---- 9 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 33f9a3309..6dfa8c991 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -240,13 +240,16 @@ wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format)) } //Create a mixer by computing the time warp factor -std::unique_ptr ExportPlugin::CreateMixer(const WaveTrackConstArray &inputTracks, - const TimeTrack *timeTrack, +std::unique_ptr ExportPlugin::CreateMixer(const TrackList &tracks, + bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, bool highQuality, MixerSpec *mixerSpec) { + const WaveTrackConstArray inputTracks = + tracks.GetWaveTrackConstArray(selectionOnly, false); + const TimeTrack *timeTrack = tracks.GetTimeTrack(); // MB: the stop time should not be warped, this was a bug. return std::make_unique(inputTracks, // Throw, to stop exporting, if read fails: diff --git a/src/export/Export.h b/src/export/Export.h index 10d39757f..6f5b5e30c 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -130,8 +130,8 @@ public: int subformat = 0) = 0; protected: - std::unique_ptr CreateMixer(const WaveTrackConstArray &inputTracks, - const TimeTrack *timeTrack, + std::unique_ptr CreateMixer(const TrackList &tracks, + bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index e265653d1..d9861e5cb 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -428,11 +428,9 @@ ProgressResult ExportCL::Export(AudacityProject *project, // Mix 'em up const auto &tracks = TrackList::Get( *project ); - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); auto mixer = CreateMixer( - waveTracks, - tracks.GetTimeTrack(), + tracks, + selectionOnly, t0, t1, channels, diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 05dcc0249..95085be0f 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -896,10 +896,7 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project, size_t pcmBufferSize = 1024; - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, channels, pcmBufferSize, true, mSampleRate, int16Sample, true, mixerSpec); diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 2741295fc..bb36115a8 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -366,10 +366,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project, } } ); - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, numChannels, SAMPLES_PER_RUN, false, rate, format, true, mixerSpec); diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index 66e829f1d..57f9de00f 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -265,12 +265,9 @@ ProgressResult ExportMP2::Export(AudacityProject *project, // We have to multiply by 4 because one sample is 2 bytes wide! ArrayOf mp2Buffer{ mp2BufferSize }; - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); auto updateResult = ProgressResult::Success; { - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, stereo ? 2 : 1, pcmBufferSize, true, rate, int16Sample, true, mixerSpec); diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 68dc4f11b..7e528b1cf 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1903,11 +1903,8 @@ ProgressResult ExportMP3::Export(AudacityProject *project, ArrayOf buffer{ bufferSize }; wxASSERT(buffer); - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); { - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, channels, inSamples, true, rate, int16Sample, true, mixerSpec); diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 04b9f0876..b317150c0 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -274,11 +274,8 @@ ProgressResult ExportOGG::Export(AudacityProject *project, } } - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); { - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, numChannels, SAMPLES_PER_RUN, false, rate, floatSample, true, mixerSpec); diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index cbdaf91d0..ded2a9de3 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -532,12 +532,9 @@ ProgressResult ExportPCM::Export(AudacityProject *project, size_t maxBlockLen = 44100 * 5; - const WaveTrackConstArray waveTracks = - tracks.GetWaveTrackConstArray(selectionOnly, false); { wxASSERT(info.channels >= 0); - auto mixer = CreateMixer(waveTracks, - tracks.GetTimeTrack(), + auto mixer = CreateMixer(tracks, selectionOnly, t0, t1, info.channels, maxBlockLen, true, rate, format, true, mixerSpec);