![]() |
Audacity 3.2.0
|
#include <RealtimeEffectManager.h>
Classes | |
struct | AllListsLock |
Public Types | |
using | Latency = std::chrono::microseconds |
![]() | |
using | message_type = RealtimeEffectManagerMessage |
using | CallbackReturn = std::conditional_t< true, void, bool > |
using | Callback = std::function< CallbackReturn(const RealtimeEffectManagerMessage &) > |
Type of functions that can be connected to the Publisher. More... | |
Public Member Functions | |
RealtimeEffectManager (AudacityProject &project) | |
~RealtimeEffectManager () | |
bool | IsActive () const noexcept |
To be called only from main thread. More... | |
std::shared_ptr< RealtimeEffectState > | AddState (RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, const PluginID &id) |
Main thread appends a global or per-group effect. More... | |
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. More... | |
void | RemoveState (RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, std::shared_ptr< RealtimeEffectState > pState) |
Main thread removes a global or per-group effect. More... | |
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. More... | |
bool | GetSuspended () const |
void | SetSuspended (bool value) |
To be called only from main thread. More... | |
![]() | |
virtual | ~Base () |
![]() | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Member Functions | |
static RealtimeEffectManager & | Get (AudacityProject &project) |
static const RealtimeEffectManager & | Get (const AudacityProject &project) |
Private Member Functions | |
std::shared_ptr< RealtimeEffectState > | MakeNewState (RealtimeEffects::InitializationScope *pScope, ChannelGroup *pGroup, const PluginID &id) |
void | Initialize (RealtimeEffects::InitializationScope &scope, double sampleRate) |
Main thread begins to define a set of groups for playback. More... | |
void | AddGroup (RealtimeEffects::InitializationScope &scope, const ChannelGroup &group, unsigned chans, float rate) |
void | Finalize () noexcept |
Main thread cleans up after playback. More... | |
void | ProcessStart (bool suspended) |
size_t | Process (bool suspended, const ChannelGroup &group, float *const *buffers, float *const *scratch, float *dummy, unsigned nBuffers, size_t numSamples) |
void | ProcessEnd (bool suspended) noexcept |
RealtimeEffectManager (const RealtimeEffectManager &)=delete | |
RealtimeEffectManager & | operator= (const RealtimeEffectManager &)=delete |
template<typename StateVisitor > | |
void | VisitGroup (ChannelGroup &group, const StateVisitor &func) |
Visit the per-project states first, then states for leader if not null. More... | |
template<typename StateVisitor > | |
void | VisitGroup (const ChannelGroup &group, const StateVisitor &func) |
template<typename StateVisitor > | |
void | VisitAll (const StateVisitor &func) |
Visit the per-project states first, then all groups from AddGroup. More... | |
Private Attributes | |
AudacityProject & | mProject |
Latency | mLatency { 0 } |
std::atomic< bool > | mSuspended { true } |
bool | mActive { false } |
std::vector< const ChannelGroup * > | mGroups |
all are non-null More... | |
std::unordered_map< const ChannelGroup *, double > | mRates |
Additional Inherited Members | |
![]() | |
static constexpr bool | notifies_all |
![]() | |
CallbackReturn | Publish (const RealtimeEffectManagerMessage &message) |
Send a message to connected callbacks. More... | |
Definition at line 48 of file RealtimeEffectManager.h.
using RealtimeEffectManager::Latency = std::chrono::microseconds |
Definition at line 53 of file RealtimeEffectManager.h.
RealtimeEffectManager::RealtimeEffectManager | ( | AudacityProject & | project | ) |
Definition at line 39 of file RealtimeEffectManager.cpp.
RealtimeEffectManager::~RealtimeEffectManager | ( | ) |
Definition at line 44 of file RealtimeEffectManager.cpp.
|
privatedelete |
|
private |
Main thread adds one group (passing the first of one or more channels), still before playback
group.IsLeader()
Definition at line 73 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::AddGroup(), ChannelGroup::IsLeader(), mGroups, mRates, anonymous_namespace{wxCommandTargets.cpp}::scope, and VisitGroup().
Referenced by RealtimeEffects::InitializationScope::AddGroup().
std::shared_ptr< RealtimeEffectState > RealtimeEffectManager::AddState | ( | RealtimeEffects::InitializationScope * | pScope, |
ChannelGroup * | pGroup, | ||
const PluginID & | id | ||
) |
Main thread appends a global or per-group effect.
pScope | if realtime is active but scope is absent, there is no effect |
pGroup | if null, then state is added to the global list |
id | identifies the effect |
!pGroup || pGroup->IsLeader()
!result || result->GetEffect() != nullptr
Definition at line 275 of file RealtimeEffectManager.cpp.
References RealtimeEffectManagerMessage::EffectAdded, anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), ChannelGroup::IsLeader(), MakeNewState(), mProject, and Observer::Publisher< RealtimeEffectManagerMessage >::Publish().
Referenced by AudioIO::AddState().
|
privatenoexcept |
Main thread cleans up after playback.
Definition at line 88 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::Finalize(), mActive, mGroups, mLatency, mRates, SetSuspended(), and VisitAll().
Referenced by RealtimeEffects::InitializationScope::~InitializationScope().
std::optional< size_t > RealtimeEffectManager::FindState | ( | ChannelGroup * | pGroup, |
const std::shared_ptr< RealtimeEffectState > & | pState | ||
) | const |
Report the position of a state in the global or a per-group list.
Definition at line 336 of file RealtimeEffectManager.cpp.
References anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), and mProject.
|
static |
Definition at line 28 of file RealtimeEffectManager.cpp.
References manager, and project.
Referenced by RealtimeEffects::InitializationScope::AddGroup(), AudioIO::AddState(), Get(), RealtimeEffects::InitializationScope::InitializationScope(), anonymous_namespace{PluginMenus.cpp}::IsRealtimeNotActiveFlag(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnChangeButtonClicked(), RealtimeEffects::ProcessingScope::Process(), RealtimeEffects::ProcessingScope::ProcessingScope(), AudioIO::RemoveState(), AudioIO::ReplaceState(), AudioIO::SetPaused(), TrackPanel::TrackPanel(), RealtimeEffects::InitializationScope::~InitializationScope(), and RealtimeEffects::ProcessingScope::~ProcessingScope().
|
static |
Definition at line 34 of file RealtimeEffectManager.cpp.
References Get(), and project.
|
inline |
Definition at line 113 of file RealtimeEffectManager.h.
|
private |
Main thread begins to define a set of groups for playback.
Definition at line 53 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::Initialize(), mActive, mGroups, mRates, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, anonymous_namespace{wxCommandTargets.cpp}::scope, SetSuspended(), and VisitAll().
Referenced by RealtimeEffects::InitializationScope::InitializationScope().
|
noexcept |
To be called only from main thread.
Definition at line 48 of file RealtimeEffectManager.cpp.
References mActive.
Referenced by anonymous_namespace{PluginMenus.cpp}::IsRealtimeNotActiveFlag().
|
private |
!pGroup || pGroup->IsLeader()
Definition at line 238 of file RealtimeEffectManager.cpp.
References ChannelGroup::IsLeader(), mActive, SharedNonInterfering< RealtimeEffectState >::make_shared(), mGroups, RealtimeEffects::InitializationScope::mInstances, RealtimeEffects::InitializationScope::mNumPlaybackChannels, mRates, and RealtimeEffects::InitializationScope::mSampleRate.
Referenced by AddState(), and ReplaceState().
|
privatedelete |
|
private |
Definition at line 122 of file RealtimeEffectManager.cpp.
References PackedArray::end(), mLatency, RealtimeEffectState::Process(), anonymous_namespace{NoteTrack.cpp}::swap(), and VisitGroup().
Referenced by RealtimeEffects::ProcessingScope::Process().
|
privatenoexcept |
Definition at line 186 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::ProcessEnd().
Referenced by RealtimeEffects::ProcessingScope::~ProcessingScope().
|
private |
Definition at line 109 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::ProcessStart(), and VisitAll().
Referenced by RealtimeEffects::ProcessingScope::ProcessingScope().
void RealtimeEffectManager::RemoveState | ( | RealtimeEffects::InitializationScope * | pScope, |
ChannelGroup * | pGroup, | ||
std::shared_ptr< RealtimeEffectState > | pState | ||
) |
Main thread removes a global or per-group effect.
pScope | if realtime is active but scope is absent, there is no effect |
pGroup | if null, then state is added to the global list |
state | the state to be removed |
No effect if realtime is active but scope is not supplied
Definition at line 319 of file RealtimeEffectManager.cpp.
References RealtimeEffectManagerMessage::EffectRemoved, anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), mActive, mProject, and Observer::Publisher< RealtimeEffectManagerMessage >::Publish().
Referenced by AudioIO::RemoveState().
std::shared_ptr< RealtimeEffectState > RealtimeEffectManager::ReplaceState | ( | RealtimeEffects::InitializationScope * | pScope, |
ChannelGroup * | pGroup, | ||
size_t | index, | ||
const PluginID & | id | ||
) |
Main thread replaces a global or per-group effect.
pScope | if realtime is active but scope is absent, there is no effect |
pGroup | if null, then state is added to the global list |
index | position in the list to replace; no effect if out of range |
id | identifies the effect |
!result || result->GetEffect() != nullptr
Definition at line 295 of file RealtimeEffectManager.cpp.
References RealtimeEffectManagerMessage::EffectReplaced, anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), ChannelGroup::IsLeader(), mActive, MakeNewState(), mProject, and Observer::Publisher< RealtimeEffectManagerMessage >::Publish().
Referenced by AudioIO::ReplaceState().
|
inline |
To be called only from main thread.
Each time a processing scope starts in the audio thread, suspension state is tested, and plug-in instances may need to do things in response to the transitions. Playback of samples may continue but with effects switched off in suspended state.
Definition at line 123 of file RealtimeEffectManager.h.
Referenced by Finalize(), and Initialize().
|
inlineprivate |
Visit the per-project states first, then all groups from AddGroup.
Groups are visited in unspecified order
Definition at line 201 of file RealtimeEffectManager.h.
References RealtimeEffectList::Get(), and RealtimeEffectList::Visit().
Referenced by Finalize(), Initialize(), and ProcessStart().
|
inlineprivate |
Visit the per-project states first, then states for leader if not null.
Definition at line 178 of file RealtimeEffectManager.h.
References RealtimeEffectList::Get(), and RealtimeEffectList::Visit().
Referenced by AddGroup(), and Process().
|
inlineprivate |
Definition at line 188 of file RealtimeEffectManager.h.
References RealtimeEffectList::Get(), and RealtimeEffectList::Visit().
|
private |
Definition at line 216 of file RealtimeEffectManager.h.
Referenced by Finalize(), Initialize(), IsActive(), MakeNewState(), RemoveState(), and ReplaceState().
|
private |
all are non-null
Definition at line 220 of file RealtimeEffectManager.h.
Referenced by AddGroup(), RealtimeEffectManager::AllListsLock::AllListsLock(), Finalize(), Initialize(), and MakeNewState().
|
private |
Definition at line 212 of file RealtimeEffectManager.h.
Referenced by Finalize(), and Process().
|
private |
Definition at line 211 of file RealtimeEffectManager.h.
Referenced by AddState(), RealtimeEffectManager::AllListsLock::AllListsLock(), FindState(), RemoveState(), and ReplaceState().
|
private |
Definition at line 222 of file RealtimeEffectManager.h.
Referenced by AddGroup(), Finalize(), Initialize(), and MakeNewState().
|
private |
Definition at line 214 of file RealtimeEffectManager.h.