Skip to content

Commit

Permalink
Print porcupine layout in EDO analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Woyten committed Jun 21, 2020
1 parent 2ffd5e8 commit afb9f39
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tune-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ The `tune edo` command prints basic information about any EDO scale. The step si
Example output of `tune edo 17`:

```rust
---- Properties of 17-EDO ----
---- Properties of 17-EDO (Meantone) ----

Number of cycles: 1
1 fifth = 10 EDO steps = +705.9c = Pythagorean +3.9c
Expand Down
27 changes: 23 additions & 4 deletions tune-cli/src/edo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@ use std::io;
use tune::{
key::{Keyboard, PianoKey},
ratio::Ratio,
temperament::EqualTemperament,
temperament::{EqualTemperament, TemperamentType},
};

pub fn print_info(mut dst: impl io::Write, num_steps_per_octave: u16) -> io::Result<()> {
let temperament = EqualTemperament::find().by_edo(num_steps_per_octave);
print_temperament(&mut dst, &temperament)?;
match temperament.temperament_type() {
TemperamentType::Meantone => {
if let Some(porcupine) = temperament.as_porcupine() {
writeln!(dst)?;
print_temperament(dst, &porcupine)?;
}
}
TemperamentType::Porcupine => {}
}

Ok(())
}

pub fn print_temperament(
mut dst: impl io::Write,
temperament: &EqualTemperament,
) -> io::Result<()> {
writeln!(
dst,
"---- Properties of {}-EDO ----",
temperament.num_steps_per_octave()
"---- Properties of {}-EDO ({}) ----",
temperament.num_steps_per_octave(),
temperament.temperament_type()
)?;
writeln!(dst)?;

Expand Down Expand Up @@ -52,7 +71,7 @@ pub fn print_info(mut dst: impl io::Write, num_steps_per_octave: u16) -> io::Res
keyboard
.get_key(x, y)
.midi_number()
.rem_euclid(i32::from(num_steps_per_octave)),
.rem_euclid(i32::from(temperament.num_steps_per_octave())),
)?;
}
writeln!(dst)?;
Expand Down
39 changes: 38 additions & 1 deletion tune-cli/tests/snapshots/edo_15.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---- Properties of 15-EDO ----
---- Properties of 15-EDO (Meantone) ----

Number of cycles: 3
1 fifth = 9 EDO steps = +720.0c = Pythagorean +18.0c
Expand Down Expand Up @@ -34,3 +34,40 @@ Number of cycles: 3
12. B / C
13. B^ / C^
14. B^^ / C^^

---- Properties of 15-EDO (Porcupine) ----

Number of cycles: 1
1 fifth = 9 EDO steps = +720.0c = Pythagorean +18.0c
1 primary step = 2 EDO steps
1 secondary step = 3 EDO steps
1 sharp = 1 EDO steps

-- Keyboard layout --
3 5 7 9 11 13 0 2 4 6
6 8 10 12 14 1 3 5 7 9
9 11 13 0 2 4 6 8 10 12
12 14 1 3 5 7 9 11 13 0
0 2 4 6 8 10 12 14 1 3
3 5 7 9 11 13 0 2 4 6
6 8 10 12 14 1 3 5 7 9
9 11 13 0 2 4 6 8 10 12
12 14 1 3 5 7 9 11 13 0
0 2 4 6 8 10 12 14 1 3

-- Scale steps --
0. D
1. Eb / D#
2. E
3. Fb / E#
4. F **Minor 3rd**
5. Gb / F# **Major 3rd**
6. G **4th**
7. G#
8. Ab
9. A **5th**
10. Bb / A#
11. B
12. Cb / B#
13. C
14. Db / C#
2 changes: 1 addition & 1 deletion tune-cli/tests/snapshots/edo_16.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---- Properties of 16-EDO ----
---- Properties of 16-EDO (Meantone) ----

Number of cycles: 1
1 fifth = 9 EDO steps = +675.0c = Pythagorean -27.0c
Expand Down

0 comments on commit afb9f39

Please sign in to comment.