Audacity 3.2.0
ExportPluginHelpers.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ExportPluginHelpers.cpp
6
7 Dominic Mazzoni
8
9 Vitaly Sverchinsky split from ExportPlugin.h
10
11**********************************************************************/
12
13#include "ExportPluginHelpers.h"
14#include "Track.h"
15#include "Mix.h"
16#include "WaveTrack.h"
17#include "MixAndRender.h"
18#include "ExportUtils.h"
19#include "ExportPlugin.h"
20#include "StretchingSequence.h"
21
22//Create a mixer by computing the time warp factor
24 bool selectionOnly,
25 double startTime, double stopTime,
26 unsigned numOutChannels, size_t outBufferSize, bool outInterleaved,
27 double outRate, sampleFormat outFormat,
28 MixerOptions::Downmix *mixerSpec)
29{
30 Mixer::Inputs inputs;
31
32 for (auto pTrack: ExportUtils::FindExportWaveTracks(tracks, selectionOnly))
33 inputs.emplace_back(
34 StretchingSequence::Create(*pTrack, pTrack->GetClipInterfaces()),
35 GetEffectStages(*pTrack));
36 // MB: the stop time should not be warped, this was a bug.
37 return std::make_unique<Mixer>(move(inputs),
38 // Throw, to stop exporting, if read fails:
39 true,
40 Mixer::WarpOptions{ tracks.GetOwner() },
41 startTime, stopTime,
42 numOutChannels, outBufferSize, outInterleaved,
43 outRate, outFormat,
44 true, mixerSpec,
46}
47
48namespace
49{
50 double EvalExportProgress(Mixer &mixer, double t0, double t1)
51 {
52 const auto duration = t1 - t0;
53 if(duration > 0)
54 return std::clamp(mixer.MixGetCurrentTime() - t0, .0, duration) / duration;
55 return .0;
56 }
57}
58
60{
61 delegate.OnProgress(EvalExportProgress(mixer, t0, t1));
62 if(delegate.IsStopped())
64 if(delegate.IsCancelled())
67}
68
ExportResult
Definition: ExportTypes.h:24
std::vector< MixerOptions::StageSpecification > GetEffectStages(const WaveTrack &track)
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
const auto tracks
declares abstract base class Track, TrackList, and iterators over TrackList
static ExportResult UpdateProgress(ExportProcessorDelegate &delegate, Mixer &mixer, double t0, double t1)
Sends progress update to delegate and retrieves state update from it. Typically used inside each expo...
static 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, MixerOptions::Downmix *mixerSpec)
virtual bool IsCancelled() const =0
virtual void OnProgress(double progress)=0
virtual bool IsStopped() const =0
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:22
Functions for doing the mixdown of the tracks.
Definition: Mix.h:27
std::vector< Input > Inputs
Definition: Mix.h:45
double MixGetCurrentTime()
Current time in seconds (unwarped, i.e. always between startTime and stopTime)
Definition: Mix.cpp:393
A matrix of booleans, one row per input channel, column per output.
Definition: MixerOptions.h:32
static std::shared_ptr< StretchingSequence > Create(const PlayableSequence &, const ClipConstHolders &clips)
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
double EvalExportProgress(Mixer &mixer, double t0, double t1)
Immutable structure is an argument to Mixer's constructor.
Definition: MixerOptions.h:56