MCC
Loading...
Searching...
No Matches
MCC::NoteValue Class Reference

Exact written note length: a power-of-two base and zero to four dots. More...

#include <NoteValue.h>

Collaboration diagram for MCC::NoteValue:
Collaboration graph

Public Member Functions

constexpr NoteValue () noexcept
 Creates the invalid note value.
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid note value.
constexpr bool IsDotted () const noexcept
 Returns true when this valid value has augmentation dots.
constexpr uint16_t BaseDenominator () const noexcept
 Returns the undotted denominator (1 through 256), or 0.
constexpr uint8_t DotCount () const noexcept
 Returns the number of dots, or InvalidDotCount when invalid.
constexpr uint16_t Numerator () const noexcept
 Returns the exact reduced numerator relative to a whole note.
constexpr uint16_t Denominator () const noexcept
 Returns the exact reduced denominator relative to a whole note.
constexpr NoteValue WithDots (int32_t dots) const noexcept
 Returns the same base with dots, or invalid for bad input.

Static Public Member Functions

static constexpr NoteValue Invalid () noexcept
 Returns the invalid note value.
static constexpr NoteValue Whole (int32_t dots=0) noexcept
 Creates a whole note, optionally augmented by dots.
static constexpr NoteValue Half (int32_t dots=0) noexcept
 Creates a half note, optionally augmented by dots.
static constexpr NoteValue Quarter (int32_t dots=0) noexcept
 Creates a quarter note, optionally augmented by dots.
static constexpr NoteValue Eighth (int32_t dots=0) noexcept
 Creates an eighth note, optionally augmented by dots.
static constexpr NoteValue Sixteenth (int32_t dots=0) noexcept
 Creates a sixteenth note, optionally augmented by dots.
static constexpr NoteValue ThirtySecond (int32_t dots=0) noexcept
 Creates a thirty-second note, optionally augmented by dots.
static constexpr NoteValue SixtyFourth (int32_t dots=0) noexcept
 Creates a sixty-fourth note, optionally augmented by dots.
static constexpr NoteValue OneHundredTwentyEighth (int32_t dots=0) noexcept
 Creates a 128th note, optionally augmented by dots.
static constexpr NoteValue TwoHundredFiftySixth (int32_t dots=0) noexcept
 Creates a 256th note, optionally augmented by dots.
static MCC_CONSTEXPR14 NoteValue FromDenominator (int32_t baseDenominator, int32_t dots=0) noexcept
 Creates a value from the undotted base denominator.

Static Public Attributes

static constexpr uint8_t MaximumDots = 4u
 Largest supported number of augmentation dots.
static constexpr uint8_t InvalidDotCount = 0xFFu
 Sentinel returned by DotCount() for an invalid value.

Friends

constexpr bool operator== (NoteValue a, NoteValue b) noexcept
 Written equality: the base and dot count must both match.
constexpr bool operator!= (NoteValue a, NoteValue b) noexcept
constexpr bool operator< (NoteValue a, NoteValue b) noexcept
 Orders by exact duration, with invalid values after valid values. Written values with equal duration compare equivalent even when their spelling differs.
constexpr bool operator> (NoteValue a, NoteValue b) noexcept
constexpr bool operator<= (NoteValue a, NoteValue b) noexcept
constexpr bool operator>= (NoteValue a, NoteValue b) noexcept

Detailed Description

Exact written note length: a power-of-two base and zero to four dots.

A note value is independent of tempo, clocks and PPQN. Its duration is an exact reduced fraction of a whole note: a quarter note is 1/4, a dotted quarter is 3/8, and a double-dotted quarter is 7/16.

Default construction and invalid factories produce the single invalid value. Invalid values return 0/0 from Numerator() and Denominator().

Member Function Documentation

◆ FromDenominator()

MCC_CONSTEXPR14 NoteValue MCC::NoteValue::FromDenominator ( int32_t baseDenominator,
int32_t dots = 0 )
inlinestaticnoexcept

Creates a value from the undotted base denominator.

baseDenominator must be one of 1, 2, 4, ..., 256; dots must be between zero and MaximumDots. Otherwise the result is invalid.


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