24 const wxString &newTrackName,
27 double startTime,
double endTime)
29 if (trackRange.
empty())
34 bool oneinput =
false;
37 auto first = *trackRange.
begin();
46 for (
auto wt : trackRange) {
47 numWaves += wt->NChannels();
48 if (
IsMono(*wt) && wt->GetPan() == 0)
52 if (numMono == numWaves)
61 double mixStartTime = 0.0;
62 bool gotstart =
false;
63 double mixEndTime = 0.0;
68 for (
auto wt : trackRange) {
69 const auto stretchingSequence =
72 tstart = wt->GetStartTime();
73 tend = wt->GetEndTime();
74 if (tend > mixEndTime)
85 mixStartTime = tstart;
87 }
else if (tstart < mixStartTime)
88 mixStartTime = tstart;
93 if (numWaves == first->NChannels())
97 auto mix = trackFactory->
Create(mono ? 1 : 2, *first);
101 mix->ConvertToSampleFormat(
format);
103 mix->SetName(newTrackName);
104 mix->MoveTo(mixStartTime);
106 auto maxBlockLen = mix->GetIdealBlockSize();
110 if (startTime == endTime) {
111 startTime = mixStartTime;
112 endTime = mixEndTime;
116 std::move(waveArray), std::nullopt,
118 true, warpOptions, startTime, endTime, mono ? 1 : 2, maxBlockLen,
false,
126 XO(
"Mixing and rendering tracks"));
129 auto blockLen = mixer.
Process();
134 for(
auto channel : mix->Channels())
136 auto buffer = mixer.
GetBuffer(channel->GetChannelIndex());
137 channel->AppendBuffer(buffer,
format, blockLen, 1, effectiveFormat);
140 updateResult = pProgress->Poll(
150 int elapsedMS = wxGetElapsedTime();
151 double elapsedTime = elapsedMS * 0.001;
152 double maxTracks = totalTime / (elapsedTime / numWaves);
156 wxPrintf(
" Tracks: %d\n", numWaves);
157 wxPrintf(
" Mix length: %f sec\n", totalTime);
158 wxPrintf(
"Elapsed time: %f sec\n", elapsedTime);
159 wxPrintf(
"Max number of tracks to mix in real time: %f\n", maxTracks);
170template<
typename Host>
171std::vector<MixerOptions::StageSpecification>
175 if (!effects.IsActive())
177 std::vector<MixerOptions::StageSpecification> result;
178 for (
size_t i = 0, count = effects.GetStatesCount(); i < count; ++i) {
179 const auto pState = effects.GetStateAt(i);
180 if (!pState->IsEnabled())
182 const auto pEffect = pState->GetEffect();
185 const auto &
settings = pState->GetSettings();
189 [pEffect]{
return pEffect->MakeInstance(); },
195std::vector<MixerOptions::StageSpecification>
201std::vector<MixerOptions::StageSpecification>
235[](
const WaveTrack &track,
auto &xmlFile) {
Toolkit-neutral facade for basic user interface services.
static ProjectFileIORegistry::ObjectReaderEntry projectAccessor
static ProjectFileIORegistry::ObjectWriterEntry projectWriter
std::vector< MixerOptions::StageSpecification > GetMasterEffectStages(const AudacityProject &project)
static WaveTrackIORegistry::ObjectWriterEntry waveTrackWriter
Track::Holder 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, per-track real-time effects,...
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
static WaveTrackIORegistry::ObjectReaderEntry waveTrackAccessor
std::vector< MixerOptions::StageSpecification > GetEffectStages(const WaveTrack &track)
std::vector< MixerOptions::StageSpecification > GetEffectStagesImpl(const Host &host)
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)
std::shared_ptr< Track > Holder
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.
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.