maiacore 1.10.1
Music analisys library
Key Class Reference

Represents a musical key signature (tonality), including circle of fifths and mode (major/minor). More...

#include <key.h>

Public Member Functions

 Key (int fifthCircle=0, bool isMajorMode=true)
 Constructs a Key from a fifth circle value and mode. More...
 
 Key (const std::string &key)
 Constructs a Key from a key name string (e.g., "C", "Gm"). More...
 
void setFifthCircle (int fifthCircle)
 Sets the fifth circle value (number of accidentals). More...
 
int getFifthCircle () const
 Returns the fifth circle value (number of accidentals). More...
 
void setIsMajorMode (bool isMajorMode)
 Sets the mode of the key (major or minor). More...
 
int isMajorMode () const
 Returns true if the key is major, false if minor. More...
 
std::string getName () const
 Returns the key name as a string (e.g., "C", "Gm"). More...
 
std::string getRelativeKeyName () const
 Returns the relative key name (e.g., for C major returns "Am", for Am returns "C"). More...
 

Detailed Description

Represents a musical key signature (tonality), including circle of fifths and mode (major/minor).

The Key class provides methods for setting and querying the key signature, including conversion between fifth circle values, key names, and relative keys. It is designed for music analysis, computational musicology, and MusicXML processing.

Examples
C:/Users/nyck/Desktop/maialib/maiacore/include/maiacore/chord.h.

Constructor & Destructor Documentation

◆ Key() [1/2]

Key::Key ( int  fifthCircle = 0,
bool  isMajorMode = true 
)

Constructs a Key from a fifth circle value and mode.

Parameters
fifthCircleNumber of accidentals in the circle of fifths (-6 to +11).
isMajorModeTrue for major mode, false for minor mode.

◆ Key() [2/2]

Key::Key ( const std::string &  key)

Constructs a Key from a key name string (e.g., "C", "Gm").

Parameters
keyKey name string.

Member Function Documentation

◆ getFifthCircle()

int Key::getFifthCircle ( ) const

Returns the fifth circle value (number of accidentals).

Returns
Integer in range -6 (Gb) to +11 (B#).

◆ getName()

std::string Key::getName ( ) const

Returns the key name as a string (e.g., "C", "Gm").

Returns
Key name string.

◆ getRelativeKeyName()

std::string Key::getRelativeKeyName ( ) const

Returns the relative key name (e.g., for C major returns "Am", for Am returns "C").

Returns
Relative key name string.

◆ isMajorMode()

int Key::isMajorMode ( ) const

Returns true if the key is major, false if minor.

Returns
1 if major, 0 if minor.

◆ setFifthCircle()

void Key::setFifthCircle ( int  fifthCircle)

Sets the fifth circle value (number of accidentals).

Parameters
fifthCircleNumber of accidentals (-6 to +11).

◆ setIsMajorMode()

void Key::setIsMajorMode ( bool  isMajorMode)

Sets the mode of the key (major or minor).

Parameters
isMajorModeTrue for major, false for minor.

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