26 auto result = std::make_unique<RealtimeEffectList>();
28 result->mStates.push_back(pState);
38 return std::make_shared<RealtimeEffectList>();
66 return std::make_unique<RealtimeEffectList>();
85 const auto &
id = pState->GetID();
86 if (pState->GetEffect() !=
nullptr) {
88 shallowCopy.emplace_back(pState);
108 std::shared_ptr<RealtimeEffectState> pState)
112 const auto &
id = pState->GetID();
113 if (pState->GetEffect() !=
nullptr) {
123 swap(pState, shallowCopy[index]);
142 const std::shared_ptr<RealtimeEffectState> pState)
145 auto end = shallowCopy.end(),
146 found = std::find(shallowCopy.begin(),
end, pState);
149 const auto index = std::distance(shallowCopy.begin(), found);
150 shallowCopy.erase(found);
157 static_cast<size_t>(index),
172 for (
auto index = temp.size(); index--;)
178 const std::shared_ptr<RealtimeEffectState> &pState)
const
182 , iter = std::find(
begin,
end, pState);
185 return std::distance(
begin, iter);
193std::shared_ptr<RealtimeEffectState>
196 if (index < mStates.size())
197 return mStates[index];
201std::shared_ptr<const RealtimeEffectState>
209 assert(fromIndex <
mStates.size());
210 assert(toIndex <
mStates.size());
213 if(fromIndex == toIndex)
215 if(fromIndex < toIndex)
217 const auto first = shallowCopy.begin() + fromIndex;
218 const auto last = shallowCopy.begin() + toIndex + 1;
224 shallowCopy.rbegin() + (shallowCopy.size() - (fromIndex + 1));
225 const auto last = shallowCopy.rbegin() + (shallowCopy.size() - toIndex);
241 static const std::string result{
"effects"};
251 for (
auto &[attr, value] : attrs) {
273 for (
const auto & state :
mStates)
274 state->WriteXML(xmlFile);
281 Set(
project, shared_from_this());
286 return mActive.load(std::memory_order_relaxed);
Abstract class ChannelGroup with two discrete iterable dimensions, channels and intervals; subclasses...
static const ChannelGroup::Attachments::RegisteredFactory channelGroupEffects
static UndoRedoExtensionRegistry::Entry sEntry
static constexpr auto activeAttribute
static const AttachedProjectObjects::RegisteredFactory masterEffects
std::vector< Attribute > AttributesList
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 RealtimeEffectListMessage &message)
Send a message to connected callbacks.
static RealtimeEffectList & Get(AudacityProject &project)
std::optional< size_t > FindState(const std::shared_ptr< RealtimeEffectState > &pState) const
Report the position of a state in the list.
std::lock_guard< Lock > LockGuard
bool AddState(std::shared_ptr< RealtimeEffectState > pState)
void RestoreUndoRedoState(AudacityProject &project) noexcept override
Modify the project when undoing or redoing to some state in history.
std::unique_ptr< ClientData::Cloneable<> > Clone() const override
virtual ~RealtimeEffectList()
size_t GetStatesCount() const noexcept
bool IsActive() const
Non-blocking atomic boolean load.
void RemoveState(std::shared_ptr< RealtimeEffectState > pState)
void Clear()
Use only in the main thread. Sends Remove messages.
std::atomic< bool > mActive
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
void SetActive(bool value)
Done by main thread only, under a lock guard.
static RealtimeEffectList & Set(AudacityProject &project, const std::shared_ptr< RealtimeEffectList > &list)
static const std::string & XMLTag()
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
Use only in the main thread. May add a state while deserializing.
void WriteXML(XMLWriter &xmlFile) const
Use only in the main thread, to avoid races.
void MoveEffect(size_t fromIndex, size_t toIndex)
Use only in the main thread. Changes effect order in the stack. Does nothing if fromIndex equals toIn...
bool ReplaceState(size_t index, std::shared_ptr< RealtimeEffectState > pState)
std::shared_ptr< RealtimeEffectState > GetStateAt(size_t index) noexcept
static const std::string & XMLTag()
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
virtual void StartTag(const wxString &name)
void WriteAttr(const wxString &name, const Identifier &value)
virtual void EndTag(const wxString &name)
template struct REGISTRIES_API Cloneable<>
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
void rotate(const float *oldPhase, const float *newPhase, std::complex< float > *dst, int32_t n)
@ Remove
Effect item was removed from the list at srcIndex position. affectedState is removed state.
@ DidReplace
Effect item was replaced with a new item at srcIndex position. affectedState is an old state.
@ Move
Item position has changed, from srcIndex to dstIndex. affectedState is the moved state.
@ Insert
New effect item was added to the list at srcIndex position. affectedState is a new state.
@ WillReplace
Effect item will be replaced with a new item at srcIndex position. affectedState is the state to be r...
static std::shared_ptr< RealtimeEffectState > make_shared(Args &&...args)
Typically statically constructed.