21class MusicalScale :
public QObject
25 ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
27 zrythm::dsp::MusicalNote rootKey READ rootKey WRITE setRootKey NOTIFY
30 QML_EXTENDED_NAMESPACE (zrythm::dsp)
110 PrometheusNeapolitan,
132 MusicalScale (QObject * parent =
nullptr) : QObject (parent) { }
133 MusicalScale (
ScaleType type, MusicalNote root, QObject * parent =
nullptr)
134 : MusicalScale (parent)
139 Z_DISABLE_COPY_MOVE (MusicalScale)
140 ~MusicalScale ()
override =
default;
146 auto scaleType ()
const {
return type_; }
153 Q_EMIT scaleTypeChanged (type);
156 Q_SIGNAL
void scaleTypeChanged (
ScaleType type);
158 auto rootKey ()
const {
return root_key_; }
159 void setRootKey (MusicalNote root_key)
161 root_key = std::clamp (root_key, MusicalNote::C, MusicalNote::B);
162 if (root_key_ != root_key)
164 root_key_ = root_key;
165 Q_EMIT rootKeyChanged (root_key);
168 Q_SIGNAL
void rootKeyChanged (MusicalNote root_key);
170 Q_INVOKABLE QString toString ()
const {
return to_string ().to_qstring (); }
198 static std::array<ChordType, 12>
217 MusicalNote chord_root,
219 ChordAccent chord_accent)
const;
221 bool is_same_scale (
const MusicalScale &other)
const
223 return type_ == other.type_ && root_key_ == other.root_key_;
227 friend void init_from (
232 obj.type_ = other.type_;
233 obj.root_key_ = other.root_key_;
236 NLOHMANN_DEFINE_TYPE_INTRUSIVE (MusicalScale, type_, root_key_)
243 MusicalNote root_key_ = MusicalNote::A;
245 BOOST_DESCRIBE_CLASS (MusicalScale, (), (), (), (type_, root_key_))