Audacity 3.2.0
|
#include <RealtimeEffectManager.h>
Classes | |
struct | AllListsLock |
Public Types | |
using | Latency = std::chrono::microseconds |
Public Types inherited from Observer::Publisher< RealtimeEffectManagerMessage > | |
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... | |
Public Member Functions inherited from ClientData::Base | |
virtual | ~Base () |
Public Member Functions inherited from Observer::Publisher< RealtimeEffectManagerMessage > | |
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 group. 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 Public Attributes inherited from Observer::Publisher< RealtimeEffectManagerMessage > | |
static constexpr bool | notifies_all |
Protected Member Functions inherited from Observer::Publisher< RealtimeEffectManagerMessage > | |
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
Definition at line 73 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::AddGroup(), 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 |
!result || result->GetEffect() != nullptr
Definition at line 273 of file RealtimeEffectManager.cpp.
References RealtimeEffectManagerMessage::EffectAdded, anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), MakeNewState(), mProject, and Observer::Publisher< RealtimeEffectManagerMessage >::Publish().
Referenced by AudioIO::AddState().
|
privatenoexcept |
Main thread cleans up after playback.
Definition at line 87 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 332 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 112 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 |
Definition at line 237 of file RealtimeEffectManager.cpp.
References 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 121 of file RealtimeEffectManager.cpp.
References details::end(), mLatency, RealtimeEffectState::Process(), anonymous_namespace{NoteTrack.cpp}::swap(), and VisitGroup().
Referenced by RealtimeEffects::ProcessingScope::Process().
|
privatenoexcept |
Definition at line 185 of file RealtimeEffectManager.cpp.
References RealtimeEffectState::ProcessEnd().
Referenced by RealtimeEffects::ProcessingScope::~ProcessingScope().
|
private |
Definition at line 108 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 315 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 292 of file RealtimeEffectManager.cpp.
References RealtimeEffectManagerMessage::EffectReplaced, anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), 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 122 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 194 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 group.
Definition at line 171 of file RealtimeEffectManager.h.
References RealtimeEffectList::Get(), and RealtimeEffectList::Visit().
Referenced by AddGroup(), and Process().
|
inlineprivate |
Definition at line 181 of file RealtimeEffectManager.h.
References RealtimeEffectList::Get(), and RealtimeEffectList::Visit().
|
private |
Definition at line 209 of file RealtimeEffectManager.h.
Referenced by Finalize(), Initialize(), IsActive(), MakeNewState(), RemoveState(), and ReplaceState().
|
private |
all are non-null
Definition at line 213 of file RealtimeEffectManager.h.
Referenced by AddGroup(), RealtimeEffectManager::AllListsLock::AllListsLock(), Finalize(), Initialize(), and MakeNewState().
|
private |
Definition at line 205 of file RealtimeEffectManager.h.
Referenced by Finalize(), and Process().
|
private |
Definition at line 204 of file RealtimeEffectManager.h.
Referenced by AddState(), RealtimeEffectManager::AllListsLock::AllListsLock(), FindState(), RemoveState(), and ReplaceState().
|
private |
Definition at line 215 of file RealtimeEffectManager.h.
Referenced by AddGroup(), Finalize(), Initialize(), and MakeNewState().
|
private |
Definition at line 207 of file RealtimeEffectManager.h.