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
Fields§
§frequencies: Vec<f32>Frequency in Hz for each MIDI note 0–127.
name: StringHuman-readable name.
description: StringDescription of the tuning system.
Implementations§
Source§impl TuningTable
impl TuningTable
Sourcepub fn equal_temperament(concert_a: f32) -> Self
pub fn equal_temperament(concert_a: f32) -> Self
Standard 12-tone equal temperament. A4 (MIDI note 69) = concert_a Hz (typically 440.0).
Examples found in repository?
10fn main() {
11 println!("AetherDSP MIDI - Tuning System Comparison");
12 println!("==========================================\n");
13
14 // Create tuning tables (all use A4=440Hz)
15 let equal_temp = TuningTable::equal_temperament(440.0);
16 let tizita = TuningTable::ethiopian_tizita(440.0);
17 let rast = TuningTable::arabic_maqam_rast(440.0);
18 let yaman = TuningTable::indian_raga_yaman(440.0);
19
20 println!("Comparing tuning systems for one octave (C4-C5):\n");
21 println!("{:4} | {:>10} | {:>10} | {:>10} | {:>10} | {:>8}",
22 "MIDI", "12-TET", "Tizita", "Rast", "Yaman", "Cents");
23 println!("{}", "-".repeat(70));
24
25 // Compare middle C octave (MIDI 60-72)
26 for midi_note in 60..=72 {
27 let freq_12tet = equal_temp.frequency(midi_note);
28 let freq_tizita = tizita.frequency(midi_note);
29 let freq_rast = rast.frequency(midi_note);
30 let freq_yaman = yaman.frequency(midi_note);
31
32 // Calculate cents deviation from 12-TET
33 let cents_tizita: f32 = 1200.0 * (freq_tizita / freq_12tet).log2();
34 let cents_rast: f32 = 1200.0 * (freq_rast / freq_12tet).log2();
35 let cents_yaman: f32 = 1200.0 * (freq_yaman / freq_12tet).log2();
36
37 let note_name = get_note_name(midi_note);
38
39 println!("{:4} | {:10.2} | {:10.2} | {:10.2} | {:10.2} | {:+8.1}",
40 format!("{} ({})", midi_note, note_name),
41 freq_12tet,
42 freq_tizita,
43 freq_rast,
44 freq_yaman,
45 cents_tizita.max(cents_rast).max(cents_yaman)
46 );
47 }
48
49 println!("\n📊 Key Observations:");
50 println!(" • Ethiopian Tizita: Pentatonic scale with characteristic flat intervals");
51 println!(" • Arabic Maqam Rast: Quarter-tone flats on 3rd and 7th degrees");
52 println!(" • Indian Raga Yaman: Just intonation with raised 4th (Kalyan thaat)");
53 println!(" • Cents: Deviation from 12-TET (100 cents = 1 semitone)");
54
55 println!("\n✓ Try these tuning systems in your music!");
56}Sourcepub fn from_cents_offsets(concert_a: f32, offsets: &[f32; 12]) -> Self
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).
Sourcepub fn from_frequencies(
freqs: Vec<f32>,
name: &str,
description: &str,
) -> Option<Self>
pub fn from_frequencies( freqs: Vec<f32>, name: &str, description: &str, ) -> Option<Self>
Build from explicit frequency list. Length must be 128.
Sourcepub fn frequency(&self, note: u8) -> f32
pub fn frequency(&self, note: u8) -> f32
Get frequency for a MIDI note number.
Examples found in repository?
10fn main() {
11 println!("AetherDSP MIDI - Tuning System Comparison");
12 println!("==========================================\n");
13
14 // Create tuning tables (all use A4=440Hz)
15 let equal_temp = TuningTable::equal_temperament(440.0);
16 let tizita = TuningTable::ethiopian_tizita(440.0);
17 let rast = TuningTable::arabic_maqam_rast(440.0);
18 let yaman = TuningTable::indian_raga_yaman(440.0);
19
20 println!("Comparing tuning systems for one octave (C4-C5):\n");
21 println!("{:4} | {:>10} | {:>10} | {:>10} | {:>10} | {:>8}",
22 "MIDI", "12-TET", "Tizita", "Rast", "Yaman", "Cents");
23 println!("{}", "-".repeat(70));
24
25 // Compare middle C octave (MIDI 60-72)
26 for midi_note in 60..=72 {
27 let freq_12tet = equal_temp.frequency(midi_note);
28 let freq_tizita = tizita.frequency(midi_note);
29 let freq_rast = rast.frequency(midi_note);
30 let freq_yaman = yaman.frequency(midi_note);
31
32 // Calculate cents deviation from 12-TET
33 let cents_tizita: f32 = 1200.0 * (freq_tizita / freq_12tet).log2();
34 let cents_rast: f32 = 1200.0 * (freq_rast / freq_12tet).log2();
35 let cents_yaman: f32 = 1200.0 * (freq_yaman / freq_12tet).log2();
36
37 let note_name = get_note_name(midi_note);
38
39 println!("{:4} | {:10.2} | {:10.2} | {:10.2} | {:10.2} | {:+8.1}",
40 format!("{} ({})", midi_note, note_name),
41 freq_12tet,
42 freq_tizita,
43 freq_rast,
44 freq_yaman,
45 cents_tizita.max(cents_rast).max(cents_yaman)
46 );
47 }
48
49 println!("\n📊 Key Observations:");
50 println!(" • Ethiopian Tizita: Pentatonic scale with characteristic flat intervals");
51 println!(" • Arabic Maqam Rast: Quarter-tone flats on 3rd and 7th degrees");
52 println!(" • Indian Raga Yaman: Just intonation with raised 4th (Kalyan thaat)");
53 println!(" • Cents: Deviation from 12-TET (100 cents = 1 semitone)");
54
55 println!("\n✓ Try these tuning systems in your music!");
56}Sourcepub fn freq_to_note_cents(&self, freq: f32) -> (u8, f32)
pub fn freq_to_note_cents(&self, freq: f32) -> (u8, f32)
Convert frequency to the nearest MIDI note + cents deviation.
Sourcepub fn ethiopian_tizita(concert_a: f32) -> Self
pub fn ethiopian_tizita(concert_a: f32) -> Self
Ethiopian Kiñit (pentatonic) approximation. Uses the Tizita major scale pattern.
Examples found in repository?
10fn main() {
11 println!("AetherDSP MIDI - Tuning System Comparison");
12 println!("==========================================\n");
13
14 // Create tuning tables (all use A4=440Hz)
15 let equal_temp = TuningTable::equal_temperament(440.0);
16 let tizita = TuningTable::ethiopian_tizita(440.0);
17 let rast = TuningTable::arabic_maqam_rast(440.0);
18 let yaman = TuningTable::indian_raga_yaman(440.0);
19
20 println!("Comparing tuning systems for one octave (C4-C5):\n");
21 println!("{:4} | {:>10} | {:>10} | {:>10} | {:>10} | {:>8}",
22 "MIDI", "12-TET", "Tizita", "Rast", "Yaman", "Cents");
23 println!("{}", "-".repeat(70));
24
25 // Compare middle C octave (MIDI 60-72)
26 for midi_note in 60..=72 {
27 let freq_12tet = equal_temp.frequency(midi_note);
28 let freq_tizita = tizita.frequency(midi_note);
29 let freq_rast = rast.frequency(midi_note);
30 let freq_yaman = yaman.frequency(midi_note);
31
32 // Calculate cents deviation from 12-TET
33 let cents_tizita: f32 = 1200.0 * (freq_tizita / freq_12tet).log2();
34 let cents_rast: f32 = 1200.0 * (freq_rast / freq_12tet).log2();
35 let cents_yaman: f32 = 1200.0 * (freq_yaman / freq_12tet).log2();
36
37 let note_name = get_note_name(midi_note);
38
39 println!("{:4} | {:10.2} | {:10.2} | {:10.2} | {:10.2} | {:+8.1}",
40 format!("{} ({})", midi_note, note_name),
41 freq_12tet,
42 freq_tizita,
43 freq_rast,
44 freq_yaman,
45 cents_tizita.max(cents_rast).max(cents_yaman)
46 );
47 }
48
49 println!("\n📊 Key Observations:");
50 println!(" • Ethiopian Tizita: Pentatonic scale with characteristic flat intervals");
51 println!(" • Arabic Maqam Rast: Quarter-tone flats on 3rd and 7th degrees");
52 println!(" • Indian Raga Yaman: Just intonation with raised 4th (Kalyan thaat)");
53 println!(" • Cents: Deviation from 12-TET (100 cents = 1 semitone)");
54
55 println!("\n✓ Try these tuning systems in your music!");
56}Sourcepub fn just_intonation(concert_a: f32) -> Self
pub fn just_intonation(concert_a: f32) -> Self
Just intonation (pure intervals based on harmonic series).
Source§impl TuningTable
impl TuningTable
Sourcepub fn arabic_maqam_rast(concert_a: f32) -> Self
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.
Examples found in repository?
10fn main() {
11 println!("AetherDSP MIDI - Tuning System Comparison");
12 println!("==========================================\n");
13
14 // Create tuning tables (all use A4=440Hz)
15 let equal_temp = TuningTable::equal_temperament(440.0);
16 let tizita = TuningTable::ethiopian_tizita(440.0);
17 let rast = TuningTable::arabic_maqam_rast(440.0);
18 let yaman = TuningTable::indian_raga_yaman(440.0);
19
20 println!("Comparing tuning systems for one octave (C4-C5):\n");
21 println!("{:4} | {:>10} | {:>10} | {:>10} | {:>10} | {:>8}",
22 "MIDI", "12-TET", "Tizita", "Rast", "Yaman", "Cents");
23 println!("{}", "-".repeat(70));
24
25 // Compare middle C octave (MIDI 60-72)
26 for midi_note in 60..=72 {
27 let freq_12tet = equal_temp.frequency(midi_note);
28 let freq_tizita = tizita.frequency(midi_note);
29 let freq_rast = rast.frequency(midi_note);
30 let freq_yaman = yaman.frequency(midi_note);
31
32 // Calculate cents deviation from 12-TET
33 let cents_tizita: f32 = 1200.0 * (freq_tizita / freq_12tet).log2();
34 let cents_rast: f32 = 1200.0 * (freq_rast / freq_12tet).log2();
35 let cents_yaman: f32 = 1200.0 * (freq_yaman / freq_12tet).log2();
36
37 let note_name = get_note_name(midi_note);
38
39 println!("{:4} | {:10.2} | {:10.2} | {:10.2} | {:10.2} | {:+8.1}",
40 format!("{} ({})", midi_note, note_name),
41 freq_12tet,
42 freq_tizita,
43 freq_rast,
44 freq_yaman,
45 cents_tizita.max(cents_rast).max(cents_yaman)
46 );
47 }
48
49 println!("\n📊 Key Observations:");
50 println!(" • Ethiopian Tizita: Pentatonic scale with characteristic flat intervals");
51 println!(" • Arabic Maqam Rast: Quarter-tone flats on 3rd and 7th degrees");
52 println!(" • Indian Raga Yaman: Just intonation with raised 4th (Kalyan thaat)");
53 println!(" • Cents: Deviation from 12-TET (100 cents = 1 semitone)");
54
55 println!("\n✓ Try these tuning systems in your music!");
56}Sourcepub fn arabic_maqam_bayati(concert_a: f32) -> Self
pub fn arabic_maqam_bayati(concert_a: f32) -> Self
Arabic Maqam Bayati — second most common Arabic maqam. Characteristic half-flat on the 2nd degree.
Sourcepub fn ethiopian_bati(concert_a: f32) -> Self
pub fn ethiopian_bati(concert_a: f32) -> Self
Ethiopian Bati scale — minor pentatonic variant.
Sourcepub fn indian_raga_yaman(concert_a: f32) -> Self
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).
Examples found in repository?
10fn main() {
11 println!("AetherDSP MIDI - Tuning System Comparison");
12 println!("==========================================\n");
13
14 // Create tuning tables (all use A4=440Hz)
15 let equal_temp = TuningTable::equal_temperament(440.0);
16 let tizita = TuningTable::ethiopian_tizita(440.0);
17 let rast = TuningTable::arabic_maqam_rast(440.0);
18 let yaman = TuningTable::indian_raga_yaman(440.0);
19
20 println!("Comparing tuning systems for one octave (C4-C5):\n");
21 println!("{:4} | {:>10} | {:>10} | {:>10} | {:>10} | {:>8}",
22 "MIDI", "12-TET", "Tizita", "Rast", "Yaman", "Cents");
23 println!("{}", "-".repeat(70));
24
25 // Compare middle C octave (MIDI 60-72)
26 for midi_note in 60..=72 {
27 let freq_12tet = equal_temp.frequency(midi_note);
28 let freq_tizita = tizita.frequency(midi_note);
29 let freq_rast = rast.frequency(midi_note);
30 let freq_yaman = yaman.frequency(midi_note);
31
32 // Calculate cents deviation from 12-TET
33 let cents_tizita: f32 = 1200.0 * (freq_tizita / freq_12tet).log2();
34 let cents_rast: f32 = 1200.0 * (freq_rast / freq_12tet).log2();
35 let cents_yaman: f32 = 1200.0 * (freq_yaman / freq_12tet).log2();
36
37 let note_name = get_note_name(midi_note);
38
39 println!("{:4} | {:10.2} | {:10.2} | {:10.2} | {:10.2} | {:+8.1}",
40 format!("{} ({})", midi_note, note_name),
41 freq_12tet,
42 freq_tizita,
43 freq_rast,
44 freq_yaman,
45 cents_tizita.max(cents_rast).max(cents_yaman)
46 );
47 }
48
49 println!("\n📊 Key Observations:");
50 println!(" • Ethiopian Tizita: Pentatonic scale with characteristic flat intervals");
51 println!(" • Arabic Maqam Rast: Quarter-tone flats on 3rd and 7th degrees");
52 println!(" • Indian Raga Yaman: Just intonation with raised 4th (Kalyan thaat)");
53 println!(" • Cents: Deviation from 12-TET (100 cents = 1 semitone)");
54
55 println!("\n✓ Try these tuning systems in your music!");
56}Sourcepub fn gamelan_slendro(_concert_a: f32) -> Self
pub fn gamelan_slendro(_concert_a: f32) -> Self
Javanese Gamelan Slendro — 5-tone scale. Approximate equal division of the octave into 5 parts.
Sourcepub fn gamelan_pelog(concert_a: f32) -> Self
pub fn gamelan_pelog(concert_a: f32) -> Self
Javanese Gamelan Pelog — 7-tone scale with characteristic large and small intervals.
Trait Implementations§
Source§impl Clone for TuningTable
impl Clone for TuningTable
Source§fn clone(&self) -> TuningTable
fn clone(&self) -> TuningTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more