1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Mixer::WarpOptions constructor for common case

This commit is contained in:
Paul Licameli 2020-11-30 13:41:10 -05:00
parent 9d6dd45973
commit 4871584cb3
6 changed files with 22 additions and 17 deletions

View File

@ -88,7 +88,7 @@ struct AudioIOStartStreamOptions
AudacityProject *pProject{};
MeterPanelBase *captureMeter{}, *playbackMeter{};
BoundedEnvelope *envelope; // for time warping
const BoundedEnvelope *envelope; // for time warping
std::shared_ptr< AudioIOListener > listener;
double rate;
bool playLooped;

View File

@ -143,11 +143,10 @@ void MixAndRender(TrackList *tracks, WaveTrackFactory *trackFactory,
endTime = mixEndTime;
}
auto timeTrack = *tracks->Any<TimeTrack>().begin();
Mixer mixer(waveArray,
// Throw to abort mix-and-render if read fails:
true,
Mixer::WarpOptions(timeTrack ? timeTrack->GetEnvelope() : nullptr),
Mixer::WarpOptions{*tracks},
startTime, endTime, mono ? 1 : 2, maxBlockLen, false,
rate, format);
@ -204,6 +203,17 @@ void MixAndRender(TrackList *tracks, WaveTrackFactory *trackFactory,
}
}
Mixer::WarpOptions::WarpOptions(const TrackList &list)
: minSpeed(0.0), maxSpeed(0.0)
{
auto timeTrack = *(list.Any<const TimeTrack>().begin());
envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
}
Mixer::WarpOptions::WarpOptions(const BoundedEnvelope *e)
: envelope(e), minSpeed(0.0), maxSpeed(0.0)
{}
Mixer::WarpOptions::WarpOptions(double min, double max)
: minSpeed(min), maxSpeed(max)
{

View File

@ -82,10 +82,13 @@ class AUDACITY_DLL_API Mixer {
class WarpOptions
{
public:
explicit WarpOptions(const BoundedEnvelope *e)
: envelope(e), minSpeed(0.0), maxSpeed(0.0)
{}
//! Construct with warp from the TimeTrack if there is one
explicit WarpOptions(const TrackList &list);
//! Construct with an explicit warp
explicit WarpOptions(const BoundedEnvelope *e);
//! Construct with no time warp
WarpOptions(double min, double max);
private:

View File

@ -21,7 +21,6 @@
#include "../Mix.h"
#include "../Project.h"
#include "../TimeTrack.h"
#include "../WaveTrack.h"
const ComponentInterfaceSymbol EffectStereoToMono::Symbol
@ -162,11 +161,9 @@ bool EffectStereoToMono::ProcessOne(sampleCount & curTime, sampleCount totalTime
tracks.push_back(left->SharedPointer< const WaveTrack >());
tracks.push_back(right->SharedPointer< const WaveTrack >());
auto timeTrack = *(inputTracks()->Any<const TimeTrack>().begin());
Mixer mixer(tracks,
true, // Throw to abort mix-and-render if read fails:
Mixer::WarpOptions(timeTrack ? timeTrack->GetEnvelope() : nullptr),
Mixer::WarpOptions{*inputTracks()},
start,
end,
1,

View File

@ -59,7 +59,6 @@
#include "../ProjectWindow.h"
#include "../ShuttleGui.h"
#include "../Tags.h"
#include "../TimeTrack.h"
#include "../WaveTrack.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/Warning.h"
@ -234,13 +233,11 @@ std::unique_ptr<Mixer> ExportPlugin::CreateMixer(const TrackList &tracks,
for (auto pTrack: range)
inputTracks.push_back(
pTrack->SharedPointer< const WaveTrack >() );
const auto timeTrack = *tracks.Any<const TimeTrack>().begin();
auto envelope = timeTrack ? timeTrack->GetEnvelope() : nullptr;
// 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:
true,
Mixer::WarpOptions(envelope),
Mixer::WarpOptions{tracks},
startTime, stopTime,
numOutChannels, outBufferSize, outInterleaved,
outRate, outFormat,

View File

@ -997,9 +997,7 @@ void OnScoreAlign(const CommandContext &context)
Mixer mix(
waveTracks, // const WaveTrackConstArray &inputTracks
false, // mayThrow -- is this right?
Mixer::WarpOptions{
*tracks->Any<const TimeTrack >().begin()
}, // const WarpOptions &warpOptions
Mixer::WarpOptions{ *tracks },
0.0, // double startTime
endTime, // double stopTime
2, // int numOutChannels