6#include "utils/utf8_string.h"
8#include <nlohmann/json.hpp>
14enum class MusicalNote : std::uint8_t
29Q_ENUM_NS (MusicalNote)
34enum class ChordType : std::uint8_t
50enum class ChordAccent : std::uint8_t
68 FlatFifthSharpEleventh,
70 SharpFifthFlatThirteenth,
74Q_ENUM_NS (ChordAccent)
85 static constexpr size_t MAX_NOTES = 48;
88 ChordDescriptor () =
default;
106 int get_max_inversion ()
const
111 case ChordAccent::None:
113 case ChordAccent::Seventh:
114 case ChordAccent::MajorSeventh:
115 case ChordAccent::FlatNinth:
116 case ChordAccent::Ninth:
117 case ChordAccent::SharpNinth:
118 case ChordAccent::Eleventh:
121 case ChordAccent::FlatFifthSharpEleventh:
122 case ChordAccent::SharpFifthFlatThirteenth:
123 case ChordAccent::SixthThirteenth:
133 int get_min_inversion ()
const {
return -get_max_inversion (); }
177 operator== (
const ChordDescriptor &lhs,
const ChordDescriptor &rhs)
184 NLOHMANN_DEFINE_TYPE_INTRUSIVE (
196 bool has_bass_ =
false;
A ChordDescriptor describes a chord and is not linked to any specific object by itself.
void update_notes()
Updates the notes array based on the current settings.
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ChordDescriptor, has_bass_, root_note_, bass_note_, type_, accent_, notes_, inversion_) public MusicalNote root_note_
Has bass note or not.
ChordAccent accent_
Chord accent.
int inversion_
0 no inversion, less than 0 highest note(s) drop an octave, greater than 0 lowest note(s) receive an ...
ChordType type_
Chord type.
utils::Utf8String to_string() const
Returns the chord in human readable string.
ChordDescriptor(MusicalNote root, bool has_bass, MusicalNote bass, ChordType type, ChordAccent accent, int inversion)
Creates a ChordDescriptor.
static utils::Utf8String chord_type_to_string(ChordType type)
Returns the chord type as a string (eg.
std::array< bool, MAX_NOTES > notes_
Only used if custom chord.
static utils::Utf8String note_to_string(MusicalNote note)
Returns the musical note as a string (eg.
MusicalNote bass_note_
Bass note 1 octave below.
bool is_key_bass(MusicalNote key) const
Returns if key is the bass or root note of chord.
bool is_key_in_chord(MusicalNote key) const
Returns if the given key is in the chord represented by the given ChordDescriptor.
static utils::Utf8String chord_accent_to_string(ChordAccent accent)
Returns the chord accent as a string (eg.
Lightweight UTF-8 string wrapper with safe conversions.