Sha256: e1129c39ef9bd61f12545ff66d99f0ff1cbcaf55b1a1b606bc66f63d77312369
Contents?: true
Size: 1.05 KB
Versions: 73
Compression:
Stored size: 1.05 KB
Contents
module ScaleGenerator open System let chromaticScale = ["C"; "C#"; "D"; "D#"; "E"; "F"; "F#"; "G"; "G#"; "A"; "A#"; "B"] let flatChromaticScale = ["C"; "Db"; "D"; "Eb"; "E"; "F"; "Gb"; "G"; "Ab"; "A"; "Bb"; "B"] let flatKeys = ["F"; "Bb"; "Eb"; "Ab"; "Db"; "Gb"; "d"; "g"; "c"; "f"; "bb"; "eb"] let shift index list = List.skip index list @ List.take index list let intervals = [('m', 1); ('M', 2); ('A', 3)] |> Map.ofList let skipInterval interval scale = List.skip (Map.find interval intervals) scale let pitches tonic intervals = let scale = if List.contains tonic flatKeys then flatChromaticScale else chromaticScale let index = List.findIndex (fun pitch -> String.Equals(pitch, tonic, StringComparison.InvariantCultureIgnoreCase)) scale let shiftedScale = shift index scale match intervals with | None -> shiftedScale | Some x -> x |> List.ofSeq |> List.fold (fun (acc, remainder) item -> (List.head remainder :: acc, skipInterval item remainder)) ([], shiftedScale) |> fst |> List.rev
Version data entries
73 entries across 73 versions & 1 rubygems