24 return std::make_shared<RealtimeEffectManager>(
project);
55 unsigned numPlaybackChannels,
84 mRates.insert({&group, rate});
88 scope.mInstances.push_back(state.
AddGroup(&group, chans, rate));
124 float *
const *buffers,
float *
const *scratch,
float *
const dummy,
125 unsigned nBuffers,
size_t numSamples)
134 static_cast<float **
>(alloca(nBuffers *
sizeof(
float *)));
136 static_cast<float **
>(alloca(nBuffers *
sizeof(
float *)));
140 for (
unsigned int i = 0; i < nBuffers; i++) {
141 ibuf[i] = buffers[i];
142 obuf[i] = scratch[i];
149 size_t discardable = 0;
154 state.
Process(group, nBuffers, ibuf, obuf, dummy, numSamples);
155 for (
auto i = 0; i < nBuffers; ++i)
166 for (
unsigned int i = 0; i < nBuffers; i++)
167 memcpy(buffers[i], ibuf[i], numSamples *
sizeof(
float));
187std::shared_ptr<RealtimeEffectState>
195 auto &state = *pNewState;
198 auto pInstance = state.Initialize(pScope->
mSampleRate);
204 if(pInstance2 != pInstance)
209 for (
const auto group :
mGroups) {
214 if (pInstance2 != pInstance)
243 if (!states.AddState(pState))
257 auto pOldState = states.GetStateAt(index);
265 if (!states.ReplaceState(index, pNewState))
268 pOldState->Finalize();
278 const std::shared_ptr<RealtimeEffectState> pState)
283 states.RemoveState(pState);
294 const std::shared_ptr<RealtimeEffectState> &pState)
const
297 return states.FindState(pState);
Abstract class ChannelGroup with two discrete iterable dimensions, channels and intervals; subclasses...
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...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
CallbackReturn Publish(const RealtimeEffectManagerMessage &message)
Send a message to connected callbacks.
static RealtimeEffectList & Get(AudacityProject &project)
AudacityProject & mProject
void Initialize(RealtimeEffects::InitializationScope &scope, unsigned numPlaybackChannels, double sampleRate)
Main thread begins to define a set of groups for playback.
void VisitAll(const StateVisitor &func)
Visit the per-project states first, then all groups from AddGroup.
RealtimeEffectManager(AudacityProject &project)
std::shared_ptr< RealtimeEffectState > MakeNewState(RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, const PluginID &id)
void SetSuspended(bool value)
To be called only from main thread.
static RealtimeEffectManager & Get(AudacityProject &project)
size_t Process(bool suspended, const ChannelGroup *group, float *const *buffers, float *const *scratch, float *dummy, unsigned nBuffers, size_t numSamples)
void VisitGroup(ChannelGroup *group, const StateVisitor &func)
Visit states for group or for the master when group is null.
void ProcessStart(bool suspended)
std::unordered_map< const ChannelGroup *, double > mRates
static constexpr ChannelGroup * MasterGroup
bool IsActive() const noexcept
To be called only from main thread.
void Finalize() noexcept
Main thread cleans up after playback.
void RemoveState(RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, std::shared_ptr< RealtimeEffectState > pState)
Main thread removes a global or per-group effect.
std::shared_ptr< RealtimeEffectState > ReplaceState(RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, size_t index, const PluginID &id)
Main thread replaces a global or per-group effect.
void AddGroup(RealtimeEffects::InitializationScope &scope, const ChannelGroup &group, unsigned chans, float rate)
std::optional< size_t > FindState(ChannelGroup *pGroup, const std::shared_ptr< RealtimeEffectState > &pState) const
Report the position of a state in the global or a per-group list.
std::shared_ptr< RealtimeEffectState > AddState(RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, const PluginID &id)
Main thread appends a global or per-group effect.
void ProcessEnd(bool suspended) noexcept
std::vector< const ChannelGroup * > mGroups
all are non-null
std::shared_ptr< EffectInstance > AddGroup(const ChannelGroup *group, unsigned chans, float sampleRate)
Main thread sets up this state before adding it to lists.
size_t Process(const ChannelGroup *group, unsigned chans, const float *const *inbuf, float *const *outbuf, float *dummybuf, size_t numSamples)
Worker thread processes part of a batch of samples.
bool ProcessEnd()
Worker thread finishes a batch of samples.
bool Finalize() noexcept
Main thread cleans up playback.
bool ProcessStart(bool running)
Worker thread begins a batch of samples.
std::shared_ptr< EffectInstance > Initialize(double rate)
Main thread sets up for playback.
Brackets processing setup and cleanup in the main thread.
std::vector< std::shared_ptr< EffectInstance > > mInstances
unsigned mNumPlaybackChannels
constexpr auto sampleRate
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
RealtimeEffectList & FindStates(AudacityProject &project, ChannelGroup *pGroup)
static CommandContext::TargetFactory::SubstituteInUnique< InteractiveOutputTargets > scope
static std::shared_ptr< RealtimeEffectState > make_shared(Args &&...args)