Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
NoteTrack Class Referencefinal

A Track that is used for Midi notes. (Somewhat old code). More...

#include <NoteTrack.h>

Inheritance diagram for NoteTrack:
[legend]
Collaboration diagram for NoteTrack:
[legend]

Classes

struct  Interval
 

Public Types

using Attachments = NoteTrackAttachments
 
using Holder = std::shared_ptr< NoteTrack >
 
- Public Types inherited from Track
using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using Holder = std::shared_ptr< Track >
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 
- Public Types inherited from ChannelGroup
enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
using Attachments = ChannelGroupAttachments
 
using Interval = WideChannelGroupInterval
 
- Public Types inherited from Channel
using Interval = ChannelInterval
 

Public Member Functions

 NoteTrack ()
 
 NoteTrack (const NoteTrack &orig)=delete
 Copy construction hasn't been necessary yet. More...
 
 NoteTrack (const NoteTrack &orig, ProtectedCreationArg &&)=delete
 
virtual ~NoteTrack ()
 
void MoveTo (double origin) override
 Change start time to given time point. More...
 
Alg_seq & GetSeq () const
 
void WarpAndTransposeNotes (double t0, double t1, const TimeWarper &warper, double semitones)
 
void SetSequence (std::unique_ptr< Alg_seq > &&seq)
 
void PrintSequence ()
 
Alg_seq * MakeExportableSeq (std::unique_ptr< Alg_seq > &cleanup) const
 
bool ExportMIDI (const wxString &f) const
 
bool ExportAllegro (const wxString &f) const
 
Track::Holder Cut (double t0, double t1) override
 Create tracks and modify this track. More...
 
Track::Holder Copy (double t0, double t1, bool forClipboard=true) const override
 Create new tracks and don't modify this track. More...
 
bool Trim (double t0, double t1)
 
void Clear (double t0, double t1) override
 
void Paste (double t, const Track &src) override
 Weak precondition allows overrides to replicate one channel into many. More...
 
void Silence (double t0, double t1, ProgressReporter reportProgress={}) override
 
void InsertSilence (double t, double len) override
 
bool Shift (double t)
 
float GetVelocity () const
 
void SetVelocity (float velocity)
 
QuantizedTimeAndBeat NearestBeatTime (double time) const
 
bool StretchRegion (QuantizedTimeAndBeat t0, QuantizedTimeAndBeat t1, double newDur)
 
bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
unsigned GetVisibleChannels () const
 
void SetVisibleChannels (unsigned value)
 
bool IsVisibleChan (int c) const
 
void SetVisibleChan (int c)
 
void ClearVisibleChan (int c)
 
void ToggleVisibleChan (int c)
 
void SoloVisibleChan (int c)
 
const TypeInfoGetTypeInfo () const override
 
Track::Holder PasteInto (AudacityProject &project, TrackList &list) const override
 
size_t NIntervals () const override
 Report the number of intervals. More...
 
- Public Member Functions inherited from UniqueChannelTrack< PlayableTrack >
size_t NChannels () const override
 Report the number of channels. More...
 
std::shared_ptr< ChannelDoGetChannel (size_t iChannel) override
 
- Public Member Functions inherited from PlayableTrack
 PlayableTrack ()
 
 PlayableTrack (const PlayableTrack &orig, ProtectedCreationArg &&)
 
bool GetMute () const
 
bool GetSolo () const
 
bool GetNotMute () const
 
bool GetNotSolo () const
 
void SetMute (bool m)
 
void SetSolo (bool s)
 
void WriteXMLAttributes (XMLWriter &xmlFile) const
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &value)
 
- Public Member Functions inherited from AudioTrack
 AudioTrack ()
 
 AudioTrack (const Track &orig, ProtectedCreationArg &&a)
 
void WriteXMLAttributes (XMLWriter &WXUNUSED(xmlFile)) const
 
bool HandleXMLAttribute (const std::string_view &, const XMLAttributeValueView &)
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> std::enable_if_t< std::is_const_v< Subclass >, std::shared_ptr< Subclass > >
 
virtual const TypeInfoGetTypeInfo () const =0
 
virtual const TypeNamesGetTypeNames () const
 
virtual bool SupportsBasicEditing () const
 Whether this track type implements cut-copy-paste; by default, true. More...
 
virtual Holder PasteInto (AudacityProject &project, TrackList &list) const =0
 
virtual bool LinkConsistencyFix (bool doFix=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck ()
 Do the non-mutating part of consistency fix only and return status. More...
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
LinkType GetLinkType () const noexcept
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate (DuplicateOptions={}) const
 public nonvirtual duplication function that invokes Clone() More...
 
void ReparentAllAttachments ()
 
const wxString & GetName () const
 Name is always the same for all channels of a group. More...
 
void SetName (const wxString &n)
 
bool GetSelected () const
 Selectedness is always the same for all channels of a group. More...
 
virtual void SetSelected (bool s)
 
virtual Holder Cut (double t0, double t1)=0
 Create tracks and modify this track. More...
 
virtual Holder Copy (double t0, double t1, bool forClipboard=true) const =0
 Create new tracks and don't modify this track. More...
 
virtual void Clear (double t0, double t1)=0
 
virtual void Paste (double t, const Track &src)=0
 Weak precondition allows overrides to replicate one channel into many. More...
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double t0, double t1, ProgressReporter reportProgress={})=0
 
virtual void InsertSilence (double t, double len)=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual std::optional< TranslatableStringGetErrorOpening () const
 
void Notify (bool allChannels, int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 
- Public Member Functions inherited from ChannelGroup
virtual ~ChannelGroup ()
 
double GetStartTime () const
 Get the minimum of Start() values of intervals, or 0 when none. More...
 
double GetEndTime () const
 Get the maximum of End() values of intervals, or 0 when none. More...
 
void ShiftBy (double t)
 Change start time by given duration. More...
 
virtual void MoveTo (double o)=0
 Change start time to given time point. More...
 
template<typename ChannelType = Channel>
std::shared_ptr< ChannelType > GetChannel (size_t iChannel)
 Retrieve a channel, cast to the given type. More...
 
template<typename ChannelType = const Channel>
auto GetChannel (size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
 
template<typename ChannelType = Channel>
IteratorRange< ChannelIterator< ChannelType > > Channels ()
 Get range of channels with mutative access. More...
 
template<typename ChannelType = const Channel>
auto Channels () const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
 Get range of channels with read-only access. More...
 
std::shared_ptr< ChannelNthChannel (size_t nChannel)
 
std::shared_ptr< const ChannelNthChannel (size_t nChannel) const
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. More...
 
- Public Member Functions inherited from Channel
virtual ~Channel ()
 
ChannelGroupGetChannelGroup ()
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
const ChannelGroupGetChannelGroup () const
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
size_t GetChannelIndex () const
 
size_t NIntervals () const
 Report the number of intervals. More...
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. More...
 
- Public Member Functions inherited from OtherPlayableSequence
virtual ~OtherPlayableSequence ()
 

Static Public Member Functions

static NoteTrackNew (AudacityProject &project)
 
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from PlayableTrack
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from AudioTrack
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static const TypeInfoClassTypeInfo ()
 
static void CopyAttachments (Track &dst, const Track &src, bool deep)
 Copy (deep) or just share (!deep) AttachedTrackObjects. More...
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t numFactories ()
 How many static factories have been registered with this specialization of Site. More...
 

Static Public Attributes

static EnumSetting< bool > AllegroStyleSetting
 

Private Member Functions

Track::Holder Clone (bool backup) const override
 
std::shared_ptr< WideChannelGroupIntervalDoGetInterval (size_t iInterval) override
 Retrieve an interval. More...
 
void DoSetVelocity (float velocity)
 
void AddToDuration (double delta)
 

Private Attributes

std::unique_ptr< Alg_seq > mSeq
 
std::unique_ptr< char[]> mSerializationBuffer
 
long mSerializationLength
 
std::atomic< float > mVelocity { 0.0f }
 Atomic because it may be read by worker threads in playback. More...
 
std::atomic< unsigned > mVisibleChannels { ALL_CHANNELS }
 A bit set; atomic because it may be read by worker threads in playback. More...
 
double mOrigin { 0.0 }
 

Additional Inherited Members

- Protected Member Functions inherited from UniqueChannelTrack< PlayableTrack >
ChannelGroupDoGetChannelGroup () const override
 Subclass must override. More...
 
- Protected Member Functions inherited from PlayableTrack
bool DoGetMute () const
 
void DoSetMute (bool value)
 
bool DoGetSolo () const
 
void DoSetSolo (bool value)
 
- Protected Member Functions inherited from Track
void SetLinkType (LinkType linkType, bool completeList=true)
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForCorresponding (Site &other, const Function &function, bool create=true)
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
void EraseIf (const Function &function)
 Erase attached objects satisfying a predicate. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. More...
 
virtual ChannelGroupDoGetChannelGroup () const =0
 Subclass must override. More...
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 

Detailed Description

A Track that is used for Midi notes. (Somewhat old code).

Definition at line 74 of file NoteTrack.h.

Member Typedef Documentation

◆ Attachments

Definition at line 80 of file NoteTrack.h.

◆ Holder

using NoteTrack::Holder = std::shared_ptr<NoteTrack>

Definition at line 92 of file NoteTrack.h.

Constructor & Destructor Documentation

◆ NoteTrack() [1/3]

NoteTrack::NoteTrack ( )

Definition at line 145 of file NoteTrack.cpp.

147{
148 SetName(_("Note Track"));
149
150 mSeq = NULL;
152}
#define _(s)
Definition: Internat.h:73
std::unique_ptr< Alg_seq > mSeq
Definition: NoteTrack.h:207
long mSerializationLength
Definition: NoteTrack.h:209
void SetName(const wxString &n)
Definition: Track.cpp:69
Generates overrides of channel-related functions.
Definition: Track.h:450

References _, mSeq, mSerializationLength, and Track::SetName().

Here is the call graph for this function:

◆ NoteTrack() [2/3]

NoteTrack::NoteTrack ( const NoteTrack orig)
delete

Copy construction hasn't been necessary yet.

◆ NoteTrack() [3/3]

NoteTrack::NoteTrack ( const NoteTrack orig,
ProtectedCreationArg &&   
)
delete

◆ ~NoteTrack()

NoteTrack::~NoteTrack ( )
virtual

Definition at line 154 of file NoteTrack.cpp.

155{
156}

Member Function Documentation

◆ AddToDuration()

void NoteTrack::AddToDuration ( double  delta)
private

Definition at line 602 of file NoteTrack.cpp.

603{
604 auto &seq = GetSeq();
605#if 0
606 // PRL: Would this be better ?
607 seq.set_real_dur( seq.get_real_dur() + delta );
608#else
609 seq.convert_to_seconds();
610 seq.set_dur( seq.get_dur() + delta );
611#endif
612}
Alg_seq & GetSeq() const
Definition: NoteTrack.cpp:158

References GetSeq().

Referenced by Paste(), and StretchRegion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClassTypeInfo()

auto NoteTrack::ClassTypeInfo ( )
static

Definition at line 574 of file NoteTrack.cpp.

575{
576 return typeInfo();
577}
static const Track::TypeInfo & typeInfo()
Definition: NoteTrack.cpp:561

References typeInfo().

Here is the call graph for this function:

◆ Clear()

void NoteTrack::Clear ( double  t0,
double  t1 
)
overridevirtual

May assume precondition: t0 <= t1

Implements Track.

Definition at line 397 of file NoteTrack.cpp.

398{
399 if (t1 < t0)
401
402 double len = t1-t0;
403
404 auto &seq = GetSeq();
405
406 auto offset = mOrigin;
407 auto start = t0 - offset;
408 if (start < 0.0) {
409 // AlgSeq::clear will shift the cleared interval, not changing len, if
410 // start is negative. That's not what we want to happen.
411 if (len > -start) {
412 seq.clear(0, len + start, false);
413 MoveTo(t0);
414 }
415 else
416 MoveTo(offset - len);
417 }
418 else {
419 //auto delta = -(
420 //( std::min( t1, GetEndTime() ) ) - ( std::max( t0, GetStartTime() ) )
421 //);
422 seq.clear(start, len, false);
423
424 // Not needed
425 // Alg_seq::clear seems to handle this
426 // AddToDuration( delta );
427 }
428}
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
void MoveTo(double origin) override
Change start time to given time point.
Definition: NoteTrack.h:98
double mOrigin
Definition: NoteTrack.h:216

References GetSeq(), mOrigin, MoveTo(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by anonymous_namespace{EditMenus.cpp}::OnCut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearVisibleChan()

void NoteTrack::ClearVisibleChan ( int  c)
inline

Definition at line 160 of file NoteTrack.h.

160 {
161 mVisibleChannels.fetch_and(~CHANNEL_BIT(c), std::memory_order_relaxed); }
#define CHANNEL_BIT(c)
Definition: NoteTrack.h:148
std::atomic< unsigned > mVisibleChannels
A bit set; atomic because it may be read by worker threads in playback.
Definition: NoteTrack.h:215

References CHANNEL_BIT.

◆ Clone()

Track::Holder NoteTrack::Clone ( bool  backup) const
overrideprivatevirtual

Subclass responsibility implements only a part of Duplicate(), copying the track data proper (not associated data such as for groups and views) including TrackId

Parameters
backupwhether the duplication is for backup purposes while opening a project, instead of other editing operations
Postcondition
result tracks have same TrackIds as the channels of this

Implements Track.

Definition at line 180 of file NoteTrack.cpp.

181{
182 auto duplicate = std::make_shared<NoteTrack>();
183 duplicate->Init(*this);
184 // The duplicate begins life in serialized state. Often the duplicate is
185 // pushed on the Undo stack. Then we want to un-serialize it (or a further
186 // copy) only on demand after an Undo.
187 if (mSeq) {
189 wxASSERT(!mSerializationBuffer);
190 // serialize from this to duplicate's mSerializationBuffer
191 void *buffer;
192 mSeq->serialize(&buffer,
193 &duplicate->mSerializationLength);
194 duplicate->mSerializationBuffer.reset( (char*)buffer );
196 }
197 else if (mSerializationBuffer) {
198 // Copy already serialized data.
199 wxASSERT(!mSeq);
200 duplicate->mSerializationLength = this->mSerializationLength;
201 duplicate->mSerializationBuffer.reset
202 ( safenew char[ this->mSerializationLength ] );
203 memcpy( duplicate->mSerializationBuffer.get(),
204 this->mSerializationBuffer.get(), this->mSerializationLength );
205 }
206 else {
207 // We are duplicating a default-constructed NoteTrack, and that's okay
208 }
209
210 // copy some other fields here
211 Attachments &attachments = *duplicate;
212 attachments = *this;
213
214 duplicate->SetVisibleChannels(GetVisibleChannels());
215 duplicate->MoveTo(mOrigin);
216 duplicate->SetVelocity(GetVelocity());
217 return duplicate;
218}
#define safenew
Definition: MemoryX.h:9
#define SonifyEndSerialize()
Definition: NoteTrack.h:238
#define SonifyBeginSerialize()
Definition: NoteTrack.h:237
NoteTrackAttachments Attachments
Definition: NoteTrack.h:80
std::unique_ptr< char[]> mSerializationBuffer
Definition: NoteTrack.h:208
float GetVelocity() const
Definition: NoteTrack.h:124
unsigned GetVisibleChannels() const
Definition: NoteTrack.h:149

References GetVelocity(), GetVisibleChannels(), mOrigin, mSeq, mSerializationBuffer, mSerializationLength, safenew, SonifyBeginSerialize, and SonifyEndSerialize.

Here is the call graph for this function:

◆ Copy()

Track::Holder NoteTrack::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
overridevirtual

Create new tracks and don't modify this track.

Returns
non-NULL or else throw Note that subclasses may want to distinguish tracks stored in a clipboard from those stored in a project May assume precondition: t0 <= t1 Should invoke Track::Init

Implements Track.

Definition at line 350 of file NoteTrack.cpp.

351{
352 if (t1 < t0)
354
355 double len = t1-t0;
356
357 auto newTrack = std::make_shared<NoteTrack>();
358
359 newTrack->Init(*this);
360
361 auto &seq = GetSeq();
362 seq.convert_to_seconds();
363 newTrack->mSeq.reset(seq.copy(t0 - mOrigin, len, false));
364 newTrack->MoveTo(0);
365
366 // What should be done with the rest of newTrack's members?
367 // (mBottomNote, mSerializationBuffer,
368 // mSerializationLength, mVisibleChannels)
369
370 return newTrack;
371}

References GetSeq(), mOrigin, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by anonymous_namespace{EditMenus.cpp}::OnCut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cut()

Track::Holder NoteTrack::Cut ( double  t0,
double  t1 
)
overridevirtual

Create tracks and modify this track.

Returns
non-NULL or else throw May assume precondition: t0 <= t1

Implements Track.

Definition at line 320 of file NoteTrack.cpp.

321{
322 if (t1 < t0)
324
325 double len = t1-t0;
326 //auto delta = -(
327 //( std::min( t1, GetEndTime() ) ) - ( std::max( t0, GetStartTime() ) )
328 //);
329
330 auto newTrack = std::make_shared<NoteTrack>();
331
332 newTrack->Init(*this);
333
334 auto &seq = GetSeq();
335 seq.convert_to_seconds();
336 newTrack->mSeq.reset(seq.cut(t0 - mOrigin, len, false));
337 newTrack->MoveTo(0);
338
339 // Not needed
340 // Alg_seq::cut seems to handle this
341 //AddToDuration( delta );
342
343 // What should be done with the rest of newTrack's members?
344 //(mBottomNote,
345 // mSerializationBuffer, mSerializationLength, mVisibleChannels)
346
347 return newTrack;
348}

References GetSeq(), mOrigin, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by anonymous_namespace{EditMenus.cpp}::OnCut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoGetInterval()

std::shared_ptr< WideChannelGroupInterval > NoteTrack::DoGetInterval ( size_t  iInterval)
overrideprivatevirtual

Retrieve an interval.

Postcondition
result: !(iInterval < NIntervals()) || result

Implements ChannelGroup.

Definition at line 594 of file NoteTrack.cpp.

595{
596 if (iInterval == 0)
597 // Just one, and no extra info in it!
598 return std::make_shared<Interval>(*this);
599 return {};
600}

◆ DoSetVelocity()

void NoteTrack::DoSetVelocity ( float  velocity)
private

Definition at line 516 of file NoteTrack.cpp.

517{
518 mVelocity.store(velocity, std::memory_order_relaxed);
519}
std::atomic< float > mVelocity
Atomic because it may be read by worker threads in playback.
Definition: NoteTrack.h:212

References mVelocity.

Referenced by HandleXMLTag(), and SetVelocity().

Here is the caller graph for this function:

◆ ExportAllegro()

bool NoteTrack::ExportAllegro ( const wxString &  f) const

Definition at line 783 of file NoteTrack.cpp.

784{
785 double offset = mOrigin;
786 auto in_seconds = AllegroStyleSetting.ReadEnum();
787 auto &seq = GetSeq();
788 if (in_seconds) {
789 seq.convert_to_seconds();
790 } else {
791 seq.convert_to_beats();
792 }
793 return seq.write(f.mb_str(), offset);
794}
Enum ReadEnum() const
Definition: Prefs.h:534
static EnumSetting< bool > AllegroStyleSetting
Definition: NoteTrack.h:81

References AllegroStyleSetting, GetSeq(), mOrigin, and EnumSetting< Enum >::ReadEnum().

Here is the call graph for this function:

◆ ExportMIDI()

bool NoteTrack::ExportMIDI ( const wxString &  f) const

Definition at line 759 of file NoteTrack.cpp.

760{
761 std::unique_ptr<Alg_seq> cleanup;
762 auto seq = MakeExportableSeq(cleanup);
763 bool rslt = seq->smf_write(f.mb_str());
764 return rslt;
765}
Alg_seq * MakeExportableSeq(std::unique_ptr< Alg_seq > &cleanup) const
Definition: NoteTrack.cpp:636

References MakeExportableSeq().

Here is the call graph for this function:

◆ GetSeq()

Alg_seq & NoteTrack::GetSeq ( ) const

Definition at line 158 of file NoteTrack.cpp.

159{
160 if (!mSeq) {
162 mSeq = std::make_unique<Alg_seq>();
163 else {
164 std::unique_ptr<Alg_track> alg_track
165 { Alg_seq::unserialize
167 wxASSERT(alg_track->get_type() == 's');
168 mSeq.reset( static_cast<Alg_seq*>(alg_track.release()) );
169
170 // Preserve the invariant that at most one of the representations is
171 // valid
172 mSerializationBuffer.reset();
174 }
175 }
176 wxASSERT(mSeq);
177 return *mSeq;
178}

References mSeq, mSerializationBuffer, and mSerializationLength.

Referenced by AddToDuration(), Clear(), Copy(), Cut(), DEFINE_ATTACHED_VIRTUAL_OVERRIDE(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteBackground(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteTrack(), ExportAllegro(), anonymous_namespace{ImportMIDI.cpp}::ImportMIDI(), InsertSilence(), MakeExportableSeq(), NearestBeatTime(), Paste(), Shift(), Silence(), StretchRegion(), Trim(), WarpAndTransposeNotes(), and WriteXML().

Here is the caller graph for this function:

◆ GetTypeInfo()

auto NoteTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 569 of file NoteTrack.cpp.

570{
571 return typeInfo();
572}

References typeInfo().

Here is the call graph for this function:

◆ GetVelocity()

float NoteTrack::GetVelocity ( ) const
inline

Definition at line 124 of file NoteTrack.h.

124 {
125 return mVelocity.load(std::memory_order_relaxed); }

Referenced by Clone(), anonymous_namespace{MIDIPlay.h}::Iterator::OutputEvent(), SetVelocity(), NoteTrackControls::VelocitySlider(), and WriteXML().

Here is the caller graph for this function:

◆ GetVisibleChannels()

unsigned NoteTrack::GetVisibleChannels ( ) const
inline

Definition at line 149 of file NoteTrack.h.

149 {
150 return mVisibleChannels.load(std::memory_order_relaxed);
151 }

Referenced by Clone(), and WriteXML().

Here is the caller graph for this function:

◆ HandleXMLChild()

XMLTagHandler * NoteTrack::HandleXMLChild ( const std::string_view &  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 843 of file NoteTrack.cpp.

844{
845 return NULL;
846}

◆ HandleXMLTag()

bool NoteTrack::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 804 of file NoteTrack.cpp.

805{
806 if (tag == "notetrack") {
807 for (auto pair : attrs)
808 {
809 auto attr = pair.first;
810 auto value = pair.second;
811
812 long nValue;
813 double dblValue;
814 if (this->Track::HandleCommonXMLAttribute(attr, value))
815 ;
816 else if (this->Attachments::FindIf([&](auto &attachment){
817 return attachment.HandleAttribute(pair);
818 }))
819 ;
820 else if (this->PlayableTrack::HandleXMLAttribute(attr, value))
821 {}
822 else if (attr == "offset" && value.TryGet(dblValue))
823 MoveTo(dblValue);
824 else if (attr == "visiblechannels") {
825 if (!value.TryGet(nValue) ||
826 !IsValidVisibleChannels(nValue))
827 return false;
828 SetVisibleChannels(nValue);
829 }
830 else if (attr == "velocity" && value.TryGet(dblValue))
831 DoSetVelocity(static_cast<float>(dblValue));
832 else if (attr == "data") {
833 std::string s(value.ToWString());
834 std::istringstream data(s);
835 mSeq = std::make_unique<Alg_seq>(data, false);
836 }
837 } // while
838 return true;
839 }
840 return false;
841}
ClientData * FindIf(const Function &function)
Return pointer to first attachment in this that is not null and satisfies a predicate,...
Definition: ClientData.h:497
void SetVisibleChannels(unsigned value)
Definition: NoteTrack.h:152
void DoSetVelocity(float velocity)
Definition: NoteTrack.cpp:516
bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &value)
bool HandleCommonXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
Definition: Track.cpp:819
bool IsValidVisibleChannels(const int nValue)
Definition: NoteTrack.cpp:798

References DoSetVelocity(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::FindIf(), Track::HandleCommonXMLAttribute(), PlayableTrack::HandleXMLAttribute(), anonymous_namespace{NoteTrack.cpp}::IsValidVisibleChannels(), MoveTo(), mSeq, and SetVisibleChannels().

Here is the call graph for this function:

◆ InsertSilence()

void NoteTrack::InsertSilence ( double  t,
double  len 
)
overridevirtual

May assume precondition: t0 <= t1

Implements Track.

Definition at line 495 of file NoteTrack.cpp.

496{
497 if (len < 0)
499
500 auto &seq = GetSeq();
501 seq.convert_to_seconds();
502 seq.insert_silence(t - mOrigin, len);
503
504 // is this needed?
505 // AddToDuration( len );
506}

References GetSeq(), mOrigin, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by Paste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsVisibleChan()

bool NoteTrack::IsVisibleChan ( int  c) const
inline

Definition at line 155 of file NoteTrack.h.

155 {
156 return (GetVisibleChannels() & CHANNEL_BIT(c)) != 0;
157 }

References CHANNEL_BIT.

Referenced by anonymous_namespace{NoteTrackControls.cpp}::DrawLabelControls(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteTrack(), and anonymous_namespace{MIDIPlay.h}::Iterator::Unmuted().

Here is the caller graph for this function:

◆ MakeExportableSeq()

Alg_seq * NoteTrack::MakeExportableSeq ( std::unique_ptr< Alg_seq > &  cleanup) const

Definition at line 636 of file NoteTrack.cpp.

637{
638 cleanup.reset();
639 double offset = mOrigin;
640 if (offset == 0)
641 return &GetSeq();
642 // make a copy, deleting events that are shifted before time 0
643 double start = -offset;
644 if (start < 0) start = 0;
645 // notes that begin before "start" are not included even if they
646 // extend past "start" (because "all" parameter is set to false)
647 cleanup.reset( GetSeq().copy(start, GetSeq().get_dur() - start, false) );
648 auto seq = cleanup.get();
649 if (offset > 0) {
650 {
651 // swap cleanup and mSeq so that Shift operates on the NEW copy
652 swap( this->mSeq, cleanup );
653 auto cleanup2 = finally( [&] { swap( this->mSeq, cleanup ); } );
654
655 const_cast< NoteTrack *>( this )->Shift(offset);
656 }
657#ifdef OLD_CODE
658 // now shift events by offset. This must be done with an integer
659 // number of measures, so first, find the beats-per-measure
660 double beats_per_measure = 4.0;
661 Alg_time_sig_ptr tsp = NULL;
662 if (seq->time_sig.length() > 0 && seq->time_sig[0].beat < ALG_EPS) {
663 // there is an initial time signature
664 tsp = &(seq->time_sig[0]);
665 beats_per_measure = (tsp->num * 4) / tsp->den;
666 }
667 // also need the initial tempo
668 double bps = ALG_DEFAULT_BPM / 60;
669 Alg_time_map_ptr map = seq->get_time_map();
670 Alg_beat_ptr bp = &(map->beats[0]);
671 if (bp->time < ALG_EPS) { // tempo change at time 0
672 if (map->beats.len > 1) { // compute slope to get tempo
673 bps = (map->beats[1].beat - map->beats[0].beat) /
674 (map->beats[1].time - map->beats[0].time);
675 } else if (seq->get_time_map()->last_tempo_flag) {
676 bps = seq->get_time_map()->last_tempo;
677 }
678 }
679 // find closest number of measures to fit in the gap
680 // number of measures is offset / measure_time
681 double measure_time = beats_per_measure / bps; // seconds per measure
682 int n = ROUND(offset / measure_time);
683 if (n == 0) n = 1;
684 // we will insert n measures. Compute the desired duration of each.
685 measure_time = offset / n;
686 bps = beats_per_measure / measure_time;
687 // insert integer multiple of measures at beginning
688 seq->convert_to_beats();
689 seq->insert_silence(0, beats_per_measure * n);
690 // make sure time signature at 0 is correct
691 if (tsp) {
692 seq->set_time_sig(0, tsp->num, tsp->den);
693 }
694 // adjust tempo to match offset
695 seq->set_tempo(bps * 60.0, 0, beats_per_measure * n);
696#endif
697 } else {
698 auto &mySeq = GetSeq();
699 // if offset is negative, it might not be a multiple of beats, but
700 // we want to preserve the relative positions of measures. I.e. we
701 // should shift barlines and time signatures as well as notes.
702 // Insert a time signature at the first bar-line if necessary.
703
704 // Translate start from seconds to beats and call it beat:
705 double beat = mySeq.get_time_map()->time_to_beat(start);
706 // Find the time signature in mySeq in effect at start (beat):
707 int i = mySeq.time_sig.find_beat(beat);
708 // i is where you would insert a NEW time sig at beat,
709 // Case 1: beat coincides with a time sig at i. Time signature
710 // at beat means that there is a barline at beat, so when beat
711 // is shifted to 0, the relative barline positions are preserved
712 if (mySeq.time_sig.length() > 0 &&
713 within(beat, mySeq.time_sig[i].beat, ALG_EPS)) {
714 // beat coincides with time signature change, so offset must
715 // be a multiple of beats
716 /* do nothing */ ;
717 // Case 2: there is no time signature before beat.
718 } else if (i == 0 && (mySeq.time_sig.length() == 0 ||
719 mySeq.time_sig[i].beat > beat)) {
720 // If beat does not fall on an implied barline, we need to
721 // insert a time signature.
722 double measures = beat / 4.0;
723 double imeasures = ROUND(measures);
724 if (!within(measures, imeasures, ALG_EPS)) {
725 double bar_offset = ((int)(measures) + 1) * 4.0 - beat;
726 seq->set_time_sig(bar_offset, 4, 4);
727 }
728 // This case should never be true because if i == 0, either there
729 // are no time signatures before beat (Case 2),
730 // or there is one time signature at beat (Case 1)
731 } else if (i == 0) {
732 /* do nothing (might be good to assert(false)) */ ;
733 // Case 3: i-1 must be the effective time sig position
734 } else {
735 i -= 1; // index the time signature in effect at beat
736 Alg_time_sig_ptr tsp = &(mySeq.time_sig[i]);
737 double beats_per_measure = (tsp->num * 4) / tsp->den;
738 double measures = (beat - tsp->beat) / beats_per_measure;
739 int imeasures = ROUND(measures);
740 if (!within(measures, imeasures, ALG_EPS)) {
741 // beat is not on a measure, so we need to insert a time sig
742 // to force a bar line at the first measure location after
743 // beat
744 double bar = tsp->beat + beats_per_measure * ((int)(measures) + 1);
745 double bar_offset = bar - beat;
746 // insert NEW time signature at bar_offset in NEW sequence
747 // It will have the same time signature, but the position will
748 // force a barline to match the barlines in mSeq
749 seq->set_time_sig(bar_offset, tsp->num, tsp->den);
750 }
751 // else beat coincides with a barline, so no need for an extra
752 // time signature to force barline alignment
753 }
754 }
755 return seq;
756}
#define ROUND(x)
Definition: NoteTrack.cpp:24
bool within(A a, B b, DIST d)
Definition: TrackPanel.cpp:170
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
bool Shift(double t)
Definition: NoteTrack.cpp:523
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), GetSeq(), mOrigin, mSeq, ROUND, Shift(), anonymous_namespace{NoteTrack.cpp}::swap(), and within().

Referenced by ExportMIDI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveTo()

void NoteTrack::MoveTo ( double  o)
inlineoverridevirtual

Change start time to given time point.

Implements ChannelGroup.

Definition at line 98 of file NoteTrack.h.

98{ mOrigin = origin; }

Referenced by Clear(), HandleXMLTag(), anonymous_namespace{ImportMIDI.cpp}::ImportMIDI(), Paste(), and Trim().

Here is the caller graph for this function:

◆ NearestBeatTime()

QuantizedTimeAndBeat NoteTrack::NearestBeatTime ( double  time) const

Definition at line 550 of file NoteTrack.cpp.

551{
552 // Alg_seq knows nothing about offset, so remove offset time
553 double seq_time = time - mOrigin;
554 double beat;
555 auto &seq = GetSeq();
556 seq_time = seq.nearest_beat_time(seq_time, &beat);
557 // add the offset back in to get "actual" audacity track time
558 return { seq_time + mOrigin, beat };
559}

References GetSeq(), and mOrigin.

Here is the call graph for this function:

◆ New()

NoteTrack * NoteTrack::New ( AudacityProject project)
static

Definition at line 137 of file NoteTrack.cpp.

138{
139 auto &tracks = TrackList::Get( project );
140 auto result = tracks.Add( std::make_shared<NoteTrack>());
141 result->AttachedTrackObjects::BuildAll();
142 return result;
143}
const auto tracks
const auto project
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References TrackList::Get(), project, and tracks.

Here is the call graph for this function:

◆ NIntervals()

size_t NoteTrack::NIntervals ( ) const
overridevirtual

Report the number of intervals.

Implements ChannelGroup.

Definition at line 588 of file NoteTrack.cpp.

589{
590 return 1;
591}

◆ Paste()

void NoteTrack::Paste ( double  t,
const Track src 
)
overridevirtual

Weak precondition allows overrides to replicate one channel into many.

Precondition
SameKindAs(src)
src.NChannels() == 1 || src.NChannels() == NChannels()

Implements Track.

Definition at line 430 of file NoteTrack.cpp.

431{
432 // Paste inserts src at time t. If src has a positive offset,
433 // the offset is treated as silence which is also inserted. If
434 // the offset is negative, the offset is ignored and the ENTIRE
435 // src is inserted (otherwise, we would either lose data from
436 // src by not inserting things at negative times, or inserting
437 // things at negative times could overlap things already in
438 // the destination track).
439
440 //Check that src is a non-NULL NoteTrack
441 bool bOk = src.TypeSwitch<bool>( [&](const NoteTrack &other) {
442
443 auto myOffset = this->mOrigin;
444 if (t < myOffset) {
445 // workaround strange behavior described at
446 // http://bugzilla.audacityteam.org/show_bug.cgi?id=1735#c3
447 MoveTo(t);
448 InsertSilence(t, myOffset - t);
449 }
450
451 double delta = 0.0;
452 auto &seq = GetSeq();
453 auto offset = other.mOrigin;
454 if (offset > 0) {
455 seq.convert_to_seconds();
456 seq.insert_silence(t - mOrigin, offset);
457 t += offset;
458 // Is this needed or does Alg_seq::insert_silence take care of it?
459 //delta += offset;
460 }
461
462 // This seems to be needed:
463 delta += std::max(0.0, t - GetEndTime());
464
465 // This, not:
466 //delta += other.GetSeq().get_real_dur();
467
468 seq.paste(t - mOrigin, &other.GetSeq());
469
470 AddToDuration(delta);
471
472 return true;
473 });
474
475 if (!bOk)
476 // THROW_INCONSISTENCY_EXCEPTION; // ?
477 (void)0;// intentionally do nothing
478}
double GetEndTime() const
Get the maximum of End() values of intervals, or 0 when none.
Definition: Channel.cpp:61
void AddToDuration(double delta)
Definition: NoteTrack.cpp:602
void InsertSilence(double t, double len) override
Definition: NoteTrack.cpp:495
R TypeSwitch(const Functions &...functions)
Definition: Track.h:381

References AddToDuration(), ChannelGroup::GetEndTime(), GetSeq(), InsertSilence(), mOrigin, MoveTo(), and Track::TypeSwitch().

Here is the call graph for this function:

◆ PasteInto()

Track::Holder NoteTrack::PasteInto ( AudacityProject project,
TrackList list 
) const
overridevirtual

Find or create the destination track for a paste, maybe in a different project

Parameters
listto which any newly created tracks are added; but left unchanged if an existing track is found in the project instead
Returns
A smart pointer to a track

Implements Track.

Definition at line 579 of file NoteTrack.cpp.

580{
581 auto pNewTrack = std::make_shared<NoteTrack>();
582 pNewTrack->Init(*this);
583 pNewTrack->Paste(0.0, *this);
584 list.Add(pNewTrack);
585 return pNewTrack;
586}
TrackKind * Add(const std::shared_ptr< TrackKind > &t, bool assignIds=true)
Definition: Track.h:1048

References TrackList::Add().

Here is the call graph for this function:

◆ PrintSequence()

void NoteTrack::PrintSequence ( )

Definition at line 261 of file NoteTrack.cpp.

262{
263 FILE *debugOutput;
264
265 debugOutput = fopen("debugOutput.txt", "wt");
266 wxFprintf(debugOutput, "Importing MIDI...\n");
267
268 // This is called for debugging purposes. Do not compute mSeq on demand
269 // with GetSeq()
270 if (mSeq) {
271 int i = 0;
272
273 while(i < mSeq->length()) {
274 wxFprintf(debugOutput, "--\n");
275 wxFprintf(debugOutput, "type: %c\n",
276 ((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type());
277 wxFprintf(debugOutput, "time: %f\n",
278 ((Alg_event_ptr)mSeq->track_list.tracks[i])->time);
279 wxFprintf(debugOutput, "channel: %li\n",
280 ((Alg_event_ptr)mSeq->track_list.tracks[i])->chan);
281
282 if(((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type() == wxT('n'))
283 {
284 wxFprintf(debugOutput, "pitch: %f\n",
285 ((Alg_note_ptr)mSeq->track_list.tracks[i])->pitch);
286 wxFprintf(debugOutput, "duration: %f\n",
287 ((Alg_note_ptr)mSeq->track_list.tracks[i])->dur);
288 wxFprintf(debugOutput, "velocity: %f\n",
289 ((Alg_note_ptr)mSeq->track_list.tracks[i])->loud);
290 }
291 else if(((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type() == wxT('n'))
292 {
293 wxFprintf(debugOutput, "key: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->get_identifier());
294 wxFprintf(debugOutput, "attribute type: %c\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type());
295 wxFprintf(debugOutput, "attribute: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_name());
296
297 if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('r'))
298 {
299 wxFprintf(debugOutput, "value: %f\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.r);
300 }
301 else if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('i')) {
302 wxFprintf(debugOutput, "value: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.i);
303 }
304 else if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('s')) {
305 wxFprintf(debugOutput, "value: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.s);
306 }
307 else {}
308 }
309
310 i++;
311 }
312 }
313 else {
314 wxFprintf(debugOutput, "No sequence defined!\n");
315 }
316
317 fclose(debugOutput);
318}
wxT("CloseDown"))

References mSeq, and wxT().

Here is the call graph for this function:

◆ SetSequence()

void NoteTrack::SetSequence ( std::unique_ptr< Alg_seq > &&  seq)

Definition at line 256 of file NoteTrack.cpp.

257{
258 mSeq = std::move(seq);
259}

References mSeq.

Referenced by anonymous_namespace{ImportMIDI.cpp}::ImportMIDI().

Here is the caller graph for this function:

◆ SetVelocity()

void NoteTrack::SetVelocity ( float  velocity)

Definition at line 508 of file NoteTrack.cpp.

509{
510 if (GetVelocity() != velocity) {
511 DoSetVelocity(velocity);
512 Notify(false);
513 }
514}
void Notify(bool allChannels, int code=-1)
Definition: Track.cpp:234

References DoSetVelocity(), GetVelocity(), and Track::Notify().

Referenced by MixerTrackCluster::HandleSliderVelocity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVisibleChan()

void NoteTrack::SetVisibleChan ( int  c)
inline

Definition at line 158 of file NoteTrack.h.

158 {
159 mVisibleChannels.fetch_or(CHANNEL_BIT(c), std::memory_order_relaxed); }

References CHANNEL_BIT.

◆ SetVisibleChannels()

void NoteTrack::SetVisibleChannels ( unsigned  value)
inline

Definition at line 152 of file NoteTrack.h.

152 {
153 mVisibleChannels.store(value, std::memory_order_relaxed);
154 }

Referenced by HandleXMLTag().

Here is the caller graph for this function:

◆ Shift()

bool NoteTrack::Shift ( double  t)

Definition at line 523 of file NoteTrack.cpp.

524{
525 if (t > 0) {
526 auto &seq = GetSeq();
527 // insert an even number of measures
528 seq.convert_to_beats();
529 // get initial tempo
530 double tempo = seq.get_tempo(0.0);
531 double beats_per_measure = seq.get_bar_len(0.0);
532 int m = ROUND(t * tempo / beats_per_measure);
533 // need at least 1 measure, so if we rounded down to zero, fix it
534 if (m == 0) m = 1;
535 // compute NEW tempo so that m measures at NEW tempo take t seconds
536 tempo = beats_per_measure * m / t; // in beats per second
537 seq.insert_silence(0.0, beats_per_measure * m);
538 seq.set_tempo(tempo * 60.0 /* bpm */, 0.0, beats_per_measure * m);
539 seq.write("afterShift.gro");
540 } else if (t < 0) {
541 auto &seq = GetSeq();
542 seq.convert_to_seconds();
543 seq.clear(0, t, true);
544 } else { // offset is zero, no modifications
545 return false;
546 }
547 return true;
548}

References GetSeq(), and ROUND.

Referenced by MakeExportableSeq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Silence()

void NoteTrack::Silence ( double  t0,
double  t1,
ProgressReporter  reportProgress = {} 
)
overridevirtual

Implements Track.

Definition at line 480 of file NoteTrack.cpp.

481{
482 if (t1 < t0)
484
485 auto len = t1 - t0;
486
487 auto &seq = GetSeq();
488 seq.convert_to_seconds();
489 // XXX: do we want to set the all param?
490 // If it's set, then it seems like notes are silenced if they start or end in the range,
491 // otherwise only if they start in the range. --Poke
492 seq.silence(t0 - mOrigin, len, false);
493}

References GetSeq(), mOrigin, and THROW_INCONSISTENCY_EXCEPTION.

Here is the call graph for this function:

◆ SoloVisibleChan()

void NoteTrack::SoloVisibleChan ( int  c)
inline

Definition at line 166 of file NoteTrack.h.

166 {
167 auto visibleChannels = 0u;
169 visibleChannels = ALL_CHANNELS;
170 else
171 visibleChannels = CHANNEL_BIT(c);
172 mVisibleChannels.store(visibleChannels, std::memory_order_relaxed);
173 }
#define ALL_CHANNELS
Definition: NoteTrack.h:147

References ALL_CHANNELS, and CHANNEL_BIT.

Referenced by LabelClick().

Here is the caller graph for this function:

◆ StretchRegion()

bool NoteTrack::StretchRegion ( QuantizedTimeAndBeat  t0,
QuantizedTimeAndBeat  t1,
double  newDur 
)

Definition at line 614 of file NoteTrack.cpp.

616{
617 auto &seq = GetSeq();
618 bool result = seq.stretch_region( t0.second, t1.second, newDur );
619 if (result) {
620 const auto oldDur = t1.first - t0.first;
621 AddToDuration( newDur - oldDur );
622 }
623 return result;
624}

References AddToDuration(), and GetSeq().

Here is the call graph for this function:

◆ ToggleVisibleChan()

void NoteTrack::ToggleVisibleChan ( int  c)
inline

Definition at line 162 of file NoteTrack.h.

162 {
163 mVisibleChannels.fetch_xor(CHANNEL_BIT(c), std::memory_order_relaxed); }

References CHANNEL_BIT.

Referenced by LabelClick().

Here is the caller graph for this function:

◆ Trim()

bool NoteTrack::Trim ( double  t0,
double  t1 
)

Definition at line 373 of file NoteTrack.cpp.

374{
375 if (t1 < t0)
376 return false;
377 auto &seq = GetSeq();
378 //auto delta = -(
379 //( GetEndTime() - std::min( GetEndTime(), t1 ) ) +
380 //( std::max(t0, GetStartTime()) - GetStartTime() )
381 //);
382 seq.convert_to_seconds();
383 // DELETE way beyond duration just in case something is out there:
384 seq.clear(t1 - mOrigin, seq.get_dur() + 10000.0, false);
385 // Now that stuff beyond selection is cleared, clear before selection:
386 seq.clear(0.0, t0 - mOrigin, false);
387 // want starting time to be t0
388 MoveTo(t0);
389
390 // Not needed
391 // Alg_seq::clear seems to handle this
392 //AddToDuration( delta );
393
394 return true;
395}

References GetSeq(), mOrigin, and MoveTo().

Here is the call graph for this function:

◆ WarpAndTransposeNotes()

void NoteTrack::WarpAndTransposeNotes ( double  t0,
double  t1,
const TimeWarper warper,
double  semitones 
)

Definition at line 220 of file NoteTrack.cpp.

223{
224 double offset = this->mOrigin; // track is shifted this amount
225 auto &seq = GetSeq();
226 seq.convert_to_seconds(); // make sure time units are right
227 t1 -= offset; // adjust time range to compensate for track offset
228 t0 -= offset;
229 if (t1 > seq.get_dur()) { // make sure t0, t1 are within sequence
230 t1 = seq.get_dur();
231 if (t0 >= t1) return;
232 }
233 Alg_iterator iter(mSeq.get(), false);
234 iter.begin();
235 Alg_event_ptr event;
236 while (0 != (event = iter.next()) && event->time < t1) {
237 if (event->is_note() && event->time >= t0) {
238 event->set_pitch(event->get_pitch() + semitones);
239 }
240 }
241 iter.end();
242 // now, use warper to warp the tempo map
243 seq.convert_to_beats(); // beats remain the same
244 Alg_time_map_ptr map = seq.get_time_map();
245 map->insert_beat(t0, map->time_to_beat(t0));
246 map->insert_beat(t1, map->time_to_beat(t1));
247 int i, len = map->length();
248 for (i = 0; i < len; i++) {
249 Alg_beat &beat = map->beats[i];
250 beat.time = warper.Warp(beat.time + offset) - offset;
251 }
252 // about to redisplay, so might as well convert back to time now
253 seq.convert_to_seconds();
254}
virtual double Warp(double originalTime) const =0

References GetSeq(), mOrigin, mSeq, and TimeWarper::Warp().

Here is the call graph for this function:

◆ WriteXML()

void NoteTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 848 of file NoteTrack.cpp.

850{
851 std::ostringstream data;
852 Track::Holder holder;
853 const NoteTrack *saveme = this;
854 if (!mSeq) {
855 // replace saveme with an (unserialized) duplicate, which is
856 // destroyed at end of function.
857 holder = Clone(false);
858 saveme = static_cast<NoteTrack*>(holder.get());
859 }
860 saveme->GetSeq().write(data, true);
861 xmlFile.StartTag(wxT("notetrack"));
862 saveme->Track::WriteCommonXMLAttributes( xmlFile );
864 xmlFile.WriteAttr(wxT("offset"), saveme->mOrigin);
865 xmlFile.WriteAttr(wxT("visiblechannels"),
866 static_cast<int>(saveme->GetVisibleChannels()));
867
868 xmlFile.WriteAttr(wxT("velocity"),
869 static_cast<double>(saveme->GetVelocity()));
870 saveme->Attachments::ForEach([&](auto &attachment){
871 attachment.WriteXML(xmlFile);
872 });
873 xmlFile.WriteAttr(wxT("data"), wxString(data.str().c_str(), wxConvUTF8));
874 xmlFile.EndTag(wxT("notetrack"));
875}
Track::Holder Clone(bool backup) const override
Definition: NoteTrack.cpp:180
void WriteXMLAttributes(XMLWriter &xmlFile) const
std::shared_ptr< Track > Holder
Definition: Track.h:202
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102

References GetSeq(), GetVelocity(), GetVisibleChannels(), mOrigin, PlayableTrack::WriteXMLAttributes(), and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ AllegroStyleSetting

EnumSetting< bool > NoteTrack::AllegroStyleSetting
static
Initial value:
{
wxT("/FileFormats/AllegroStyleChoice"),
{
EnumValueSymbol{ wxT("Seconds"), XXO("&Seconds") },
EnumValueSymbol{ wxT("Beats"), XXO("&Beats") },
},
0,
{
true, false,
},
wxT("/FileFormats/AllegroStyle"),
}
XXO("&Cut/Copy/Paste Toolbar")
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...

Definition at line 81 of file NoteTrack.h.

Referenced by anonymous_namespace{ExportMIDI.cpp}::AddControls(), and ExportAllegro().

◆ mOrigin

double NoteTrack::mOrigin { 0.0 }
private

◆ mSeq

std::unique_ptr<Alg_seq> NoteTrack::mSeq
mutableprivate

◆ mSerializationBuffer

std::unique_ptr<char[]> NoteTrack::mSerializationBuffer
mutableprivate

Definition at line 208 of file NoteTrack.h.

Referenced by Clone(), and GetSeq().

◆ mSerializationLength

long NoteTrack::mSerializationLength
mutableprivate

Definition at line 209 of file NoteTrack.h.

Referenced by Clone(), GetSeq(), and NoteTrack().

◆ mVelocity

std::atomic<float> NoteTrack::mVelocity { 0.0f }
private

Atomic because it may be read by worker threads in playback.

Definition at line 212 of file NoteTrack.h.

Referenced by DoSetVelocity().

◆ mVisibleChannels

std::atomic<unsigned> NoteTrack::mVisibleChannels { ALL_CHANNELS }
private

A bit set; atomic because it may be read by worker threads in playback.

Definition at line 215 of file NoteTrack.h.


The documentation for this class was generated from the following files: