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

Wraps an EntryInfo instance and a note index. More...

#include <Entries.h>

Public Member Functions

 NoteInfoPtr ()
 Default constructor.
 
 NoteInfoPtr (const EntryInfoPtr &entryInfo, size_t noteIndex)
 Constructor.
 
 operator bool () const
 Provides a boolean conversion based on whether the EntryInfoPtr is valid and the note index is valid.
 
bool isSameNote (const NoteInfoPtr &src) const
 Returns whether the input and the current instance refer to the same note.
 
NoteInfoPtr findEqualPitch (const EntryInfoPtr &entry) const
 Finds a note with the same pitch in the supplied entry.
 
std::shared_ptr< const Noteoperator-> () const
 Allows -> access to the underlying Note instance.
 
EntryInfoPtr getEntryInfo () const
 Gets the entry info for this note.
 
std::tuple< Note::NoteName, int, int, int > calcNoteProperties (const std::optional< bool > &enharmonicRespell=std::nullopt) const
 Calculates the note name, octave number, actual alteration, and staff position. This function does not take into account percussion notes and their staff position override. To discover if a note is a percussion note, call calcPercussionNoteInfo. If it returns non-null, use that for staff position instead of this function.
 
std::shared_ptr< others::PercussionNoteInfocalcPercussionNoteInfo () const
 Calculates the percussion note info for this note, if any.
 
NoteInfoPtr calcTieTo () const
 Calculates the note that this note could tie to. Check the return value's Note::tieEnd to see if there is actually a tie end.
 
NoteInfoPtr calcTieFrom () const
 Calculates the note that this note could tie from. Check the return value's Note::tieStart to see if there is actually a tie.
 
InstCmper calcStaff () const
 Calculates the staff number, taking into account cross staffing.
 
std::unique_ptr< music_theory::TransposercreateTransposer () const
 Creates a transposer for this Note instance.
 
NoteInfoPtr getNext () const
 Gets the next note in a chord on the same entry.
 
NoteInfoPtr getPrevious () const
 Gets the next note in a chord on the same entry.
 

Detailed Description

Wraps an EntryInfo instance and a note index.

Constructor & Destructor Documentation

◆ NoteInfoPtr()

musx::dom::NoteInfoPtr::NoteInfoPtr ( const EntryInfoPtr entryInfo,
size_t  noteIndex 
)
inline

Constructor.

Parameters
entryInfoThe entry info containing the note.
noteIndexThe index of this note within Entry::notes.

Member Function Documentation

◆ calcNoteProperties()

std::tuple< Note::NoteName, int, int, int > musx::dom::NoteInfoPtr::calcNoteProperties ( const std::optional< bool > &  enharmonicRespell = std::nullopt) const

Calculates the note name, octave number, actual alteration, and staff position. This function does not take into account percussion notes and their staff position override. To discover if a note is a percussion note, call calcPercussionNoteInfo. If it returns non-null, use that for staff position instead of this function.

Parameters
enharmonicRespellIf supplied, return the default enharmonic respelling based on this value. If omitted, this value is calculated automatically based on the score or part settings. Normally you will omit it.
Returns
A tuple containing:
  • NoteName: The note name (C, D, E, F, G, A, B)
  • int: The octave number (where 4 is the middle C octave)
  • int: The actual alteration in EDO divisions (normally semitones), relative to natural
  • int: The staff position of the note relative to the staff reference line. (For 5-line staves this is the top line.)

◆ calcPercussionNoteInfo()

std::shared_ptr< others::PercussionNoteInfo > musx::dom::NoteInfoPtr::calcPercussionNoteInfo ( ) const

Calculates the percussion note info for this note, if any.

Returns
If the note is on a percussion staff and has percussion note info assigned, returns it. Otherwise nullptr.

◆ calcTieFrom()

NoteInfoPtr musx::dom::NoteInfoPtr::calcTieFrom ( ) const

Calculates the note that this note could tie from. Check the return value's Note::tieStart to see if there is actually a tie.

Returns
The candidate note or an empty NoteInfoPtr if no candidate was found.

◆ calcTieTo()

NoteInfoPtr musx::dom::NoteInfoPtr::calcTieTo ( ) const

Calculates the note that this note could tie to. Check the return value's Note::tieEnd to see if there is actually a tie end.

Returns
The candidate note or an empty NoteInfoPtr if no candidate was found.

◆ createTransposer()

std::unique_ptr< music_theory::Transposer > musx::dom::NoteInfoPtr::createTransposer ( ) const

Creates a transposer for this Note instance.

Returns
A unique pointer to a transposer for this Note.

◆ findEqualPitch()

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

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

Parameters
entrythe entry to search
Returns
The found note or an null instance of NoteInfoPtr.

◆ getNext()

NoteInfoPtr musx::dom::NoteInfoPtr::getNext ( ) const
inline

Gets the next note in a chord on the same entry.

Returns
The next note or nullptr if none.

◆ getPrevious()

NoteInfoPtr musx::dom::NoteInfoPtr::getPrevious ( ) const
inline

Gets the next note in a chord on the same entry.

Returns
The next note or nullptr if none.