hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Tuning.Scala.Interval

Contents

Description

Parser for the SCALA intnam.par file.

Synopsis

Documentation

type INTERVAL = (Rational, String) Source #

Interval and name, ie. (3/2,"perfect fifth")

type INTNAM = (Int, [INTERVAL]) Source #

Length prefixed list of INTERVAL.

intnam_search_ratio :: INTNAM -> Rational -> Maybe INTERVAL Source #

Lookup ratio in INTNAM.

db <- load_intnam
intnam_search_ratio db (3/2) == Just (3/2,"perfect fifth")
intnam_search_ratio db (2/3) == Nothing
intnam_search_ratio db (4/3) == Just (4/3,"perfect fourth")
intnam_search_ratio db (31/16) == Just (31/16,"=31st harmonic")
intnam_search_ratio db (64/49) == Just (64 % 49,"=2 septatones or septatonic major third")
map (intnam_search_ratio db) [3/2,4/3,7/4,7/6,9/7,9/8,12/7,14/9]
import Data.Maybe 
mapMaybe (intnam_search_ratio db) [567/512,147/128,21/16,1323/1024,189/128,49/32,441/256,63/32]

intnam_search_fratio :: (Fractional n, Ord n) => n -> INTNAM -> n -> Maybe INTERVAL Source #

Lookup approximate ratio in INTNAM given espilon.

r = [Just (3/2,"perfect fifth"),Just (64/49,"=2 septatones or septatonic major third")]
map (intnam_search_fratio 0.0001 db) [1.5,1.3061] == r

intnam_search_ratio_name_err :: INTNAM -> Rational -> String Source #

Lookup name of interval, or error.

intnam_search_description_ci :: INTNAM -> String -> [INTERVAL] Source #

Lookup interval name in INTNAM, ci = case-insensitive.

db <- load_intnam
intnam_search_description_ci db "didymus" == [(81/80,"syntonic comma, Didymus comma")]

Parser

parse_intnam_entry :: String -> INTERVAL Source #

Parse line from intnam.par

parse_intnam :: [String] -> INTNAM Source #

Parse non-comment lines from intnam.par

IO

load_intnam :: IO INTNAM Source #

parse_intnam of load_dist_file_ln of "intnam.par".

intnam <- load_intnam
fst intnam == 516 -- Scala 2.42p
fst intnam == length (snd intnam)
lookup (129140163/128000000) (snd intnam) == Just "gravity comma"