|
MUSX Document Model
|
Shared key signature class that is contained in other classes. (See others::Measure) More...
#include <CommonClasses.h>
Inheritance diagram for musx::dom::KeySignature:Public Types | |
| enum class | KeyContext { Concert , Written } |
| Indicates whether to compute key signature values in concert or written pitch. More... | |
Public Types inherited from musx::dom::EnigmaBase | |
| 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 | |
| Cmper | getKeyMode () const |
| Returns the key mode. | |
| int | getAlteration (KeyContext ctx) const |
| For linear keys, returns the number of sharps or flats from -7..7 (if any). | |
| bool | isLinear () const |
| whether this is a linear key | |
| bool | isNonLinear () const |
| whether this is a non-linear key | |
| bool | isBuiltIn () const |
| whether this is a built-in key | |
| bool | isMajor () const |
| whether this is a built-in major key | |
| bool | isMinor () const |
| whether this is a built-in minor key | |
| std::optional< music_theory::DiatonicMode > | calcDiatonicMode () const |
| If this key specifies a diatonic mode, returns the mode. This value is independent of EDO divisions. Any correctly configured linear key signature should return a value. | |
| bool | isSame (const KeySignature &src) const |
| returns whether the two key signatures represent the same key signature, taking into account transposition. | |
| bool | isSameConcert (const KeySignature &src) const |
| returns whether the two key signatures represent the same concert key signature, ignoring transposition. | |
| int | calcScaleDegree (int displacement) const |
| Calculates the scale degree for the given displacement, where 0 is the tonic. | |
| void | setTransposition (int interval, int keyAdjustment, bool simplify) |
| Transposes the key by the specified amounts. Set them to zero to remove transposition. | |
| void | setTransposition (const MusxInstance< others::Staff > &staff) |
| Sets the key's transposition based on the input staff's transposition settings. | |
| int | calcTonalCenterIndex (KeyContext ctx) const |
| Calculates the tonal center index for the key, where C=0, D=1, E=2, ... | |
| int | calcAlterationOnNote (unsigned noteIndex, KeyContext ctx) const |
| Calculates the amount of alteration on a note int the key. | |
| music_theory::Pitch | calcPitch (int displacement, int alteration, KeyContext ctx) const |
| Converts a key-relative pitch representation into a spelled pitch. | |
| int | getOctaveDisplacement (KeyContext ctx) const |
| The octave displacement if this key is a transposed key. | |
| int | calcEDODivisions () const |
| Calculates the number of EDO division for the key. (The standard value is 12.) | |
| std::optional< std::vector< int > > | calcKeyMap () const |
| Calculates the key's diatonic key map. | |
| std::unique_ptr< music_theory::Transposer > | createTransposer (int displacement, int alteration) const |
| Creates a transposer for this KeySignature instance. | |
| void | integrityCheck (const std::shared_ptr< EnigmaBase > &ptrToThis) override |
| Performs a final consistency check after population. | |
| CommonClassBase (const DocumentWeakPtr &document) | |
| Constructs a CommonClassBase object. | |
Public Member Functions inherited from musx::dom::CommonClassBase | |
| CommonClassBase (const DocumentWeakPtr &document) | |
| Constructs a CommonClassBase object. | |
Public Member Functions inherited from musx::dom::EnigmaBase | |
| 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 SharedNodes & | getUnlinkedNodes () 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 bool | requireAllFields () const |
| Returns true if all fields are required for valid input. | |
Public Member Functions inherited from musx::dom::DocumentElement | |
| virtual | ~DocumentElement () noexcept(false)=default |
| Virtual destructor for polymorphic behavior. | |
| DocumentPtr | getDocument () const |
| Gets a reference to the Document. | |
| Cmper | getPartId () const |
| Gets the part id associated with this instance. | |
Static Public Member Functions | |
| static const xml::XmlElementArray< KeySignature > & | xmlMappingArray () |
| Required for musx::factory::FieldPopulator. | |
Public Attributes | |
| uint16_t | key {} |
| 16-bit value intepreted as follows: | |
| bool | keyless {} |
| Indicates the absence of a key signature. | |
| bool | hideKeySigShowAccis {} |
| Instead of a key signature, show accidentals for the key on the notes where they occur. | |
Additional Inherited Members | |
Protected Member Functions inherited from musx::dom::CommonClassBase | |
| ShareMode | getShareMode () const |
| Gets the sharing mode for this instance. | |
| const SharedNodes & | getUnlinkedNodes () const |
Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial) | |
Protected Member Functions inherited from musx::dom::EnigmaBase | |
| EnigmaBase (const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode) | |
| Constructs the base class. | |
| EnigmaBase (const EnigmaBase &)=default | |
| explicit default copy constructor | |
| EnigmaBase (EnigmaBase &&) noexcept=default | |
| explicit default move constructor | |
| EnigmaBase & | operator= (const EnigmaBase &) |
| no-op copy assignment operator allows subclasses to copy their values. | |
| EnigmaBase & | operator= (EnigmaBase &&) noexcept |
| no-op move assignment operator allows subclasses to move their values. | |
Protected Member Functions inherited from musx::dom::DocumentElement | |
| DocumentElement (const DocumentWeakPtr &document, Cmper partId) | |
| Constructs the document element. | |
| DocumentElement (const DocumentElement &)=default | |
| explicit default copy constructor | |
| DocumentElement (DocumentElement &&) noexcept=default | |
| explicit default move constructor | |
| DocumentElement & | operator= (const DocumentElement &) |
| no-op copy assignment operator allows subclasses to copy their values. | |
| DocumentElement & | operator= (DocumentElement &&) noexcept |
| no-op move assignment operator allows subclasses to move their values. | |
Shared key signature class that is contained in other classes. (See others::Measure)
|
strong |
Indicates whether to compute key signature values in concert or written pitch.
This enum is used to control whether computations such as alteration, tonal center, or key maps should be performed using the concert pitch (untransposed key) or the written pitch (transposed key).
Pass this as an optional argument to key signature methods to specify the desired context.
| Enumerator | |
|---|---|
| Concert | Use concert pitch (untransposed) |
| Written | Use written pitch (with transposition) |
| int musx::dom::KeySignature::calcAlterationOnNote | ( | unsigned | noteIndex, |
| KeyContext | ctx | ||
| ) | const |
Calculates the amount of alteration on a note int the key.
| noteIndex | note index, where C=0, D=1, E=3, F=3, G=4, A=5, B=6 |
| ctx | Whether to calculate the alteration for concert or written pitch. |
| std::optional< music_theory::DiatonicMode > musx::dom::KeySignature::calcDiatonicMode | ( | ) | const |
If this key specifies a diatonic mode, returns the mode. This value is independent of EDO divisions. Any correctly configured linear key signature should return a value.
| music_theory::Pitch musx::dom::KeySignature::calcPitch | ( | int | displacement, |
| int | alteration, | ||
| KeyContext | ctx | ||
| ) | const |
Converts a key-relative pitch representation into a spelled pitch.
| displacement | Diatonic displacement relative to the key tonic in the C4 octave. |
| alteration | Alteration relative to the key signature, in EDO divisions. |
| ctx | Whether to use concert or written key-signature values. |
| int musx::dom::KeySignature::calcScaleDegree | ( | int | displacement | ) | const |
Calculates the scale degree for the given displacement, where 0 is the tonic.
| displacement | The diatonic displacement value. Zero is the tonic in the middle-C octave. |
| int musx::dom::KeySignature::calcTonalCenterIndex | ( | KeyContext | ctx | ) | const |
Calculates the tonal center index for the key, where C=0, D=1, E=2, ...
This is the modal tonal center, so a minor key with no sharps or flats returns 5 (=A).
|
inline |
Constructs a CommonClassBase object.
| document | A weak pointer to the parent document. |
| std::unique_ptr< music_theory::Transposer > musx::dom::KeySignature::createTransposer | ( | int | displacement, |
| int | alteration | ||
| ) | const |
Creates a transposer for this KeySignature instance.
| displacement | Displacement value (e.g., from Note) |
| alteration | Alteration value (e.g., from Note) |
|
inline |
For linear keys, returns the number of sharps or flats from -7..7 (if any).
| ctx | (optional) Specifies whether to return the concert or written alteration value. Default is written. |
|
inline |
Returns the key mode.
For linear keys, this is a value from 0..127 where 0 is reserved for built-in major keys and 1 is reserved for built-in minor keys. Values from 2..127 are user-defined linear modes and are a Cmper value for finding the custom key signature information related to the key. User-defined linear keys might, for example, represent diatonic jazz modes or church modes. They can also be used to define microtonal scales with key signatures.
For non-linear keys, this is a value from 0x4000..0x4fff. This is a Cmper that is used to find all the custom key signature information that defines the key. These are sometimes used to define modes like Klezmer Freyish mode, or other modes whose accidentals do not follow the circle of fifths. They can also be used to define microtonal scales without key signatures.
Values from 0x8000 and higher are invalid.
|
inline |
The octave displacement if this key is a transposed key.
|
inlineoverridevirtual |
Performs a final consistency check after population.
Reimplemented from musx::dom::EnigmaBase.
| void musx::dom::KeySignature::setTransposition | ( | int | interval, |
| int | keyAdjustment, | ||
| bool | simplify | ||
| ) |
Transposes the key by the specified amounts. Set them to zero to remove transposition.
This is used to adjust the key signature for staves that use Key Signature transposition. Staves that use Chromatic transposition do not transpose the key. They transpose the pitches directly.
Finale works pretty well with key signature transposition in microtone scales. However, it does not simplify key signatures usefully. This function simplifies them correctly, provided that the step values for accidentals are set to cycle through sharps and flats by chromatic half-steps rather than the default of 1. See others::AcciAmountSharps and others::AcciAmountFlats.
| interval | The interval by which to transpose. |
| keyAdjustment | The key adjustment (positive for sharps, negative for flats) |
| simplify | If true, enharmonically adjust the key to have 6 or fewer accidentals |
| uint16_t musx::dom::KeySignature::key {} |
16-bit value intepreted as follows: