Skip to main content

TuningTable

Struct TuningTable 

Source
pub struct TuningTable {
    pub frequencies: Vec<f32>,
    pub name: String,
    pub description: String,
}
Expand description

Maps MIDI note numbers (0–127) to frequencies in Hz. Stored as Vec<f32> for serde compatibility.

Fields§

§frequencies: Vec<f32>

Frequency in Hz for each MIDI note 0–127.

§name: String

Human-readable name.

§description: String

Description of the tuning system.

Implementations§

Source§

impl TuningTable

Source

pub fn equal_temperament(concert_a: f32) -> Self

Standard 12-tone equal temperament. A4 (MIDI note 69) = concert_a Hz (typically 440.0).

Source

pub fn from_cents_offsets(concert_a: f32, offsets: &[f32; 12]) -> Self

Build a tuning table from cents offsets per semitone within an octave. offsets is a 12-element array of cent offsets from 12-TET for each pitch class (C, C#, D, D#, E, F, F#, G, G#, A, A#, B).

Source

pub fn from_frequencies( freqs: Vec<f32>, name: &str, description: &str, ) -> Option<Self>

Build from explicit frequency list. Length must be 128.

Source

pub fn frequency(&self, note: u8) -> f32

Get frequency for a MIDI note number.

Source

pub fn freq_to_note_cents(&self, freq: f32) -> (u8, f32)

Convert frequency to the nearest MIDI note + cents deviation.

Source

pub fn ethiopian_tizita(concert_a: f32) -> Self

Ethiopian Tizita major — the most common Ethiopian qenet mode. Scale pattern: C - D - E - G - A (major pentatonic). Intervals: M2, M2, m3, M2, m3

NOTE: This implementation uses 12-TET. Traditional Ethiopian performance includes microtonal inflections and flexible intonation that cannot be captured in fixed tuning tables. The scale is defined more by melodic contour and emotional intent than exact intervals.

Source: Ethiopian music theory documentation (Scribd, PubPub, Wikipedia). Equivalent to Western major pentatonic when played in 12-TET.

Source

pub fn ethiopian_tizita_minor(concert_a: f32) -> Self

Ethiopian Tizita minor — nostalgic, melancholic variant of Tizita. Scale pattern: C - D - Eb - G - Ab Intervals: M2, m2, M3, m2, M3

This scale expresses “tizita” (memory, nostalgia, longing) in its minor form, commonly used in slower, more introspective Ethiopian music.

NOTE: Traditional performance includes microtonal inflections.

Source: Ethiopian music theory (PubPub 2022, pianoencyclopedia.com). Pattern documented as C-D-Eb-G-Ab in academic sources.

Source

pub fn just_intonation(concert_a: f32) -> Self

Just intonation (5-limit) — pure intervals based on harmonic series. Uses ratios with prime factors up to 5 (e.g., 3/2, 5/4).

This produces perfectly consonant major thirds (5/4) and perfect fifths (3/2) with no beating, unlike 12-TET which has slight detuning.

Source: Traditional Western just intonation, documented since Ptolemy (2nd century). Note: This is 5-limit JI. For septimal intervals (7/4, 7/6), see just_intonation_7_limit.

Source

pub fn just_intonation_7_limit(concert_a: f32) -> Self

Just intonation (7-limit) — includes septimal intervals. Uses ratios with prime factors up to 7 (e.g., 7/4, 7/6, 7/5).

7-limit JI adds septimal intervals that appear in blues, barbershop harmony, and many non-Western musical traditions. The harmonic seventh (7/4) is significantly flatter than the 12-TET minor seventh, creating a characteristic “bluesy” sound.

Key septimal intervals:

  • 7/6: Septimal minor third (~267 cents, between minor and major third)
  • 7/5: Septimal tritone (~583 cents, slightly flat of 12-TET tritone)
  • 7/4: Harmonic seventh (~969 cents, much flatter than 12-TET minor 7th)

Source: Extended just intonation theory, used by microtonal composers (Harry Partch, Ben Johnston) and in blues/barbershop traditions.

Source§

impl TuningTable

Source

pub fn arabic_maqam_rast(concert_a: f32) -> Self

Arabic Maqam Rast — the most common Arabic maqam. Uses quarter-tone flats on the 3rd and 7th scale degrees.

NOTE: This implementation uses 24-TET (50-cent quarter-tones), which is the modern theoretical standard established by Mikhail Mishaqa (19th century). Historical Arabic music theory (al-Farabi, al-Urmawi) used ratio-based intervals. Performance practice often deviates from both systems based on melodic context and regional tradition.

Source: Modern 24-TET Arabic music theory (24-tone equal temperament).

Source

pub fn arabic_maqam_bayati(concert_a: f32) -> Self

Arabic Maqam Bayati — second most common Arabic maqam. Characteristic half-flat on the 2nd degree.

NOTE: This implementation uses 24-TET (50-cent quarter-tones), which is the modern theoretical standard. Performance practice varies by region and melodic context.

Source: Modern 24-TET Arabic music theory (24-tone equal temperament).

Source

pub fn arabic_maqam_hijaz(concert_a: f32) -> Self

Arabic Maqam Hijaz — characteristic augmented 2nd interval. Tetrachord pattern: semitone - augmented 2nd - semitone (1-3-1).

The Hijaz tetrachord is one of the most distinctive sounds in Arabic music, featuring a large augmented 2nd (300 cents) between the 2nd and 3rd degrees. Also known as “Phrygian dominant” in Western theory and “Freygish” in Jewish music.

Scale structure from root: C - Db - E - F - G - Ab - B - C Intervals: semitone (100¢), augmented 2nd (300¢), semitone (100¢), whole tone (200¢), semitone (100¢), augmented 2nd (300¢), semitone (100¢)

Source: Traditional Arabic maqam theory, documented in maqamworld.com and ethnomusicological literature.

Source

pub fn ethiopian_bati(concert_a: f32) -> Self

Ethiopian Bati minor — the most common Bati variant. Scale pattern: C - Eb - F - G - Bb (minor pentatonic) Intervals: m3, M2, M2, m3, M2

This is equivalent to the Western minor pentatonic scale and is the standard “Bati” used in Ethiopian music. It expresses melancholy and depth.

NOTE: Traditional performance includes microtonal inflections.

Source: Ethiopian music theory. Documented as equivalent to Western minor pentatonic in Timothy Johnson’s research (Scribd 2018).

Source

pub fn ethiopian_bati_major(concert_a: f32) -> Self

Ethiopian Bati major — bright, uplifting variant of Bati. Scale pattern: C - E - F - G - B Intervals: M3, m2, M2, M3, m2

This scale creates a distinctly Ethiopian sound through its unusual interval structure, particularly the major third followed by a semitone. Less common than Bati minor but used for more joyful or energetic pieces.

NOTE: Traditional performance includes microtonal inflections.

Source: Ethiopian music theory (PubPub 2022). Pattern documented as C-E-F-G-B in academic sources.

Source

pub fn ethiopian_ambassel(concert_a: f32) -> Self

Ethiopian Ambassel — pentatonic with raised 4th. Scale pattern: C - Db - F - G - Ab Intervals: m2, M3, M2, m2, M3

Ambassel (also spelled Ambasel or Ambessel) is characterized by its prominent use of the flat 2nd degree, creating a sound similar to Phrygian mode. The raised 4th (F natural) distinguishes it from Bati.

The scale structure creates characteristic “long intervals” (major 3rds) that are a hallmark of Ethiopian pentatonic music.

NOTE: Traditional performance includes microtonal inflections.

Source: Wikipedia “Ambassel scale” (2025). Documented as pentatonic subset of Phrygian: 1, ♭2, 4, 5, ♭6 (C-Db-F-G-Ab).

Source

pub fn ethiopian_anchihoye(concert_a: f32) -> Self

Ethiopian Anchihoye — the fourth main qenet mode. Scale pattern: C - D - F - G - A Intervals: M2, m3, M2, M2, m3

Anchihoye (also spelled Anchi Hoye or አንቺሆዬ in Amharic) is one of the four fundamental qenet modes of Ethiopian music. This scale has a unique character distinct from the other modes, with its specific pattern of whole and minor third intervals.

NOTE: Documentation on Anchihoye is limited compared to other qenet modes. This implementation uses the most commonly referenced interval pattern, but traditional performance practice may include microtonal variations.

Source: Ethiopian music theory documentation (Scribd, Wikipedia “Qenet”). Pattern inferred from pentatonic analysis and Ethiopian musical traditions.

Source

pub fn indian_raga_yaman(concert_a: f32) -> Self

Indian Raga Yaman (Kalyan thaat) — the most common North Indian raga. Uses a raised 4th (Ma tivra).

This implementation uses just intonation ratios from Sa (root): Sa Re Ga Ma# Pa Dha Ni Sa = 1/1, 9/8, 5/4, 45/32, 3/2, 5/3, 15/8, 2/1

Source: North Indian classical music theory, just intonation ratios.

Source

pub fn gamelan_slendro(_concert_a: f32) -> Self

Javanese Gamelan Slendro — 5-tone scale. Approximate equal division of the octave into 5 parts.

NOTE: This uses exact 2:1 octaves (1200 cents). Real gamelan ensembles often have stretched octaves (~1210-1215 cents) due to inharmonic overtones of bronze/iron bars. For stretched octave version, see gamelan_slendro_stretched.

Source: Generic approximation. Real gamelan tunings vary by ensemble. Reference: “On the Tuning and Stretched Octave of Javanese Gamelans” (2016).

Source

pub fn gamelan_slendro_stretched(_concert_a: f32) -> Self

Javanese Gamelan Slendro with stretched octave — ethnomusicologically accurate.

Real Javanese gamelan instruments have stretched octaves due to the inharmonic overtones of bronze and iron bars. Measurements show octaves ranging from approximately 1210-1215 cents (not the Western 1200 cents).

This implementation uses 1210-cent octaves, dividing them into 5 roughly equal steps of ~242 cents each. This creates the characteristic “pseudo-octave” sound of authentic gamelan.

Source: “On the Tuning and Stretched Octave of Javanese Gamelans” (JHU Muse, 2016), “Ombak and octave stretching in Balinese gamelan” (ResearchGate, 2020).

Source

pub fn gamelan_pelog(concert_a: f32) -> Self

Javanese Gamelan Pelog — 7-tone scale with characteristic large and small intervals.

NOTE: Pelog tuning varies dramatically between gamelan ensembles. This is a generic approximation using commonly cited interval patterns. Real gamelan instruments are tuned individually and not intended to match Western pitch standards or other ensembles.

For authentic reproduction, measure a specific ensemble or use documented measurements from ethnomusicological studies.

Source: Generic approximation. Reference: “Javanese Pelog Tunings Reconsidered” (1980).

Trait Implementations§

Source§

impl Clone for TuningTable

Source§

fn clone(&self) -> TuningTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TuningTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TuningTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TuningTable

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TuningTable

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.