26 auto result = std::make_unique<RealtimeEffectList>();
28 result->mStates.push_back(pState);
38 return std::make_shared<RealtimeEffectList>();
48 AudacityProject &project,
const std::shared_ptr<RealtimeEffectList> &list)
64 return std::make_unique<RealtimeEffectList>();
77 return Get(
const_cast<Track &
>(track));
83 const auto &
id = pState->GetID();
84 if (pState->GetEffect() !=
nullptr) {
86 shallowCopy.emplace_back(pState);
106 std::shared_ptr<RealtimeEffectState> pState)
110 const auto &
id = pState->GetID();
111 if (pState->GetEffect() !=
nullptr) {
121 swap(pState, shallowCopy[index]);
140 const std::shared_ptr<RealtimeEffectState> pState)
143 auto end = shallowCopy.end(),
144 found = std::find(shallowCopy.begin(),
end, pState);
147 const auto index = std::distance(shallowCopy.begin(), found);
148 shallowCopy.erase(found);
155 static_cast<size_t>(index),
170 for (
auto index = temp.size(); index--;)
176 const std::shared_ptr<RealtimeEffectState> &pState)
const
180 , iter = std::find(
begin,
end, pState);
183 return std::distance(
begin, iter);
191std::shared_ptr<RealtimeEffectState>
194 if (index < mStates.size())
195 return mStates[index];
199std::shared_ptr<const RealtimeEffectState>
207 assert(fromIndex <
mStates.size());
208 assert(toIndex <
mStates.size());
211 if(fromIndex == toIndex)
213 if(fromIndex < toIndex)
215 const auto first = shallowCopy.begin() + fromIndex;
216 const auto last = shallowCopy.begin() + toIndex + 1;
217 std::rotate(first, first + 1, last);
221 const auto first = shallowCopy.rbegin() + (shallowCopy.size() - (fromIndex + 1));
222 const auto last = shallowCopy.rbegin() + (shallowCopy.size() - toIndex);
223 std::rotate(first, first + 1, last);
238 static const std::string result{
"effects"};
248 for (
auto &[attr, value] : attrs) {
270 for (
const auto & state :
mStates)
271 state->WriteXML(xmlFile);
278 Set(project, shared_from_this());
283 return mActive.load(std::memory_order_relaxed);
static const Track::ChannelGroupAttachments::RegisteredFactory trackEffects
static UndoRedoExtensionRegistry::Entry sEntry
static constexpr auto activeAttribute
static const AttachedProjectObjects::RegisteredFactory masterEffects
declares abstract base class Track, TrackList, and iterators over TrackList
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.
static const RealtimeEffectList & Get(const Track &track)
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()
Abstract base class for an object holding data associated with points on a time axis.
ChannelGroupData & GetGroupData()
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)
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)
@ 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.