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

A ChordDescriptor describes a chord and is not linked to any specific object by itself. More...

#include <src/dsp/chord_descriptor.h>

Collaboration diagram for zrythm::dsp::ChordDescriptor:

Public Member Functions

 ChordDescriptor (MusicalNote root, bool has_bass, MusicalNote bass, ChordType type, ChordAccent accent, int inversion)
 Creates a ChordDescriptor.
int get_max_inversion () const
int get_min_inversion () const
bool is_key_in_chord (MusicalNote key) const
 Returns if the given key is in the chord represented by the given ChordDescriptor.
bool is_key_bass (MusicalNote key) const
 Returns if key is the bass or root note of chord.
utils::Utf8String to_string () const
 Returns the chord in human readable string.
void update_notes ()
 Updates the notes array based on the current settings.

Static Public Member Functions

static utils::Utf8String chord_type_to_string (ChordType type)
 Returns the chord type as a string (eg.
static utils::Utf8String chord_accent_to_string (ChordAccent accent)
 Returns the chord accent as a string (eg.
static utils::Utf8String note_to_string (MusicalNote note)
 Returns the musical note as a string (eg.

Data Fields

NLOHMANN_DEFINE_TYPE_INTRUSIVE(ChordDescriptor, has_bass_, root_note_, bass_note_, type_, accent_, notes_, inversion_) public MusicalNote root_note_ = MusicalNote::C
 Has bass note or not.
MusicalNote bass_note_ = MusicalNote::C
 Bass note 1 octave below.
ChordType type_ = ChordType::None
 Chord type.
ChordAccent accent_ = ChordAccent::None
 Chord accent.
std::array< bool, MAX_NOTES > notes_ {}
 Only used if custom chord.
int inversion_ = 0
 0 no inversion, less than 0 highest note(s) drop an octave, greater than 0 lowest note(s) receive an octave.

Static Public Attributes

static constexpr size_t MAX_NOTES = 48

Friends

bool operator== (const ChordDescriptor &lhs, const ChordDescriptor &rhs)

Detailed Description

A ChordDescriptor describes a chord and is not linked to any specific object by itself.

Chord objects should include a ChordDescriptor.

Definition at line 82 of file chord_descriptor.h.

Constructor & Destructor Documentation

◆ ChordDescriptor()

zrythm::dsp::ChordDescriptor::ChordDescriptor ( MusicalNote root,
bool has_bass,
MusicalNote bass,
ChordType type,
ChordAccent accent,
int inversion )
inline

Creates a ChordDescriptor.

Definition at line 93 of file chord_descriptor.h.

Member Function Documentation

◆ chord_accent_to_string()

utils::Utf8String zrythm::dsp::ChordDescriptor::chord_accent_to_string ( ChordAccent accent)
static

Returns the chord accent as a string (eg.

"j7").

◆ chord_type_to_string()

utils::Utf8String zrythm::dsp::ChordDescriptor::chord_type_to_string ( ChordType type)
static

Returns the chord type as a string (eg.

"aug").

◆ get_max_inversion()

int zrythm::dsp::ChordDescriptor::get_max_inversion ( ) const
inline

Definition at line 106 of file chord_descriptor.h.

◆ get_min_inversion()

int zrythm::dsp::ChordDescriptor::get_min_inversion ( ) const
inline

Definition at line 133 of file chord_descriptor.h.

◆ is_key_bass()

bool zrythm::dsp::ChordDescriptor::is_key_bass ( MusicalNote key) const

Returns if key is the bass or root note of chord.

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

◆ is_key_in_chord()

bool zrythm::dsp::ChordDescriptor::is_key_in_chord ( MusicalNote key) const

Returns if the given key is in the chord represented by the given ChordDescriptor.

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

◆ note_to_string()

utils::Utf8String zrythm::dsp::ChordDescriptor::note_to_string ( MusicalNote note)
static

Returns the musical note as a string (eg.

"C3").

◆ operator==

bool operator== ( const ChordDescriptor & lhs,
const ChordDescriptor & rhs )
friend

Definition at line 177 of file chord_descriptor.h.

Field Documentation

◆ accent_

ChordAccent zrythm::dsp::ChordDescriptor::accent_ = ChordAccent::None

Chord accent.

Does not apply to custom chords.

Definition at line 212 of file chord_descriptor.h.

◆ bass_note_

MusicalNote zrythm::dsp::ChordDescriptor::bass_note_ = MusicalNote::C

Bass note 1 octave below.

Definition at line 202 of file chord_descriptor.h.

◆ inversion_

int zrythm::dsp::ChordDescriptor::inversion_ = 0

0 no inversion, less than 0 highest note(s) drop an octave, greater than 0 lowest note(s) receive an octave.

Definition at line 229 of file chord_descriptor.h.

◆ MAX_NOTES

size_t zrythm::dsp::ChordDescriptor::MAX_NOTES = 48
staticconstexpr

Definition at line 85 of file chord_descriptor.h.

◆ notes_

std::array<bool, MAX_NOTES> zrythm::dsp::ChordDescriptor::notes_ {}

Only used if custom chord.

4 octaves, 1st octave is where bass note is, but bass note should not be part of this.

Starts at C always, from MIDI pitch 36.

Definition at line 222 of file chord_descriptor.h.

◆ root_note_

NLOHMANN_DEFINE_TYPE_INTRUSIVE ( ChordDescriptor, has_bass_, root_note_, bass_note_, type_, accent_, notes_, inversion_) public MusicalNote zrythm::dsp::ChordDescriptor::root_note_ = MusicalNote::C

Has bass note or not.

Root note.

Definition at line 199 of file chord_descriptor.h.

◆ type_

ChordType zrythm::dsp::ChordDescriptor::type_ = ChordType::None

Chord type.

Definition at line 205 of file chord_descriptor.h.


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