Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::MusicalScale Class Reference

Musical scale descriptor. More...

#include <src/dsp/musical_scale.h>

Inheritance diagram for zrythm::dsp::MusicalScale:
Collaboration diagram for zrythm::dsp::MusicalScale:

Public Types

enum class  ScaleType : std::uint8_t {
  Chromatic , Major , Minor , Ionian ,
  Dorian , Phrygian , Lydian , Mixolydian ,
  Aeolian , Locrian , MelodicMinor , HarmonicMinor ,
  WholeTone , MajorPentatonic , MinorPentatonic , OctatonicHalfWhole ,
  OctatonicWholeHalf , Acoustic , HarmonicMajor , PhrygianDominant ,
  MajorLocrian , Algerian , Augmented , DoubleHarmonic ,
  Chinese , Diminished , DominantDiminished , Egyptian ,
  EightToneSpanish , Enigmatic , Geez , Hindu ,
  Hirajoshi , HungarianGypsy , Insen , NeapolitanMajor ,
  NeapolitanMinor , Oriental , RomanianMinor , Altered ,
  Maqam , Yo , BebopLocrian , BebopDominant ,
  BebopMajor , SuperLocrian , EnigmaticMinor , Composite ,
  Bhairav , HungarianMinor , Persian , Iwato ,
  Kumoi , Pelog , Prometheus , PrometheusNeapolitan ,
  PrometheusLiszt , Balinese , Ragatodi , Japanese1 ,
  Japanese2 , Blues , Flamenco , Gypsy ,
  HalfDiminished , In , Istrian , LydianAugmented ,
  Tritone , UkranianDorian
}
 Scale type (name) eg Aeolian. More...

Public Member Functions

 MusicalScale (QObject *parent=nullptr)
 MusicalScale (ScaleType type, MusicalNote root, QObject *parent=nullptr)
auto scaleType () const
void setScaleType (ScaleType type)
Q_SIGNAL void scaleTypeChanged (ScaleType type)
auto rootKey () const
void setRootKey (MusicalNote root_key)
Q_SIGNAL void rootKeyChanged (MusicalNote root_key)
Q_INVOKABLE QString toString () const
Q_INVOKABLE bool containsNote (MusicalNote note) const
 Returns if the given key is in the given MusicalScale.
utils::Utf8String to_string () const
 Prints the MusicalScale to a string.
bool contains_chord (const ChordDescriptor &chord) const
 Returns if all of the chord's notes are in the scale.
bool is_accent_in_scale (MusicalNote chord_root, ChordType type, ChordAccent chord_accent) const
 Returns if the accent is in the scale.
bool is_same_scale (const MusicalScale &other) const

Static Public Member Functions

static const bool * get_notes_for_type (ScaleType type, bool ascending)
 Returns the notes in the given scale.
static std::array< ChordType, 12 > get_triad_types_for_type (ScaleType type, bool ascending)
 Returns the triads in the given scale.
static utils::Utf8String type_to_string (ScaleType type)

Properties

ScaleType scaleType
zrythm::dsp::MusicalNote rootKey

Friends

void init_from (MusicalScale &obj, const MusicalScale &other, utils::ObjectCloneType clone_type)

Detailed Description

Musical scale descriptor.

See also
https://pianoscales.org/

Definition at line 21 of file musical_scale.h.

Member Enumeration Documentation

◆ ScaleType

enum class zrythm::dsp::MusicalScale::ScaleType : std::uint8_t
strong

Scale type (name) eg Aeolian.

Enumerator
Chromatic 

All keys.

Minor 

Natural minor.

Ionian 

Major (same as SCALE_MAJOR).

Aeolian 

Natural minor (same as Minor).

Acoustic 

Lydian dominant.

Definition at line 33 of file musical_scale.h.

Constructor & Destructor Documentation

◆ MusicalScale() [1/2]

zrythm::dsp::MusicalScale::MusicalScale ( QObject * parent = nullptr)
inline

Definition at line 129 of file musical_scale.h.

◆ MusicalScale() [2/2]

zrythm::dsp::MusicalScale::MusicalScale ( ScaleType type,
MusicalNote root,
QObject * parent = nullptr )
inline

Definition at line 130 of file musical_scale.h.

Member Function Documentation

◆ containsNote()

Q_INVOKABLE bool zrythm::dsp::MusicalScale::containsNote ( MusicalNote note) const

Returns if the given key is in the given MusicalScale.

Parameters
noteA note inside a single octave (0-11).

◆ get_notes_for_type()

const bool * zrythm::dsp::MusicalScale::get_notes_for_type ( ScaleType type,
bool ascending )
static

Returns the notes in the given scale.

Parameters
ascendingWhether to get the notes when ascending or descending (some scales have different notes when rising/falling).

◆ get_triad_types_for_type()

std::array< ChordType, 12 > zrythm::dsp::MusicalScale::get_triad_types_for_type ( ScaleType type,
bool ascending )
static

Returns the triads in the given scale.

There will be as many chords are enabled notes in the scale, and the rest of the array will be filled with CHORD_TYPE_NONE.

Parameters
ascendingWhether to get the triads when ascending or descending (some scales have different triads when rising/falling).

◆ is_same_scale()

bool zrythm::dsp::MusicalScale::is_same_scale ( const MusicalScale & other) const
inline

Definition at line 218 of file musical_scale.h.

◆ rootKey()

auto zrythm::dsp::MusicalScale::rootKey ( ) const
inline

Definition at line 155 of file musical_scale.h.

◆ scaleType()

auto zrythm::dsp::MusicalScale::scaleType ( ) const
inline

Definition at line 143 of file musical_scale.h.

◆ setRootKey()

void zrythm::dsp::MusicalScale::setRootKey ( MusicalNote root_key)
inline

Definition at line 156 of file musical_scale.h.

◆ setScaleType()

void zrythm::dsp::MusicalScale::setScaleType ( ScaleType type)
inline

Definition at line 144 of file musical_scale.h.

◆ toString()

Q_INVOKABLE QString zrythm::dsp::MusicalScale::toString ( ) const
inline

Definition at line 167 of file musical_scale.h.

◆ init_from

void init_from ( MusicalScale & obj,
const MusicalScale & other,
utils::ObjectCloneType clone_type )
friend

Definition at line 224 of file musical_scale.h.

Property Documentation

◆ rootKey

zrythm::dsp::MusicalNote zrythm::dsp::MusicalScale::rootKey
readwrite

Definition at line 25 of file musical_scale.h.

◆ scaleType

ScaleType zrythm::dsp::MusicalScale::scaleType
readwrite

Definition at line 24 of file musical_scale.h.


The documentation for this class was generated from the following file: