Skip to content

Commit

Permalink
added entries in interval comparison tables
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbin committed Jul 29, 2023
1 parent d1f5ae2 commit 7a3fbd9
Show file tree
Hide file tree
Showing 4 changed files with 366 additions and 12 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"microtonal",
"semiton",
"semitons",
"substr",
"textutils",
"uncapitalize",
"Zarlinean"
Expand Down
149 changes: 149 additions & 0 deletions systems/cello/e53/e53.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,152 @@ let%expect_test "tables" =
8z-e53-23577158-53edo │
└───────────┴───────┴───────────┘ |}]
;;

let%expect_test "approximating just and pythagorean intervals" =
let module Kind = struct
type t =
| Exact
| E53
| Equal_temperament
[@@deriving enumerate, sexp_of]
end
in
let module Row = struct
type t =
| Octave
| Pythagorean_major_sixth
| Just_major_sixth
| Pythagorean_minor_sixth
| Just_minor_sixth
| Fifth
| Fourth
| Pythagorean_major_third
| Just_major_third
| Pythagorean_minor_third
| Just_minor_third
| Pythagorean_major_second
| Just_minor_ton
| Pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton
| Just_diatonic_semiton
[@@deriving enumerate, sexp_of]
end
in
let acoustic_interval (interval : Row.t) (kind : Kind.t) =
match (kind : Kind.t) with
| Exact ->
(match interval with
| Octave -> Acoustic_interval.octave
| Pythagorean_major_sixth ->
Acoustic_interval.pythagorean
{ number = Sixth; quality = Major; additional_octaves = 0 }
| Just_major_sixth -> Acoustic_interval.just_major_sixth
| Pythagorean_minor_sixth ->
Acoustic_interval.pythagorean
{ number = Sixth; quality = Minor; additional_octaves = 0 }
| Just_minor_sixth -> Acoustic_interval.just_minor_sixth
| Fifth ->
Acoustic_interval.pythagorean
{ number = Fifth; quality = Perfect; additional_octaves = 0 }
| Fourth ->
Acoustic_interval.pythagorean
{ number = Fourth; quality = Perfect; additional_octaves = 0 }
| Pythagorean_major_third ->
Acoustic_interval.pythagorean
{ number = Third; quality = Major; additional_octaves = 0 }
| Just_major_third -> Acoustic_interval.just_major_third
| Pythagorean_minor_third ->
Acoustic_interval.pythagorean
{ number = Third; quality = Minor; additional_octaves = 0 }
| Just_minor_third -> Acoustic_interval.just_minor_third
| Pythagorean_major_second ->
Acoustic_interval.pythagorean
{ number = Second; quality = Major; additional_octaves = 0 }
| Just_minor_ton -> Acoustic_interval.just_minor_ton
| Pythagorean_diatonic_semiton -> Acoustic_interval.pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton -> Acoustic_interval.pythagorean_chromatic_semiton
| Just_diatonic_semiton -> Acoustic_interval.just_diatonic_semiton)
| Equal_temperament ->
let number_of_divisions =
match interval with
| Octave -> 12
| Pythagorean_major_sixth | Just_major_sixth -> 9
| Pythagorean_minor_sixth | Just_minor_sixth -> 8
| Fifth -> 7
| Fourth -> 5
| Pythagorean_major_third | Just_major_third -> 4
| Pythagorean_minor_third | Just_minor_third -> 3
| Pythagorean_major_second | Just_minor_ton -> 2
| Pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton
| Just_diatonic_semiton -> 1
in
Acoustic_interval.equal_division_of_the_octave ~divisor:12 ~number_of_divisions
| E53 ->
let number_of_divisions =
match interval with
| Octave -> 53
| Pythagorean_major_sixth -> 40
| Just_major_sixth -> 39
| Pythagorean_minor_sixth -> 35
| Just_minor_sixth -> 36
| Fifth -> 31
| Fourth -> 22
| Pythagorean_major_third -> 18
| Just_major_third -> 17
| Pythagorean_minor_third -> 13
| Just_minor_third -> 14
| Pythagorean_major_second -> 9
| Just_minor_ton -> 8
| Pythagorean_diatonic_semiton -> 4
| Pythagorean_chromatic_semiton -> 5
| Just_diatonic_semiton -> 5
in
Acoustic_interval.equal_division_of_the_octave ~divisor:53 ~number_of_divisions
in
let columns =
let cents_column kind =
Ascii_table.Column.create_attr
~align:Right
(Sexp.to_string [%sexp (kind : Kind.t)])
(fun (t : Row.t) ->
acoustic_interval t kind
|> Acoustic_interval.to_cents
|> Float.iround_exn ~dir:`Nearest
|> Int.to_string
|> fun i -> [], i)
in
Ascii_table.Column.(
[ [ create_attr "Interval" (fun (t : Row.t) ->
( []
, Sexp.to_string_hum [%sexp (t : Row.t)]
|> String.substr_replace_all ~pattern:"_" ~with_:" " ))
]
; List.map Kind.all ~f:cents_column
]
|> List.concat)
in
Ascii_table.to_string columns Row.all |> print_endline;
[%expect
{|
┌───────────────────────────────┬───────┬──────┬───────────────────┐
IntervalExactE53Equal_temperament
├───────────────────────────────┼───────┼──────┼───────────────────┤
Octave120012001200
Pythagorean major sixth │ 906906900
Just major sixth │ 884883900
Pythagorean minor sixth │ 792792800
Just minor sixth │ 814815800
Fifth702702700
Fourth498498500
Pythagorean major third │ 408408400
Just major third │ 386385400
Pythagorean minor third │ 294294300
Just minor third │ 316317300
Pythagorean major second │ 204204200
Just minor ton │ 182181200
Pythagorean diatonic semiton │ 9091100
Pythagorean chromatic semiton │ 114113100
Just diatonic semiton │ 112113100
└───────────────────────────────┴───────┴──────┴───────────────────┘ |}]
;;
138 changes: 138 additions & 0 deletions systems/cello/e55/e55.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,141 @@ let%expect_test "tables" =
│ d8-e55-23513161-55edo │
└──────────┴───────┴───────────┘ |}]
;;

let%expect_test "approximating just intervals" =
let module Kind = struct
type t =
| Exact
| E55
| E53
| Equal_temperament
[@@deriving enumerate, sexp_of]
end
in
let module Row = struct
type t =
| Octave
| Just_major_sixth
| Just_minor_sixth
| Fifth
| Fourth
| Just_major_third
| Just_minor_third
| Pythagorean_major_second
| Pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton
| Just_diatonic_semiton
[@@deriving enumerate, sexp_of]
end
in
let acoustic_interval (interval : Row.t) (kind : Kind.t) =
match (kind : Kind.t) with
| Exact ->
(match interval with
| Octave -> Acoustic_interval.octave
| Just_major_sixth -> Acoustic_interval.just_major_sixth
| Just_minor_sixth -> Acoustic_interval.just_minor_sixth
| Fifth ->
Acoustic_interval.pythagorean
{ number = Fifth; quality = Perfect; additional_octaves = 0 }
| Fourth ->
Acoustic_interval.pythagorean
{ number = Fourth; quality = Perfect; additional_octaves = 0 }
| Just_major_third -> Acoustic_interval.just_major_third
| Just_minor_third -> Acoustic_interval.just_minor_third
| Pythagorean_major_second ->
Acoustic_interval.pythagorean
{ number = Second; quality = Major; additional_octaves = 0 }
| Pythagorean_diatonic_semiton -> Acoustic_interval.pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton -> Acoustic_interval.pythagorean_chromatic_semiton
| Just_diatonic_semiton -> Acoustic_interval.just_diatonic_semiton)
| Equal_temperament ->
let number_of_divisions =
match interval with
| Octave -> 12
| Just_major_sixth -> 9
| Just_minor_sixth -> 8
| Fifth -> 7
| Fourth -> 5
| Just_major_third -> 4
| Just_minor_third -> 3
| Pythagorean_major_second -> 2
| Pythagorean_diatonic_semiton
| Pythagorean_chromatic_semiton
| Just_diatonic_semiton -> 1
in
Acoustic_interval.equal_division_of_the_octave ~divisor:12 ~number_of_divisions
| E55 ->
let number_of_divisions =
match interval with
| Octave -> 55
| Just_major_sixth -> 41
| Just_minor_sixth -> 37
| Fifth -> 32
| Fourth -> 23
| Just_major_third -> 18
| Just_minor_third -> 14
| Pythagorean_major_second -> 9
| Pythagorean_diatonic_semiton -> 4
| Pythagorean_chromatic_semiton -> 5
| Just_diatonic_semiton -> 5
in
Acoustic_interval.equal_division_of_the_octave ~divisor:55 ~number_of_divisions
| E53 ->
let number_of_divisions =
match interval with
| Octave -> 53
| Just_major_sixth -> 39
| Just_minor_sixth -> 36
| Fifth -> 31
| Fourth -> 22
| Just_major_third -> 17
| Just_minor_third -> 14
| Pythagorean_major_second -> 9
| Pythagorean_diatonic_semiton -> 4
| Pythagorean_chromatic_semiton -> 5
| Just_diatonic_semiton -> 5
in
Acoustic_interval.equal_division_of_the_octave ~divisor:53 ~number_of_divisions
in
let columns =
let cents_column kind =
Ascii_table.Column.create_attr
~align:Right
(Sexp.to_string [%sexp (kind : Kind.t)])
(fun (t : Row.t) ->
acoustic_interval t kind
|> Acoustic_interval.to_cents
|> Float.iround_exn ~dir:`Nearest
|> Int.to_string
|> fun i -> [], i)
in
Ascii_table.Column.(
[ [ create_attr "Interval" (fun (t : Row.t) ->
( []
, Sexp.to_string_hum [%sexp (t : Row.t)]
|> String.substr_replace_all ~pattern:"_" ~with_:" " ))
]
; List.map Kind.all ~f:cents_column
]
|> List.concat)
in
Ascii_table.to_string columns Row.all |> print_endline;
[%expect
{|
┌───────────────────────────────┬───────┬──────┬──────┬───────────────────┐
IntervalExactE55E53Equal_temperament
├───────────────────────────────┼───────┼──────┼──────┼───────────────────┤
Octave1200120012001200
Just major sixth │ 884895883900
Just minor sixth │ 814807815800
Fifth702698702700
Fourth498502498500
Just major third │ 386393385400
Just minor third │ 316305317300
Pythagorean major second │ 204196204200
Pythagorean diatonic semiton │ 908791100
Pythagorean chromatic semiton │ 114109113100
Just diatonic semiton │ 112109113100
└───────────────────────────────┴───────┴──────┴──────┴───────────────────┘ |}]
;;
Loading

0 comments on commit 7a3fbd9

Please sign in to comment.