24 const wxString &newTrackName,
27 double startTime,
double endTime)
29 if (trackRange.
empty())
34 bool oneinput =
false;
37 auto first = *trackRange.
begin();
39 assert(first->IsLeader());
47 for (
auto wt : trackRange) {
48 numWaves += wt->NChannels();
49 if (
IsMono(*wt) && wt->GetPan() == 0)
53 if (numMono == numWaves)
62 double mixStartTime = 0.0;
63 bool gotstart =
false;
64 double mixEndTime = 0.0;
69 for (
auto wt : trackRange) {
70 const auto stretchingSequence =
73 tstart = wt->GetStartTime();
74 tend = wt->GetEndTime();
75 if (tend > mixEndTime)
86 mixStartTime = tstart;
88 }
else if (tstart < mixStartTime)
89 mixStartTime = tstart;
98 auto result = trackFactory->
Create(mono ? 1 : 2, *first);
99 auto mix =
static_cast<WaveTrack*
>(*result->begin());
103 mix->ConvertToSampleFormat(
format);
105 mix->SetName(newTrackName);
106 mix->MoveTo(mixStartTime);
108 auto maxBlockLen = mix->GetIdealBlockSize();
112 if (startTime == endTime) {
113 startTime = mixStartTime;
114 endTime = mixEndTime;
117 Mixer mixer(move(waveArray),
120 startTime, endTime, mono ? 1 : 2, maxBlockLen,
false,
128 XO(
"Mixing and rendering tracks"));
131 auto blockLen = mixer.
Process();
136 for(
auto channel : mix->Channels())
138 auto buffer = mixer.
GetBuffer(channel->ReallyGetChannelIndex());
139 channel->AppendBuffer(buffer,
format, blockLen, 1, effectiveFormat);
142 updateResult = pProgress->Poll(
148 updateResult == ProgressResult::Failed)
152 int elapsedMS = wxGetElapsedTime();
153 double elapsedTime = elapsedMS * 0.001;
154 double maxTracks = totalTime / (elapsedTime / numWaves);
158 wxPrintf(
" Tracks: %d\n", numWaves);
159 wxPrintf(
" Mix length: %f sec\n", totalTime);
160 wxPrintf(
"Elapsed time: %f sec\n", elapsedTime);
161 wxPrintf(
"Max number of tracks to mix in real time: %f\n", maxTracks);
172std::vector<MixerOptions::StageSpecification>
176 if (!effects.IsActive())
178 std::vector<MixerOptions::StageSpecification> result;
179 for (
size_t i = 0, count = effects.GetStatesCount(); i < count; ++i) {
180 const auto pState = effects.GetStateAt(i);
181 if (!pState->IsEnabled())
183 const auto pEffect = pState->GetEffect();
186 const auto &
settings = pState->GetSettings();
190 [pEffect]{
return pEffect->MakeInstance(); },
224[](
const WaveTrack &track,
auto &xmlFile) {
Toolkit-neutral facade for basic user interface services.
static ProjectFileIORegistry::ObjectReaderEntry projectAccessor
static ProjectFileIORegistry::ObjectWriterEntry projectWriter
static WaveTrackIORegistry::ObjectWriterEntry waveTrackWriter
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
TrackListHolder MixAndRender(const TrackIterRange< const WaveTrack > &trackRange, const Mixer::WarpOptions &warpOptions, const wxString &newTrackName, WaveTrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime)
Mixes together all input tracks, applying any envelopes, amplitude gain, panning, and real-time effec...
static WaveTrackIORegistry::ObjectReaderEntry waveTrackAccessor
std::vector< MixerOptions::StageSpecification > GetEffectStages(const WaveTrack &track)
std::shared_ptr< TrackList > TrackListHolder
static Settings & settings()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Functions for doing the mixdown of the tracks.
size_t Process(size_t maxSamples)
std::vector< Input > Inputs
sampleFormat EffectiveFormat() const
Deduce the effective width of the output, which may be narrower than the stored format.
constSamplePtr GetBuffer()
Retrieve the main buffer or the interleaved buffer.
double MixGetCurrentTime()
Current time in seconds (unwarped, i.e. always between startTime and stopTime)
static RealtimeEffectList & Get(AudacityProject &project)
void Clear()
Use only in the main thread. Sends Remove messages.
static const std::string & XMLTag()
void WriteXML(XMLWriter &xmlFile) const
Use only in the main thread, to avoid races.
static std::shared_ptr< StretchingSequence > Create(const PlayableSequence &, const ClipConstHolders &clips)
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
A Track that contains audio waveform data.
bool IsLeader() const override
void SetPan(float newPan)
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
bool IsMono(const Channel &channel)
Whether the channel is mono.
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Immutable structure is an argument to Mixer's constructor.
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Typically statically constructed.