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::tuple< NoteName, int, int, int > calcNoteProperties (const std::shared_ptr< KeySignature > &key, ClefIndex clefIndex, const std::shared_ptr< const others::Staff > &staff=nullptr) const
 Calculates the note name, octave number, actual alteration, and staff position.
 
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.
 
Cmper getPartId () const
 Gets the partId for this instance (or 0 for score)
 
std::shared_ptr< others::PartDefinitiongetPartDefinition () const
 Gets the others::PartDefinition corresponding to getPartId.
 
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 showAcci {}
 True if the note has an accidental. (Dynamically changed by Finale unless freezeAcci is set.)
 
bool freezeAcci {}
 True if the accidental should be forced on or off (based on showAcci.)
 

Additional Inherited Members

- Protected Member Functions inherited from musx::dom::Base
 Base (const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
 Constructs the base class and enforces the static constexpr XmlNodeName.
 
Baseoperator= (const Base &)
 assignment constructor: m_unlinkedNodes is intentionally omitted
 

Detailed Description

Represents a single note element in an entry.

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

Member Function Documentation

◆ 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 
) const

Calculates the note name, octave number, actual alteration, and staff position.

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.
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.