MUSX Document Model
Loading...
Searching...
No Matches
musx::dom::EntryInfoPtr Class Reference

Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ownership of the frame so that any instance of it keeps the frame alive without the need for circular references. More...

#include <Entries.h>

Public Member Functions

 EntryInfoPtr ()
 Default constructor.
 
 EntryInfoPtr (const std::shared_ptr< const EntryFrame > &entryFrame, size_t index=0)
 Constructor function.
 
const std::shared_ptr< const EntryInfooperator-> () const
 Allows -> access to the underlying EntryInfo instance.
 
 operator bool () const
 Provides a boolean conversion based on whether the frame is valid and contains entries.
 
bool isSameEntry (const EntryInfoPtr &src) const
 Returns whether the input and the current instance refer to the same entry.
 
std::shared_ptr< const EntryFramegetFrame () const
 Returns the frame.
 
size_t getIndexInFrame () const
 Returns the index within the frame.
 
LayerIndex getLayerIndex () const
 Get the layer index (0..3) of the entry.
 
InstCmper getStaff () const
 Get the staff cmper.
 
MeasCmper getMeasure () const
 Get the measure cmper.
 
std::shared_ptr< others::StaffCompositecreateCurrentStaff (const std::optional< InstCmper > &forStaffId=std::nullopt) const
 Creates the current StaffComposite for the entry.
 
std::shared_ptr< KeySignaturegetKeySignature () const
 Get the key signature of the entry.
 
unsigned calcReverseGraceIndex () const
 Caclulates the grace index counting leftward (used by other standards such as MNX)
 
std::optional< size_t > calcNextTupletIndex (std::optional< size_t > currentIndex) const
 Returns the next higher tuplet index that this entry starts, or std::nullopt if none.
 
EntryInfoPtr getNextInFrame () const
 Get the next entry in the frame.
 
EntryInfoPtr getNextInLayer () const
 Get the next entry in the same layer and staff. This can be in the next measure.
 
EntryInfoPtr getNextSameV () const
 Get the next entry in the frame in the same voice.
 
EntryInfoPtr getPreviousInLayer () const
 Get the previous entry in the same layer and staff. This can be in the previous measure.
 
EntryInfoPtr getPreviousInFrame () const
 Get the previous entry in the frame.
 
EntryInfoPtr getPreviousSameV () const
 Get the previous entry in the frame in the same voice.
 
EntryInfoPtr getNextInVoice (int voice) const
 Returns the next entry in the frame in the specified v1/v2 or null if none.
 
EntryInfoPtr getNextInBeamGroup (bool includeHiddenEntries=false) const
 Gets the next entry in a beamed group or nullptr if the entry is not beamed or is the last in the group.
 
EntryInfoPtr getPreviousInBeamGroup (bool includeHiddenEntries=false) const
 Gets the previous entry in a beamed group or nullptr if the entry is not beamed or is the first in the group.
 
bool calcDisplaysAsRest () const
 Calculates if an entry displays as a rest.
 
bool calcUnbeamed () const
 Returns whether this is an unbeamed entry.
 
bool calcIsBeamStart () const
 Returns whether this is the start of a primary beam.
 
EntryInfoPtr findBeamEnd () const
 Finds the end entry of a beamed group.
 
NoteInfoPtr findEqualPitch (const NoteInfoPtr &src) const
 Finds a note with the same pitch in the current entry.
 
unsigned calcNumberOfBeams () const
 Calculates the number of beams or flags on the entry.
 
unsigned calcLowestBeamStart () const
 Returns the lowest beam number starting at this entry, where 1 = 8th note beam, 2 = 16th note beam, etc.
 
unsigned calcLowestBeamEnd () const
 Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam, etc.
 
unsigned calcLowestBeamStub () const
 Returns the lowest beam stub at this entry, where 2 = 16th note stub, 3 = 32nd note stub, etc.
 
bool calcBeamStubIsLeft () const
 Calculates if a beam stub on this entry would go left or right. It does not check that an entry actually has a beam stub. Use calcLowestBeamStub to discover if the entry has a beam stub.
 

Detailed Description

Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ownership of the frame so that any instance of it keeps the frame alive without the need for circular references.

Constructor & Destructor Documentation

◆ EntryInfoPtr()

musx::dom::EntryInfoPtr::EntryInfoPtr ( const std::shared_ptr< const EntryFrame > &  entryFrame,
size_t  index = 0 
)
inline

Constructor function.

Parameters
entryFrameThe entry frame.
indexThe index of this instance within the frame.

Member Function Documentation

◆ calcBeamStubIsLeft()

bool musx::dom::EntryInfoPtr::calcBeamStubIsLeft ( ) const

Calculates if a beam stub on this entry would go left or right. It does not check that an entry actually has a beam stub. Use calcLowestBeamStub to discover if the entry has a beam stub.

Note
This is a best approximation of Finale's behavior for default beam stub direction. No doubt there are edge cases where it does not match.
Returns
True if a beam stub would go left; false if it would go right or if no calculation is possible.

◆ calcDisplaysAsRest()

bool musx::dom::EntryInfoPtr::calcDisplaysAsRest ( ) const

Calculates if an entry displays as a rest.

Todo:
Eventually calcDisplaysAsRest should take into account voiced parts.

◆ calcLowestBeamEnd()

unsigned musx::dom::EntryInfoPtr::calcLowestBeamEnd ( ) const

Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam, etc.

Returns
0 if not beamed or no beam ends this entry; otherwise, the beam number

◆ calcLowestBeamStart()

unsigned musx::dom::EntryInfoPtr::calcLowestBeamStart ( ) const

Returns the lowest beam number starting at this entry, where 1 = 8th note beam, 2 = 16th note beam, etc.

Returns
0 if not beamed or no beam starts this entry; otherwise, the beam number

◆ calcLowestBeamStub()

unsigned musx::dom::EntryInfoPtr::calcLowestBeamStub ( ) const

Returns the lowest beam stub at this entry, where 2 = 16th note stub, 3 = 32nd note stub, etc.

Returns
0 if not beamed or no beam stub exists on this entry; otherwise, the lowest beam stub number

◆ calcUnbeamed()

bool musx::dom::EntryInfoPtr::calcUnbeamed ( ) const

Returns whether this is an unbeamed entry.

Returns

◆ createCurrentStaff()

std::shared_ptr< others::StaffComposite > musx::dom::EntryInfoPtr::createCurrentStaff ( const std::optional< InstCmper > &  forStaffId = std::nullopt) const

Creates the current StaffComposite for the entry.

Parameters
forStaffIdSpecifies optional staff ID. If supplied, it overrides the entry's staff ID. (Usefule when notes are cross-staffed.)

◆ findBeamEnd()

EntryInfoPtr musx::dom::EntryInfoPtr::findBeamEnd ( ) const

Finds the end entry of a beamed group.

Returns
The entry if found, NULL if the entry cannot be beamed or if it is not part of a beamed group.

◆ findEqualPitch()

NoteInfoPtr musx::dom::EntryInfoPtr::findEqualPitch ( const NoteInfoPtr src) const

Finds a note with the same pitch in the current entry.

Parameters
srcthe pitch to search for
Returns
The found note or an null instance of NoteInfoPtr.
Todo:
(possibly) figure out which is the correct note when two notes of the same pitch exist. We would want to associate the first with the first and the second with the second.

◆ getNextInLayer()

EntryInfoPtr musx::dom::EntryInfoPtr::getNextInLayer ( ) const

Get the next entry in the same layer and staff. This can be in the next measure.

Returns
The next continguous entry. Returns nullptr if it encounters an empty frame or end of file.

◆ getNextInVoice()

EntryInfoPtr musx::dom::EntryInfoPtr::getNextInVoice ( int  voice) const

Returns the next entry in the frame in the specified v1/v2 or null if none.

Unlike getNextSameV, this returns the next v2 entry in any v2 launch sequence.

Parameters
voice1 or 2

◆ getNextSameV()

EntryInfoPtr musx::dom::EntryInfoPtr::getNextSameV ( ) const

Get the next entry in the frame in the same voice.

For V2, it returns null after the current V2 launch sequence.

◆ getPreviousInLayer()

EntryInfoPtr musx::dom::EntryInfoPtr::getPreviousInLayer ( ) const

Get the previous entry in the same layer and staff. This can be in the previous measure.

Returns
The previous continguous entry. Returns nullptr if it encounters an empty frame or the beginning of the file.

◆ getPreviousSameV()

EntryInfoPtr musx::dom::EntryInfoPtr::getPreviousSameV ( ) const

Get the previous entry in the frame in the same voice.

For V2, it returns null when it hits the v2Launch note for the current V2 launch sequence.

◆ isSameEntry()

bool musx::dom::EntryInfoPtr::isSameEntry ( const EntryInfoPtr src) const

Returns whether the input and the current instance refer to the same entry.

Returns
false if either this or src is null and true if they are both non null and refer to the same entry.