25class MusicalScale :
public QObject
29 ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
31 zrythm::dsp::chords::MusicalNote rootKey READ rootKey WRITE setRootKey
32 NOTIFY rootKeyChanged)
34 QML_EXTENDED_NAMESPACE (zrythm::dsp::chords)
114 PrometheusNeapolitan,
136 MusicalScale (QObject * parent =
nullptr) : QObject (parent) { }
137 MusicalScale (
ScaleType type, MusicalNote root, QObject * parent =
nullptr)
138 : MusicalScale (parent)
143 Q_DISABLE_COPY_MOVE (MusicalScale)
144 ~MusicalScale ()
override =
default;
150 auto scaleType ()
const {
return type_; }
157 Q_EMIT scaleTypeChanged (type);
160 Q_SIGNAL
void scaleTypeChanged (
ScaleType type);
162 auto rootKey ()
const {
return root_key_; }
163 void setRootKey (MusicalNote root_key)
165 root_key = std::clamp (root_key, MusicalNote::C, MusicalNote::B);
166 if (root_key_ != root_key)
168 root_key_ = root_key;
169 Q_EMIT rootKeyChanged (root_key);
172 Q_SIGNAL
void rootKeyChanged (MusicalNote root_key);
174 Q_INVOKABLE QString toString ()
const;
183 Q_INVOKABLE
static bool
184 scaleContainsNote (
ScaleType type, MusicalNote rootKey, MusicalNote note);
186 Q_INVOKABLE
static QString noteToString (MusicalNote note);
196 Q_INVOKABLE
static QVariantList availableScaleTypes ();
197 Q_INVOKABLE
static QVariantList availableScaleTypesExotic ();
209 Q_INVOKABLE
static QVariantList
220 static std::array<bool, 12>
232 static std::array<ChordType, 12>
240 MusicalNote root_note;
241 ChordType chord_type;
254 static boost::container::static_vector<DiatonicTriad, 12>
270 ChordAccent accent = ChordAccent::None)
const;
276 MusicalNote chord_root,
278 ChordAccent chord_accent)
const;
280 bool is_same_scale (
const MusicalScale &other)
const
282 return type_ == other.type_ && root_key_ == other.root_key_;
286 static constexpr auto kRootKeyKey =
"rootKey"sv;
287 static constexpr auto kTypeKey =
"type"sv;
289 friend void init_from (
294 friend void to_json (nlohmann::json &j,
const MusicalScale &s);
295 friend void from_json (
const nlohmann::json &j,
MusicalScale &s);
302 MusicalNote root_key_ = MusicalNote::A;
304 BOOST_DESCRIBE_CLASS (
MusicalScale, (), (), (), (type_, root_key_))
static Q_INVOKABLE QVariantList getDiatonicChords(ScaleType type, MusicalNote rootKey)
Returns a QVariantList of diatonic chord descriptors for the given scale, each as {display,...
Q_INVOKABLE bool containsChord(MusicalNote root, ChordType type, ChordAccent accent=ChordAccent::None) const
Returns if all of the chord's notes are in the scale.
static boost::container::static_vector< DiatonicTriad, 12 > get_diatonic_triads(ScaleType type, MusicalNote root_note)
Returns the diatonic triads for the given scale and root note.