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>();
86 const auto &
id = pState->GetID();
87 if (pState->GetEffect() !=
nullptr) {
89 shallowCopy.emplace_back(pState);
109 std::shared_ptr<RealtimeEffectState> pState)
113 const auto &
id = pState->GetID();
114 if (pState->GetEffect() !=
nullptr) {
124 swap(pState, shallowCopy[index]);
143 const std::shared_ptr<RealtimeEffectState> pState)
146 auto end = shallowCopy.end(),
147 found = std::find(shallowCopy.begin(),
end, pState);
150 const auto index = std::distance(shallowCopy.begin(), found);
151 shallowCopy.erase(found);
158 static_cast<size_t>(index),
173 for (
auto index = temp.size(); index--;)
179 const std::shared_ptr<RealtimeEffectState> &pState)
const
183 , iter = std::find(
begin,
end, pState);
186 return std::distance(
begin, iter);
194std::shared_ptr<RealtimeEffectState>
197 if (index < mStates.size())
198 return mStates[index];
202std::shared_ptr<const RealtimeEffectState>
210 assert(fromIndex <
mStates.size());
211 assert(toIndex <
mStates.size());
214 if(fromIndex == toIndex)
216 if(fromIndex < toIndex)
218 const auto first = shallowCopy.begin() + fromIndex;
219 const auto last = shallowCopy.begin() + toIndex + 1;
225 shallowCopy.rbegin() + (shallowCopy.size() - (fromIndex + 1));
226 const auto last = shallowCopy.rbegin() + (shallowCopy.size() - toIndex);
242 static const std::string result{
"effects"};
252 for (
auto &[attr, value] : attrs) {
274 for (
const auto & state :
mStates)
275 state->WriteXML(xmlFile);
282 Set(
project, shared_from_this());
287 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...
ChannelGroupData & GetGroupData()
Make attachment site on demand as needed.
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<>
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
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.