23class MusicalScale :
public QObject
27 ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
29 zrythm::dsp::MusicalNote rootKey READ rootKey WRITE setRootKey NOTIFY
32 QML_EXTENDED_NAMESPACE (zrythm::dsp)
112 PrometheusNeapolitan,
134 MusicalScale (QObject * parent =
nullptr) : QObject (parent) { }
135 MusicalScale (
ScaleType type, MusicalNote root, QObject * parent =
nullptr)
136 : MusicalScale (parent)
141 Q_DISABLE_COPY_MOVE (MusicalScale)
142 ~MusicalScale ()
override =
default;
148 auto scaleType ()
const {
return type_; }
155 Q_EMIT scaleTypeChanged (type);
158 Q_SIGNAL
void scaleTypeChanged (
ScaleType type);
160 auto rootKey ()
const {
return root_key_; }
161 void setRootKey (MusicalNote root_key)
163 root_key = std::clamp (root_key, MusicalNote::C, MusicalNote::B);
164 if (root_key_ != root_key)
166 root_key_ = root_key;
167 Q_EMIT rootKeyChanged (root_key);
170 Q_SIGNAL
void rootKeyChanged (MusicalNote root_key);
172 Q_INVOKABLE QString toString ()
const;
200 static std::array<ChordType, 12>
219 MusicalNote chord_root,
221 ChordAccent chord_accent)
const;
223 bool is_same_scale (
const MusicalScale &other)
const
225 return type_ == other.type_ && root_key_ == other.root_key_;
229 static constexpr auto kRootKeyKey =
"rootKey"sv;
230 static constexpr auto kTypeKey =
"type"sv;
232 friend void init_from (
237 friend void to_json (nlohmann::json &j,
const MusicalScale &s);
238 friend void from_json (
const nlohmann::json &j,
MusicalScale &s);
245 MusicalNote root_key_ = MusicalNote::A;
247 BOOST_DESCRIBE_CLASS (
MusicalScale, (), (), (), (type_, root_key_))