22class MusicalScale :
public QObject
26 ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
28 zrythm::dsp::MusicalNote rootKey READ rootKey WRITE setRootKey NOTIFY
31 QML_EXTENDED_NAMESPACE (zrythm::dsp)
111 PrometheusNeapolitan,
133 MusicalScale (QObject * parent =
nullptr) : QObject (parent) { }
134 MusicalScale (
ScaleType type, MusicalNote root, QObject * parent =
nullptr)
135 : MusicalScale (parent)
140 Z_DISABLE_COPY_MOVE (MusicalScale)
141 ~MusicalScale ()
override =
default;
147 auto scaleType ()
const {
return type_; }
154 Q_EMIT scaleTypeChanged (type);
157 Q_SIGNAL
void scaleTypeChanged (
ScaleType type);
159 auto rootKey ()
const {
return root_key_; }
160 void setRootKey (MusicalNote root_key)
162 root_key = std::clamp (root_key, MusicalNote::C, MusicalNote::B);
163 if (root_key_ != root_key)
165 root_key_ = root_key;
166 Q_EMIT rootKeyChanged (root_key);
169 Q_SIGNAL
void rootKeyChanged (MusicalNote root_key);
171 Q_INVOKABLE QString toString ()
const {
return to_string ().to_qstring (); }
199 static std::array<ChordType, 12>
218 MusicalNote chord_root,
220 ChordAccent chord_accent)
const;
222 bool is_same_scale (
const MusicalScale &other)
const
224 return type_ == other.type_ && root_key_ == other.root_key_;
228 static constexpr auto kRootKeyKey =
"rootKey"sv;
229 static constexpr auto kTypeKey =
"type"sv;
231 friend void init_from (
236 friend void to_json (nlohmann::json &j,
const MusicalScale &s);
237 friend void from_json (
const nlohmann::json &j,
MusicalScale &s);
244 MusicalNote root_key_ = MusicalNote::A;
246 BOOST_DESCRIBE_CLASS (
MusicalScale, (), (), (), (type_, root_key_))