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

Twelve-tone equal temperament relative to a Tuning. More...

#include <EqualTemperament.h>

Collaboration diagram for MCC::EqualTemperament:
Collaboration graph

Public Member Functions

constexpr EqualTemperament () noexcept
 Creates the invalid temperament (SPEC-ERR-2).
constexpr EqualTemperament (MCC::Tuning tuning) noexcept
 Creates the temperament for tuning.
constexpr bool IsValid () const noexcept
 Returns true when the tuning is valid.
constexpr MCC::Tuning Tuning () const noexcept
 Returns the tuning reference.
MCC_CONSTEXPR14 float Frequency (MCC::Pitch pitch) const noexcept
 Returns the frequency of pitch in hertz.

Static Public Member Functions

static constexpr EqualTemperament Standard () noexcept
 Returns equal temperament with A4 = 440 Hz (SPEC-OCT-2).

Friends

constexpr bool operator== (EqualTemperament a, EqualTemperament b) noexcept
 Equality of tunings.
constexpr bool operator!= (EqualTemperament a, EqualTemperament b) noexcept

Detailed Description

Twelve-tone equal temperament relative to a Tuning.

A pitch n semitones above the reference sounds at referenceFrequency * 2^(n / 12). Enharmonic pitches share a frequency. The frequency is computed from a table of the twelve semitone ratios and exact octave doublings, without pow() or the math library.

Default construction produces the invalid temperament (invalid tuning).

Member Function Documentation

◆ Frequency()

MCC_CONSTEXPR14 float MCC::EqualTemperament::Frequency ( MCC::Pitch pitch) const
inlinenoexcept

Returns the frequency of pitch in hertz.

Returns 0 when the temperament or the pitch is invalid, or when the frequency exceeds the largest finite float (SPEC-ERR-5, SPEC-ERR-7). Under A4 = 440 Hz that happens above B123; every lower pitch down to octave -128 has a finite positive frequency.


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