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

Describes a musical chord by its root note, type, accent, inversion, and optional bass note. More...

#include <src/dsp/chord_descriptor.h>

Inheritance diagram for zrythm::dsp::ChordDescriptor:
Collaboration diagram for zrythm::dsp::ChordDescriptor:

Data Structures

struct  ChordPitches
 Stack-allocated container for chord MIDI pitches. More...

Public Member Functions

 ChordDescriptor (QObject *parent=nullptr)
 ChordDescriptor (MusicalNote root, ChordType type, ChordAccent accent=ChordAccent::None, int inversion=0, std::optional< MusicalNote > bass=std::nullopt, QObject *parent=nullptr)
MusicalNote rootNote () const
void setRootNote (MusicalNote v)
bool hasBass () const
void setHasBass (bool v)
MusicalNote bassNote () const
void setBassNote (MusicalNote v)
ChordType chordType () const
void setChordType (ChordType v)
ChordAccent chordAccent () const
void setChordAccent (ChordAccent v)
int inversion () const
void setInversion (int v)
QString displayName () const
Q_SIGNAL void rootNoteChanged (zrythm::dsp::chords::MusicalNote note)
Q_SIGNAL void hasBassChanged (bool has)
Q_SIGNAL void bassNoteChanged (zrythm::dsp::chords::MusicalNote note)
Q_SIGNAL void chordTypeChanged (zrythm::dsp::chords::ChordType type)
Q_SIGNAL void chordAccentChanged (zrythm::dsp::chords::ChordAccent accent)
Q_SIGNAL void inversionChanged (int inversion)
Q_SIGNAL void displayNameChanged ()
Q_SIGNAL void changed ()
Q_INVOKABLE bool isKeyInChord (MusicalNote key) const
Q_INVOKABLE bool isKeyBass (MusicalNote key) const
boost::container::static_vector< int, kMaxIntervals > getIntervals () const
 Returns the semitone intervals from root for the current type and accent.
ChordPitches getMidiPitches (std::uint8_t base_pitch=kDefaultBasePitch) const
 Returns the MIDI pitches for this chord's voicing.
int maxInversion () const
int minInversion () const
utils::Utf8String to_string () const
bool isEquivalent (const ChordDescriptor &other) const

Static Public Member Functions

static boost::container::static_vector< int, kMaxIntervals > get_intervals_for_type_and_accent (ChordType type, ChordAccent accent)
 Returns the semitone intervals from root for the given type and accent.
static utils::Utf8String chord_type_to_string (ChordType type)
static utils::Utf8String chord_accent_to_string (ChordAccent accent)
static utils::Utf8String note_to_string (MusicalNote note)

Static Public Attributes

static constexpr std::uint8_t kDefaultBasePitch = 36
static constexpr size_t kMaxIntervals = 12

Properties

zrythm::dsp::chords::MusicalNote rootNote
bool hasBass
zrythm::dsp::chords::MusicalNote bassNote
zrythm::dsp::chords::ChordType chordType
zrythm::dsp::chords::ChordAccent chordAccent
int inversion
QString displayName

Friends

void to_json (nlohmann::json &j, const ChordDescriptor &c)
void from_json (const nlohmann::json &j, ChordDescriptor &c)

Detailed Description

Describes a musical chord by its root note, type, accent, inversion, and optional bass note.

The chord's note content is defined by intervals computed on demand from (type, accent) — no cached derived state.

Definition at line 119 of file chord_descriptor.h.

Constructor & Destructor Documentation

◆ ChordDescriptor() [1/2]

zrythm::dsp::ChordDescriptor::ChordDescriptor ( QObject * parent = nullptr)
inlineexplicit

Definition at line 127 of file chord_descriptor.h.

◆ ChordDescriptor() [2/2]

zrythm::dsp::ChordDescriptor::ChordDescriptor ( MusicalNote root,
ChordType type,
ChordAccent accent = ChordAccent::None,
int inversion = 0,
std::optional< MusicalNote > bass = std::nullopt,
QObject * parent = nullptr )
inline

Definition at line 129 of file chord_descriptor.h.

Member Function Documentation

◆ bassNote()

MusicalNote zrythm::dsp::ChordDescriptor::bassNote ( ) const
inline

Definition at line 178 of file chord_descriptor.h.

◆ chordAccent()

ChordAccent zrythm::dsp::ChordDescriptor::chordAccent ( ) const
inline

Definition at line 205 of file chord_descriptor.h.

◆ chordType()

ChordType zrythm::dsp::ChordDescriptor::chordType ( ) const
inline

Definition at line 193 of file chord_descriptor.h.

◆ get_intervals_for_type_and_accent()

boost::container::static_vector< int, kMaxIntervals > zrythm::dsp::ChordDescriptor::get_intervals_for_type_and_accent ( ChordType type,
ChordAccent accent )
static

Returns the semitone intervals from root for the given type and accent.

e.g., Major = {0, 4, 7}, Minor7 = {0, 3, 7, 10}

◆ getIntervals()

boost::container::static_vector< int, kMaxIntervals > zrythm::dsp::ChordDescriptor::getIntervals ( ) const

Returns the semitone intervals from root for the current type and accent.

e.g., Major = {0, 4, 7}, Minor7 = {0, 3, 7, 10}

◆ getMidiPitches()

ChordPitches zrythm::dsp::ChordDescriptor::getMidiPitches ( std::uint8_t base_pitch = kDefaultBasePitch) const

Returns the MIDI pitches for this chord's voicing.

Applies octave placement, bass note, and inversion. Stack-allocated, realtime-safe.

◆ hasBass()

bool zrythm::dsp::ChordDescriptor::hasBass ( ) const
inline

Definition at line 166 of file chord_descriptor.h.

◆ inversion()

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

Definition at line 217 of file chord_descriptor.h.

◆ minInversion()

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

Definition at line 291 of file chord_descriptor.h.

◆ rootNote()

MusicalNote zrythm::dsp::ChordDescriptor::rootNote ( ) const
inline

Definition at line 154 of file chord_descriptor.h.

◆ setBassNote()

void zrythm::dsp::ChordDescriptor::setBassNote ( MusicalNote v)
inline

Definition at line 179 of file chord_descriptor.h.

◆ setChordAccent()

void zrythm::dsp::ChordDescriptor::setChordAccent ( ChordAccent v)
inline

Definition at line 206 of file chord_descriptor.h.

◆ setChordType()

void zrythm::dsp::ChordDescriptor::setChordType ( ChordType v)
inline

Definition at line 194 of file chord_descriptor.h.

◆ setHasBass()

void zrythm::dsp::ChordDescriptor::setHasBass ( bool v)
inline

Definition at line 167 of file chord_descriptor.h.

◆ setInversion()

void zrythm::dsp::ChordDescriptor::setInversion ( int v)
inline

Definition at line 218 of file chord_descriptor.h.

◆ setRootNote()

void zrythm::dsp::ChordDescriptor::setRootNote ( MusicalNote v)
inline

Definition at line 155 of file chord_descriptor.h.

Field Documentation

◆ kDefaultBasePitch

std::uint8_t zrythm::dsp::ChordDescriptor::kDefaultBasePitch = 36
staticconstexpr

Definition at line 125 of file chord_descriptor.h.

◆ kMaxIntervals

size_t zrythm::dsp::ChordDescriptor::kMaxIntervals = 12
staticconstexpr

Definition at line 248 of file chord_descriptor.h.

Property Documentation

◆ bassNote

zrythm::dsp::chords::MusicalNote zrythm::dsp::ChordDescriptor::bassNote
readwrite

Definition at line 148 of file chord_descriptor.h.

◆ chordAccent

zrythm::dsp::chords::ChordAccent zrythm::dsp::ChordDescriptor::chordAccent
readwrite

Definition at line 150 of file chord_descriptor.h.

◆ chordType

zrythm::dsp::chords::ChordType zrythm::dsp::ChordDescriptor::chordType
readwrite

Definition at line 149 of file chord_descriptor.h.

◆ displayName

QString zrythm::dsp::ChordDescriptor::displayName
read

Definition at line 152 of file chord_descriptor.h.

◆ hasBass

bool zrythm::dsp::ChordDescriptor::hasBass
readwrite

Definition at line 147 of file chord_descriptor.h.

◆ inversion

int zrythm::dsp::ChordDescriptor::inversion
readwrite

Definition at line 151 of file chord_descriptor.h.

◆ rootNote

zrythm::dsp::chords::MusicalNote zrythm::dsp::ChordDescriptor::rootNote
readwrite

Definition at line 146 of file chord_descriptor.h.


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