maiacore 1.10.1
Music analisys library
Clef Class Reference

Represents a musical clef for a staff, including sign, line, and change status. More...

#include <clef.h>

Public Member Functions

 Clef (const ClefSign sign=ClefSign::G, int line=-1)
 Constructs a Clef with a given sign and line. More...
 
 ~Clef ()
 Destructor.
 
int getLine () const
 Returns the staff line for the clef. More...
 
void setLine (int line)
 Sets the staff line for the clef. More...
 
ClefSign getSign () const
 Returns the clef sign (G, F, C, percussion). More...
 
void setSign (const ClefSign sign)
 Sets the clef sign and updates the staff line accordingly. More...
 
bool isClefChanged () const
 Returns true if the clef has changed in the current measure. More...
 
std::string getClefSignStr () const
 Returns the clef sign as a string ("G", "F", "C", "percussion"). More...
 
std::string toXML (const int clefNumber=-1, const int identSize=2) const
 Serializes the clef to MusicXML format. More...
 

Static Public Member Functions

static ClefSign clefSignStr2ClefSign (const std::string &clefStr)
 Converts a clef sign string to a ClefSign enum value. More...
 

Detailed Description

Represents a musical clef for a staff, including sign, line, and change status.

The Clef class provides methods for setting and querying the clef sign (G, F, C, percussion), the staff line on which the clef appears, and whether the clef has changed in the current measure. It supports MusicXML serialization and is designed for music analysis, computational musicology, and MusicXML processing.

Constructor & Destructor Documentation

◆ Clef()

Clef::Clef ( const ClefSign  sign = ClefSign::G,
int  line = -1 
)

Constructs a Clef with a given sign and line.

Parameters
signClef sign (default: G).
lineStaff line for the clef (default: -1, auto-detect).

Member Function Documentation

◆ clefSignStr2ClefSign()

static ClefSign Clef::clefSignStr2ClefSign ( const std::string &  clefStr)
static

Converts a clef sign string to a ClefSign enum value.

Parameters
clefStrClef sign string ("G", "F", "C", "percussion").
Returns
ClefSign enum value.

◆ getClefSignStr()

std::string Clef::getClefSignStr ( ) const

Returns the clef sign as a string ("G", "F", "C", "percussion").

Returns
String representation of the clef sign.

◆ getLine()

int Clef::getLine ( ) const

Returns the staff line for the clef.

Returns
Integer representing the staff line.

◆ getSign()

ClefSign Clef::getSign ( ) const

Returns the clef sign (G, F, C, percussion).

Returns
ClefSign enum value.

◆ isClefChanged()

bool Clef::isClefChanged ( ) const

Returns true if the clef has changed in the current measure.

Returns
True if clef changed.

◆ setLine()

void Clef::setLine ( int  line)

Sets the staff line for the clef.

Only applicable for C and percussion clefs.

Parameters
lineNew staff line.

◆ setSign()

void Clef::setSign ( const ClefSign  sign)

Sets the clef sign and updates the staff line accordingly.

Parameters
signNew clef sign.

◆ toXML()

std::string Clef::toXML ( const int  clefNumber = -1,
const int  identSize = 2 
) const

Serializes the clef to MusicXML format.

Parameters
clefNumberClef number (default: -1 for single staff).
identSizeIndentation size (default: 2).
Returns
MusicXML string for the clef.

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