23 const wxString &newTrackName,
26 double startTime,
double endTime,
29 uLeft.reset(), uRight.reset();
30 if (trackRange.
empty())
35 bool oneinput =
false;
38 auto first = *trackRange.
begin();
47 for(
auto wt : trackRange) {
49 float pan = wt->GetPan();
54 if (numMono == numWaves)
63 double mixStartTime = 0.0;
64 bool gotstart =
false;
65 double mixEndTime = 0.0;
70 for(
auto wt : trackRange) {
71 waveArray.emplace_back(
73 tstart = wt->GetStartTime();
74 tend = wt->GetEndTime();
75 if (tend > mixEndTime)
86 mixStartTime = tstart;
88 }
else if (tstart < mixStartTime)
89 mixStartTime = tstart;
105 mixLeft->SetRate(rate);
106 mixLeft->ConvertToSampleFormat(
format);
108 mixLeft->SetName(first->GetName());
111 mixLeft->SetName(newTrackName);
112 mixLeft->SetOffset(mixStartTime);
115 decltype(mixLeft) mixRight{};
120 if (channels.size() > 1)
121 mixRight->SetName((*channels.begin().advance(1))->GetName());
123 mixRight->SetName(first->GetName());
126 mixRight->SetName(newTrackName);
127 mixRight->SetOffset(mixStartTime);
131 auto maxBlockLen = mixLeft->GetIdealBlockSize();
135 if (startTime == endTime) {
136 startTime = mixStartTime;
137 endTime = mixEndTime;
140 Mixer mixer(move(waveArray),
143 startTime, endTime, mono ? 1 : 2, maxBlockLen,
false,
151 XO(
"Mixing and rendering tracks"));
154 auto blockLen = mixer.
Process();
161 mixLeft->Append(buffer,
format, blockLen, 1, effectiveFormat);
165 mixLeft->Append(buffer,
format, blockLen, 1, effectiveFormat);
167 mixRight->Append(buffer,
format, blockLen, 1, effectiveFormat);
170 updateResult = pProgress->Poll(
183 uLeft = mixLeft, uRight = mixRight;
185 int elapsedMS = wxGetElapsedTime();
186 double elapsedTime = elapsedMS * 0.001;
187 double maxTracks = totalTime / (elapsedTime / numWaves);
191 wxPrintf(
" Tracks: %d\n", numWaves);
192 wxPrintf(
" Mix length: %f sec\n", totalTime);
193 wxPrintf(
"Elapsed time: %f sec\n", elapsedTime);
194 wxPrintf(
"Max number of tracks to mix in real time: %f\n", maxTracks);
197 for (
auto pTrack : { uLeft.get(), uRight.get() })
206std::vector<MixerOptions::StageSpecification>
210 if (!effects.IsActive())
212 std::vector<MixerOptions::StageSpecification> result;
213 for (
size_t i = 0, count = effects.GetStatesCount(); i < count; ++i) {
214 const auto pState = effects.GetStateAt(i);
215 if (!pState->IsEnabled())
217 const auto pEffect = pState->GetEffect();
220 const auto &
settings = pState->GetSettings();
224 [pEffect]{
return pEffect->MakeInstance(); },
258[](
const WaveTrack &track,
auto &xmlFile) {
Toolkit-neutral facade for basic user interface services.
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
static ProjectFileIORegistry::ObjectReaderEntry projectAccessor
static ProjectFileIORegistry::ObjectWriterEntry projectWriter
void MixAndRender(const TrackIterRange< const WaveTrack > &trackRange, const Mixer::WarpOptions &warpOptions, const wxString &newTrackName, WaveTrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime, WaveTrack::Holder &uLeft, WaveTrack::Holder &uRight)
Mixes together all input tracks, applying any envelopes, amplitude gain, panning, and real-time effec...
static WaveTrackIORegistry::ObjectWriterEntry waveTrackWriter
static WaveTrackIORegistry::ObjectReaderEntry waveTrackAccessor
std::vector< MixerOptions::StageSpecification > GetEffectStages(const WaveTrack &track)
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 auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
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.
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
A Track that contains audio waveform data.
std::shared_ptr< WaveTrack > Holder
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
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.