11#ifndef __AUDACITY_REALTIME_EFFECT_MANAGER__
12#define __AUDACITY_REALTIME_EFFECT_MANAGER__
19#include <unordered_map>
30 class InitializationScope;
31 class ProcessingScope;
52 using Latency = std::chrono::microseconds;
63 bool IsActive() const noexcept;
104 std::optional<
size_t> FindState(
107 bool GetSuspended()
const
108 {
return mSuspended.load(std::memory_order_relaxed); }
118 { mSuspended.store(value, std::memory_order_relaxed); }
123 std::shared_ptr<RealtimeEffectState>
133 Track &track,
unsigned chans,
float rate);
135 void Finalize() noexcept;
147 void ProcessStart(
bool suspended);
149 size_t Process(
bool suspended,
Track &track,
150 float *
const *buffers,
float *
const *scratch,
151 unsigned nBuffers,
size_t numSamples);
152 void ProcessEnd(
bool suspended)
noexcept;
163 template<
typename StateVisitor>
175 template<
typename StateVisitor>
182 for (
auto leader : mGroupLeaders)
189 std::atomic<bool> mSuspended{
true };
191 bool mActive{
false };
197 std::unordered_map<Track *, unsigned>
mChans;
198 std::unordered_map<Track *, double>
mRates;
207 std::weak_ptr<AudacityProject> wProject,
double sampleRate)
226 .
AddTrack(*
this, track, chans, rate);
249 std::weak_ptr<AudacityProject> wProject)
264 float *
const *buffers,
265 float *
const *scratch,
273 nBuffers, numSamples);
Utility ClientData::Site to register hooks into a host class that attach client data.
static TransactionScope::Factory::Scope scope
Generalized interface for discovery of plug-ins for one protocol.
static const AttachedProjectObjects::RegisteredFactory manager
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Performs effect computation.
An object that sends messages to an open-ended list of subscribed callbacks.
Publisher & operator=(Publisher &&)=default
void Visit(const StateVisitor &func)
Apply the function to all states sequentially.
static RealtimeEffectList & Get(AudacityProject &project)
AudacityProject & mProject
std::unordered_map< Track *, double > mRates
std::vector< Track * > mGroupLeaders
all are non-null
void VisitAll(const StateVisitor &func)
Visit the per-project states first, then all tracks from AddTrack.
size_t Process(bool suspended, Track &track, float *const *buffers, float *const *scratch, unsigned nBuffers, size_t numSamples)
void SetSuspended(bool value)
To be called only from main thread.
static RealtimeEffectManager & Get(AudacityProject &project)
void Initialize(RealtimeEffects::InitializationScope &scope, double sampleRate)
Main thread begins to define a set of tracks for playback.
void ProcessStart(bool suspended)
void Finalize() noexcept
Main thread cleans up after playback.
std::unordered_map< Track *, unsigned > mChans
RealtimeEffectManager & operator=(const RealtimeEffectManager &)=delete
void ProcessEnd(bool suspended) noexcept
void AddTrack(RealtimeEffects::InitializationScope &scope, Track &track, unsigned chans, float rate)
std::chrono::microseconds Latency
RealtimeEffectManager(const RealtimeEffectManager &)=delete
void VisitGroup(Track &leader, const StateVisitor &func)
Visit the per-project states first, then states for leader if not null.
Brackets processing setup and cleanup in the main thread.
void AddTrack(Track &track, unsigned chans, float rate)
InitializationScope(std::weak_ptr< AudacityProject > wProject, double sampleRate)
InitializationScope(InitializationScope &&other)=default
std::vector< std::shared_ptr< EffectInstance > > mInstances
std::weak_ptr< AudacityProject > mwProject
InitializationScope & operator=(InitializationScope &&other)=default
Brackets one block of processing in one thread.
ProcessingScope & operator=(ProcessingScope &&other)=default
std::weak_ptr< AudacityProject > mwProject
RealtimeEffectManager::AllListsLock mLocks
size_t Process(Track &track, float *const *buffers, float *const *scratch, unsigned nBuffers, size_t numSamples)
ProcessingScope(ProcessingScope &&other)=default
ProcessingScope(InitializationScope &, std::weak_ptr< AudacityProject > wProject)
Require a prior InializationScope to ensure correct nesting.
Abstract base class for an object holding data associated with points on a time axis.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
A convenient default parameter for class template Site.
Posted when effect is being added or removed to/from track or project.
std::shared_ptr< Track > track
null, if changes happened in the project scope