1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-24 23:33:50 +02:00

Avoid repetition in computing arguments for export mixers

This commit is contained in:
Paul Licameli
2019-05-24 10:11:52 -04:00
parent 0563372216
commit 1dce507aaf
9 changed files with 15 additions and 32 deletions

View File

@@ -240,13 +240,16 @@ wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format))
}
//Create a mixer by computing the time warp factor
std::unique_ptr<Mixer> ExportPlugin::CreateMixer(const WaveTrackConstArray &inputTracks,
const TimeTrack *timeTrack,
std::unique_ptr<Mixer> 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<Mixer>(inputTracks,
// Throw, to stop exporting, if read fails:

View File

@@ -130,8 +130,8 @@ public:
int subformat = 0) = 0;
protected:
std::unique_ptr<Mixer> CreateMixer(const WaveTrackConstArray &inputTracks,
const TimeTrack *timeTrack,
std::unique_ptr<Mixer> CreateMixer(const TrackList &tracks,
bool selectionOnly,
double startTime, double stopTime,
unsigned numOutChannels, size_t outBufferSize, bool outInterleaved,
double outRate, sampleFormat outFormat,

View File

@@ -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,

View File

@@ -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);

View File

@@ -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);

View File

@@ -265,12 +265,9 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
// We have to multiply by 4 because one sample is 2 bytes wide!
ArrayOf<unsigned char> 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);

View File

@@ -1903,11 +1903,8 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
ArrayOf<unsigned char> 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);

View File

@@ -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);

View File

@@ -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);