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

enum class  NoteName : int {
  C = 0 , D = 1 , E = 2 , F = 3 ,
  G = 4 , A = 5 , B = 6
}
 The available note names, in array order.
 
- 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 std::shared_ptr< KeySignature > &key) const
 Calculates the default enharmonic equivalent of this note. This is the value that Finale uses when details::NoteAlterations::enharmonic is true.
 
std::tuple< NoteName, int, int, int > calcNoteProperties (const std::shared_ptr< KeySignature > &key, ClefIndex clefIndex, const std::shared_ptr< const 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.
 
bool requireAllFields () const override
 Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.
 
- 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.
 
virtual Cmper getPartId () const
 Gets the partId for this instance (or SCORE_PARTID for score)
 
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 ()
 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.
 

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 crossStaff {}
 Signifies that the note has a details::CrossStaff note detail.
 
bool tieStart {}
 Indicates a tie starts on this note.
 
bool tieEnd {}
 Indicates a tie ends on this note.
 
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 freezeAcci {}
 True if the accidental should be forced on or off (based on showAcci.)
 

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 Function Documentation

◆ calcDefaultEnharmonic()

std::pair< int, int > musx::dom::Note::calcDefaultEnharmonic ( const std::shared_ptr< 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()

std::tuple< Note::NoteName, int, int, int > musx::dom::Note::calcNoteProperties ( const std::shared_ptr< KeySignature > &  key,
ClefIndex  clefIndex,
const std::shared_ptr< const 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.

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

Parameters
keyThe key signature in effect.
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
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.)

◆ requireAllFields()

bool musx::dom::Note::requireAllFields ( ) const
inlineoverridevirtual

Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.

Some classes make it difficult to discover all the possible xml tags that might be used for all its options. An example is others::TextBlock. By overriding this function, a class can allow its members to be discovered as needed without causing error messages or throwing exceptions.

Remarks
This value only escapes errors on fields. Enum values must still have all values provided to avoid error messages or exceptions.

Reimplemented from musx::dom::Base.

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.