maiacore 1.10.1
Music analisys library
Duration Class Reference

Represents the duration of a musical note, supporting multiple temporal representations. More...

#include <duration.h>

Public Member Functions

 Duration (float quarterDuration, int divisionsPerQuarterNote=256)
 Constructs a Duration from a quarter note value. More...
 
 Duration (int ticks, int divisionsPerQuarterNote=256, int actualNotes=1, int normalNotes=1)
 Constructs a Duration from ticks, with optional tuplet information. More...
 
void setQuarterDuration (float quarterDuration, int divisionsPerQuarterNote=256)
 Sets the duration using a quarter note value. More...
 
RhythmFigure getRhythmFigure () const
 Returns the rhythm figure (e.g., QUARTER, EIGHTH) for this duration. More...
 
const std::string getNoteType () const
 Returns the MusicXML note type string for this duration (e.g., "quarter", "eighth"). More...
 
int getDots () const
 Returns the number of dots (augmentation dots) for this duration. More...
 
int getTicks () const
 Returns the duration in ticks. More...
 
int getDivisionsPerQuarterNote () const
 Returns the number of ticks per quarter note. More...
 
const Fraction & getFractionDuration () const
 Returns the duration as a Fraction object. More...
 
std::string getFractionDurationAsString () const
 Returns the duration as a string in fractional notation (e.g., "1/4"). More...
 
float getQuarterDuration () const
 Returns the duration in quarter notes as a float. More...
 
bool isTuplet () const
 Returns true if the duration represents a tuplet (e.g., triplet, quintuplet). More...
 
void setTupleValues (const int actualNotes, const int normalNotes, const std::string &normalType)
 Sets the tuplet values for the duration. More...
 
int getTimeModificationActualNotes () const
 Returns the tuplet numerator (actual notes). More...
 
int getTimeModificationNormalNotes () const
 Returns the tuplet denominator (normal notes). More...
 
std::string getTimeModificationNormalType () const
 Returns the note type string for the tuplet's normal notes. More...
 

Detailed Description

Represents the duration of a musical note, supporting multiple temporal representations.

The Duration class provides methods for converting between quarter note values, ticks, rhythm figures, tuplets, and fractional durations. It is designed for music analysis, computational musicology, and MusicXML processing, allowing precise control over note durations in various formats.

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

Constructor & Destructor Documentation

◆ Duration() [1/2]

Duration::Duration ( float  quarterDuration,
int  divisionsPerQuarterNote = 256 
)

Constructs a Duration from a quarter note value.

Parameters
quarterDurationDuration in quarter notes (e.g., 1.0 for a quarter note, 0.5 for an eighth).
divisionsPerQuarterNoteNumber of ticks per quarter note (default: 256).

◆ Duration() [2/2]

Duration::Duration ( int  ticks,
int  divisionsPerQuarterNote = 256,
int  actualNotes = 1,
int  normalNotes = 1 
)

Constructs a Duration from ticks, with optional tuplet information.

Parameters
ticksDuration in ticks.
divisionsPerQuarterNoteNumber of ticks per quarter note (default: 256).
actualNotesTuplet numerator (default: 1).
normalNotesTuplet denominator (default: 1).

Member Function Documentation

◆ getDivisionsPerQuarterNote()

int Duration::getDivisionsPerQuarterNote ( ) const

Returns the number of ticks per quarter note.

Returns
Divisions per quarter note.

◆ getDots()

int Duration::getDots ( ) const

Returns the number of dots (augmentation dots) for this duration.

Returns
Number of dots (0, 1, or 2).

◆ getFractionDuration()

const Fraction & Duration::getFractionDuration ( ) const

Returns the duration as a Fraction object.

Returns
Fraction representing the duration.

◆ getFractionDurationAsString()

std::string Duration::getFractionDurationAsString ( ) const

Returns the duration as a string in fractional notation (e.g., "1/4").

Returns
String representing the fractional duration.

◆ getNoteType()

const std::string Duration::getNoteType ( ) const

Returns the MusicXML note type string for this duration (e.g., "quarter", "eighth").

Returns
Note type string.

◆ getQuarterDuration()

float Duration::getQuarterDuration ( ) const

Returns the duration in quarter notes as a float.

Returns
Duration in quarter notes.

◆ getRhythmFigure()

RhythmFigure Duration::getRhythmFigure ( ) const

Returns the rhythm figure (e.g., QUARTER, EIGHTH) for this duration.

Returns
RhythmFigure enum value.

◆ getTicks()

int Duration::getTicks ( ) const

Returns the duration in ticks.

Returns
Duration in ticks.

◆ getTimeModificationActualNotes()

int Duration::getTimeModificationActualNotes ( ) const

Returns the tuplet numerator (actual notes).

Returns
Integer representing the actual notes in the tuplet.

◆ getTimeModificationNormalNotes()

int Duration::getTimeModificationNormalNotes ( ) const

Returns the tuplet denominator (normal notes).

Returns
Integer representing the normal notes in the tuplet.

◆ getTimeModificationNormalType()

std::string Duration::getTimeModificationNormalType ( ) const

Returns the note type string for the tuplet's normal notes.

Returns
String representing the normal note type (e.g., "eighth").

◆ isTuplet()

bool Duration::isTuplet ( ) const

Returns true if the duration represents a tuplet (e.g., triplet, quintuplet).

Returns
True if tuplet.

◆ setQuarterDuration()

void Duration::setQuarterDuration ( float  quarterDuration,
int  divisionsPerQuarterNote = 256 
)

Sets the duration using a quarter note value.

Parameters
quarterDurationDuration in quarter notes.
divisionsPerQuarterNoteNumber of ticks per quarter note (default: 256).

◆ setTupleValues()

void Duration::setTupleValues ( const int  actualNotes,
const int  normalNotes,
const std::string &  normalType 
)

Sets the tuplet values for the duration.

Parameters
actualNotesTuplet numerator (number of notes played).
normalNotesTuplet denominator (number of notes expected).
normalTypeNote type for the tuplet (e.g., "eighth").

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