Skip to content

Commit

Permalink
Merge remote-tracking branch 'audacity/release-3.4.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Oct 19, 2023
2 parents f0a1e4c + 3e470ab commit 0f6767c
Show file tree
Hide file tree
Showing 63 changed files with 609,007 additions and 588,886 deletions.
29 changes: 25 additions & 4 deletions libraries/lib-effects/PerTrackEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,27 @@ bool PerTrackEffect::Process(
EffectInstance &instance, EffectSettings &settings) const
{
auto pThis = const_cast<PerTrackEffect *>(this);
EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };

// Destroy any pre-formed output tracks when done
auto pOutputs = mpOutputTracks.get();

std::optional<EffectOutputTracks> outputs;
if (!pOutputs)
pOutputs = &outputs.emplace(*mTracks, GetType(),
EffectOutputTracks::TimeInterval{ mT0, mT1 }, true);

bool bGoodResult = true;
// mPass = 1;
if (DoPass1()) {
auto &myInstance = dynamic_cast<Instance&>(instance);
bGoodResult = pThis->ProcessPass(outputs.Get(), myInstance, settings);
bGoodResult = pThis->ProcessPass(pOutputs->Get(), myInstance, settings);
// mPass = 2;
if (bGoodResult && DoPass2())
bGoodResult = pThis->ProcessPass(outputs.Get(), myInstance, settings);
bGoodResult = pThis->ProcessPass(pOutputs->Get(), myInstance, settings);
}
if (bGoodResult)
outputs.Commit();
pOutputs->Commit();
DestroyOutputTracks();
return bGoodResult;
}

Expand Down Expand Up @@ -359,3 +368,15 @@ bool PerTrackEffect::ProcessTrack(int channel, const Factory &factory,
AudioGraph::Task task{ *pSource, outBuffers, sink };
return task.RunLoop();
}

std::shared_ptr<EffectOutputTracks> PerTrackEffect::MakeOutputTracks()
{
return mpOutputTracks =
std::make_shared<EffectOutputTracks>(*mTracks, GetType(),
EffectOutputTracks::TimeInterval{ mT0, mT1 }, true);
}

void PerTrackEffect::DestroyOutputTracks() const
{
mpOutputTracks.reset();
}
11 changes: 11 additions & 0 deletions libraries/lib-effects/PerTrackEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "MemoryX.h"
#include "SampleCount.h"
#include <functional>
#include <memory>

class EffectOutputTracks;
class SampleTrack;

//! Base class for Effects that treat each (mono or stereo) track independently
Expand Down Expand Up @@ -66,6 +68,12 @@ class EFFECTS_API PerTrackEffect

sampleCount mSampleCnt{};

// Pre-compute the output track list
std::shared_ptr<EffectOutputTracks> MakeOutputTracks();

// Clean up unnecessary output track list
void DestroyOutputTracks() const;

private:
using Buffers = AudioGraph::Buffers;

Expand All @@ -89,5 +97,8 @@ class EFFECTS_API PerTrackEffect
std::optional<sampleCount> genLength,
double sampleRate, const SampleTrack &leader,
Buffers &inBuffers, Buffers &outBuffers);

// TODO: put this in struct EffectContext? (Which doesn't exist yet)
mutable std::shared_ptr<EffectOutputTracks> mpOutputTracks;
};
#endif
Loading

0 comments on commit 0f6767c

Please sign in to comment.