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

Represents a single note element in an entry. More...

#include <Entries.h>

+ Inheritance diagram for musx::dom::Note:

Public Types

using NoteProperties = std::tuple< music_theory::NoteName, int, int, int >
 Note properites. A tuple containing:
 
- Public Types inherited from musx::dom::Base
enum class  ShareMode { All , Partial , None }
 Describes how this instance is shared between part and score. More...
 
using SharedNodes = std::set< std::string >
 The container type for shared nodes.
 

Public Member Functions

 Note (const DocumentWeakPtr &document, NoteNumber noteId)
 Constructor function.
 
NoteNumber getNoteId () const
 Gets the note id for this note. This value does not change, even if the notes in a chord are rearranged (which affects the order of Entry::notes.)
 
std::pair< int, int > calcDefaultEnharmonic (const MusxInstance< KeySignature > &key) const
 Calculates the default enharmonic equivalent of this note. This is the value that Finale uses when details::NoteAlterations::enharmonic is true.
 
NoteProperties calcNoteProperties (const MusxInstance< KeySignature > &key, KeySignature::KeyContext ctx, ClefIndex clefIndex, const MusxInstance< others::Staff > &staff=nullptr, bool respellEnharmonic=false) 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.
 
- Public Member Functions inherited from musx::dom::Base
virtual ~Base () noexcept(false)=default
 Virtual destructor for polymorphic behavior.
 
DocumentPtr getDocument () const
 Gets a reference to the Document.
 
Cmper getSourcePartId () const
 Gets the source partId for this instance. If an instance is fully shared with the score, the source is SCORE_PARTID. If an instance is partially shared or non shared, the source is the ID of the part that sourced it.
 
ShareMode getShareMode () const
 Gets the sharing mode for this instance.
 
const SharedNodesgetUnlinkedNodes () const
 Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial)
 
void addUnlinkedNode (const std::string &nodeName)
 Adds a shared node for this instance.
 
virtual void integrityCheck (const std::shared_ptr< Base > &ptrToThis)
 Allows a class to determine if it has been properly contructed by the factory and fix issues that it can, such as creating default instances of contained classes.
 
virtual bool requireAllFields () const
 Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.
 

Static Public Member Functions

static const xml::XmlElementArray< Note > & xmlMappingArray ()
 Required for musx::factory::FieldPopulator.
 

Public Attributes

int harmLev {}
 Diatonic displacement relative to middle C or to the tonic in the middle C octave (if the key signature tonic is not C).
 
int harmAlt {}
 Chromatic alteration relative to the key signature. Never has a magnitude greater than +/-7.
 
bool isValid {}
 Should always be true but otherwise appears to be used internally by Finale.
 
bool tieStart {}
 Indicates a tie starts on this note.
 
bool tieEnd {}
 Indicates a tie ends on this note.
 
bool crossStaff {}
 Signifies that the note has a details::CrossStaff note detail.
 
bool upStemSecond {}
 When the entry is upstem, it is drawn on the "wrong" side of the stem.
 
bool downStemSecond {}
 When the entry is downstem, it is drawn on the "wrong" side of the stem.
 
bool upSplitStem {}
 
bool showAcci {}
 True if the note has an accidental. (Dynamically changed by Finale unless freezeAcci is set.)
 
bool parenAcci {}
 True if the accidental has parentheses.
 
bool noPlayback {}
 Indicates that this note should not be played back.
 
bool noSpacing {}
 Indicates that this note should ignored when calculating spacing.
 
bool freezeAcci {}
 True if the accidental should be forced on or off (based on showAcci.)
 
bool playDisabledByHP {}
 Used by Finale's smart playback engine.
 

Static Public Attributes

static constexpr NoteNumber RESTID = 31
 Non floating rests have a note with this noteId that defines their staff positions.
 

Additional Inherited Members

- Protected Member Functions inherited from musx::dom::Base
 Base (const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
 Constructs the base class.
 
 Base (const Base &)=default
 explicit default copy constructor
 
 Base (Base &&) noexcept=default
 explicit default move constructor
 
Baseoperator= (const Base &)
 no-op copy assignment operator allows subclasses to copy their values.
 
Baseoperator= (Base &&) noexcept
 no-op move assignment operator allows subclasses to move their values.
 

Detailed Description

Represents a single note element in an entry.

This class is identified by the XML node name "note".

Member Typedef Documentation

◆ NoteProperties

using musx::dom::Note::NoteProperties = std::tuple<music_theory::NoteName, int, int, int>

Note properites. 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.)

Member Function Documentation

◆ calcDefaultEnharmonic()

std::pair< int, int > musx::dom::Note::calcDefaultEnharmonic ( const MusxInstance< KeySignature > &  key) const

Calculates the default enharmonic equivalent of this note. This is the value that Finale uses when details::NoteAlterations::enharmonic is true.

Normally you do not have to call this function directly. It is called inside calcNoteProperties. But the function is available if you need it.

Parameters
keyThe key signature to use for transposition.
Returns
A std::pair containing
  • int: the enharmonic equivalent's displacement value relative to the tonic.
  • int: the enharmonic equivalent's alteration value relative to the key signature.

◆ calcNoteProperties()

Note::NoteProperties musx::dom::Note::calcNoteProperties ( const MusxInstance< KeySignature > &  key,
KeySignature::KeyContext  ctx,
ClefIndex  clefIndex,
const MusxInstance< others::Staff > &  staff = nullptr,
bool  respellEnharmonic = false 
) 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.

Finale does not transpose correctly with microtonal key signatures. This function transposes mostly correctly for them, which means that microtonal key signatures may have different results than in Finale. Of particular note is Chromatic Transposition, which produces nonsense results in Finale but here produces correct results, provided that the alteration value is understood to be a chromatic half-step alteration rather than a step alteration in EDO divisions.

Note
In Finale, the default whole rest staff position is the middle staff line. Other music notation systems frequently expect the standard whole rest staff position to be the second line from the top. You may need to interpolate the staff position returned by calcNoteProperties for whole rests.

See KeySignature::setTransposition for information about differences in key signature transposition.

Parameters
keyThe key signature in effect.
ctxThe key context (concert or written pitch).
clefIndexThe index of the clef in effect.
staffIf provided, the notes are transposed by any Chromatic Transposition specified for the staff. If calling calcNoteProperties for Concert Pitch (sounding pitch) values, omit this parameter.
respellEnharmonicIf true, the notes are enharmonically respelled using the default enharmonic spelling.
Returns
NoteProperties

Member Data Documentation

◆ downStemSecond

bool musx::dom::Note::downStemSecond {}

When the entry is downstem, it is drawn on the "wrong" side of the stem.

Indicates that this note is the lower note of a second.

◆ upSplitStem

bool musx::dom::Note::upSplitStem {}

True if the stem splits on this note. To split a chord in the normal way, every note from this higher should have upSplitStem set to true. Only takes effect if Entry::splitStem is true.

◆ upStemSecond

bool musx::dom::Note::upStemSecond {}

When the entry is upstem, it is drawn on the "wrong" side of the stem.

Indicates that this note is the upper note of a second.