Sha256: f3a146fbbe95b0a7e9f8af76faf20434520a9e8871ab5e302867d3d9a36ceb31
Contents?: true
Size: 986 Bytes
Versions: 323
Compression:
Stored size: 986 Bytes
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 pattern = 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 pattern |> List.ofSeq |> List.fold (fun (acc, remainder) item -> (List.head remainder :: acc, skipInterval item remainder)) ([], shiftedScale) |> fst |> List.rev
Version data entries
323 entries across 323 versions & 1 rubygems