TuningSystem class
Container for data describing a tuning system.
Contents
This class can store and manipulate a set of intervals representing a scale, along with data that can be used to turn scales into tuning systems that spans the entire hearing range.
Constructors, destructors, conversion operators
- TuningSystem ()
- Creates an empty tuning system.
- TuningSystem (const TuningSystem& otherTuningSystem)
- Creates a copy of another tuning system.
- ~TuningSystem ()
- Destructor.
Public functions
- auto numNotes () const -> int noexcept
- Returns the number of notes in the tuning system.
- void setName (String newName) noexcept
- Sets the tuning system's name.
- auto getName () const -> String noexcept
- Returns the tuning system's name.
- void addInterval (float newFrequencyRatio)
- Adds a new interval to the tuning system.
- void setFreqRatio (int intervalNum, float newFreqRatio)
- Sets an interval's frequency ratio to the tonic.
- auto getFreqRatio (int intervalNum) const -> float
- Returns an interval's frequency ratio to the tonic.
- void removeInterval (int intervalNum)
- Removes a frequency ratio.
- void clearIntervals ()
- Removes all frequency ratio.
- void setReferenceFrequency (float newReferenceFreq) noexcept
- Sets the real frequency of a tonic (first scale degree).
- auto getReferenceFrequency () const -> float noexcept
- Returns the real frequency value of a tonic (first scale degree).
- void setRepeatRatio (float newRepeatRatio) noexcept
- Sets the repeat ratio.
- auto getRepeatRatio () const -> float noexcept
- Returns the repeat ratio.
- void setMinInterval (float newMinInterval) noexcept
- Sets the minimum interval.
- auto getMinInterval () const -> float noexcept
- Returns the minimum interval between two notes.
Protected functions
- auto alreadyContains (double freqToCheck) const -> bool
- Returns true if an interval in the intervals array already has the input frequency ratio.
- auto tooCloseToOther (double freqToCheck) const -> bool
- Returns true if the frequency ratio is closer to another interval than the minimum frequency ratio permits.
Function documentation
void TuningSystem:: addInterval (float newFrequencyRatio)
Adds a new interval to the tuning system.
Intervals should have positive values that represent ratios of the intervals' frequencies to the frequency of the tonic as in
As intervals are represented as ratios to the tonic, it is unnecessary to set intervals[0] as the tonic (doing so would just set it to 1 for every tuning system). Thus, the intervals array should be used to store intervals to the tonic. Use the repeat ratio and reference frequency to define the tonic in a more meaningful and useful way.
void TuningSystem:: setFreqRatio (int intervalNum,
float newFreqRatio)
Sets an interval's frequency ratio to the tonic.
void TuningSystem:: setReferenceFrequency (float newReferenceFreq) noexcept
Sets the real frequency of a tonic (first scale degree).
Using the reference frequency, other intervals' real frequency values can be calculated.
void TuningSystem:: setRepeatRatio (float newRepeatRatio) noexcept
Sets the repeat ratio.
Also known as a pseudo-octave, this represents the frequency ratio at which the tuning system will repeat, beginning with the repeat ratio as the tonic.
void TuningSystem:: setMinInterval (float newMinInterval) noexcept
Sets the minimum interval.
This value represents the minimum frequency ratio between any two notes and should be greater than or equal to 1. A value of 1 means that there is no minimum, although a tuning system cannot have two notes with the same interval.
bool TuningSystem:: tooCloseToOther (double freqToCheck) const protected
Returns true if the frequency ratio is closer to another interval than the minimum frequency ratio permits.