-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell Music Theory -- -- Haskell library for Music Theory @package hmt @version 0.20 -- | Directions in an array. module Music.Theory.Array.Direction -- | (column,row) type LOC n = (n, n) -- | (Δcolumn,Δrow), rows descend, ie. down is positive, up is -- negative. type VEC n = (n, n) vector_add :: Num n => VEC n -> VEC n -> VEC n vector_sub :: Num n => VEC n -> VEC n -> VEC n vector_sum :: Num n => [VEC n] -> VEC n apply_vec :: Num n => LOC n -> VEC n -> LOC n -- | Segment VEC into a sequence of unit steps. -- --
--   let r = [[(0,0)],[(0,1)],[(0,1),(-1,0)],[(0,1),(0,1),(0,1),(-1,0),(-1,0)]]
--   in map segment_vec [(0,0),(0,1),(-1,1),(-2,3)] == r
--   
segment_vec :: Integral n => VEC n -> [VEC n] derive_vec :: Num n => LOC n -> LOC n -> VEC n unfold_path :: Num n => LOC n -> [VEC n] -> [LOC n] type DIRECTION_S = String -- | Directions are D=down, L=left, R=right, U=up. is_direction :: String -> Bool type DIRECTION_C = Char -- | Reads either S|D W|L E|R N|U, reverse lookup gives SWEN. A period -- indicates (0,0). S=south, W=west, E=east, N=north. direction_char_to_vector_tbl :: Num n => [(DIRECTION_C, VEC n)] direction_char_to_vector :: Num n => DIRECTION_C -> VEC n direction_to_vector :: Num n => [DIRECTION_C] -> VEC n vector_to_direction_char :: (Eq n, Num n) => VEC n -> DIRECTION_C -- | Direction sequence to cell references. dir_seq_to_cell_seq :: (String, [String]) -> [String] -- | Godfried T. Toussaint et. al. "The distance geometry of music" -- Journal of Computational Geometry: Theory and Applications -- Volume 42, Issue 5, July, 2009 -- (http://dx.doi.org/10.1016/j.comgeo.2008.04.005) module Music.Theory.Bjorklund -- | Bjorklund state type BJORKLUND_ST a = ((Int, Int), ([[a]], [[a]])) -- | Bjorklund left process bjorklund_left_f :: BJORKLUND_ST a -> BJORKLUND_ST a -- | Bjorklund right process bjorklund_right_f :: BJORKLUND_ST a -> BJORKLUND_ST a -- | Bjorklund process, left & recur or right & recur or halt. bjorklund_f :: BJORKLUND_ST a -> BJORKLUND_ST a -- | Bjorklund's algorithm to construct a binary sequence of n bits -- with k ones such that the k ones are distributed as -- evenly as possible among the (n - k) zeroes. -- --
--   bjorklund (5,9) == [True,False,True,False,True,False,True,False,True]
--   map xdot_ascii (bjorklund (5,9)) == "x.x.x.x.x"
--   
-- --
--   let es = [(2,[3,5]),(3,[4,5,8]),(4,[7,9,12,15]),(5,[6,7,8,9,11,12,13,16]),(6,[7,13]),(7,[8,9,10,12,15,16,17,18]),(8,[17,19]),(9,[14,16,22,23]),(11,[12,24]),(13,[24]),(15,[34])]
--   let es' = concatMap (\(i,j) -> map ((,) i) j) es
--   mapM_ (putStrLn . euler_pp_unicode) es'
--   
-- --
--   > E(2,3) [××·] (12)
--   > E(2,5) [×·×··] (23)
--   > E(3,4) [×××·] (112)
--   > E(3,5) [×·×·×] (221)
--   > E(3,8) [×··×··×·] (332)
--   > E(4,7) [×·×·×·×] (2221)
--   > E(4,9) [×·×·×·×··] (2223)
--   > E(4,12) [×··×··×··×··] (3333)
--   > E(4,15) [×···×···×···×··] (4443)
--   > E(5,6) [×××××·] (11112)
--   > E(5,7) [×·××·××] (21211)
--   > E(5,8) [×·××·××·] (21212)
--   > E(5,9) [×·×·×·×·×] (22221)
--   > E(5,11) [×·×·×·×·×··] (22223)
--   > E(5,12) [×··×·×··×·×·] (32322)
--   > E(5,13) [×··×·×··×·×··] (32323)
--   > E(5,16) [×··×··×··×··×···] (33334)
--   > E(6,7) [××××××·] (111112)
--   > E(6,13) [×·×·×·×·×·×··] (222223)
--   > E(7,8) [×××××××·] (1111112)
--   > E(7,9) [×·×××·×××] (2112111)
--   > E(7,10) [×·××·××·××] (2121211)
--   > E(7,12) [×·××·×·××·×·] (2122122)
--   > E(7,15) [×·×·×·×·×·×·×··] (2222223)
--   > E(7,16) [×··×·×·×··×·×·×·] (3223222)
--   > E(7,17) [×··×·×··×·×··×·×·] (3232322)
--   > E(7,18) [×··×·×··×·×··×·×··] (3232323)
--   > E(8,17) [×·×·×·×·×·×·×·×··] (22222223)
--   > E(8,19) [×··×·×·×··×·×·×··×·] (32232232)
--   > E(9,14) [×·××·××·××·××·] (212121212)
--   > E(9,16) [×·××·×·×·××·×·×·] (212221222)
--   > E(9,22) [×··×·×··×·×··×·×··×·×·] (323232322)
--   > E(9,23) [×··×·×··×·×··×·×··×·×··] (323232323)
--   > E(11,12) [×××××××××××·] (11111111112)
--   > E(11,24) [×··×·×·×·×·×··×·×·×·×·×·] (32222322222)
--   > E(13,24) [×·××·×·×·×·×·××·×·×·×·×·] (2122222122222)
--   > E(15,34) [×··×·×·×·×··×·×·×·×··×·×·×·×··×·×·] (322232223222322)
--   
bjorklund :: (Int, Int) -> [Bool] -- | rotate_right of bjorklund. -- --
--   map xdot_unicode (bjorklund_r 2 (5,16)) == "··×··×··×··×··×·"
--   
bjorklund_r :: Int -> (Int, Int) -> [Bool] -- | Pretty printer, generalise. euler_pp_f :: (Bool -> Char) -> (Int, Int) -> String -- | Unicode form, ie. ×·. -- --
--   euler_pp_unicode (7,12) == "E(7,12) [×·××·×·××·×·] (2122122)"
--   
euler_pp_unicode :: (Int, Int) -> String -- | ASCII form, ie. x.. -- --
--   euler_pp_ascii (7,12) == "E(7,12) [x.xx.x.xx.x.] (2122122)"
--   
euler_pp_ascii :: (Int, Int) -> String -- | xdot notation for pattern. -- --
--   map xdot_ascii (bjorklund (5,9)) == "x.x.x.x.x"
--   
xdot_ascii :: Bool -> Char -- | Unicode variant. -- --
--   map xdot_unicode (bjorklund (5,12)) == "×··×·×··×·×·"
--   map xdot_unicode (bjorklund (5,16)) == "×··×··×··×··×···"
--   
xdot_unicode :: Bool -> Char -- | The iseq of a pattern is the distance between True -- values. -- --
--   iseq (bjorklund (5,9)) == [2,2,2,2,1]
--   
iseq :: [Bool] -> [Int] -- | iseq of pattern as compact string. -- --
--   iseq_str (bjorklund (5,9)) == "(22221)"
--   
iseq_str :: [Bool] -> String -- | Tom Johnson. "Networks". In Conference on Mathematics and Computation -- in Music, Berlin, May 2007. module Music.Theory.Block_Design.Johnson_2007 data Design i Design :: [i] -> [[i]] -> Design i c_7_3_1 :: Num i => [i] b_7_3_1 :: (Ord i, Num i) => ([[i]], [[i]]) d_7_3_1 :: (Enum n, Ord n, Num n) => (Design n, Design n) n_7_3_1 :: Num i => [(i, i)] p_9_3_1 :: Num i => [[i]] b_13_4_1 :: (Enum i, Num i, Ord i) => ([[i]], [[i]]) d_13_4_1 :: (Enum n, Ord n, Num n) => (Design n, Design n) n_13_4_1 :: Num i => [(i, i)] b_12_4_3 :: Integral i => [[i]] n_12_4_3 :: Num i => [(i, i)] -- | http://en.wikipedia.org/wiki/Braille_Patterns module Music.Theory.Braille -- | Braille coding data. Elements are: (ASCII HEX,ASCII CHAR,DOT -- LIST,UNICODE CHAR,MEANING). The dot numbers are in column order. type BRAILLE = (Int, Char, [Int], Char, String) -- | ASCII Char of BRAILLE. braille_ascii :: BRAILLE -> Char -- | Unicode Char of BRAILLE. braille_unicode :: BRAILLE -> Char -- | Dot list of BRAILLE. braille_dots :: BRAILLE -> [Int] -- | ASCII Braille table. -- --
--   all id (map (\(x,c,_,_,_) -> x == fromEnum c) braille_table) == True
--   
braille_table :: [BRAILLE] -- | Lookup BRAILLE value for unicode character. -- --
--   braille_lookup_unicode '⠝' == Just (0x4E,'N',[1,3,4,5],'⠝',"n")
--   
braille_lookup_unicode :: Char -> Maybe BRAILLE -- | Lookup BRAILLE value for ascii character (case invariant). -- --
--   braille_lookup_ascii 'N' == Just (0x4E,'N',[1,3,4,5],'⠝',"n")
--   
braille_lookup_ascii :: Char -> Maybe BRAILLE -- | The arrangement of the 6-dot patterns into decades, sequences -- of (1,10,3) cells. The cell to the left of the decade is the empty -- cell, the two cells to the right are the first two cells of the decade -- shifted right. -- -- For each decade there are two extra cells that shift the first two -- cells of the decade right one place. Subsequent decades are derived by -- simple transformation of the first. The second is the first with the -- addition of dot 3, the third adds dots 3 and -- 6, the fourth adds dot 6 and the fifth shifts the -- first down one row. -- -- The first decade has the 13 of the 16 4-dot patterns, the remaining 3 -- are in the fifth decade, that is they are the three 4-dot patterns -- that are down shifts of a 4-dot pattern. -- --
--   let trimap f (p,q,r) = (f p,f q,f r)
--   let f = map (fromJust . decode) in map (trimap f) braille_64
--   
braille_64 :: [(String, String, String)] -- | Transcribe ASCII to unicode braille. -- --
--   transcribe_unicode "BRAILLE ASCII CHAR GRID" == "⠃⠗⠁⠊⠇⠇⠑⠀⠁⠎⠉⠊⠊⠀⠉⠓⠁⠗⠀⠛⠗⠊⠙"
--   transcribe_unicode "BRAILLE HTML TABLE GRID" == "⠃⠗⠁⠊⠇⠇⠑⠀⠓⠞⠍⠇⠀⠞⠁⠃⠇⠑⠀⠛⠗⠊⠙"
--   
transcribe_unicode :: String -> String -- | Generate a character grid using inidicated values for filled and empty -- cells. -- --
--   let ch = (' ','.')
--   putStrLn$ transcribe_char_grid ch "BRAILLE ASCII CHAR GRID"
--   
-- --
--   let ch = (white_circle,black_circle)
--   putStrLn$ string_html_table $ transcribe_char_grid ch "BRAILLE HTML TABLE GRID"
--   
transcribe_char_grid :: (Char, Char) -> String -> String -- | Generate 6-dot grid given (white,black) values. -- --
--   dots_grid (0,1) [1,2,3,5] == [[1,0],[1,1],[1,0]]
--   
dots_grid :: (c, c) -> [Int] -> [[c]] -- | lines as rows and Char as cells in HTML table. string_html_table :: String -> String -- | Decoding. -- --
--   let t0 = ["⠠⠁⠇⠇⠀⠓⠥⠍⠁⠝⠀⠆⠬⠎⠀⠜⠑⠀⠃⠕⠗⠝⠀⠋⠗⠑⠑⠀⠯⠀⠑⠟⠥⠁⠇⠀⠔⠀⠙⠊⠛⠝⠰⠽⠀⠯⠀⠐⠗⠎⠲"
--            ,"⠠⠮⠽⠀⠜⠑⠀⠢⠙⠪⠫⠀⠾⠀⠗⠂⠎⠕⠝⠀⠯⠀⠒⠎⠉⠊⠰⠑⠀⠯⠀⠩⠙⠀⠁⠉⠞⠀⠞⠪⠜⠙⠎⠀⠐⠕⠀⠁⠝⠕⠤"
--            ,"⠮⠗⠀⠔⠀⠁⠀⠸⠎⠀⠷⠀⠃⠗⠕⠮⠗⠓⠕⠕⠙⠲"]
--   
-- --
--   concatMap (fromMaybe "#" . decode) (concat t0)
--   
decode :: Char -> Maybe String -- | Start and end unicode indices. braille_rng :: Integral i => (i, i) -- | All characters, in sequence. -- --
--   length braille_seq == 256
--   putStrLn braille_seq
--   
braille_seq :: [Char] -- | The nth character, zero indexed. braille_char :: Int -> Char -- | Two element index, 255 * 255 = 65025 places. -- --
--   map braille_ix [100,300]
--   
braille_ix :: Int -> (Char, Char) -- | HTML character encoding (as hex integer). -- --
--   unwords $ map unicode_html braille_seq
--   
unicode_html :: Char -> String -- | White (empty) circle. white_circle :: Char -- | Black (filled) circle. black_circle :: Char -- | Shaded (hatched) circle. shaded_circle :: Char -- | Table of one letter contractions. one_letter_contractions :: [(Char, String)] -- | Database as [[(key,value)]] module Music.Theory.Db.Common type Entry k v = (k, v) type Record k v = [Entry k v] type Db k v = [Record k v] type Key = String type Value = String type Entry' = Entry Key Value type Record' = Record Key Value type Db' = Db Key Value -- | The sequence of keys at Record. record_key_seq :: Record k v -> [k] -- | True if Key is present in Entity. record_has_key :: Eq k => k -> Record k v -> Bool -- | histogram of record_key_seq. record_key_histogram :: Ord k => Record k v -> [(k, Int)] -- | Duplicate keys predicate. record_has_duplicate_keys :: Ord k => Record k v -> Bool -- | Find all associations for key using given equality function. record_lookup_by :: (k -> k -> Bool) -> k -> Record k v -> [v] -- | record_lookup_by of ==. record_lookup :: Eq k => k -> Record k v -> [v] -- | nth element of record_lookup. record_lookup_at :: Eq k => (k, Int) -> Record k v -> Maybe v -- | Variant of record_lookup requiring a unique key. Nothing -- indicates there is no entry, it is an error if duplicate keys -- are present. record_lookup_uniq :: Eq k => k -> Record k v -> Maybe v -- | True if key exists and is unique. record_has_key_uniq :: Eq k => k -> Record k v -> Bool -- | Error variant. record_lookup_uniq_err :: Eq k => k -> Record k v -> v -- | Default value variant. record_lookup_uniq_def :: Eq k => v -> k -> Record k v -> v -- | Remove all associations for key using given equality function. record_delete_by :: (k -> k -> Bool) -> k -> Record k v -> Record k v -- | record_delete_by of ==. record_delete :: Eq k => k -> Record k v -> Record k v -- | Preserves order of occurence. db_key_set :: Ord k => Db k v -> [k] db_lookup_by :: (k -> k -> Bool) -> (v -> v -> Bool) -> k -> v -> Db k v -> [Record k v] db_lookup :: (Eq k, Eq v) => k -> v -> Db k v -> [Record k v] db_has_duplicate_keys :: Ord k => Db k v -> Bool db_key_histogram :: Ord k => Db k v -> [(k, Int)] db_to_table :: Ord k => (Maybe v -> e) -> Db k v -> ([k], [[e]]) record_collate_from :: Eq k => (k, [v]) -> Record k v -> Record k [v] -- | Collate adjacent entries of existing sequence with equal key. record_collate :: Eq k => Record k v -> Record k [v] record_uncollate :: Record k [v] -> Record k v -- | Keys are given in the header, empty fields are omitted from records. module Music.Theory.Db.Csv -- | Load DB from FilePath. db_load_utf8 :: FilePath -> IO Db' db_store_utf8 :: FilePath -> Db' -> IO () -- | key: value database, allows duplicate keys. module Music.Theory.Db.Plain -- | (Record-, Field-, Entry-) separators type Sep = (String, String, String) type Key = String type Value = String type Entry = (Key, [Value]) type Record = [Entry] type Db = [Record] sep_plain :: Sep record_parse :: (String, String) -> String -> Record record_lookup :: Key -> Record -> [Value] record_lookup_at :: (Key, Int) -> Record -> Maybe Value record_has_key :: Key -> Record -> Bool record_lookup_uniq :: Key -> Record -> Maybe Value db_parse :: Sep -> String -> [Record] db_sort :: [(Key, Int)] -> [Record] -> [Record] db_load_utf8 :: Sep -> FilePath -> IO [Record] record_pp :: (String, String) -> Record -> String db_store_utf8 :: Sep -> FilePath -> [Record] -> IO () module Music.Theory.Db.Cli db_load_ty :: String -> FilePath -> IO (Db String String) db_store_ty :: String -> FilePath -> Db String String -> IO () convert :: (String, String) -> (FilePath, FilePath) -> IO () stat :: String -> FilePath -> IO () help :: [String] db_cli :: [String] -> IO () -- | Common music notation duration model. module Music.Theory.Duration type Division = Integer type Dots = Int -- | Common music notation durational model data Duration Duration :: Division -> Int -> Rational -> Duration -- | division of whole note [division] :: Duration -> Division -- | number of dots [dots] :: Duration -> Int -- | tuplet modifier [multiplier] :: Duration -> Rational -- | Are multipliers equal? duration_meq :: Duration -> Duration -> Bool -- | Is multiplier the identity (ie. 1)? duration_m1 :: Duration -> Bool -- | Compare durations with equal multipliers. duration_compare_meq :: Duration -> Duration -> Maybe Ordering -- | Erroring variant of duration_compare_meq. duration_compare_meq_err :: Duration -> Duration -> Ordering -- | True if neither duration is dotted. no_dots :: (Duration, Duration) -> Bool -- | Sum undotted divisions, input is required to be sorted. sum_dur_undotted :: Rational -> (Division, Division) -> Maybe Duration -- | Sum dotted divisions, input is required to be sorted. -- --
--   sum_dur_dotted 1 (4,1,4,1) == Just (Duration 2 1 1)
--   sum_dur_dotted 1 (4,0,2,1) == Just (Duration 1 0 1)
--   sum_dur_dotted 1 (8,1,4,0) == Just (Duration 4 2 1)
--   sum_dur_dotted 1 (16,0,4,2) == Just (Duration 2 0 1)
--   
sum_dur_dotted :: Rational -> (Division, Dots, Division, Dots) -> Maybe Duration -- | Sum durations. Not all durations can be summed, and the present -- algorithm is not exhaustive. -- --
--   import Music.Theory.Duration
--   import Music.Theory.Duration.Name
--   sum_dur quarter_note eighth_note == Just dotted_quarter_note
--   sum_dur dotted_quarter_note eighth_note == Just half_note
--   sum_dur quarter_note dotted_eighth_note == Just double_dotted_quarter_note
--   
sum_dur :: Duration -> Duration -> Maybe Duration -- | Erroring variant of sum_dur. sum_dur_err :: Duration -> Duration -> Duration -- | Standard divisions (from 1 to 256). MusicXml allows 0 for breve and -1 -- for long. Negative divisors can represent any number of longer -- durations, -2 be a breve, -4 a long, -8 a maximus, &etc. divisions_std_set :: [Division] divisions_musicxml_set :: [Division] -- | Durations set derived from divisions_std_set with up to -- k dots. Multiplier of 1. duration_set :: Dots -> [Duration] -- | Table of number of beams at notated division. beam_count_tbl :: [(Division, Int)] -- | Lookup beam_count_tbl. -- --
--   whole_note_division_to_beam_count 32 == Just 3
--   
whole_note_division_to_beam_count :: Division -> Maybe Int -- | Calculate number of beams at Duration. -- --
--   map duration_beam_count [Duration 2 0 1,Duration 16 0 1] == [0,2]
--   
duration_beam_count :: Duration -> Int -- | Table giving MusicXml types for divisions. division_musicxml_tbl :: [(Division, String)] -- | Lookup division_musicxml_tbl. -- --
--   map whole_note_division_to_musicxml_type [2,4] == ["half","quarter"]
--   
whole_note_division_to_musicxml_type :: Division -> String -- | Variant of whole_note_division_to_musicxml_type extracting -- division from Duration, dots & multipler are -- ignored. -- --
--   duration_to_musicxml_type (Duration 4 0 1) == "quarter"
--   
duration_to_musicxml_type :: Duration -> String -- | Table giving Unicode symbols for divisions. division_unicode_tbl :: [(Integer, Char)] -- | Lookup division_unicode_tbl. -- --
--   map whole_note_division_to_unicode_symbol [1,2,4,8] == "𝅝𝅗𝅥𝅘𝅥𝅘𝅥𝅮"
--   
whole_note_division_to_unicode_symbol :: Division -> Char -- | Give Unicode string for Duration. The duration multiplier is -- not written. -- --
--   map duration_to_unicode [Duration 1 2 1,Duration 4 1 1] == ["𝅝𝅭𝅭","𝅘𝅥𝅭"]
--   
duration_to_unicode :: Duration -> String -- | Give Lilypond notation for Duration. Note that the -- duration multiplier is not written. -- --
--   map duration_to_lilypond_type [Duration 2 0 1,Duration 4 1 1] == ["2","4."]
--   
duration_to_lilypond_type :: Duration -> String -- | Duration to **recip notation. -- -- http://humdrum.org/Humdrum/representations/recip.rep.html -- --
--   let d = map (\z -> Duration z 0 1) [0,1,2,4,8,16,32]
--   map duration_recip_pp d == ["0","1","2","4","8","16","32"]
--   
-- --
--   let d = [Duration 1 1 (1/3),Duration 4 1 1,Duration 4 1 (2/3)]
--   map duration_recip_pp d == ["3.","4.","6."]
--   
duration_recip_pp :: Duration -> String -- | Names for note divisions. Starting from 1/32 these names haev uniqe -- initial letters that can be used for concise notation. whole_note_division_name_tbl :: [(Division, String)] whole_note_division_name :: Division -> Maybe String whole_note_division_letter_tbl :: [(Division, Char)] whole_note_division_letter_pp :: Division -> Maybe Char duration_letter_pp :: Duration -> Maybe String instance GHC.Show.Show Music.Theory.Duration.Duration instance GHC.Classes.Eq Music.Theory.Duration.Duration instance GHC.Classes.Ord Music.Theory.Duration.Duration -- | Names for common music notation durations. module Music.Theory.Duration.Name breve :: Duration whole_note :: Duration half_note :: Duration quarter_note :: Duration eighth_note :: Duration sixteenth_note :: Duration thirtysecond_note :: Duration dotted_breve :: Duration dotted_whole_note :: Duration dotted_half_note :: Duration dotted_quarter_note :: Duration dotted_eighth_note :: Duration dotted_sixteenth_note :: Duration dotted_thirtysecond_note :: Duration double_dotted_breve :: Duration double_dotted_whole_note :: Duration double_dotted_half_note :: Duration double_dotted_quarter_note :: Duration double_dotted_eighth_note :: Duration double_dotted_sixteenth_note :: Duration double_dotted_thirtysecond_note :: Duration -- | Abbreviated names for Duration values when written as Haskell -- literals. There are letter names where w is -- whole_note and so on, and numerical names where -- _4 is quarter_note and so on. In both cases a ' -- extension means a dot so that e'' is a double dotted -- eighth_note. The prefix is _ not d since -- d4 etc. are also note names. -- --
--   zipWith duration_compare_meq [e,e,e,e'] [e,s,q,e] == [EQ,GT,LT,GT]
--   zipWith sum_dur [e,q,q'] [e,e,e] == [Just q,Just q',Just h]
--   zipWith sum_dur' [e,q,q'] [e,e,e] == [q,q',h]
--   
module Music.Theory.Duration.Name.Abbreviation w :: Duration h :: Duration q :: Duration e :: Duration s :: Duration w' :: Duration h' :: Duration q' :: Duration e' :: Duration s' :: Duration w'' :: Duration h'' :: Duration q'' :: Duration e'' :: Duration s'' :: Duration _1 :: Duration _2 :: Duration _4 :: Duration _8 :: Duration _16 :: Duration _32 :: Duration _1' :: Duration _2' :: Duration _4' :: Duration _8' :: Duration _16' :: Duration _32' :: Duration _1'' :: Duration _2'' :: Duration _4'' :: Duration _8'' :: Duration _16'' :: Duration _32'' :: Duration -- | Rational quarter-note notation for durations. module Music.Theory.Duration.Rq -- | Rational Quarter-Note type Rq = Rational -- | Table mapping tuple Rq values to Durations. Only has cases where the -- duration can be expressed without a tie. Currently has entries for -- 3-,5-,6- and 7-tuplets. -- --
--   all (\(i,j) -> i == duration_to_rq j) rq_tuplet_duration_table == True
--   
rq_tuplet_duration_table :: [(Rq, Duration)] -- | Lookup rq_tuplet_duration_tbl. -- --
--   rq_tuplet_to_duration (1/3) == Just (Duration 8 0 (2/3))
--   
rq_tuplet_to_duration :: Rq -> Maybe Duration -- | Make table of (Rq,Duration) associations. Only lists durations with a -- multiplier of 1. -- --
--   map (length . rq_plain_duration_tbl) [1,2,3] == [20,30,40]
--   map (multiplier . snd) (rq_plain_duration_tbl 1) == replicate 20 1
--   
rq_plain_duration_tbl :: Dots -> [(Rq, Duration)] rq_plain_to_duration :: Dots -> Rq -> Maybe Duration rq_plain_to_duration_err :: Dots -> Rq -> Duration -- | Rational quarter note to duration value. Lookup composite plain (hence -- dots) and tuplet tables. It is a mistake to hope this could handle -- tuplets directly in a general sense. For instance, a 3:2 -- dotted note is the same duration as a plain undotted note. However it -- does give durations for simple notations of simple tuplet values. -- --
--   rq_to_duration 2 (3/4) == Just (Duration 8 1 1) -- dotted_eighth_note
--   rq_to_duration 2 (1/3) == Just (Duration 8 0 (2/3))
--   
rq_to_duration :: Dots -> Rq -> Maybe Duration -- | Variant of rq_to_duration with error message. rq_to_duration_err :: Show a => a -> Dots -> Rq -> Duration -- | Is Rq a cmn duration (ie. rq_plain_to_duration) -- --
--   map (rq_is_cmn 2) [1/4,1/5,1/8,3/32] == [True,False,True,True]
--   
rq_is_cmn :: Dots -> Rq -> Bool -- | Convert a whole note division integer to an Rq value. -- --
--   map whole_note_division_to_rq [1,2,4,8] == [4,2,1,1/2]
--   
whole_note_division_to_rq :: Division -> Rq -- | Apply dots to an Rq duration. -- --
--   map (rq_apply_dots 1) [1,2] == [1 + 1/2,1 + 1/2 + 1/4]
--   
rq_apply_dots :: Rq -> Dots -> Rq -- | Convert Duration to Rq value, see rq_to_duration -- for partial inverse. -- --
--   let d = [Duration 2 0 1,Duration 4 1 1,Duration 1 1 1]
--   map duration_to_rq d == [2,3/2,6] -- half_note,dotted_quarter_note,dotted_whole_note
--   
duration_to_rq :: Duration -> Rq -- | compare function for Duration via duration_to_rq. -- --
--   half_note `duration_compare_rq` quarter_note == GT
--   
duration_compare_rq :: Duration -> Duration -> Ordering -- | Rq modulo. -- --
--   map (rq_mod (5/2)) [3/2,3/4,5/2] == [1,1/4,0]
--   
rq_mod :: Rq -> Rq -> Rq -- | Is p divisible by q, ie. is the denominator of -- p/q == 1. -- --
--   map (rq_divisible_by (3%2)) [1%2,1%3] == [True,False]
--   
rq_divisible_by :: Rq -> Rq -> Bool -- | Is Rq a whole number (ie. is denominator == -- 1. -- --
--   map rq_is_integral [1,3/2,2] == [True,False,True]
--   
rq_is_integral :: Rq -> Bool -- | Return numerator of Rq if denominator == -- 1. -- --
--   map rq_integral [1,3/2,2] == [Just 1,Nothing,Just 2]
--   
rq_integral :: Rq -> Maybe Integer -- | Derive the tuplet structure of a set of Rq values. -- --
--   rq_derive_tuplet_plain [1/2] == Nothing
--   rq_derive_tuplet_plain [1/2,1/2] == Nothing
--   rq_derive_tuplet_plain [1/4,1/4] == Nothing
--   rq_derive_tuplet_plain [1/3,2/3] == Just (3,2)
--   rq_derive_tuplet_plain [1/2,1/3,1/6] == Just (6,4)
--   rq_derive_tuplet_plain [1/3,1/6] == Just (6,4)
--   rq_derive_tuplet_plain [2/5,3/5] == Just (5,4)
--   rq_derive_tuplet_plain [1/3,1/6,2/5,1/10] == Just (30,16)
--   
-- --
--   map rq_derive_tuplet_plain [[1/3,1/6],[2/5,1/10]] == [Just (6,4)
--                                                        ,Just (10,8)]
--   
rq_derive_tuplet_plain :: [Rq] -> Maybe (Integer, Integer) -- | Derive the tuplet structure of a set of Rq values. -- --
--   rq_derive_tuplet [1/4,1/8,1/8] == Nothing
--   rq_derive_tuplet [1/3,2/3] == Just (3,2)
--   rq_derive_tuplet [1/2,1/3,1/6] == Just (3,2)
--   rq_derive_tuplet [2/5,3/5] == Just (5,4)
--   rq_derive_tuplet [1/3,1/6,2/5,1/10] == Just (15,8)
--   
rq_derive_tuplet :: [Rq] -> Maybe (Integer, Integer) -- | Remove tuplet multiplier from value, ie. to give notated duration. -- This seems odd but is neccessary to avoid ambiguity. Ie. is 1 -- a quarter note or a 3:2 tuplet dotted-quarter-note etc. -- --
--   map (rq_un_tuplet (3,2)) [1,2/3,1/2,1/3] == [3/2,1,3/4,1/2]
--   
rq_un_tuplet :: (Integer, Integer) -> Rq -> Rq -- | If an Rq duration is un-representable by a single cmn -- duration, give tied notation. -- --
--   catMaybes (map rq_to_cmn [1..9]) == [(4,1),(4,3),(8,1)]
--   
-- --
--   map rq_to_cmn [5/4,5/8] == [Just (1,1/4),Just (1/2,1/8)]
--   
rq_to_cmn :: Rq -> Maybe (Rq, Rq) -- | Predicate to determine if a segment can be notated either without a -- tuplet or with a single tuplet. -- --
--   rq_can_notate 2 [1/2,1/4,1/4] == True
--   rq_can_notate 2 [1/3,1/6] == True
--   rq_can_notate 2 [2/5,1/10] == True
--   rq_can_notate 2 [1/3,1/6,2/5,1/10] == False
--   rq_can_notate 2 [4/7,1/7,6/7,3/7] == True
--   rq_can_notate 2 [4/7,1/7,2/7] == True
--   
rq_can_notate :: Dots -> [Rq] -> Bool -- | Duration in seconds of Rq given qpm -- -- qpm = pulses-per-minute, rq = rational-quarter-note -- --
--   map (\sd -> rq_to_seconds_qpm (90 * sd) 1) [1,2,4,8,16] == [2/3,1/3,1/6,1/12,1/24]
--   map (rq_to_seconds_qpm 90) [1,2,3,4] == [2/3,1 + 1/3,2,2 + 2/3]
--   map (rq_to_seconds_qpm 90) [0::Rq,1,1 + 1/2,1 + 3/4,1 + 7/8,2] == [0,2/3,1,7/6,5/4,4/3]
--   
rq_to_seconds_qpm :: Fractional a => a -> a -> a -- | Qpm given that rq has duration x, ie. inverse of -- rq_to_seconds_qpm -- --
--   map (rq_to_qpm 1) [0.4,0.5,0.8,1,1.5,2] == [150,120,75,60,40,30]
--   map (\qpm -> rq_to_seconds_qpm qpm 1) [150,120,75,60,40,30] == [0.4,0.5,0.8,1,1.5,2]
--   
rq_to_qpm :: Fractional a => a -> a -> a -- | Duration annotations. module Music.Theory.Duration.Annotation -- | Standard music notation durational model annotations data D_Annotation Tie_Right :: D_Annotation Tie_Left :: D_Annotation Begin_Tuplet :: (Integer, Integer, Duration) -> D_Annotation End_Tuplet :: D_Annotation -- | Annotated Duration. type Duration_A = (Duration, [D_Annotation]) begin_tuplet :: D_Annotation -> Maybe (Integer, Integer, Duration) da_begin_tuplet :: Duration_A -> Maybe (Integer, Integer, Duration) begins_tuplet :: D_Annotation -> Bool -- | Does Duration_A begin a tuplet? da_begins_tuplet :: Duration_A -> Bool -- | Does Duration_A end a tuplet? da_ends_tuplet :: Duration_A -> Bool -- | Is Duration_A tied to the the right? da_tied_right :: Duration_A -> Bool -- | Annotate a sequence of Duration_A as a tuplet. -- --
--   import Music.Theory.Duration.Name
--   da_tuplet (3,2) [(quarter_note,[Tie_Left]),(eighth_note,[Tie_Right])]
--   
da_tuplet :: (Integer, Integer) -> [Duration_A] -> [Duration_A] -- | Group tuplets into a Tree. Branch nodes have label -- Nothing, leaf nodes label Just Duration_A. -- --
--   import Music.Theory.Duration.Name.Abbreviation
--   
-- --
--   let d = [(q,[])
--           ,(e,[Begin_Tuplet (3,2,e)])
--           ,(s,[Begin_Tuplet (3,2,s)]),(s,[]),(s,[End_Tuplet])
--           ,(e,[End_Tuplet])
--           ,(q,[])]
--   in catMaybes (flatten (da_group_tuplets d)) == d
--   
da_group_tuplets :: [Duration_A] -> Tree (Maybe Duration_A) -- | Variant of break that places separator at left. -- --
--   break_left (== 3) [1..6] == ([1..3],[4..6])
--   break_left (== 3) [1..3] == ([1..3],[])
--   
break_left :: (a -> Bool) -> [a] -> ([a], [a]) -- | Variant of break_left that balances begin & end predicates. -- --
--   break_left (== ')') "test (sep) _) balanced"
--   sep_balanced True (== '(') (== ')') "test (sep) _) balanced"
--   sep_balanced False (== '(') (== ')') "(test (sep) _) balanced"
--   
sep_balanced :: Bool -> (a -> Bool) -> (a -> Bool) -> [a] -> ([a], [a]) -- | Group non-nested tuplets, ie. groups nested tuplets at one level. da_group_tuplets_nn :: [Duration_A] -> [Either Duration_A [Duration_A]] -- | Keep right variant of zip, unused rhs values are returned. -- --
--   zip_kr [1..4] ['a'..'f'] == ([(1,'a'),(2,'b'),(3,'c'),(4,'d')],"ef")
--   
zip_kr :: [a] -> [b] -> ([(a, b)], [b]) -- | zipWith variant that adopts the shape of the lhs. -- --
--   let {p = [Left 1,Right [2,3],Left 4]
--       ;q = "abcd"}
--   in nn_reshape (,) p q == [Left (1,'a'),Right [(2,'b'),(3,'c')],Left (4,'d')]
--   
nn_reshape :: (a -> b -> c) -> [Either a [a]] -> [b] -> [Either c [c]] -- | Does a have Tie_Left and Tie_Right? d_annotated_tied_lr :: [D_Annotation] -> (Bool, Bool) -- | Does d have Tie_Left and Tie_Right? duration_a_tied_lr :: Duration_A -> (Bool, Bool) instance GHC.Show.Show Music.Theory.Duration.Annotation.D_Annotation instance GHC.Classes.Eq Music.Theory.Duration.Annotation.D_Annotation -- | Rq values with tie right qualifier. module Music.Theory.Duration.Rq.Tied -- | Boolean. type Tied_Right = Bool -- | Rq with tie right. type Rq_Tied = (Rq, Tied_Right) -- | If Rq_Tied is not tied, get Rq. rqt_to_rq :: Rq_Tied -> Maybe Rq -- | Erroring variant of rqt_to_rq. rqt_to_rq_err :: Rq_Tied -> Rq -- | Construct Rq_Tied. rqt :: Tied_Right -> Rq -> Rq_Tied -- | Rq field of Rq_Tied. rqt_rq :: Rq_Tied -> Rq -- | Tied field of Rq_Tied. rqt_tied :: Rq_Tied -> Tied_Right -- | Is Rq_Tied tied right. is_tied_right :: Rq_Tied -> Bool -- | Rq_Tied variant of rq_un_tuplet. -- --
--   rqt_un_tuplet (3,2) (1,T) == (3/2,T)
--   
-- --
--   let f = rqt_un_tuplet (7,4)
--   in map f [(2/7,F),(4/7,T),(1/7,F)] == [(1/2,F),(1,T),(1/4,F)]
--   
rqt_un_tuplet :: (Integer, Integer) -> Rq_Tied -> Rq_Tied -- | Transform Rq to untied Rq_Tied. -- --
--   rq_rqt 3 == (3,F)
--   
rq_rqt :: Rq -> Rq_Tied -- | Tie last element only of list of Rq. -- --
--   rq_tie_last [1,2,3] == [(1,F),(2,F),(3,T)]
--   
rq_tie_last :: [Rq] -> [Rq_Tied] -- | Transform a list of Rq_Tied to a list of Duration_A. -- The flag indicates if the initial value is tied left. -- --
--   rqt_to_duration_a False [(1,T),(1/4,T),(3/4,F)]
--   
rqt_to_duration_a :: Bool -> [Rq_Tied] -> [Duration_A] -- | Rq_Tied variant of rq_can_notate. rqt_can_notate :: Dots -> [Rq_Tied] -> Bool -- | Rq_Tied variant of rq_to_cmn. -- --
--   rqt_to_cmn (5,T) == Just ((4,T),(1,T))
--   rqt_to_cmn (5/4,T) == Just ((1,T),(1/4,T))
--   rqt_to_cmn (5/7,F) == Just ((4/7,T),(1/7,F))
--   
rqt_to_cmn :: Rq_Tied -> Maybe (Rq_Tied, Rq_Tied) -- | List variant of rqt_to_cmn. -- --
--   rqt_to_cmn_l (5,T) == [(4,T),(1,T)]
--   
rqt_to_cmn_l :: Rq_Tied -> [Rq_Tied] -- | concatMap rqt_to_cmn_l. -- --
--   rqt_set_to_cmn [(1,T),(5/4,F)] == [(1,T),(1,T),(1/4,F)]
--   rqt_set_to_cmn [(1/5,True),(1/20,False),(1/2,False),(1/4,True)]
--   
rqt_set_to_cmn :: [Rq_Tied] -> [Rq_Tied] -- | Common music notation dynamic marks. module Music.Theory.Dynamic_Mark -- | Enumeration of dynamic mark symbols. data Dynamic_Mark Niente :: Dynamic_Mark Ppppp :: Dynamic_Mark Pppp :: Dynamic_Mark Ppp :: Dynamic_Mark Pp :: Dynamic_Mark P :: Dynamic_Mark Mp :: Dynamic_Mark Mf :: Dynamic_Mark F :: Dynamic_Mark Ff :: Dynamic_Mark Fff :: Dynamic_Mark Ffff :: Dynamic_Mark Fffff :: Dynamic_Mark Fp :: Dynamic_Mark Sf :: Dynamic_Mark Sfp :: Dynamic_Mark Sfpp :: Dynamic_Mark Sfz :: Dynamic_Mark Sffz :: Dynamic_Mark -- | Case insensitive reader for Dynamic_Mark. -- --
--   map dynamic_mark_t_parse_ci (words "pP p Mp F")
--   
dynamic_mark_t_parse_ci :: String -> Maybe Dynamic_Mark -- | Lookup Midi velocity for Dynamic_Mark. The range is linear in -- 0-127. -- --
--   let r = [0,6,17,28,39,50,61,72,83,94,105,116,127]
--   mapMaybe dynamic_mark_midi [Niente .. Fffff] == r
--   
-- --
--   mapMaybe dynamic_mark_midi [Pp .. Ff] == [39,50,61,72,83,94]
--   
-- --
--   map dynamic_mark_midi [Fp,Sf,Sfp,Sfpp,Sfz,Sffz] == replicate 6 Nothing
--   
dynamic_mark_midi :: (Num n, Enum n) => Dynamic_Mark -> Maybe n -- | Error variant. dynamic_mark_midi_err :: Integral n => Dynamic_Mark -> n -- | Map midi velocity (0-127) to dynamic mark. -- --
--   histogram (mapMaybe midi_dynamic_mark [0 .. 127])
--   
midi_dynamic_mark :: (Ord n, Num n, Enum n) => n -> Maybe Dynamic_Mark -- | Translate fixed Dynamic_Marks to db amplitude -- over given range. -- --
--   mapMaybe (dynamic_mark_db 120) [Niente,P,F,Fffff] == [-120,-70,-40,0]
--   mapMaybe (dynamic_mark_db 60) [Niente,P,F,Fffff] == [-60,-35,-20,0]
--   
dynamic_mark_db :: Fractional n => n -> Dynamic_Mark -> Maybe n -- | http://www.csounds.com/manual/html/ampmidid.html -- --
--   import Sound.Sc3.Plot 
--   plot_p1_ln [map (ampmidid 20) [0 .. 127],map (ampmidid 60) [0 .. 127]]
--   
ampmidid :: Floating a => a -> a -> a -- | JMcC (Sc3) equation. -- --
--   plot_p1_ln [map amp_db [0,0.005 .. 1]]
--   
amp_db :: Floating a => a -> a -- | JMcC (Sc3) equation. -- --
--   plot_p1_ln [map db_amp [-60,-59 .. 0]]
--   
db_amp :: Floating a => a -> a -- | Enumeration of hairpin indicators. data Hairpin Crescendo :: Hairpin Diminuendo :: Hairpin End_Hairpin :: Hairpin -- | The Hairpin implied by a ordered pair of Dynamic_Marks. -- --
--   map (implied_hairpin Mf) [Mp,F] == [Just Diminuendo,Just Crescendo]
--   
implied_hairpin :: Dynamic_Mark -> Dynamic_Mark -> Maybe Hairpin -- | A node in a dynamic sequence. type Dynamic_Node = (Maybe Dynamic_Mark, Maybe Hairpin) -- | The empty Dynamic_Node. empty_dynamic_node :: Dynamic_Node -- | Calculate a Dynamic_Node sequence from a sequence of -- Dynamic_Marks. -- --
--   let r = [(Just Pp,Just Crescendo), (Just Mp,Just End_Hairpin) ,(Nothing,Just Diminuendo) ,(Just Pp,Just End_Hairpin)]
--   dynamic_sequence [Pp,Mp,Mp,Pp] == r
--   
dynamic_sequence :: [Dynamic_Mark] -> [Dynamic_Node] -- | Delete redundant (unaltered) dynamic marks. -- --
--   let r = [Just P,Nothing,Nothing,Nothing,Just F]
--   delete_redundant_marks [Just P,Nothing,Just P,Just P,Just F] == r
--   
delete_redundant_marks :: [Maybe Dynamic_Mark] -> [Maybe Dynamic_Mark] -- | Variant of dynamic_sequence for sequences of -- Dynamic_Mark with holes (ie. rests). Runs -- delete_redundant_marks. -- --
--   let r = [Just (Just P,Just Crescendo),Just (Just F,Just End_Hairpin),Nothing,Just (Just P,Nothing)]
--   dynamic_sequence_sets [Just P,Just F,Nothing,Just P] == r
--   
-- --
--   dynamic_sequence_sets [Just P,Nothing,Just P] == [Just (Just P,Nothing),Nothing,Nothing]
--   
dynamic_sequence_sets :: [Maybe Dynamic_Mark] -> [Maybe Dynamic_Node] -- | Apply Hairpin and Dynamic_Mark functions in that order -- as required by Dynamic_Node. -- --
--   let f _ x = show x
--   apply_dynamic_node f f (Nothing,Just Crescendo) undefined
--   
apply_dynamic_node :: (a -> Dynamic_Mark -> a) -> (a -> Hairpin -> a) -> Dynamic_Node -> a -> a -- | Ascii pretty printer for Dynamic_Mark. dynamic_mark_ascii :: Dynamic_Mark -> String -- | Ascii pretty printer for Hairpin. hairpin_ascii :: Hairpin -> String -- | Ascii pretty printer for Dynamic_Node. dynamic_node_ascii :: Dynamic_Node -> String -- | Ascii pretty printer for Dynamic_Node sequence. dynamic_sequence_ascii :: [Dynamic_Node] -> String instance GHC.Read.Read Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Show.Show Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Enum.Bounded Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Enum.Enum Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Classes.Ord Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Classes.Eq Music.Theory.Dynamic_Mark.Dynamic_Mark instance GHC.Show.Show Music.Theory.Dynamic_Mark.Hairpin instance GHC.Enum.Bounded Music.Theory.Dynamic_Mark.Hairpin instance GHC.Enum.Enum Music.Theory.Dynamic_Mark.Hairpin instance GHC.Classes.Ord Music.Theory.Dynamic_Mark.Hairpin instance GHC.Classes.Eq Music.Theory.Dynamic_Mark.Hairpin -- | Graph (fgl) functions. module Music.Theory.Graph.Fgl -- | Lbl to FGL graph lbl_to_fgl :: Graph gr => Lbl v e -> gr v e -- | Type-specialised. lbl_to_fgl_gr :: Lbl v e -> Gr v e -- | FGL graph to Lbl fgl_to_lbl :: Graph gr => gr v e -> Lbl v e -- | Synonym for noNodes. g_degree :: Gr v e -> Int -- | subgraph of each of components. g_partition :: Gr v e -> [Gr v e] -- | Find first Node with given label. g_node_lookup :: (Eq v, Graph gr) => gr v e -> v -> Maybe Node -- | Erroring variant. g_node_lookup_err :: (Eq v, Graph gr) => gr v e -> v -> Node -- | Set of nodes with given labels, plus all neighbours of these nodes. -- (impl = implications) ug_node_set_impl :: (Eq v, DynGraph gr) => gr v e -> [v] -> [Node] -- | Node select function, ie. given a graph g and a node n -- select a set of related nodes from g type G_Node_Sel_f v e = Gr v e -> Node -> [Node] -- | msum . map return. ml_from_list :: MonadPlus m => [t] -> m t -- | Use sel_f of pre for directed graphs and -- neighbors for undirected. g_hamiltonian_path_ml :: (MonadPlus m, MonadLogic m) => G_Node_Sel_f v e -> Gr v e -> Node -> m [Node] -- | g_hamiltonian_path_ml of neighbors starting at first -- node. -- --
--   map (L.observeAll . ug_hamiltonian_path_ml_0) (g_partition gr)
--   
ug_hamiltonian_path_ml_0 :: (MonadPlus m, MonadLogic m) => Gr v e -> m [Node] -- | Edge, no label. type Edge v = (v, v) -- | Edge, with label. type Edge_Lbl v l = (Edge v, l) -- | Generate a graph given a set of labelled edges. g_from_edges_l :: (Eq v, Ord v) => [Edge_Lbl v e] -> Gr v e -- | Variant that supplies () as the (constant) edge label. -- --
--   let g = G.mkGraph [(0,'a'),(1,'b'),(2,'c')] [(0,1,()),(1,2,())]
--   in g_from_edges_ul [('a','b'),('b','c')] == g
--   
g_from_edges :: Ord v => [Edge v] -> Gr v () -- | Label sequence of edges starting at one. e_label_seq :: [Edge v] -> [Edge_Lbl v Int] -- | Normalised undirected labeled edge (ie. order nodes). e_normalise_l :: Ord v => Edge_Lbl v l -> Edge_Lbl v l -- | Collate labels for edges that are otherwise equal. e_collate_l :: Ord v => [Edge_Lbl v l] -> [Edge_Lbl v [l]] -- | e_collate_l of e_normalise_l. e_collate_normalised_l :: Ord v => [Edge_Lbl v l] -> [Edge_Lbl v [l]] -- | Apply predicate to universe of possible edges. e_univ_select_edges :: (t -> t -> Bool) -> [t] -> [Edge t] -- | Consider only edges (p,q) where p < q. e_univ_select_u_edges :: Ord t => (t -> t -> Bool) -> [t] -> [Edge t] -- | Sequence of connected vertices to edges. -- --
--   e_path_to_edges "abcd" == [('a','b'),('b','c'),('c','d')]
--   
e_path_to_edges :: [t] -> [Edge t] -- | Undirected edge equality. e_undirected_eq :: Eq t => Edge t -> Edge t -> Bool -- | any of f. elem_by :: (p -> q -> Bool) -> p -> [q] -> Bool -- | Is the sequence of vertices a path at the graph, ie. are all -- adjacencies in the sequence edges. e_is_path :: Eq t => [Edge t] -> [t] -> Bool -- | -- https://github.com/ivan-m/Graphalyze/blob/master/Data/Graph/Analysis/Algorithms/Common.hs -- Graphalyze has pandoc as a dependency... pathTree :: DynGraph g => Decomp g a b -> [[Node]] -- | Remove all outgoing edges makeLeaf :: Context a b -> Context a b -- | Graph (dot) functions. module Music.Theory.Graph.Dot -- | Classify s using a first element predicate, a remainder -- predicate and a unit predicate. s_classify :: (t -> Bool) -> (t -> Bool) -> ([t] -> Bool) -> [t] -> Bool -- | Symbol rule. -- --
--   map is_symbol ["sym","Sym2","3sym","1",""] == [True,True,False,False,False]
--   
is_symbol :: String -> Bool -- | Number rule. -- --
--   map is_number ["123","123.45",".25","1.","1.2.3",""] == [True,True,False,True,False,False]
--   
is_number :: String -> Bool -- | Quote s if is_symbol or is_number. -- --
--   map maybe_quote ["abc","a b c","12","12.3"] == ["abc","\"a b c\"","12","12.3"]
--   
maybe_quote :: String -> String type Dot_Key = String type Dot_Value = String type Dot_Attr = (Dot_Key, Dot_Value) -- | Format Dot_Attr. dot_attr_pp :: Dot_Attr -> String -- | Format sequence of Dot_Attr. -- --
--   dot_attr_seq_pp [("layout","neato"),("epsilon","0.0001")]
--   
dot_attr_seq_pp :: [Dot_Attr] -> String -- | Merge attributes, left-biased. dot_attr_ext :: [Dot_Attr] -> [Dot_Attr] -> [Dot_Attr] -- | graph|node|edge type Dot_Type = String -- | (type,[attr]) type Dot_Attr_Set = (Dot_Type, [Dot_Attr]) -- | Format Dot_Attr_Set. -- --
--   a = ("graph",[("layout","neato"),("epsilon","0.0001")])
--   dot_attr_set_pp a == "graph [layout=neato,epsilon=0.0001]"
--   
dot_attr_set_pp :: Dot_Attr_Set -> String -- | type:attr (type = graph|node|edge) type Dot_Meta_Key = String type Dot_Meta_Attr = (Dot_Meta_Key, Dot_Value) -- | Keys are given as "type:attr". -- --
--   dot_key_sep "graph:layout" == ("graph","layout")
--   
dot_key_sep :: Dot_Meta_Key -> (Dot_Type, Dot_Key) -- | Collate Dot_Key attribute set to Dot_Attr_Set. dot_attr_collate :: [Dot_Meta_Attr] -> [Dot_Attr_Set] -- | Default values for default meta-keys. -- --
--   k = dot_attr_def ("neato","century schoolbook",10,"plaintext")
--   map dot_attr_set_pp (dot_attr_collate k)
--   
dot_attr_def :: (String, String, Double, String) -> [Dot_Meta_Attr] -- | Graph pretty-printer, (v -> [attr],e -> [attr]) type Graph_Pp v e = ((Int, v) -> [Dot_Attr], ((Int, Int), e) -> [Dot_Attr]) -- | Make Graph_Pp value given label functions for vertices and edges. gr_pp_label_m :: Maybe (v -> Dot_Value) -> Maybe (e -> Dot_Value) -> Graph_Pp v e -- | Label V & E. gr_pp_label :: (v -> Dot_Value) -> (e -> Dot_Value) -> Graph_Pp v e -- | Label V only. gr_pp_label_v :: (v -> Dot_Value) -> Graph_Pp v e -- | br = brace, csl = comma separated list br_csl_pp :: Show t => [t] -> String -- | Graph type, directed or un-directed. data Graph_Type Graph_Digraph :: Graph_Type Graph_Ugraph :: Graph_Type g_type_to_string :: Graph_Type -> String g_type_to_edge_symbol :: Graph_Type -> String -- | Generate node position attribute given (x,y) coordinate. node_pos_attr :: (Show n, Real n) => (n, n) -> Dot_Attr -- | Edge POS attributes are sets of cubic bezier control points. edge_pos_attr :: Real t => [(t, t)] -> Dot_Attr -- | Variant that accepts single cubic bezier data set. edge_pos_attr_1 :: Real t => ((t, t), (t, t), (t, t), (t, t)) -> Dot_Attr lbl_to_dot :: Graph_Type -> [Dot_Meta_Attr] -> Graph_Pp v e -> Lbl v e -> [String] lbl_to_udot :: [Dot_Meta_Attr] -> Graph_Pp v e -> Lbl v e -> [String] -- | writeFile of lbl_to_udot lbl_to_udot_wr :: FilePath -> [Dot_Meta_Attr] -> Graph_Pp v e -> Lbl v e -> IO () fgl_to_dot :: Graph gr => Graph_Type -> [Dot_Meta_Attr] -> Graph_Pp v e -> gr v e -> [String] fgl_to_udot :: Graph gr => [Dot_Meta_Attr] -> Graph_Pp v e -> gr v e -> [String] -- | Run dot to generate a file type based on the output file -- extension (ie. .svg, .png, .jpeg, .gif) -n must be given to not -- run the layout algorithm and to use position data in the dot -- file. dot_to_ext :: [String] -> FilePath -> FilePath -> IO () -- | dot_to_ext generating .svg filename by replacing .dot extension -- with .svg dot_to_svg :: [String] -> FilePath -> IO () -- | Geometrical Drawings -- -- A. Bernard Deacon and Camilla H. Wedgwood. “Geometrical Drawings from -- Malekula and Other Islands of the New Hebrides”. The Journal of the -- Royal Anthropological Institute of Great Britain and Ireland, -- 64:129—175, 1934. module Music.Theory.Graph.Deacon_1934 gen_graph :: Ord v => [Dot_Attr] -> Graph_Pp v e -> [Edge_Lbl v e] -> [String] gen_graph_ul :: Ord v => [Dot_Attr] -> (v -> String) -> [Edge v] -> [String] gen_digraph :: Ord v => [Dot_Attr] -> Graph_Pp v e -> [Edge_Lbl v e] -> [String] type G = ([Edge String], [Dot_Attr], FilePath) g1 :: G g2 :: G g4 :: G g6 :: G g8 :: G g9 :: G g10 :: G g11 :: G g12 :: G g13 :: G g_all :: [G] wr :: G -> IO () wr_all :: IO () module Music.Theory.Instrument.Names -- | (family,abbreviations,names,transpositions) instrument_db' :: [(String, String, String, String)] -- | (family,[abbreviations],[names],[transpositions]) instrument_db :: [(String, [String], [String], [String])] -- | List/Logic functions. module Music.Theory.List.Logic -- | MonadLogic value to enumerate indices for all embeddings of -- q in p. all_embeddings_m :: (Eq t, MonadPlus m, MonadLogic m) => [t] -> [t] -> m [Int] -- | observeAll of all_embeddings_m -- --
--   all_embeddings "all_embeddings" "leg" == [[1,4,12],[1,7,12],[2,4,12],[2,7,12]]
--   
all_embeddings :: Eq t => [t] -> [t] -> [[Int]] -- | Conversion between signed and sized integral types with bounds -- checking. Types are aliased as Ux and Ix. Includes sizes 4 (MIDI), 7 -- (ASCII,MIDI), 12 (SND,AKAI), 14 (MIDI) and 24 (SND). Autogenerated: -- see mk/mk-convert.hs. module Music.Theory.Math.Convert.Fx -- | Alias type U4 = Word8 -- | Alias type U7 = Word8 -- | Alias type U8 = Word8 -- | Alias type U12 = Word16 -- | Alias type U14 = Word16 -- | Alias type U16 = Word16 -- | Alias type U24 = Word32 -- | Alias type U32 = Word32 -- | Alias type U64 = Word64 -- | Alias type I4 = Int8 -- | Alias type I7 = Int8 -- | Alias type I8 = Int8 -- | Alias type I12 = Int16 -- | Alias type I14 = Int16 -- | Alias type I16 = Int16 -- | Alias type I24 = Int32 -- | Alias type I32 = Int32 -- | Alias type I64 = Int64 -- | Type specialised fromIntegral u4_to_u7 :: U4 -> U7 -- | Type specialised fromIntegral u4_to_u8 :: U4 -> U8 -- | Type specialised fromIntegral u4_to_u12 :: U4 -> U12 -- | Type specialised fromIntegral u4_to_u14 :: U4 -> U14 -- | Type specialised fromIntegral u4_to_u16 :: U4 -> U16 -- | Type specialised fromIntegral u4_to_u24 :: U4 -> U24 -- | Type specialised fromIntegral u4_to_u32 :: U4 -> U32 -- | Type specialised fromIntegral u4_to_u64 :: U4 -> U64 -- | Type specialised fromIntegral with out-of-range error. u4_to_i4 :: U4 -> I4 -- | Type specialised fromIntegral u4_to_i7 :: U4 -> I7 -- | Type specialised fromIntegral u4_to_i8 :: U4 -> I8 -- | Type specialised fromIntegral u4_to_i12 :: U4 -> I12 -- | Type specialised fromIntegral u4_to_i14 :: U4 -> I14 -- | Type specialised fromIntegral u4_to_i16 :: U4 -> I16 -- | Type specialised fromIntegral u4_to_i24 :: U4 -> I24 -- | Type specialised fromIntegral u4_to_i32 :: U4 -> I32 -- | Type specialised fromIntegral u4_to_i64 :: U4 -> I64 -- | Type specialised fromIntegral with out-of-range error. u7_to_u4 :: U7 -> U4 -- | Type specialised fromIntegral u7_to_u8 :: U7 -> U8 -- | Type specialised fromIntegral u7_to_u12 :: U7 -> U12 -- | Type specialised fromIntegral u7_to_u14 :: U7 -> U14 -- | Type specialised fromIntegral u7_to_u16 :: U7 -> U16 -- | Type specialised fromIntegral u7_to_u24 :: U7 -> U24 -- | Type specialised fromIntegral u7_to_u32 :: U7 -> U32 -- | Type specialised fromIntegral u7_to_u64 :: U7 -> U64 -- | Type specialised fromIntegral with out-of-range error. u7_to_i4 :: U7 -> I4 -- | Type specialised fromIntegral with out-of-range error. u7_to_i7 :: U7 -> I7 -- | Type specialised fromIntegral u7_to_i8 :: U7 -> I8 -- | Type specialised fromIntegral u7_to_i12 :: U7 -> I12 -- | Type specialised fromIntegral u7_to_i14 :: U7 -> I14 -- | Type specialised fromIntegral u7_to_i16 :: U7 -> I16 -- | Type specialised fromIntegral u7_to_i24 :: U7 -> I24 -- | Type specialised fromIntegral u7_to_i32 :: U7 -> I32 -- | Type specialised fromIntegral u7_to_i64 :: U7 -> I64 -- | Type specialised fromIntegral with out-of-range error. u8_to_u4 :: U8 -> U4 -- | Type specialised fromIntegral with out-of-range error. u8_to_u7 :: U8 -> U7 -- | Type specialised fromIntegral u8_to_u12 :: U8 -> U12 -- | Type specialised fromIntegral u8_to_u14 :: U8 -> U14 -- | Type specialised fromIntegral u8_to_u16 :: U8 -> U16 -- | Type specialised fromIntegral u8_to_u24 :: U8 -> U24 -- | Type specialised fromIntegral u8_to_u32 :: U8 -> U32 -- | Type specialised fromIntegral u8_to_u64 :: U8 -> U64 -- | Type specialised fromIntegral with out-of-range error. u8_to_i4 :: U8 -> I4 -- | Type specialised fromIntegral with out-of-range error. u8_to_i7 :: U8 -> I7 -- | Type specialised fromIntegral with out-of-range error. u8_to_i8 :: U8 -> I8 -- | Type specialised fromIntegral u8_to_i12 :: U8 -> I12 -- | Type specialised fromIntegral u8_to_i14 :: U8 -> I14 -- | Type specialised fromIntegral u8_to_i16 :: U8 -> I16 -- | Type specialised fromIntegral u8_to_i24 :: U8 -> I24 -- | Type specialised fromIntegral u8_to_i32 :: U8 -> I32 -- | Type specialised fromIntegral u8_to_i64 :: U8 -> I64 -- | Type specialised fromIntegral with out-of-range error. u12_to_u4 :: U12 -> U4 -- | Type specialised fromIntegral with out-of-range error. u12_to_u7 :: U12 -> U7 -- | Type specialised fromIntegral with out-of-range error. u12_to_u8 :: U12 -> U8 -- | Type specialised fromIntegral u12_to_u14 :: U12 -> U14 -- | Type specialised fromIntegral u12_to_u16 :: U12 -> U16 -- | Type specialised fromIntegral u12_to_u24 :: U12 -> U24 -- | Type specialised fromIntegral u12_to_u32 :: U12 -> U32 -- | Type specialised fromIntegral u12_to_u64 :: U12 -> U64 -- | Type specialised fromIntegral with out-of-range error. u12_to_i4 :: U12 -> I4 -- | Type specialised fromIntegral with out-of-range error. u12_to_i7 :: U12 -> I7 -- | Type specialised fromIntegral with out-of-range error. u12_to_i8 :: U12 -> I8 -- | Type specialised fromIntegral with out-of-range error. u12_to_i12 :: U12 -> I12 -- | Type specialised fromIntegral u12_to_i14 :: U12 -> I14 -- | Type specialised fromIntegral u12_to_i16 :: U12 -> I16 -- | Type specialised fromIntegral u12_to_i24 :: U12 -> I24 -- | Type specialised fromIntegral u12_to_i32 :: U12 -> I32 -- | Type specialised fromIntegral u12_to_i64 :: U12 -> I64 -- | Type specialised fromIntegral with out-of-range error. u14_to_u4 :: U14 -> U4 -- | Type specialised fromIntegral with out-of-range error. u14_to_u7 :: U14 -> U7 -- | Type specialised fromIntegral with out-of-range error. u14_to_u8 :: U14 -> U8 -- | Type specialised fromIntegral with out-of-range error. u14_to_u12 :: U14 -> U12 -- | Type specialised fromIntegral u14_to_u16 :: U14 -> U16 -- | Type specialised fromIntegral u14_to_u24 :: U14 -> U24 -- | Type specialised fromIntegral u14_to_u32 :: U14 -> U32 -- | Type specialised fromIntegral u14_to_u64 :: U14 -> U64 -- | Type specialised fromIntegral with out-of-range error. u14_to_i4 :: U14 -> I4 -- | Type specialised fromIntegral with out-of-range error. u14_to_i7 :: U14 -> I7 -- | Type specialised fromIntegral with out-of-range error. u14_to_i8 :: U14 -> I8 -- | Type specialised fromIntegral with out-of-range error. u14_to_i12 :: U14 -> I12 -- | Type specialised fromIntegral with out-of-range error. u14_to_i14 :: U14 -> I14 -- | Type specialised fromIntegral u14_to_i16 :: U14 -> I16 -- | Type specialised fromIntegral u14_to_i24 :: U14 -> I24 -- | Type specialised fromIntegral u14_to_i32 :: U14 -> I32 -- | Type specialised fromIntegral u14_to_i64 :: U14 -> I64 -- | Type specialised fromIntegral with out-of-range error. u16_to_u4 :: U16 -> U4 -- | Type specialised fromIntegral with out-of-range error. u16_to_u7 :: U16 -> U7 -- | Type specialised fromIntegral with out-of-range error. u16_to_u8 :: U16 -> U8 -- | Type specialised fromIntegral with out-of-range error. u16_to_u12 :: U16 -> U12 -- | Type specialised fromIntegral with out-of-range error. u16_to_u14 :: U16 -> U14 -- | Type specialised fromIntegral u16_to_u24 :: U16 -> U24 -- | Type specialised fromIntegral u16_to_u32 :: U16 -> U32 -- | Type specialised fromIntegral u16_to_u64 :: U16 -> U64 -- | Type specialised fromIntegral with out-of-range error. u16_to_i4 :: U16 -> I4 -- | Type specialised fromIntegral with out-of-range error. u16_to_i7 :: U16 -> I7 -- | Type specialised fromIntegral with out-of-range error. u16_to_i8 :: U16 -> I8 -- | Type specialised fromIntegral with out-of-range error. u16_to_i12 :: U16 -> I12 -- | Type specialised fromIntegral with out-of-range error. u16_to_i14 :: U16 -> I14 -- | Type specialised fromIntegral with out-of-range error. u16_to_i16 :: U16 -> I16 -- | Type specialised fromIntegral u16_to_i24 :: U16 -> I24 -- | Type specialised fromIntegral u16_to_i32 :: U16 -> I32 -- | Type specialised fromIntegral u16_to_i64 :: U16 -> I64 -- | Type specialised fromIntegral with out-of-range error. u24_to_u4 :: U24 -> U4 -- | Type specialised fromIntegral with out-of-range error. u24_to_u7 :: U24 -> U7 -- | Type specialised fromIntegral with out-of-range error. u24_to_u8 :: U24 -> U8 -- | Type specialised fromIntegral with out-of-range error. u24_to_u12 :: U24 -> U12 -- | Type specialised fromIntegral with out-of-range error. u24_to_u14 :: U24 -> U14 -- | Type specialised fromIntegral with out-of-range error. u24_to_u16 :: U24 -> U16 -- | Type specialised fromIntegral u24_to_u32 :: U24 -> U32 -- | Type specialised fromIntegral u24_to_u64 :: U24 -> U64 -- | Type specialised fromIntegral with out-of-range error. u24_to_i4 :: U24 -> I4 -- | Type specialised fromIntegral with out-of-range error. u24_to_i7 :: U24 -> I7 -- | Type specialised fromIntegral with out-of-range error. u24_to_i8 :: U24 -> I8 -- | Type specialised fromIntegral with out-of-range error. u24_to_i12 :: U24 -> I12 -- | Type specialised fromIntegral with out-of-range error. u24_to_i14 :: U24 -> I14 -- | Type specialised fromIntegral with out-of-range error. u24_to_i16 :: U24 -> I16 -- | Type specialised fromIntegral with out-of-range error. u24_to_i24 :: U24 -> I24 -- | Type specialised fromIntegral u24_to_i32 :: U24 -> I32 -- | Type specialised fromIntegral u24_to_i64 :: U24 -> I64 -- | Type specialised fromIntegral with out-of-range error. u32_to_u4 :: U32 -> U4 -- | Type specialised fromIntegral with out-of-range error. u32_to_u7 :: U32 -> U7 -- | Type specialised fromIntegral with out-of-range error. u32_to_u8 :: U32 -> U8 -- | Type specialised fromIntegral with out-of-range error. u32_to_u12 :: U32 -> U12 -- | Type specialised fromIntegral with out-of-range error. u32_to_u14 :: U32 -> U14 -- | Type specialised fromIntegral with out-of-range error. u32_to_u16 :: U32 -> U16 -- | Type specialised fromIntegral with out-of-range error. u32_to_u24 :: U32 -> U24 -- | Type specialised fromIntegral u32_to_u64 :: U32 -> U64 -- | Type specialised fromIntegral with out-of-range error. u32_to_i4 :: U32 -> I4 -- | Type specialised fromIntegral with out-of-range error. u32_to_i7 :: U32 -> I7 -- | Type specialised fromIntegral with out-of-range error. u32_to_i8 :: U32 -> I8 -- | Type specialised fromIntegral with out-of-range error. u32_to_i12 :: U32 -> I12 -- | Type specialised fromIntegral with out-of-range error. u32_to_i14 :: U32 -> I14 -- | Type specialised fromIntegral with out-of-range error. u32_to_i16 :: U32 -> I16 -- | Type specialised fromIntegral with out-of-range error. u32_to_i24 :: U32 -> I24 -- | Type specialised fromIntegral with out-of-range error. u32_to_i32 :: U32 -> I32 -- | Type specialised fromIntegral u32_to_i64 :: U32 -> I64 -- | Type specialised fromIntegral with out-of-range error. u64_to_u4 :: U64 -> U4 -- | Type specialised fromIntegral with out-of-range error. u64_to_u7 :: U64 -> U7 -- | Type specialised fromIntegral with out-of-range error. u64_to_u8 :: U64 -> U8 -- | Type specialised fromIntegral with out-of-range error. u64_to_u12 :: U64 -> U12 -- | Type specialised fromIntegral with out-of-range error. u64_to_u14 :: U64 -> U14 -- | Type specialised fromIntegral with out-of-range error. u64_to_u16 :: U64 -> U16 -- | Type specialised fromIntegral with out-of-range error. u64_to_u24 :: U64 -> U24 -- | Type specialised fromIntegral with out-of-range error. u64_to_u32 :: U64 -> U32 -- | Type specialised fromIntegral with out-of-range error. u64_to_i4 :: U64 -> I4 -- | Type specialised fromIntegral with out-of-range error. u64_to_i7 :: U64 -> I7 -- | Type specialised fromIntegral with out-of-range error. u64_to_i8 :: U64 -> I8 -- | Type specialised fromIntegral with out-of-range error. u64_to_i12 :: U64 -> I12 -- | Type specialised fromIntegral with out-of-range error. u64_to_i14 :: U64 -> I14 -- | Type specialised fromIntegral with out-of-range error. u64_to_i16 :: U64 -> I16 -- | Type specialised fromIntegral with out-of-range error. u64_to_i24 :: U64 -> I24 -- | Type specialised fromIntegral with out-of-range error. u64_to_i32 :: U64 -> I32 -- | Type specialised fromIntegral with out-of-range error. u64_to_i64 :: U64 -> I64 -- | Type specialised fromIntegral with out-of-range error. i4_to_u4 :: I4 -> U4 -- | Type specialised fromIntegral with out-of-range error. i4_to_u7 :: I4 -> U7 -- | Type specialised fromIntegral with out-of-range error. i4_to_u8 :: I4 -> U8 -- | Type specialised fromIntegral with out-of-range error. i4_to_u12 :: I4 -> U12 -- | Type specialised fromIntegral with out-of-range error. i4_to_u14 :: I4 -> U14 -- | Type specialised fromIntegral with out-of-range error. i4_to_u16 :: I4 -> U16 -- | Type specialised fromIntegral with out-of-range error. i4_to_u24 :: I4 -> U24 -- | Type specialised fromIntegral with out-of-range error. i4_to_u32 :: I4 -> U32 -- | Type specialised fromIntegral with out-of-range error. i4_to_u64 :: I4 -> U64 -- | Type specialised fromIntegral i4_to_i7 :: I4 -> I7 -- | Type specialised fromIntegral i4_to_i8 :: I4 -> I8 -- | Type specialised fromIntegral i4_to_i12 :: I4 -> I12 -- | Type specialised fromIntegral i4_to_i14 :: I4 -> I14 -- | Type specialised fromIntegral i4_to_i16 :: I4 -> I16 -- | Type specialised fromIntegral i4_to_i24 :: I4 -> I24 -- | Type specialised fromIntegral i4_to_i32 :: I4 -> I32 -- | Type specialised fromIntegral i4_to_i64 :: I4 -> I64 -- | Type specialised fromIntegral with out-of-range error. i7_to_u4 :: I7 -> U4 -- | Type specialised fromIntegral with out-of-range error. i7_to_u7 :: I7 -> U7 -- | Type specialised fromIntegral with out-of-range error. i7_to_u8 :: I7 -> U8 -- | Type specialised fromIntegral with out-of-range error. i7_to_u12 :: I7 -> U12 -- | Type specialised fromIntegral with out-of-range error. i7_to_u14 :: I7 -> U14 -- | Type specialised fromIntegral with out-of-range error. i7_to_u16 :: I7 -> U16 -- | Type specialised fromIntegral with out-of-range error. i7_to_u24 :: I7 -> U24 -- | Type specialised fromIntegral with out-of-range error. i7_to_u32 :: I7 -> U32 -- | Type specialised fromIntegral with out-of-range error. i7_to_u64 :: I7 -> U64 -- | Type specialised fromIntegral with out-of-range error. i7_to_i4 :: I7 -> I4 -- | Type specialised fromIntegral i7_to_i8 :: I7 -> I8 -- | Type specialised fromIntegral i7_to_i12 :: I7 -> I12 -- | Type specialised fromIntegral i7_to_i14 :: I7 -> I14 -- | Type specialised fromIntegral i7_to_i16 :: I7 -> I16 -- | Type specialised fromIntegral i7_to_i24 :: I7 -> I24 -- | Type specialised fromIntegral i7_to_i32 :: I7 -> I32 -- | Type specialised fromIntegral i7_to_i64 :: I7 -> I64 -- | Type specialised fromIntegral with out-of-range error. i8_to_u4 :: I8 -> U4 -- | Type specialised fromIntegral with out-of-range error. i8_to_u7 :: I8 -> U7 -- | Type specialised fromIntegral with out-of-range error. i8_to_u8 :: I8 -> U8 -- | Type specialised fromIntegral with out-of-range error. i8_to_u12 :: I8 -> U12 -- | Type specialised fromIntegral with out-of-range error. i8_to_u14 :: I8 -> U14 -- | Type specialised fromIntegral with out-of-range error. i8_to_u16 :: I8 -> U16 -- | Type specialised fromIntegral with out-of-range error. i8_to_u24 :: I8 -> U24 -- | Type specialised fromIntegral with out-of-range error. i8_to_u32 :: I8 -> U32 -- | Type specialised fromIntegral with out-of-range error. i8_to_u64 :: I8 -> U64 -- | Type specialised fromIntegral with out-of-range error. i8_to_i4 :: I8 -> I4 -- | Type specialised fromIntegral with out-of-range error. i8_to_i7 :: I8 -> I7 -- | Type specialised fromIntegral i8_to_i12 :: I8 -> I12 -- | Type specialised fromIntegral i8_to_i14 :: I8 -> I14 -- | Type specialised fromIntegral i8_to_i16 :: I8 -> I16 -- | Type specialised fromIntegral i8_to_i24 :: I8 -> I24 -- | Type specialised fromIntegral i8_to_i32 :: I8 -> I32 -- | Type specialised fromIntegral i8_to_i64 :: I8 -> I64 -- | Type specialised fromIntegral with out-of-range error. i12_to_u4 :: I12 -> U4 -- | Type specialised fromIntegral with out-of-range error. i12_to_u7 :: I12 -> U7 -- | Type specialised fromIntegral with out-of-range error. i12_to_u8 :: I12 -> U8 -- | Type specialised fromIntegral with out-of-range error. i12_to_u12 :: I12 -> U12 -- | Type specialised fromIntegral with out-of-range error. i12_to_u14 :: I12 -> U14 -- | Type specialised fromIntegral with out-of-range error. i12_to_u16 :: I12 -> U16 -- | Type specialised fromIntegral with out-of-range error. i12_to_u24 :: I12 -> U24 -- | Type specialised fromIntegral with out-of-range error. i12_to_u32 :: I12 -> U32 -- | Type specialised fromIntegral with out-of-range error. i12_to_u64 :: I12 -> U64 -- | Type specialised fromIntegral with out-of-range error. i12_to_i4 :: I12 -> I4 -- | Type specialised fromIntegral with out-of-range error. i12_to_i7 :: I12 -> I7 -- | Type specialised fromIntegral with out-of-range error. i12_to_i8 :: I12 -> I8 -- | Type specialised fromIntegral i12_to_i14 :: I12 -> I14 -- | Type specialised fromIntegral i12_to_i16 :: I12 -> I16 -- | Type specialised fromIntegral i12_to_i24 :: I12 -> I24 -- | Type specialised fromIntegral i12_to_i32 :: I12 -> I32 -- | Type specialised fromIntegral i12_to_i64 :: I12 -> I64 -- | Type specialised fromIntegral with out-of-range error. i14_to_u4 :: I14 -> U4 -- | Type specialised fromIntegral with out-of-range error. i14_to_u7 :: I14 -> U7 -- | Type specialised fromIntegral with out-of-range error. i14_to_u8 :: I14 -> U8 -- | Type specialised fromIntegral with out-of-range error. i14_to_u12 :: I14 -> U12 -- | Type specialised fromIntegral with out-of-range error. i14_to_u14 :: I14 -> U14 -- | Type specialised fromIntegral with out-of-range error. i14_to_u16 :: I14 -> U16 -- | Type specialised fromIntegral with out-of-range error. i14_to_u24 :: I14 -> U24 -- | Type specialised fromIntegral with out-of-range error. i14_to_u32 :: I14 -> U32 -- | Type specialised fromIntegral with out-of-range error. i14_to_u64 :: I14 -> U64 -- | Type specialised fromIntegral with out-of-range error. i14_to_i4 :: I14 -> I4 -- | Type specialised fromIntegral with out-of-range error. i14_to_i7 :: I14 -> I7 -- | Type specialised fromIntegral with out-of-range error. i14_to_i8 :: I14 -> I8 -- | Type specialised fromIntegral with out-of-range error. i14_to_i12 :: I14 -> I12 -- | Type specialised fromIntegral i14_to_i16 :: I14 -> I16 -- | Type specialised fromIntegral i14_to_i24 :: I14 -> I24 -- | Type specialised fromIntegral i14_to_i32 :: I14 -> I32 -- | Type specialised fromIntegral i14_to_i64 :: I14 -> I64 -- | Type specialised fromIntegral with out-of-range error. i16_to_u4 :: I16 -> U4 -- | Type specialised fromIntegral with out-of-range error. i16_to_u7 :: I16 -> U7 -- | Type specialised fromIntegral with out-of-range error. i16_to_u8 :: I16 -> U8 -- | Type specialised fromIntegral with out-of-range error. i16_to_u12 :: I16 -> U12 -- | Type specialised fromIntegral with out-of-range error. i16_to_u14 :: I16 -> U14 -- | Type specialised fromIntegral with out-of-range error. i16_to_u16 :: I16 -> U16 -- | Type specialised fromIntegral with out-of-range error. i16_to_u24 :: I16 -> U24 -- | Type specialised fromIntegral with out-of-range error. i16_to_u32 :: I16 -> U32 -- | Type specialised fromIntegral with out-of-range error. i16_to_u64 :: I16 -> U64 -- | Type specialised fromIntegral with out-of-range error. i16_to_i4 :: I16 -> I4 -- | Type specialised fromIntegral with out-of-range error. i16_to_i7 :: I16 -> I7 -- | Type specialised fromIntegral with out-of-range error. i16_to_i8 :: I16 -> I8 -- | Type specialised fromIntegral with out-of-range error. i16_to_i12 :: I16 -> I12 -- | Type specialised fromIntegral with out-of-range error. i16_to_i14 :: I16 -> I14 -- | Type specialised fromIntegral i16_to_i24 :: I16 -> I24 -- | Type specialised fromIntegral i16_to_i32 :: I16 -> I32 -- | Type specialised fromIntegral i16_to_i64 :: I16 -> I64 -- | Type specialised fromIntegral with out-of-range error. i24_to_u4 :: I24 -> U4 -- | Type specialised fromIntegral with out-of-range error. i24_to_u7 :: I24 -> U7 -- | Type specialised fromIntegral with out-of-range error. i24_to_u8 :: I24 -> U8 -- | Type specialised fromIntegral with out-of-range error. i24_to_u12 :: I24 -> U12 -- | Type specialised fromIntegral with out-of-range error. i24_to_u14 :: I24 -> U14 -- | Type specialised fromIntegral with out-of-range error. i24_to_u16 :: I24 -> U16 -- | Type specialised fromIntegral with out-of-range error. i24_to_u24 :: I24 -> U24 -- | Type specialised fromIntegral with out-of-range error. i24_to_u32 :: I24 -> U32 -- | Type specialised fromIntegral with out-of-range error. i24_to_u64 :: I24 -> U64 -- | Type specialised fromIntegral with out-of-range error. i24_to_i4 :: I24 -> I4 -- | Type specialised fromIntegral with out-of-range error. i24_to_i7 :: I24 -> I7 -- | Type specialised fromIntegral with out-of-range error. i24_to_i8 :: I24 -> I8 -- | Type specialised fromIntegral with out-of-range error. i24_to_i12 :: I24 -> I12 -- | Type specialised fromIntegral with out-of-range error. i24_to_i14 :: I24 -> I14 -- | Type specialised fromIntegral with out-of-range error. i24_to_i16 :: I24 -> I16 -- | Type specialised fromIntegral i24_to_i32 :: I24 -> I32 -- | Type specialised fromIntegral i24_to_i64 :: I24 -> I64 -- | Type specialised fromIntegral with out-of-range error. i32_to_u4 :: I32 -> U4 -- | Type specialised fromIntegral with out-of-range error. i32_to_u7 :: I32 -> U7 -- | Type specialised fromIntegral with out-of-range error. i32_to_u8 :: I32 -> U8 -- | Type specialised fromIntegral with out-of-range error. i32_to_u12 :: I32 -> U12 -- | Type specialised fromIntegral with out-of-range error. i32_to_u14 :: I32 -> U14 -- | Type specialised fromIntegral with out-of-range error. i32_to_u16 :: I32 -> U16 -- | Type specialised fromIntegral with out-of-range error. i32_to_u24 :: I32 -> U24 -- | Type specialised fromIntegral with out-of-range error. i32_to_u32 :: I32 -> U32 -- | Type specialised fromIntegral with out-of-range error. i32_to_u64 :: I32 -> U64 -- | Type specialised fromIntegral with out-of-range error. i32_to_i4 :: I32 -> I4 -- | Type specialised fromIntegral with out-of-range error. i32_to_i7 :: I32 -> I7 -- | Type specialised fromIntegral with out-of-range error. i32_to_i8 :: I32 -> I8 -- | Type specialised fromIntegral with out-of-range error. i32_to_i12 :: I32 -> I12 -- | Type specialised fromIntegral with out-of-range error. i32_to_i14 :: I32 -> I14 -- | Type specialised fromIntegral with out-of-range error. i32_to_i16 :: I32 -> I16 -- | Type specialised fromIntegral with out-of-range error. i32_to_i24 :: I32 -> I24 -- | Type specialised fromIntegral i32_to_i64 :: I32 -> I64 -- | Type specialised fromIntegral with out-of-range error. i64_to_u4 :: I64 -> U4 -- | Type specialised fromIntegral with out-of-range error. i64_to_u7 :: I64 -> U7 -- | Type specialised fromIntegral with out-of-range error. i64_to_u8 :: I64 -> U8 -- | Type specialised fromIntegral with out-of-range error. i64_to_u12 :: I64 -> U12 -- | Type specialised fromIntegral with out-of-range error. i64_to_u14 :: I64 -> U14 -- | Type specialised fromIntegral with out-of-range error. i64_to_u16 :: I64 -> U16 -- | Type specialised fromIntegral with out-of-range error. i64_to_u24 :: I64 -> U24 -- | Type specialised fromIntegral with out-of-range error. i64_to_u32 :: I64 -> U32 -- | Type specialised fromIntegral with out-of-range error. i64_to_u64 :: I64 -> U64 -- | Type specialised fromIntegral with out-of-range error. i64_to_i4 :: I64 -> I4 -- | Type specialised fromIntegral with out-of-range error. i64_to_i7 :: I64 -> I7 -- | Type specialised fromIntegral with out-of-range error. i64_to_i8 :: I64 -> I8 -- | Type specialised fromIntegral with out-of-range error. i64_to_i12 :: I64 -> I12 -- | Type specialised fromIntegral with out-of-range error. i64_to_i14 :: I64 -> I14 -- | Type specialised fromIntegral with out-of-range error. i64_to_i16 :: I64 -> I16 -- | Type specialised fromIntegral with out-of-range error. i64_to_i24 :: I64 -> I24 -- | Type specialised fromIntegral with out-of-range error. i64_to_i32 :: I64 -> I32 -- | Nichomachus of Gerasa (Νικόμαχος) c.60-c.120 -- -- -- https://pdfs.semanticscholar.org/5dac/8842ad857c822ab854ede3decadfe0464f15.pdf module Music.Theory.Math.Nichomachus -- | a-b = b-c ; b = a+c / 2 -- --
--   arithmetic_mean 2 6 == 4
--   arithmetic_mean 1 2 == (1+2)/2 -- 3/2
--   
arithmetic_mean :: Fractional a => a -> a -> a -- | ab = bc ; b = sqrt ac -- --
--   geometric_mean 1 4 == 2
--   geometric_mean 1 2 == sqrt (1*2) -- sqrt 2
--   
geometric_mean :: Floating a => a -> a -> a -- | a-b a = b-c c ; 2ac / a+c -- --
--   harmonic_mean 2 6 == 3
--   harmonic_mean 1 2 == (2*1*2)/(1+2) -- 4/3
--   
harmonic_mean :: Fractional a => a -> a -> a -- | a-b c = b-c a ; a-b b-c = ca ; aa+cc / a+c -- --
--   cont_harmonic_mean 3 6 == 5
--   cont_harmonic_mean 1 2 == (1*1+2*2)/(1+2) -- 5/3
--   
cont_harmonic_mean :: Fractional a => a -> a -> a -- | a-b c = b-c b ; a-b b-c = cb ; c - a + (sqrt (5aa - -- 2ac + cc)) / 2 -- --
--   cont_geometric_mean 2 5 == 4
--   cont_geometric_mean 1 2 == (2-1+sqrt(5*1*1-2*1*2+2*2))/2 -- (1+sqrt 5)/2 -- GOLDEN RATIO -- 1.6180
--   
cont_geometric_mean :: Floating a => a -> a -> a -- | a-b c = b-c b ; a-b b-c = cb ; a - c + (sqrt (aa - -- 2ac + 5cc)) / 2 -- --
--   subcont_geometric_mean 1 6 == 4
--   subcont_geometric_mean 1 2 == (-1 + sqrt 17) / 2 -- 1.5616
--   
subcont_geometric_mean :: Floating a => a -> a -> a -- | Prime number related functions. module Music.Theory.Math.Prime -- | Alias for primes. -- --
--   take 12 primes_list == [2,3,5,7,11,13,17,19,23,29,31,37]
--   
primes_list :: Integral i => [i] -- | Give zero-index of prime, or Nothing if value is not prime. -- --
--   map prime_k [2,3,5,7,11,13,17,19,23,29,31,37] == map Just [0 .. 11]
--   map prime_k [1,4,6,8,9,10,12,14,15,16,18,20,21,22] == replicate 14 Nothing
--   
prime_k :: Integral a => a -> Maybe Int -- | maybe error of prime_k -- --
--   prime_k_err 13 == 5
--   
prime_k_err :: Integral a => a -> Int -- | Generate list of factors of n from x. -- --
--   factor primes_list 315 == [3,3,5,7]
--   Primes.primeFactors 315 == [3,3,5,7]
--   
-- -- As a special case 1 gives the empty list. -- --
--   factor primes_list 1 == []
--   Primes.primeFactors 1 == []
--   
factor :: Integral i => [i] -> i -> [i] -- | factor of primes_list. -- --
--   map prime_factors [-1,0,1] == [[],[],[]]
--   map prime_factors [1,4,231,315] == [[],[2,2],[3,7,11],[3,3,5,7]]
--   map Primes.primeFactors [1,4,231,315] == [[],[2,2],[3,7,11],[3,3,5,7]]
--   
prime_factors :: Integral i => i -> [i] -- | maximum of prime_factors -- --
--   map prime_limit [243,125] == [3,5]
--   map prime_limit [0,1] == [1,1]
--   
prime_limit :: Integral i => i -> i -- | Collect number of occurences of each element of a sorted list. -- --
--   multiplicities [1,1,1,2,2,3] == [(1,3),(2,2),(3,1)]
--   
multiplicities :: Eq t => [t] -> [(t, Int)] -- | Pretty printer for histogram (multiplicites). -- --
--   multiplicities_pp [(3,2),(5,1),(7,1)] == "3×2 5×1 7×1"
--   
multiplicities_pp :: Show t => [(t, Int)] -> String -- | multiplicities of primeFactors. -- --
--   prime_factors_m 1 == []
--   prime_factors_m 315 == [(3,2),(5,1),(7,1)]
--   
prime_factors_m :: Integral i => i -> [(i, Int)] -- | multiplicities_pp of prime_factors_m. prime_factors_m_pp :: (Show i, Integral i) => i -> String -- | Prime factors of n and d. rat_prime_factors :: Integral i => (i, i) -> ([i], [i]) -- | Ratio variant of rat_prime_factors rational_prime_factors :: Integral i => Ratio i -> ([i], [i]) -- | Variant that writes factors of numerator as positive and factors for -- denominator as negative. Sorted by absolute value. -- --
--   rat_prime_factors_sgn (3 * 5 * 7 * 11,1) == [3,5,7,11]
--   rat_prime_factors_sgn (3 * 5,7 * 11) == [3,5,-7,-11]
--   rat_prime_factors_sgn (3 * 7,5) == [3,-5,7]
--   
rat_prime_factors_sgn :: Integral i => (i, i) -> [i] -- | Rational variant. -- --
--   rational_prime_factors_sgn (2 * 2 * 2 * 1/3 * 1/3 * 1/3 * 1/3 * 5) == [2,2,2,-3,-3,-3,-3,5]
--   
rational_prime_factors_sgn :: Integral i => Ratio i -> [i] -- | The largest prime factor of n/d. rat_prime_limit :: Integral i => (i, i) -> i -- | The largest prime factor of n. -- --
--   rational_prime_limit (243/125) == 5
--   
rational_prime_limit :: Integral i => Ratio i -> i -- | Merge function for rat_prime_factors_m rat_pf_merge :: Ord t => [(t, Int)] -> [(t, Int)] -> [(t, Int)] -- | Collect the prime factors in a rational number given as a numerator/ -- denominator pair (n,m). Prime factors are listed in ascending order -- with their positive or negative multiplicities, depending on whether -- the prime factor occurs in the numerator or the denominator (after -- cancelling out common factors). -- --
--   rat_prime_factors_m (1,1) == []
--   rat_prime_factors_m (16,15) == [(2,4),(3,-1),(5,-1)]
--   rat_prime_factors_m (10,9) == [(2,1),(3,-2),(5,1)]
--   rat_prime_factors_m (81,64) == [(2,-6),(3,4)]
--   rat_prime_factors_m (27,16) == [(2,-4),(3,3)]
--   rat_prime_factors_m (12,7) == [(2,2),(3,1),(7,-1)]
--   rat_prime_factors_m (5,31) == [(5,1),(31,-1)]
--   
rat_prime_factors_m :: Integral i => (i, i) -> [(i, Int)] -- | Ratio variant of rat_prime_factors_m rational_prime_factors_m :: Integral i => Ratio i -> [(i, Int)] -- | Variant of rat_prime_factors_m giving results in a list. -- --
--   rat_prime_factors_l (1,1) == []
--   rat_prime_factors_l (2^5,9) == [5,-2]
--   rat_prime_factors_l (2*2*3,7) == [2,1,0,-1]
--   rat_prime_factors_l (3*3,11*13) == [0,2,0,0,-1,-1]
--   
rat_prime_factors_l :: Integral i => (i, i) -> [Int] -- | Ratio variant of rat_prime_factors_l -- --
--   map rational_prime_factors_l [1/31,256/243] == [[0,0,0,0,0,0,0,0,0,0,-1],[8,-5]]
--   
rational_prime_factors_l :: Integral i => Ratio i -> [Int] -- | Variant of rational_prime_factors_l padding table to k -- places. It is an error for k to indicate a prime less than the -- limit of x. -- --
--   map (rat_prime_factors_t 6) [(5,13),(12,7)] == [[0,0,1,0,0,-1],[2,1,0,-1,0,0]]
--   rat_prime_factors_t 3 (9,7) == undefined
--   
rat_prime_factors_t :: (Integral i, Show i) => Int -> (i, i) -> [Int] -- | Ratio variant of rat_prime_factors_t rational_prime_factors_t :: (Integral i, Show i) => Int -> Ratio i -> [Int] -- | Condense factors list to include only indicated places. It is an error -- if a deleted factor has a non-zero entry in the table. -- --
--   rat_prime_factors_l (12,7) == [2,1,0,-1]
--   rat_prime_factors_c [2,3,5,7] (12,7) == [2,1,0,-1]
--   rat_prime_factors_c [2,3,7] (12,7) == [2,1,-1]
--   
rat_prime_factors_c :: (Integral i, Show i) => [i] -> (i, i) -> [Int] -- | Ratio variant of rat_prime_factors_t -- --
--   map (rational_prime_factors_c [3,5,31]) [3,5,31]
--   
rational_prime_factors_c :: (Integral i, Show i) => [i] -> Ratio i -> [Int] -- | Pretty printer for prime factors. sup=superscript ol=overline prime_factors_pp :: [Integer] -> String -- | Pretty printer for prime factors. sup=superscript ol=overline -- --
--   prime_factors_pp_sup_ol True [2,2,-3,5] == "2²·3̅·5"
--   prime_factors_pp_sup_ol False [-2,-2,-2,3,3,5,5,5,5] == "-2³·3²·5⁴"
--   
prime_factors_pp_sup_ol :: Bool -> [Integer] -> String -- | The On-Line Encyclopedia of Integer Sequences, http://oeis.org/ module Music.Theory.Math.Oeis -- | http://oeis.org/A000005 -- -- d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. -- (Formerly M0246 N0086) -- -- a000005 :: Integral n => [n] -- | http://oeis.org/A000010 -- -- Euler totient function phi(n): count numbers <= n and prime to n. -- --
--   [1,1,2,2,4,2,6,4,6,4,10,4,12,6,8,8,16,6,18,8,12,10,22,8,20,12] `isPrefixOf` a000010
--   
a000010 :: Integral n => [n] a000010_n :: Integral n => n -> n -- | http://oeis.org/A000012 -- -- The simplest sequence of positive numbers: the all 1's sequence. a000012 :: Num n => [n] -- | https://oeis.org/A000031 -- -- Number of n-bead necklaces with 2 colors when turning over is not -- allowed; also number of output sequences from a simple n-stage cycling -- shift register; also number of binary irreducible polynomials whose -- degree divides n. -- --
--   [1,2,3,4,6,8,14,20,36,60,108,188,352,632,1182,2192,4116,7712,14602,27596] `isPrefixOf` a000031
--   
a000031 :: Integral n => [n] a000031_n :: Integral n => n -> n -- | http://oeis.org/A000032 -- -- Lucas numbers beginning at 2: L(n) = L(n-1) + L(n-2), L(0) = 2, L(1) = -- 1. (Formerly M0155) -- --
--   [2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127] `isPrefixOf` a000032
--   
a000032 :: Num n => [n] -- | http://oeis.org/A000040 -- -- The prime numbers. -- --
--   [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103] `isPrefixOf` a000040
--   
a000040 :: Integral n => [n] -- | http://oeis.org/A000041 -- -- a(n) is the number of partitions of n (the partition numbers). -- -- a000041 :: Num n => [n] -- | http://oeis.org/A000045 -- -- Fibonacci numbers -- --
--   [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946] `isPrefixOf` a000045
--   
a000045 :: Num n => [n] -- | http://oeis.org/A000051 -- -- a(n) = 2^n + 1 -- --
--   [2,3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385,32769,65537,131073] `isPrefixOf` a000051
--   
a000051 :: Num n => [n] -- | http://oeis.org/A000071 -- -- a(n) = Fibonacci(n) - 1. -- --
--   [0,0,1,2,4,7,12,20,33,54,88,143,232,376,609,986,1596,2583,4180,6764,10945,17710] `isPrefixOf` a000071
--   
a000071 :: Num n => [n] -- | http://oeis.org/A000073 -- -- Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) for n >= 3 with -- a(0) = a(1) = 0 and a(2) = 1. -- --
--   [0,0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890] `isPrefixOf` a000073
--   
a000073 :: Num n => [n] -- | http://oeis.org/A000078 -- -- Tetranacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) + a(n-4) with -- a(0)=a(1)=a(2)=0, a(3)=1. -- --
--   [0,0,0,1,1,2,4,8,15,29,56,108,208,401,773,1490,2872,5536,10671,20569,39648] `isPrefixOf` a000078
--   
a000078 :: Num n => [n] -- | http://oeis.org/A000079 -- -- Powers of 2: a(n) = 2^n. (Formerly M1129 N0432) -- --
--   [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536] `isPrefixOf` a000079
--   [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536] `isPrefixOf` map (2 ^) [0..]
--   
a000079 :: Num n => [n] -- | http://oeis.org/A000085 -- -- Number of self-inverse permutations on n letters, also known as -- involutions; number of standard Young tableaux with n cells. -- --
--   [1,1,2,4,10,26,76,232,764,2620,9496,35696,140152,568504,2390480,10349536] `isPrefixOf` a000085
--   
a000085 :: Integral n => [n] -- | http://oeis.org/A000108 -- -- Catalan numbers: C(n) = binomial(2n,n)(n+1) = (2n)!(n!(n+1)!). -- --
--   [1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845] `isPrefixOf` a000108
--   
a000108 :: Num n => [n] -- | http://oeis.org/A000120 -- -- 1's-counting sequence: number of 1's in binary expansion of n (or the -- binary weight of n). -- --
--   [0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3] `isPrefixOf` a000120
--   
a000120 :: Integral i => [i] -- | http://oeis.org/A000142 -- -- Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, -- number of permutations of n letters). -- --
--   [1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800] `isPrefixOf` a000142
--   
a000142 :: (Enum n, Num n) => [n] -- | https://oeis.org/A000201 -- -- Lower Wythoff sequence (a Beatty sequence): a(n) = floor(n*phi), where -- phi = (1+sqrt(5))/2 = A001622 -- --
--   [1,3,4,6,8,9,11,12,14,16,17,19,21,22,24,25,27,29,30,32,33,35,37,38,40,42] `isPrefixOf` a000201
--   
-- --
--   import Sound.SC3.Plot 
--   plot_p1_imp [take 128 a000201 :: [Int]]
--   
a000201 :: Integral n => [n] -- | https://oeis.org/A000204 -- -- Lucas numbers (beginning with 1): L(n) = L(n-1) + L(n-2) with L(1) = -- 1, L(2) = 3 -- --
--   [1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127] `isPrefixOf` a000204
--   
a000204 :: Num n => [n] -- | http://oeis.org/A000213 -- -- Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) with -- a(0)=a(1)=a(2)=1. -- -- a000213 :: Num n => [n] -- | https://oeis.org/A000217 -- -- Triangular numbers: a(n) = binomial(n+1,2) = n(n+1)/2 = 0 + 1 + 2 + -- ... + n. -- --
--   [0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210,231,253,276] `isPrefixOf` a000217
--   
a000217 :: (Enum n, Num n) => [n] -- | http://oeis.org/A000225 -- -- a(n) = 2^n - 1 (Sometimes called Mersenne numbers, although that name -- is usually reserved for A001348) -- --
--   [0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535] `isPrefixOf` a000225
--   
a000225 :: Num n => [n] -- | http://oeis.org/000285 -- -- a(0) = 1, a(1) = 4, and a(n) = a(n-1) + a(n-2) for n >= 2. -- (Formerly M3246 N1309) -- --
--   [1,4,5,9,14,23,37,60,97,157,254,411,665,1076,1741,2817,4558,7375,11933,19308] `isPrefixOf` a000285
--   
a000285 :: Num n => [n] -- | http://oeis.org/A000290 -- -- The squares of the non-negative integers. -- --
--   [0,1,4,9,16,25,36,49,64,81,100] `isPrefixOf` a000290
--   
a000290 :: Integral n => [n] -- | https://oeis.org/A000292 -- -- Tetrahedral (or triangular pyramidal) numbers: a(n) = C(n+2,3) = -- n*(n+1)*(n+2)/6. -- --
--   [0,1,4,10,20,35,56,84,120,165,220,286,364,455,560,680,816,969,1140,1330,1540] `isPrefixOf` a000292
--   
a000292 :: (Enum n, Num n) => [n] -- | http://oeis.org/A000384 -- -- Hexagonal numbers: a(n) = n*(2*n-1). (Formerly M4108 N1705) -- --
--   [0,1,6,15,28,45,66,91,120,153,190,231,276,325,378,435,496,561,630,703,780,861] `isPrefixOf` a000384
--   
a000384 :: Integral n => [n] -- | http://oeis.org/A000578 -- -- The cubes: a(n) = n^3. -- --
--   [0,1,8,27,64,125,216,343,512,729,1000,1331,1728,2197,2744,3375,4096,4913,5832] `isPrefixOf` a000578
--   
a000578 :: Num n => [n] -- | http://oeis.org/A000583 -- -- Fourth powers: a(n) = n^4. -- --
--   [0,1,16,81,256,625,1296,2401,4096,6561,10000,14641,20736,28561,38416,50625] `isPrefixOf` a000583
--   
a000583 :: Integral n => [n] -- | http://oeis.org/A000670 -- -- Fubini numbers: number of preferential arrangements of n labeled -- elements; or number of weak orders on n labeled elements; or number of -- ordered partitions of [n]. -- --
--   [1,1,3,13,75,541,4683,47293,545835,7087261,102247563,1622632573,28091567595] `isPrefixOf` a000670
--   
a000670 :: Integral n => [n] -- | https://oeis.org/A000796 -- -- Decimal expansion of Pi (or digits of Pi). -- --
--   [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9] `isPrefixOf` a000796
--   
-- --
--   pi :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 
--   
a000796 :: Integral n => [n] -- | https://oeis.org/A000930 -- -- Narayana's cows sequence. -- --
--   [1,1,1,2,3,4,6,9,13,19,28,41,60] `isPrefixOf` a000930
--   
a000930 :: Num n => [n] -- | https://oeis.org/A000931 -- -- Padovan sequence (or Padovan numbers): a(n) = a(n-2) + a(n-3) with -- a(0) = 1, a(1) = a(2) = 0. -- --
--   [1,0,0,1,0,1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265] `isPrefixOf` a000931
--   
a000931 :: Num n => [n] -- | https://oeis.org/A001008 -- -- Numerators of harmonic numbers H(n) = Sum_{i=1..n} 1/i -- -- a001008 :: Integral i => [i] -- | http://oeis.org/A001037 -- -- Number of degree-n irreducible polynomials over GF(2); number of -- n-bead necklaces with beads of 2 colors when turning over is not -- allowed and with primitive period n; number of binary Lyndon words of -- length n. -- --
--   [1,2,1,2,3,6,9,18,30,56,99,186,335,630,1161,2182,4080,7710,14532,27594,52377,99858,190557,364722,698870] `isPrefixOf` a001037
--   
a001037 :: Integral n => [n] a001037_n :: Integral n => n -> n -- | http://oeis.org/A001113 -- -- Decimal expansion of e. -- --
--   [2,7,1,8,2,8,1,8,2,8,4,5,9,0,4,5,2,3,5,3,6,0,2,8,7,4,7,1,3,5,2,6,6,2,4,9,7,7,5] `isPrefixOf` a001113
--   
-- --
--   exp 1 :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 
--   
a001113 :: Integral n => [n] -- | https://oeis.org/A001147 -- -- Double factorial of odd numbers: a(n) = (2*n-1)!! = 1*3*5*...*(2*n-1). -- (Formerly M3002 N1217) -- --
--   [1,1,3,15,105,945,10395,135135,2027025,34459425,654729075,13749310575] `isPrefixOf` a001147
--   
a001147 :: Integral t => [t] -- | https://oeis.org/A001156 -- -- Number of partitions of n into squares. -- --
--   [1,1,1,1,2,2,2,2,3,4,4,4,5,6,6,6,8,9,10,10,12,13,14,14,16,19,20,21,23,26,27,28] `isPrefixOf` a001156
--   
a001156 :: Num n => [n] -- | https://oeis.org/A001333 -- -- Numerators of continued fraction convergents to sqrt(2). -- -- a001333 :: Num n => [n] -- | http://oeis.org/A001622 -- -- Decimal expansion of golden ratio phi (or tau) = (1 + sqrt(5))/2. -- --
--   [1,6,1,8,0,3,3,9,8,8,7,4,9,8,9,4,8,4,8,2,0,4,5,8,6,8,3,4,3,6,5,6,3,8,1,1,7,7,2] `isPrefixOf` a001622
--   
-- --
--   a001622_k :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 
--   
a001622 :: Num n => [n] a001622_k :: Floating n => n -- | http://oeis.org/A001644 -- -- a(n) = a(n-1) + a(n-2) + a(n-3), a(0)=3, a(1)=1, a(2)=3. -- -- a001644 :: Num n => [n] -- | https://oeis.org/A001653 -- -- Numbers k such that 2*k^2 - 1 is a square. -- --
--   [1, 5, 29, 169, 985, 5741, 33461, 195025, 1136689, 6625109, 38613965, 225058681, 1311738121, 7645370045, 44560482149] `isPrefixOf` a001653
--   
a001653 :: [Integer] -- | http://oeis.org/A001687 -- -- a(n) = a(n-2) + a(n-5). -- -- a001687 :: Num n => [n] -- | https://oeis.org/A001950 -- -- Upper Wythoff sequence (a Beatty sequence): a(n) = floor(n*phi^2), -- where phi = (1+sqrt(5))/2 -- --
--   [2,5,7,10,13,15,18,20,23,26,28,31,34,36,39,41,44,47,49,52,54,57,60,62,65] `isPrefixOf` a001950
--   
a001950 :: Integral n => [n] -- | http://oeis.org/A002267 -- -- The 15 supersingular primes. a002267 :: Num n => [n] -- | https://oeis.org/A002487 -- -- Stern's diatomic series (or Stern-Brocot sequence) -- --
--   [0,1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5] `isPrefixOf` a002487
--   
a002487 :: Num n => [n] -- | https://oeis.org/A002858 -- -- Ulam numbers: a(1) = 1; a(2) = 2; for n>2, a(n) = least number > -- a(n-1) which is a unique sum of two distinct earlier terms. -- --
--   [1, 2, 3, 4, 6, 8, 11, 13, 16, 18, 26, 28, 36, 38, 47, 48, 53, 57, 62, 69, 72, 77, 82, 87, 97, 99, 102, 106, 114, 126] `isPrefixOf` a002858
--   
a002858 :: [Integer] ulam :: Int -> Integer -> [Integer] -> [Integer] -- | http://oeis.org/A003108 -- -- Number of partitions of n into cubes. -- --
--   [1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,5,6,6,6,7,7,7,7] `isPrefixOf` a003108
--   
a003108 :: Num n => [n] a003215_n :: Num n => n -> n -- | http://oeis.org/A003215 -- -- Hex (or centered hexagonal) numbers: 3*n*(n+1)+1 (crystal ball -- sequence for hexagonal lattice). -- --
--   [1,7,19,37,61,91,127,169,217,271,331,397,469,547,631,721,817,919,1027,1141] `isPrefixOf` a003215
--   
a003215 :: (Enum n, Num n) => [n] -- | http://oeis.org/A003269 -- --
--   [0,1,1,1,1,2,3,4,5,7,10,14,19,26,36,50,69,95,131,181,250,345,476,657] `isPrefixOf` a003269
--   
a003269 :: Num n => [n] -- | http://oeis.org/A003520 -- -- a(n) = a(n-1) + a(n-5); a(0) = ... = a(4) = 1. -- --
--   [1,1,1,1,1,2,3,4,5,6,8,11,15,20,26,34,45,60,80,106,140,185,245,325,431] `isPrefixOf` a003520
--   
a003520 :: Num n => [n] -- | http://oeis.org/A003462 -- -- a(n) = (3^n - 1)/2. (Formerly M3463) -- -- a003462 :: [Integer] a003462_n :: Integer -> Integer -- | http://oeis.org/A003586 -- -- 3-smooth numbers: numbers of the form 2^i*3^j with i, j >= 0 -- -- a003586 :: [Integer] -- | https://oeis.org/A003849 -- -- The infinite Fibonacci word (start with 0, apply 0->01, 1->0, -- take limit). -- --
--   [0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0] `isPrefixOf` a003849
--   
a003849 :: Num n => [n] -- | http://oeis.org/A004001 -- -- Hofstadter-Conway sequence: a(n) = a(a(n-1)) + a(n-a(n-1)) with a(1) = -- a(2) = 1. -- --
--   [1,1,2,2,3,4,4,4,5,6,7,7,8,8,8,8,9,10,11,12,12,13,14,14,15,15,15,16,16,16,16,16] `isPrefixOf` a004001
--   
-- --
--   plot_p1_ln [take 250 a004001]
--   plot_p1_ln [zipWith (-) a004001 (map (`div` 2) [1 .. 2000])]
--   
a004001 :: [Int] -- | http://oeis.org/A004718 -- -- Per Nørgård's "infinity sequence" -- --
--   take 32 a004718 == [0,1,-1,2,1,0,-2,3,-1,2,0,1,2,-1,-3,4,1,0,-2,3,0,1,-1,2,-2,3,1,0,3,-2,-4,5]
--   
-- --
--   plot_p1_imp [take 1024 a004718]
--   
-- -- -- https://www.tandfonline.com/doi/abs/10.1080/17459737.2017.1299807 -- https://arxiv.org/pdf/1402.3091.pdf a004718 :: Num n => [n] -- | http://oeis.org/A005185 -- -- Hofstadter Q-sequence: a(1) = a(2) = 1; a(n) = a(n-a(n-1)) + -- a(n-a(n-2)) for n > 2. -- --
--   [1,1,2,3,3,4,5,5,6,6,6,8,8,8,10,9,10,11,11,12,12,12,12,16,14,14,16,16,16,16,20] `isPrefixOf` a005185
--   
a005185 :: [Int] -- | https://oeis.org/A005448 -- -- Centered triangular numbers: a(n) = 3n(n-1)/2 + 1. -- --
--   [1,4,10,19,31,46,64,85,109,136,166,199,235,274,316,361,409,460,514,571,631,694] `isPrefixOf` a005448
--   
-- --
--   map a005448_n [1 .. 1000] `isPrefixOf` a005448
--   
a005448 :: Integral n => [n] a005448_n :: Integral n => n -> n -- | http://oeis.org/A005728 -- -- Number of fractions in Farey series of order n. -- --
--   [1,2,3,5,7,11,13,19,23,29,33,43,47,59,65,73,81,97,103,121,129,141,151] `isPrefixOf` a005728
--   
a005728 :: Integral i => [i] -- | http://oeis.org/A005811 -- -- Number of runs in binary expansion of n (n>0); number of 1's in -- Gray code for n -- --
--   take 32 a005811 == [0,1,2,1,2,3,2,1,2,3,4,3,2,3,2,1,2,3,4,3,4,5,4,3,2,3,4,3,2,3,2,1]
--   
a005811 :: Integral n => [n] -- | http://oeis.org/A005917 -- -- Rhombic dodecahedral numbers: a(n) = n^4 - (n - 1)^4. -- --
--   [1,15,65,175,369,671,1105,1695,2465,3439,4641,6095,7825,9855,12209,14911,17985] `isPrefixOf` a005917
--   
a005917 :: Integral n => [n] -- | https://oeis.org/A006003 -- -- a(n) = n*(n^2 + 1)/2. -- --
--   [0,1,5,15,34,65,111,175,260,369,505,671,870,1105,1379,1695,2056,2465,2925,3439] `isPrefixOf` a006003
--   
-- --
--   map a006003_n [0 .. 1000] `isPrefixOf` a006003
--   
a006003 :: Integral n => [n] a006003_n :: Integral n => n -> n -- | http://oeis.org/A006046 -- -- Total number of odd entries in first n rows of Pascal's triangle: a(0) -- = 0, a(1) = 1, a(2k) = 3*a(k), a(2k+1) = 2*a(k) + a(k+1). -- --
--   [0,1,3,5,9,11,15,19,27,29,33,37,45,49,57,65,81,83,87,91,99,103,111,119,135,139] `isPrefixOf` a006046
--   
-- --
--   import Sound.SC3.Plot 
--   plot_p1_ln [take 250 a006046]
--   let t = log 3 / log 2
--   plot_p1_ln [zipWith (/) (map fromIntegral a006046) (map (\n -> n ** t) [0.0,1 .. 200])]
--   
a006046 :: [Int] -- | http://oeis.org/A006052 -- -- Number of magic squares of order n composed of the numbers from 1 to -- n^2, counted up to rotations and reflections. -- --
--   [1,0,1,880,275305224] == a006052
--   
a006052 :: Integral n => [n] -- | http://oeis.org/A006842 -- -- Triangle read by rows: row n gives numerators of Farey series of order -- n. -- --
--   [0,1,0,1,1,0,1,1,2,1,0,1,1,1,2,3,1,0,1,1,1,2,1,3,2,3,4,1,0,1,1,1,1,2,1,3] `isPrefixOf` a006842
--   plot_p1_imp [take 200 (a006842 :: [Int])]
--   plot_p1_pt [take 10000 (a006842 :: [Int])]
--   
a006842 :: Integral i => [i] -- | http://oeis.org/A006843 -- -- Triangle read by rows: row n gives denominators of Farey series of -- order n -- --
--   [1,1,1,2,1,1,3,2,3,1,1,4,3,2,3,4,1,1,5,4,3,5,2,5,3,4,5,1,1,6,5,4,3,5,2,5] `isPrefixOf` a006843
--   plot_p1_imp [take 200 (a006843 :: [Int])]
--   plot_p1_pt [take 10000 (a006843 :: [Int])]
--   
a006843 :: Integral i => [i] -- | https://oeis.org/A007318 -- -- Pascal's triangle read by rows -- -- a007318 :: Integral i => [i] a007318_tbl :: Integral i => [[i]] -- | https://oeis.org/A008277 -- -- Triangle of Stirling numbers of the second kind, S2(n,k), n >= 1, 1 -- <= k <= n. -- -- a008277 :: (Enum n, Num n) => [n] a008277_tbl :: (Enum n, Num n) => [[n]] -- | http://oeis.org/A008278 -- -- Triangle of Stirling numbers of 2nd kind, S(n,n-k+1), n >= 1, -- 1<=k<=n. -- -- a008278 :: (Enum n, Num n) => [n] a008278_tbl :: (Enum n, Num n) => [[n]] -- | http://oeis.org/A008683 -- -- Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is -- the product of k different primes; otherwise mu(n) = 0. -- --
--   [1,-1,-1,0,-1,1,-1,0,0,1,-1,0,-1,1,1,0,-1,0,-1,0,1,1,-1,0,0,1,0,0,-1,-1,-1,0,1] `isPrefixOf` a008683
--   
a008683 :: Integral n => [n] a008683_n :: Integral n => n -> n -- | http://oeis.org/A010049 -- -- Second-order Fibonacci numbers. -- --
--   [0,1,1,3,5,10,18,33,59,105,185,324,564,977,1685,2895,4957,8462,14406,24465,41455] `isInfixOf` a010049
--   
a010049 :: Num n => [n] -- | https://oeis.org/A010060 -- -- Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 -- and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtained from A_k -- by interchanging 0's and 1's. -- -- a010060 :: [Integer] -- | https://oeis.org/A014081 -- -- a(n) is the number of occurrences of '11' in binary expansion of n. -- --
--   [0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 0, 0, 0, 1, 0, 0, 1, 2] `isPrefixOf` a014081
--   
a014081 :: (Integral i, Bits i) => [i] -- | https://oeis.org/A014577 -- -- The regular paper-folding sequence (or dragon curve sequence). -- --
--   [1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1] `isPrefixOf` a014577
--   
a014577 :: Integral i => [i] -- | http://oeis.org/A016813 -- -- a(n) = 4*n + 1. -- --
--   [1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101] `isPrefixOf` a016813
--   
a016813 :: Integral n => [n] -- | http://oeis.org/A017817 -- -- a(n) = a(n-3) + a(n-4), with a(0)=1, a(1)=a(2)=0, a(3)=1 -- --
--   [1,0,0,1,1,0,1,2,1,1,3,3,2,4,6,5,6,10,11,11,16,21,22,27,37,43,49,64,80,92] `isPrefixOf` a017817
--   
a017817 :: Num n => [n] -- | http://oeis.org/A020695 -- -- Pisot sequence E(2,3). -- --
--   [2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711] `isPrefixOf` a020695
--   
a020695 :: Num n => [n] -- | https://oeis.org/A020985 -- -- The Rudin-Shapiro or Golay-Rudin-Shapiro sequence (coefficients of the -- Shapiro polynomials). 45 -- --
--   [1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1] `isPrefixOf` a020985
--   
a020985 :: [Integer] -- | http://oeis.org/A022095 -- -- Fibonacci sequence beginning 1, 5. -- --
--   [1,5,6,11,17,28,45,73,118,191,309,500,809,1309,2118,3427,5545,8972,14517,23489] `isPrefixOf` a022095
--   
a022095 :: Num n => [n] -- | http://oeis.org/A022096 -- -- Fibonacci sequence beginning 1, 6. -- --
--   [1,6,7,13,20,33,53,86,139,225,364,589,953,1542,2495,4037,6532,10569,17101,27670] `isPrefixOf` a022096
--   
a022096 :: Num n => [n] -- | https://oeis.org/A027750 -- -- Triangle read by rows in which row n lists the divisors of n. -- --
--   [1,1,2,1,3,1,2,4,1,5,1,2,3,6,1,7,1,2,4,8,1,3,9,1,2,5,10,1,11,1,2,3,4,6,12,1,13] `isPrefixOf` a027750
--   
a027750 :: Integral n => [n] a027750_row :: Integral n => n -> [n] -- | http://oeis.org/A027934 -- -- a(0)=0, a(1)=1, a(2)=2; for n > 2, a(n) = 3*a(n-1) - a(n-2) - -- 2*a(n-3). -- --
--   [0,1,2,5,11,24,51,107,222,457,935,1904,3863,7815,15774,31781,63939,128488] `isPrefixOf` a027934
--   
a027934 :: Num n => [n] -- | http://oeis.org/A029635 -- -- The (1,2)-Pascal triangle (or Lucas triangle) read by rows. -- --
--   [2,1,2,1,3,2,1,4,5,2,1,5,9,7,2,1,6,14,16,9,2,1,7,20,30,25,11,2,1,8,27,50,55,36] `isPrefixOf` a029635
--   take 7 a029635_tbl == [[2],[1,2],[1,3,2],[1,4,5,2],[1,5,9,7,2],[1,6,14,16,9,2],[1,7,20,30,25,11,2]]
--   
a029635 :: Num i => [i] a029635_tbl :: Num i => [[i]] -- | http://oeis.org/A030308 -- -- Triangle T(n,k): Write n in base 2, reverse order of digits, to get -- the n-th row -- --
--   take 9 a030308 == [[0],[1],[0,1],[1,1],[0,0,1],[1,0,1],[0,1,1],[1,1,1],[0,0,0,1]]
--   
a030308 :: (Eq n, Num n) => [[n]] -- | https://oeis.org/A033622 -- -- Good sequence of increments for Shell sort (best on big values). -- -- a033622 :: [Integer] a033622_n :: Integer -> Integer -- | http://oeis.org/A033812 -- -- The Loh-Shu 3 X 3 magic square, lexicographically largest variant when -- read by columns. a033812 :: Num n => [n] -- | http://oeis.org/A034968 -- -- Minimal number of factorials that add to n. -- --
--   [0,1,1,2,2,3,1,2,2,3,3,4,2,3,3,4,4,5,3,4,4,5,5,6,1,2,2,3,3,4,2,3,3,4,4,5,3,4,4] `isPrefixOf` a034968
--   
a034968 :: Integral n => [n] -- | https://oeis.org/A036562 -- -- a(n) = 4^(n+1) + 3*2^n + 1 -- -- a036562 :: [Integer] a036562_n :: Integer -> Integer -- | http://oeis.org/A046042 -- -- Number of partitions of n into fourth powers. -- --
--   [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3] `isPrefixOf` a046042
--   
a046042 :: Num n => [n] -- | http://oeis.org/A047999 -- -- Sierpiński's triangle (or gasket): triangle, read by rows, formed by -- reading Pascal's triangle mod 2. -- --
--   [1,1,1,1,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,0] `isPrefixOf` a047999
--   
a047999 :: [Int] a047999_tbl :: [[Int]] -- | https://oeis.org/A048993 -- -- Triangle of Stirling numbers of 2nd kind, S(n,k), n >= 0, 0 <= k -- <= n. -- --
--   [1,0,1,0,1,1,0,1,3,1,0,1,7,6,1,0,1,15,25,10,1,0,1,31,90,65,15,1] `isPrefixOf` a048993
--   
a048993 :: (Enum n, Num n) => [n] a048993_tbl :: (Enum n, Num n) => [[n]] -- | http://oeis.org/A049455 -- -- Triangle read by rows, numerator of fractions of a variant of the -- Farey series. -- --
--   [0,1,0,1,1,0,1,1,2,1,0,1,1,2,1,3,2,3,1,0,1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,0] `isPrefixOf` a049455
--   plot_p1_imp [take 200 (a049455 :: [Int])]
--   plot_p1_pt [take 10000 (a049455 :: [Int])]
--   
a049455 :: Integral n => [n] -- | http://oeis.org/A049456 -- -- Triangle read by rows, denominator of fractions of a variant of the -- Farey series. -- -- a049456 :: Integral n => [n] -- | http://oeis.org/A053121 -- -- Catalan triangle (with 0's) read by rows. -- --
--   [1,0,1,1,0,1,0,2,0,1,2,0,3,0,1,0,5,0,4,0,1,5,0,9,0,5,0,1,0,14,0,14,0,6,0,1,14,0] `isPrefixOf` a053121
--   take 7 a053121_tbl == [[1],[0,1],[1,0,1],[0,2,0,1],[2,0,3,0,1],[0,5,0,4,0,1],[5,0,9,0,5,0,1]]
--   
a053121 :: Num n => [n] a053121_tbl :: Num n => [[n]] -- | http://oeis.org/A058265 -- -- Decimal expansion of the tribonacci constant t, the real root of x^3 - -- x^2 - x - 1. -- --
--   [1,8,3,9,2,8,6,7,5,5,2,1,4,1,6,1,1,3,2,5,5,1,8,5,2,5,6,4,6,5,3,2,8,6,6,0,0,4,2] `isPrefixOf` a058265
--   
-- --
--   a058265_k :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 
--   
a058265 :: Num n => [n] -- | A058265 as Floating calculation, see Data.Number.Fixed. a058265_k :: Floating n => n -- | http://oeis.org/A060588 -- -- If the final two digits of n written in base 3 are the same then this -- digit, otherwise mod 3-sum of these two digits. -- --
--   [0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1] `isPrefixOf` a060588a
--   
a060588a :: Integral n => [n] a060588a_n :: Integral n => n -> n -- | http://oeis.org/A061654 -- -- a(n) = (3*16^n + 2)/5 -- --
--   [1,10,154,2458,39322,629146,10066330,161061274,2576980378,41231686042] `isPrefixOf` a061654
--   
a061654 :: Integral n => [n] a061654_n :: Integral n => n -> n -- | http://oeis.org/A071996 -- -- a(1) = 0, a(2) = 1, a(n) = a(floor(n3)) + a(n - floor(n3)). -- --
--   [0,1,1,1,1,2,2,3,3,3,4,4,4,4,4,5,5,6,6,6,6,6,7,8,8,9,9,9,9,9,9,9,10,11,12,12,12] `isPrefixOf` a071996
--   
-- --
--   plot_p1_ln [take 50 a000201 :: [Int]]
--   plot_p1_imp [map length (take 250 (group a071996))]
--   
a071996 :: Integral n => [n] -- | http://oeis.org/A073334 -- -- The "rhythmic infinity system" of Danish composer Per Nørgård -- --
--   take 24 a073334 == [3,5,8,5,8,13,8,5,8,13,21,13,8,13,8,5,8,13,21,13,21,34,21,13]
--   plot_p1_imp [take 200 (a073334 :: [Int])]
--   
a073334 :: Num n => [n] -- | https://oeis.org/A080843 -- -- Tribonacci word: limit S(infinity), where S(0) = 0, S(1) = 0,1, S(2) = -- 0,1,0,2 and for n >= 0, S(n+3) = S(n+2) S(n+1) S(n). -- --
--   [0,1,0,2,0,1,0,0,1,0,2,0,1,0,1,0,2,0,1,0,0,1,0,2,0,1,0,2,0,1,0,0,1,0,2,0,1,0,1] `isPrefixOf` a080843
--   
a080843 :: Integral n => [n] -- | http://oeis.org/A080992 -- -- Entries in Durer's magic square. -- --
--   [16,3,2,13,5,10,11,8,9,6,7,12,4,15,14,1] == a080992
--   
a080992 :: Num n => [n] -- | http://oeis.org/A083866 -- -- Positions of zeros in Per Nørgård's infinity sequence (A004718). -- --
--   take 24 a083866 == [0,5,10,17,20,27,34,40,45,54,65,68,75,80,85,90,99,105,108,119,130,136,141,150]
--   
a083866 :: (Enum n, Num n) => [n] -- | http://oeis.org/A095660 -- -- Pascal (1,3) triangle. -- --
--   [3,1,3,1,4,3,1,5,7,3,1,6,12,10,3,1,7,18,22,13,3,1,8,25,40,35,16,3,1,9,33,65,75] `isPrefixOf` a095660
--   take 6 a095660_tbl == [[3],[1,3],[1,4,3],[1,5,7,3],[1,6,12,10,3],[1,7,18,22,13,3]]
--   
a095660 :: Num i => [i] a095660_tbl :: Num i => [[i]] -- | http://oeis.org/A095666 -- -- Pascal (1,4) triangle. -- --
--   [4,1,4,1,5,4,1,6,9,4,1,7,15,13,4,1,8,22,28,17,4,1,9,30,50,45,21,4,1,10,39,80,95] `isPrefixOf` a095666
--   take 6 a095666_tbl == [[4],[1,4],[1,5,4],[1,6,9,4],[1,7,15,13,4],[1,8,22,28,17,4]]
--   
a095666 :: Num i => [i] a095666_tbl :: Num i => [[i]] -- | http://oeis.org/A096940 -- -- Pascal (1,5) triangle. -- --
--   [5,1,5,1,6,5,1,7,11,5,1,8,18,16,5,1,9,26,34,21,5,1,10,35,60,55,26,5,1,11,45,95] `isPrefixOf` a096940
--   take 6 a096940_tbl == [[5],[1,5],[1,6,5],[1,7,11,5],[1,8,18,16,5],[1,9,26,34,21,5]]
--   
a096940 :: Num i => [i] a096940_tbl :: Num i => [[i]] -- | http://oeis.org/A105809 -- -- A Fibonacci-Pascal matrix. -- --
--   [1,1,1,2,2,1,3,4,3,1,5,7,7,4,1,8,12,14,11,5,1,13,20,26,25,16,6,1,21,33,46,51,41] `isPrefixOf` a105809
--   
a105809 :: Num n => [n] a105809_tbl :: Num n => [[n]] -- | http://oeis.org/A124010 -- -- Triangle in which first row is 0, n-th row (n>1) lists the -- (ordered) prime signature of n, that is, the exponents of distinct -- prime factors in factorization of n. -- --
--   [0,1,1,2,1,1,1,1,3,2,1,1,1,2,1,1,1,1,1,1,4,1,1,2,1,2,1,1,1,1,1,1,3,1,2,1,1,3,2,1,1,1,1,1,1,5,1] `isPrefixOf` a124010
--   
a124010 :: Integral n => [n] a124010_row :: Integral n => n -> [n] -- | https://oeis.org/A124472 -- -- Benjamin Franklin's 16 X 16 magic square read by rows. -- --
--   [200,217,232,249,8,25,40,57,72,89,104,121,136,153,168,185,58,39,26,7,250,231] `isPrefixOf` a124472
--   
a124472 :: Num n => [n] -- | http://oeis.org/A125519 -- -- A 4 x 4 permutation-free magic square. a125519 :: Num n => [n] -- | http://oeis.org/A126275 -- -- Moment of inertia of all magic squares of order n. -- --
--   [5,60,340,1300,3885,9800,21840,44280,83325,147620,248820,402220,627445,949200] `isPrefixOf` a126275
--   
a126275 :: Integral n => [n] a126275_n :: Integral n => n -> n -- | http://oeis.org/A126276 -- -- Moment of inertia of all magic cubes of order n. -- --
--   [18,504,5200,31500,136710,471968,1378944,3547800,8258250,17728920,35603568] `isPrefixOf` a126276
--   
a126276 :: Integral n => [n] a126276_n :: Integral n => n -> n -- | http://oeis.org/A126651 -- -- A 7 x 7 magic square. a126651 :: Num n => [n] -- | http://oeis.org/A126652 -- -- A 3 X 3 magic square with magic sum 75: the Loh-Shu square A033812 -- multiplied by 5. -- --
--   a126652 == map (* 5) a033812
--   
a126652 :: Num n => [n] -- | http://oeis.org/A126653 -- -- A 3 X 3 magic square with magic sum 45: the Loh-Shu square A033812 -- multiplied by 3. -- --
--   a126653 == map (* 3) a033812
--   
a126653 :: Num n => [n] -- | http://oeis.org/A126654 -- -- A 3 x 3 magic square. a126654 :: Num n => [n] -- | http://oeis.org/A126709 -- -- The Loh-Shu 3 x 3 magic square, variant 2. -- -- Loh-Shu magic square, attributed to the legendary Fu Xi (Fuh-Hi). a126709 :: Num n => [n] -- | http://oeis.org/A126710 -- -- Jaina inscription of the twelfth or thirteenth century, Khajuraho, -- India. a126710 :: Num n => [n] -- | http://oeis.org/A126976 -- -- A 6 x 6 magic square read by rows. -- -- Agrippa (Magic Square of the Sun) a126976 :: Num n => [n] -- | https://oeis.org/A212804 -- -- Expansion of (1 - x)/(1 - x - x^2). -- -- a212804 :: Integral n => [n] -- | https://oeis.org/A245553 -- -- A Rauzy fractal sequence: trajectory of 1 under morphism 1 -> 2,3; -- 2 -> 3; 3 -> 1. -- --
--   [1,2,3,2,3,3,1,2,3,3,1,3,1,1,2,3,2,3,3,1,3,1,1,2,3,3,1,1,2,3,1,2,3,2,3,3,1,2,3] `isPrefixOf` a245553
--   
a245553 :: Integral n => [n] -- | http://oeis.org/A255723 -- -- Another variant of Per Nørgård's "infinity sequence" -- --
--   take 24 a255723 == [0,-2,-1,2,-2,-4,1,0,-1,-3,0,1,2,0,-3,4,-2,-4,1,0,-4,-6,3,-2]
--   plot_p1_imp [take 400 (a255723 :: [Int])]
--   
a255723 :: Num n => [n] -- | http://oeis.org/A256184 -- -- First of two variations by Per Nørgård of his "infinity sequence" -- --
--   take 24 a256184 == [0,-2,-1,2,-4,-3,1,-3,-2,-2,0,1,4,-6,-5,3,-5,-4,-1,-1,0,3,-5,-4]
--   
a256184 :: Num n => [n] -- | http://oeis.org/A256185 -- -- Second of two variations by Per Nørgård of his "infinity sequence" -- --
--   take 24 a256185 == [0,-3,-2,3,-6,1,2,-5,0,-3,0,-5,6,-9,4,-1,-2,-3,-2,-1,-4,5,-8,3]
--   
a256185 :: Num n => [n] -- | http://oeis.org/A270876 -- -- Number of magic tori of order n composed of the numbers from 1 to n^2. -- --
--   [1,0,1,255,251449712] == a270876
--   
a270876 :: Integral n => [n] -- | http://oeis.org/A320872 -- -- For all possible 3 X 3 magic squares made of primes, in order of -- increasing magic sum, list the lexicographically smallest -- representative of each equivalence class (modulo symmetries of the -- square), as a row of the 9 elements (3 rows of 3 elements each). a320872 :: Num n => [n] -- | Square arrays, where the number of rows and columns are equal. module Music.Theory.Array.Square -- | Square as list of lists. type Square t = [[t]] -- | Squares are functors sq_map :: (t -> t) -> Square t -> Square t -- | sq_map of * n sq_scale :: Num t => t -> Square t -> Square t -- | f pointwise at two squares (of equal size, un-checked) sq_zip :: (t -> t -> t) -> Square t -> Square t -> Square t -- | sq_zip of * sq_mul :: Num t => Square t -> Square t -> Square t -- | sq_zip of + sq_add :: Num t => Square t -> Square t -> Square t -- | foldl1 of sq_add sq_sum :: Num t => [Square t] -> Square t -- | Predicate to determine if Square is actually square. sq_is_square :: Square t -> Bool -- | Square as row order list type Square_Linear t = [t] -- | Given degree of square, form Square from Square_Linear. sq_from_list :: Int -> Square_Linear t -> Square t -- | True if list can form a square, ie. if length is a square. -- --
--   sq_is_linear_square T.a126710 == True
--   
sq_is_linear_square :: Square_Linear t -> Bool -- | Calculate degree of linear square, ie. square root of length. -- --
--   sq_linear_degree T.a126710 == 4
--   
sq_linear_degree :: Square_Linear t -> Int -- | Type specialised transpose sq_transpose :: Square t -> Square t -- | Full upper-left (ul) to lower-right (lr) diagonals of a square. -- --
--   sq = sq_from_list 4 T.a126710
--   sq_wr $ sq
--   sq_wr $ sq_diagonals_ul_lr sq
--   sq_wr $ sq_diagonals_ll_ur sq
--   sq_undiagonals_ul_lr (sq_diagonals_ul_lr sq) == sq
--   sq_undiagonals_ll_ur (sq_diagonals_ll_ur sq) == sq
--   
-- --
--   sq_diagonal_ul_lr sq == sq_diagonals_ul_lr sq !! 0
--   sq_diagonal_ll_ur sq == sq_diagonals_ll_ur sq !! 0
--   
sq_diagonals_ul_lr :: Square t -> Square t -- | Full lower-left (ll) to upper-right (ur) diagonals of a square. sq_diagonals_ll_ur :: Square t -> Square t -- | Inverse of diagonals_ul_lr sq_undiagonals_ul_lr :: Square t -> Square t -- | Inverse of diagonals_ll_ur sq_undiagonals_ll_ur :: Square t -> Square t -- | Main diagonal (upper-left -> lower-right) sq_diagonal_ul_lr :: Square t -> [t] -- | Main diagonal (lower-left -> upper-right) sq_diagonal_ll_ur :: Square t -> [t] -- | Horizontal reflection (ie. map reverse). -- --
--   sq = sq_from_list 4 T.a126710
--   sq_wr $ sq
--   sq_wr $ sq_h_reflection sq
--   
sq_h_reflection :: Square t -> Square t -- | An n×n square is normal if it has the elements (1 .. n×n). sq_is_normal :: Integral n => Square n -> Bool -- | Sums of (rows, columns, left-right-diagonals, right-left-diagonals) sq_sums :: Num n => Square n -> ([n], [n], [n], [n]) sq_opt :: Text_Table_Opt sq_pp :: Show t => Square t -> String sq_wr :: Show t => Square t -> IO () sq_pp_m :: Show t => String -> Square (Maybe t) -> String sq_wr_m :: Show t => String -> Square (Maybe t) -> IO () -- | (row,column) index. type Square_Ix = Ix Int -- | Map from Square_Ix to value. type Square_Map t = Map Square_Ix t -- | Square to Square_Map. sq_to_map :: Square t -> Square_Map t -- | Alias for ! sqm_ix :: Square_Map t -> Square_Ix -> t -- | map of sqm_ix. sqm_ix_seq :: Square_Map t -> [Square_Ix] -> [t] -- | Make a Square of dimension dm that has elements from -- m at indicated indices, else Nothing. sqm_to_partial_sq :: Int -> Square_Map t -> [Square_Ix] -> Square (Maybe t) sq_trs_op :: [(String, Square t -> Square t)] sq_trs_seq :: Square t -> [(String, Square t)] -- | Clarence Barlow. "Two Essays on Theory". Computer Music -- Journal, 11(1):44-60, 1987. Translated by Henning Lohner. module Music.Theory.Meter.Barlow_1987 traceShow :: a -> b -> b -- | One indexed variant of genericIndex. -- --
--   map (at1 [11..13]) [1..3] == [11,12,13]
--   
at1 :: Integral n => [a] -> n -> a -- | Variant of at1 with boundary rules and specified error message. -- --
--   map (at1_bnd_err 'x' [11..13]) [0..4] == [1,11,12,13,1]
--   at1_bnd_err 'x' [0] 3 == undefined
--   
at1_bnd_err :: (Num a, Show a, Integral n, Show n, Show m) => m -> [a] -> n -> a -- | Variant of mod with input constraints. -- --
--   mod_pos_err (-1) 2 == 1
--   mod_pos_err 1 (-2) == undefined
--   
mod_pos_err :: (Integral a, Show a) => a -> a -> a -- | Type-specialised variant of fromIntegral. to_r :: Integral n => n -> Double -- | Variant on div with input constraints. div_pos_err :: (Integral a, Show a) => String -> a -> a -> a -- | A stratification is a tree of integral subdivisions. type Stratification t = [t] -- | Indispensibilities from stratification. -- --
--   indispensibilities [3,2,2] == [11,0,6,3,9,1,7,4,10,2,8,5]
--   indispensibilities [2,3,2] == [11,0,6,2,8,4,10,1,7,3,9,5]
--   indispensibilities [2,2,3] == [11,0,4,8,2,6,10,1,5,9,3,7]
--   indispensibilities [3,5] == [14,0,9,3,6,12,1,10,4,7,13,2,11,5,8]
--   
indispensibilities :: (Integral n, Show n) => Stratification n -> [n] -- | The indispensibility measure (ψ). -- --
--   map (lower_psi [2] 1) [1..2] == [1,0]
--   map (lower_psi [3] 1) [1..3] == [2,0,1]
--   map (lower_psi [2,2] 2) [1..4] == [3,0,2,1]
--   map (lower_psi [5] 1) [1..5] == [4,0,3,1,2]
--   map (lower_psi [3,2] 2) [1..6] == [5,0,3,1,4,2]
--   map (lower_psi [2,3] 2) [1..6] == [5,0,2,4,1,3]
--   
lower_psi :: (Integral a, Show a) => Stratification a -> a -> a -> a -- | The first n primes, reversed. -- --
--   reverse_primes 14 == [43,41,37,31,29,23,19,17,13,11,7,5,3,2]
--   length (reverse_primes 14) == 14
--   
reverse_primes :: Integral n => n -> [n] -- | Generate prime stratification for n. -- --
--   map prime_stratification [2,3,5,7,11] == [[2],[3],[5],[7],[11]]
--   map prime_stratification [6,8,9,12] == [[3,2],[2,2,2],[3,3],[3,2,2]]
--   map prime_stratification [22,10,4,1] == [[11,2],[5,2],[2,2],[]]
--   map prime_stratification [18,16,12] == [[3,3,2],[2,2,2,2],[3,2,2]]
--   
prime_stratification :: (Integral n, Show n) => n -> Stratification n -- | Fundamental indispensibilities for prime numbers (Ψ). -- --
--   map (upper_psi 2) [1..2] == [1,0]
--   map (upper_psi 3) [1..3] == [2,0,1]
--   map (upper_psi 5) [1..5] == [4,0,3,1,2]
--   map (upper_psi 7) [1..7] == [6,0,4,2,5,1,3]
--   map (upper_psi 11) [1..11] == [10,0,6,4,9,1,7,3,8,2,5]
--   map (upper_psi 13) [1..13] == [12,0,7,4,10,1,8,5,11,2,9,3,6]
--   
upper_psi :: (Integral a, Show a) => a -> a -> a -- | Table such that each subsequent row deletes the least indispensibile -- pulse. -- --
--   thinning_table [3,2] == [[True,True,True,True,True,True]
--                           ,[True,False,True,True,True,True]
--                           ,[True,False,True,False,True,True]
--                           ,[True,False,True,False,True,False]
--                           ,[True,False,False,False,True,False]
--                           ,[True,False,False,False,False,False]]
--   
thinning_table :: (Integral n, Show n) => Stratification n -> [[Bool]] -- | Trivial pretty printer for thinning_table. -- --
--   putStrLn (thinning_table_pp [3,2])
--   putStrLn (thinning_table_pp [2,3])
--   
-- --
--   ******   ******
--   *.****   *.****
--   *.*.**   *.**.*
--   *.*.*.   *..*.*
--   *...*.   *..*..
--   *.....   *.....
--   
thinning_table_pp :: (Integral n, Show n) => Stratification n -> String -- | Scale values against length of list minus one. -- --
--   relative_to_length [0..5] == [0.0,0.2,0.4,0.6,0.8,1.0]
--   
relative_to_length :: (Real a, Fractional b) => [a] -> [b] -- | Variant of indispensibilities that scales value to lie in -- (0,1). -- -- relative_indispensibilities [3,2] == [1,0,0.6,0.2,0.8,0.4] relative_indispensibilities :: (Integral n, Show n) => Stratification n -> [Double] -- | Align two meters (given as stratifications) to least common multiple -- of their degrees. The indispensibilities function is given as -- an argument so that it may be relative if required. This generates -- Table 7 (p.58). -- --
--   let r = [(5,5),(0,0),(2,3),(4,1),(1,4),(3,2)]
--   in align_meters indispensibilities [2,3] [3,2] == r
--   
-- --
--   let r = [(1,1),(0,0),(0.4,0.6),(0.8,0.2),(0.2,0.8),(0.6,0.4)]
--   in align_meters relative_indispensibilities [2,3] [3,2] == r
--   
-- --
--   align_meters indispensibilities [2,2,3] [3,5]
--   align_meters relative_indispensibilities [2,2,3] [3,5]
--   
align_meters :: (t -> [b]) -> t -> t -> [(b, b)] -- | Type pairing a stratification and a tempo. type S_MM t = ([t], t) -- | Variant of div that requires 'mod_pos_err be 0. whole_div :: Integral a => a -> a -> a -- | Variant of quot that requires rem be 0. whole_quot :: Integral a => a -> a -> a -- | Rule to prolong stratification of two S_MM values such that -- pulse at the deeper level are aligned. (Paragraph 2, p.58) -- --
--   let x = ([2,2,2],1)
--   in prolong_stratifications x x == (fst x,fst x)
--   
-- --
--   let r = ([2,5,3,3,2],[3,2,5,5])
--   in prolong_stratifications ([2,5],50) ([3,2],60) == r
--   
-- --
--   prolong_stratifications ([2,2,3],5) ([3,5],4) == ([2,2,3],[3,5])
--   
prolong_stratifications :: (Integral n, Show n) => S_MM n -> S_MM n -> ([n], [n]) -- | Composition of prolong_stratifications and align_meters. -- --
--   align_s_mm indispensibilities ([2,2,3],5) ([3,5],4)
--   
align_s_mm :: (Integral n, Show n) => ([n] -> [t]) -> S_MM n -> S_MM n -> [(t, t)] -- | An attempt at Equation 5 of the CMJ paper. When n is -- h-1 the output is incorrect (it is the product of the correct -- values for n at h-1 and h). -- --
--   map (upper_psi' 5) [1..5] /= [4,0,3,1,2]
--   map (upper_psi' 7) [1..7] /= [6,0,4,2,5,1,3]
--   map (upper_psi' 11) [1..11] /= [10,0,6,4,9,1,7,3,8,2,5]
--   map (upper_psi' 13) [1..13] /= [12,0,7,4,10,1,8,5,11,2,9,3,6]
--   
upper_psi' :: (Integral a, Show a) => a -> a -> a -- | The MPS limit equation given on p.58. -- --
--   mps_limit 3 == 21 + 7/9
--   
mps_limit :: Floating a => a -> a -- | The square of the product of the input sequence is summed, then -- divided by the square of the sequence length. -- --
--   mean_square_product [(0,0),(1,1),(2,2),(3,3)] == 6.125
--   mean_square_product [(2,3),(4,5)] == (6^2 + 20^2) / 2^2
--   
mean_square_product :: Fractional n => [(n, n)] -> n -- | An incorrect attempt at the description in paragraph two of p.58 of -- the CMJ paper. -- --
--   let p ~= q = abs (p - q) < 1e-4
--   metrical_affinity [2,3] 1 [3,2] 1 ~= 0.0324
--   metrical_affinity [2,2,3] 20 [3,5] 16 ~= 0.0028
--   
metrical_affinity :: (Integral n, Show n) => [n] -> n -> [n] -> n -> Double -- | An incorrect attempt at Equation 6 of the CMJ paper, see -- omega_z. -- --
--   let p ~= q = abs (p - q) < 1e-4
--   metrical_affinity' [2,2,2] 1 [2,2,2] 1 ~= 1.06735
--   metrical_affinity' [2,2,2] 1 [2,2,3] 1 ~= 0.57185
--   metrical_affinity' [2,2,2] 1 [2,3,2] 1 ~= 0.48575
--   metrical_affinity' [2,2,2] 1 [3,2,2] 1 ~= 0.45872
--   
-- --
--   metrical_affinity' [3,2,2] 3 [2,2,3] 2 ~= 0.10282
--   
metrical_affinity' :: (Integral t, Show t) => [t] -> t -> [t] -> t -> Double -- | Parsing utilities module Music.Theory.Parse -- | A Char parser. type P a = GenParser Char () a -- | Boolean P for given Char. is_char :: Char -> P Bool -- | Parse Integral. parse_int :: Integral i => P i run_parser :: P t -> String -> Either ParseError t run_parser_maybe :: P t -> String -> Maybe t run_parser_error :: P c -> String -> c -- | List permutation functions. module Music.Theory.Permutations.List -- | Generate all permutations. -- --
--   permutations_l [0,3] == [[0,3],[3,0]]
--   length (permutations_l [1..5]) == P.n_permutations 5
--   
permutations_l :: [a] -> [[a]] -- | k-element permutations of a set of n-elements. -- --
--   permutations_nk_l 3 2 "abc" == ["ab","ac","ba","bc","ca","cb"]
--   
permutations_nk_l :: Eq e => Int -> Int -> [e] -> [[e]] -- | Generate all distinct permutations of a multi-set. -- --
--   multiset_permutations [0,1,1] == [[0,1,1],[1,1,0],[1,0,1]]
--   
multiset_permutations :: Ord a => [a] -> [[a]] -- | Calculate number of permutations of a multiset. -- --
--   let r = P.factorial 11 `div` product (map P.factorial [1,4,4,2])
--   multiset_permutations_n "MISSISSIPPI" == r
--   
-- --
--   multiset_permutations_n "MISSISSIPPI" == 34650
--   length (multiset_permutations "MISSISSIPPI") == 34650
--   
multiset_permutations_n :: Ord a => [a] -> Int -- | Rq sub-divisions. module Music.Theory.Duration.Rq.Division -- | Divisions of n Rq into i equal parts grouped as -- j. A quarter and eighth note triplet is written -- (1,1,[2,1],False). type Rq_Div = (Rational, Integer, [Integer], Tied_Right) -- | Variant of Rq_Div where n is 1. type Rq1_Div = (Integer, [Integer], Tied_Right) -- | Lift Rq1_Div to Rq_Div. rq1_div_to_rq_div :: Rq1_Div -> Rq_Div -- | Verify that grouping j sums to the divisor i. rq_div_verify :: Rq_Div -> Bool rq_div_mm_verify :: Int -> [Rq_Div] -> [(Integer, [Rq])] -- | Translate from Rq_Div to a sequence of Rq values. -- --
--   rq_div_to_rq_set_t (1,5,[1,3,1],True) == ([1/5,3/5,1/5],True)
--   rq_div_to_rq_set_t (1/2,6,[3,1,2],False) == ([1/4,1/12,1/6],False)
--   
rq_div_to_rq_set_t :: Rq_Div -> ([Rq], Tied_Right) -- | Translate from result of rq_div_to_rq_set_t to seqeunce of -- Rq_Tied. -- --
--   rq_set_t_to_rqt ([1/5,3/5,1/5],True) == [(1/5,_f),(3/5,_f),(1/5,_t)]
--   
rq_set_t_to_rqt :: ([Rq], Tied_Right) -> [Rq_Tied] -- | Transform sequence of Rq_Div into sequence of Rq, -- discarding any final tie. -- --
--   let q = [(1,5,[1,3,1],True),(1/2,6,[3,1,2],True)]
--   in rq_div_seq_rq q == [1/5,3/5,9/20,1/12,1/6]
--   
rq_div_seq_rq :: [Rq_Div] -> [Rq] -- | Partitions of an Integral that sum to n. This includes -- the two 'trivial paritions, into a set n 1, and a set -- of 1 n. -- --
--   partitions_sum 4 == [[1,1,1,1],[2,1,1],[2,2],[3,1],[4]]
--   
-- --
--   map (length . partitions_sum) [9..15] == [30,42,56,77,101,135,176]
--   
partitions_sum :: Integral i => i -> [[i]] -- | The multiset_permutations of partitions_sum. -- --
--   map (length . partitions_sum_p) [9..12] == [256,512,1024,2048]
--   
partitions_sum_p :: Integral i => i -> [[i]] -- | The set of all Rq1_Div that sum to n, a variant on -- partitions_sum_p. -- --
--   map (length . rq1_div_univ) [3..5] == [8,16,32]
--   map (length . rq1_div_univ) [9..12] == [512,1024,2048,4096]
--   
rq1_div_univ :: Integer -> [Rq1_Div] -- | Place notation (method ringing). -- -- Morris, R. G. T. "Place Notation" Central Council of Church Bell -- Ringers (1984). http://www.cccbr.org.uk/bibliography/ module Music.Theory.Permutations.Morris_1984 -- | A change either swaps all adjacent bells, or holds a subset of bells. data Change Swap_All :: Change Hold :: [Int] -> Change -- | A method is a sequence of changes, if symmetrical only half the -- changes are given and the lead end. data Method Method :: [Change] -> Maybe [Change] -> Method -- | Maximum hold value at Method method_limit :: Method -> Int -- | Complete list of Changes at Method, writing out -- symmetries. method_changes :: Method -> [Change] -- | Parse a change notation. -- --
--   map parse_change ["-","x","38"] == [Swap_All,Swap_All,Hold [3,8]]
--   
parse_change :: String -> Change -- | Separate changes. -- --
--   split_changes "-38-14-1258-36-14-58-16-78"
--   split_changes "345.145.5.1.345" == ["345","145","5","1","345"]
--   
split_changes :: String -> [String] -- | Place notation, sequence of changes with possible lead end. type Place = (String, Maybe String) -- | Parse Method given PLACE notation. parse_method :: Place -> Method -- | Parse string into Place. -- --
--   parse_method (parse_place "-38-14-1258-36-14-58-16-78,12")
--   
parse_place :: String -> Place -- | -- --
--   map is_swap_all ["-","x","38"] == [True,True,False]
--   
is_swap_all :: String -> Bool -- | Flatten list of pairs. -- --
--   flatten_pairs [(1,2),(3,4)] == [1..4]
--   
flatten_pairs :: [(a, a)] -> [a] -- | Swap all adjacent pairs at list. -- --
--   swap_all [1 .. 8] == [2,1,4,3,6,5,8,7]
--   
swap_all :: [a] -> [a] numeric_spelling_tbl :: [(Char, Int)] -- | Parse abbreviated Hold notation, characters are NOT -- hexadecimal. -- --
--   map nchar_to_int "380ETA" == [3,8,10,11,12,13]
--   
nchar_to_int :: Char -> Int -- | Inverse of nchar_to_int. -- --
--   map int_to_nchar [3,8,10,11,12,13] == "380ETA"
--   
int_to_nchar :: Int -> Char -- | Given a Hold notation, generate permutation cycles. -- --
--   let r = [Right (1,2),Left 3,Right (4,5),Right (6,7),Left 8]
--   gen_swaps 8 [3,8] == r
--   
-- --
--   r = [Left 1,Left 2,Right (3,4),Right (5,6),Right (7,8)]
--   gen_swaps 8 [1,2] == r
--   
gen_swaps :: (Num t, Ord t) => t -> [t] -> [Either t (t, t)] -- | Given two sequences, derive the one-indexed "hold" list. -- --
--   derive_holds ("12345","13254") == [1]
--   
derive_holds :: (Eq a, Enum n, Num n) => ([a], [a]) -> [n] -- | Two-tuple to two element list. pair_to_list :: (t, t) -> [t] -- | Swap notation to plain permutation cycles notation. -- --
--   let n = [Left 1,Left 2,Right (3,4),Right (5,6),Right (7,8)]
--   in swaps_to_cycles n == [[1],[2],[3,4],[5,6],[7,8]]
--   
swaps_to_cycles :: [Either t (t, t)] -> [[t]] -- | One-indexed permutation cycles to zero-indexed. -- --
--   let r = [[0],[1],[2,3],[4,5],[6,7]]
--   to_zero_indexed [[1],[2],[3,4],[5,6],[7,8]] == r
--   
to_zero_indexed :: Enum t => [[t]] -> [[t]] -- | Apply abbreviated Hold notation, given cardinality. -- --
--   swap_abbrev 8 [3,8] [2,1,4,3,6,5,8,7] == [1,2,4,6,3,8,5,7]
--   
swap_abbrev :: Int -> [Int] -> [a] -> [a] -- | Apply a Change. apply_change :: Int -> Change -> [a] -> [a] -- | Apply a Method, gives next starting sequence and the course of -- the method. -- --
--   let r = ([1,2,4,5,3]
--           ,[[1,2,3,4,5],[2,1,3,4,5],[2,3,1,4,5],[3,2,4,1,5],[3,4,2,5,1]
--            ,[4,3,2,5,1],[4,2,3,1,5],[2,4,1,3,5],[2,1,4,3,5],[1,2,4,3,5]])
--   apply_method cambridgeshire_slow_course_doubles [1..5] == r
--   
apply_method :: Method -> [a] -> ([a], [[a]]) -- | Iteratively apply a Method until it closes (ie. arrives back at -- the starting sequence). -- --
--   length (closed_method cambridgeshire_slow_course_doubles [1..5]) == 3
--   
closed_method :: Eq a => Method -> [a] -> [[[a]]] -- | concat of closed_method with initial sequence appended. closed_method_lp :: Eq a => Method -> [a] -> [[a]] -- | closed_method of parse_method closed_place :: Eq t => Place -> [t] -> [[[t]]] -- | -- https://rsw.me.uk/blueline/methods/view/Cambridgeshire_Place_Doubles -- --
--   length (closed_place cambridgeshire_place_doubles_pl [1..5]) == 3
--   
cambridgeshire_place_doubles_pl :: Place -- | parse_method of cambridgeshire_place_doubles_pl cambridgeshire_slow_course_doubles :: Method -- | -- https://rsw.me.uk/blueline/methods/view/Double_Cambridge_Cyclic_Bob_Minor -- --
--   length (closed_place double_cambridge_cyclic_bob_minor_pl [1..6]) == 5
--   
double_cambridge_cyclic_bob_minor_pl :: Place -- | parse_method of double_cambridge_cyclic_bob_minor_pl double_cambridge_cyclic_bob_minor :: Method -- | https://rsw.me.uk/blueline/methods/view/Hammersmith_Bob_Triples -- --
--   length (closed_place hammersmith_bob_triples_pl [1..7]) == 6
--   
hammersmith_bob_triples_pl :: Place hammersmith_bob_triples :: Method -- | -- https://rsw.me.uk/blueline/methods/view/Cambridge_Surprise_Major -- --
--   length (closed_place cambridge_surprise_major_pl [1..8]) == 7
--   
cambridge_surprise_major_pl :: Place cambridge_surprise_major :: Method -- | -- https://rsw.me.uk/blueline/methods/view/Smithsonian_Surprise_Royal -- --
--   let c = closed_place smithsonian_surprise_royal_pl [1..10]
--   (length c,nub (map length c),sum (map length c)) == (9,[40],360)
--   
smithsonian_surprise_royal_pl :: Place smithsonian_surprise_royal :: Method -- | -- https://rsw.me.uk/blueline/methods/view/Ecumenical_Surprise_Maximus -- --
--   c = closed_place ecumenical_surprise_maximus_pl [1..12]
--   (length c,nub (map length c),sum (map length c)) == (11,[48],528)
--   
ecumenical_surprise_maximus_pl :: Place ecumenical_surprise_maximus :: Method instance GHC.Show.Show Music.Theory.Permutations.Morris_1984.Change instance GHC.Classes.Eq Music.Theory.Permutations.Morris_1984.Change instance GHC.Show.Show Music.Theory.Permutations.Morris_1984.Method instance GHC.Classes.Eq Music.Theory.Permutations.Morris_1984.Method -- | Zwicker, E. (1961) "Subdivision of the audible frequency range into -- critical bands" The Journal of the Acoustical Society of America, -- Volume 33, Issue 2, p. 248 (1961) -- -- https://ccrma.stanford.edu/courses/120-fall-2003/lecture-5.html module Music.Theory.Pitch.Bark -- | Center freqencies of Bark scale critical bands (hz). bark_center :: Num n => [n] -- | Edge freqencies of Bark scale critical bands (hz). bark_edge :: Num n => [n] -- | Bandwidths of Bark scale critical bands (hz). bark_bandwidth :: Num n => [n] -- | Zwicker & Terhardt (1980) -- --
--   map (round . cps_to_bark_zwicker) bark_centre == concat [[0..7],[9..15],[15..19],[21..24]]
--   let f = [0,100 .. 8000] in Sound.SC3.Plot.plot_p2_ln [zip f (map cps_to_bark_zwicker f)]
--   
cps_to_bark_zwicker :: Floating a => a -> a -- | Traunmüller, Hartmut. "Analytical Expressions for the Tonotopic -- Sensory Scale." Journal of the Acoustical Society of America. Vol. 88, -- Issue 1, 1990, pp. 97-100. -- --
--   r = concat [[0,1],[3,4],[4],[6..9],[9,10],[12],[12..17],[19,20],[20..23]]
--   map (round . cps_to_bark_traunmuller) bark_centre == r
--   let f = [0,100 .. 8000] in Sound.SC3.Plot.plot_p2_ln [zip f (map cps_to_bark_traunmuller f)]
--   
cps_to_bark_traunmuller :: (Fractional n, Ord n) => n -> n -- | Traunmüller (1990) -- --
--   Sound.SC3.Plot.plot_p2_ln [zip (map bark_to_cps_traunmuller [0..23]) [0..23]]
--   
bark_to_cps_traunmuller :: (Fractional n, Ord n) => n -> n -- | Wang, Sekey & Gersho (1992) -- --
--   map (round . cps_to_bark_wsg) bark_centre == concat [[0..9],[9..21],[23]]
--   let f = [0,100 .. 8000] in Sound.SC3.Plot.plot_p2_ln [zip f (map cps_to_bark_wsg f)]
--   
cps_to_bark_wsg :: Floating a => a -> a -- | Wang, Sekey & Gersho (1992) -- --
--   r = [100,204,313,430,560,705,870,1059,1278,1532,1828,2176,2584,3065,3630,4297,5083,6011,7106,8399]
--   map (round . bark_to_cps_wsg) [1 .. 20] == r
--   Sound.SC3.Plot.plot_p2_ln [zip (map bark_to_cps_wsg [0..23]) [0..23]]
--   
bark_to_cps_wsg :: Floating a => a -> a -- | Common music notation note and alteration values. module Music.Theory.Pitch.Note -- | Enumeration of common music notation note names (C to -- B). data Note C :: Note D :: Note E :: Note F :: Note G :: Note A :: Note B :: Note -- | Note sequence as usually understood, ie. C - B. note_seq :: [Note] -- | Char variant of show. note_pp :: Note -> Char -- | Note name in lilypond syntax (ie. lower case). note_pp_ly :: Note -> String -- | Table of Note and corresponding pitch-classes. note_pc_tbl :: Num i => [(Note, i)] -- | Transform Note to pitch-class number. -- --
--   map note_to_pc [C,E,G] == [0,4,7]
--   
note_to_pc :: Num i => Note -> i -- | Inverse of note_to_pc. -- --
--   mapMaybe pc_to_note [0,4,7] == [C,E,G]
--   
pc_to_note :: (Eq i, Num i) => i -> Maybe Note -- | Modal transposition of Note value. -- --
--   note_t_transpose C 2 == E
--   
note_t_transpose :: Note -> Int -> Note -- | Parser from Char, case insensitive flag. -- --
--   mapMaybe (parse_note True) "CDEFGab" == [C,D,E,F,G,A,B]
--   
parse_note_t :: Bool -> Char -> Maybe Note char_to_note_t :: Bool -> Char -> Note -- | Inclusive set of Note within indicated interval. This is not -- equal to enumFromTo which is not circular. -- --
--   note_span E B == [E,F,G,A,B]
--   note_span B D == [B,C,D]
--   enumFromTo B D == []
--   
note_span :: Note -> Note -> [Note] -- | Enumeration of common music notation note alterations. data Alteration DoubleFlat :: Alteration ThreeQuarterToneFlat :: Alteration Flat :: Alteration QuarterToneFlat :: Alteration Natural :: Alteration QuarterToneSharp :: Alteration Sharp :: Alteration ThreeQuarterToneSharp :: Alteration DoubleSharp :: Alteration -- | Generic form. generic_alteration_to_diff :: Integral i => Alteration -> Maybe i -- | Transform Alteration to semitone alteration. Returns -- Nothing for non-semitone alterations. -- --
--   map alteration_to_diff [Flat,QuarterToneSharp] == [Just (-1),Nothing]
--   
alteration_to_diff :: Alteration -> Maybe Int -- | Is Alteration 12-ET. alteration_is_12et :: Alteration -> Bool -- | Transform Alteration to semitone alteration. -- --
--   map alteration_to_diff_err [Flat,Sharp] == [-1,1]
--   
alteration_to_diff_err :: Integral i => Alteration -> i -- | Transform Alteration to fractional semitone alteration, ie. -- allow quarter tones. -- --
--   alteration_to_fdiff QuarterToneSharp == 0.5
--   
alteration_to_fdiff :: Fractional n => Alteration -> n -- | Transform fractional semitone alteration to Alteration, ie. -- allow quarter tones. -- --
--   map fdiff_to_alteration [-0.5,0.5] == [Just QuarterToneFlat
--                                         ,Just QuarterToneSharp]
--   
fdiff_to_alteration :: (Fractional n, Eq n) => n -> Maybe Alteration -- | Raise Alteration by a quarter tone where possible. -- --
--   alteration_raise_quarter_tone Flat == Just QuarterToneFlat
--   alteration_raise_quarter_tone DoubleSharp == Nothing
--   
alteration_raise_quarter_tone :: Alteration -> Maybe Alteration -- | Lower Alteration by a quarter tone where possible. -- --
--   alteration_lower_quarter_tone Sharp == Just QuarterToneSharp
--   alteration_lower_quarter_tone DoubleFlat == Nothing
--   
alteration_lower_quarter_tone :: Alteration -> Maybe Alteration -- | Edit Alteration by a quarter tone where possible, -0.5 -- lowers, 0 retains, 0.5 raises. -- --
--   import Data.Ratio
--   alteration_edit_quarter_tone (-1 % 2) Flat == Just ThreeQuarterToneFlat
--   
alteration_edit_quarter_tone :: (Fractional n, Eq n) => n -> Alteration -> Maybe Alteration -- | Simplify Alteration to standard 12ET by deleting quarter tones. -- --
--   Data.List.nub (map alteration_clear_quarter_tone [minBound..maxBound])
--   
alteration_clear_quarter_tone :: Alteration -> Alteration -- | Table of Unicode characters for alterations. alteration_symbol_tbl :: [(Alteration, Char)] -- | Unicode has entries for Musical Symbols in the range -- U+1D100 through U+1D1FF. The 3/4 symbols -- are non-standard, here they correspond to MUSICAL SYMBOL FLAT -- DOWN and MUSICAL SYMBOL SHARP UP. -- --
--   map alteration_symbol [minBound .. maxBound] == "𝄫𝄭♭𝄳♮𝄲♯𝄰𝄪"
--   
alteration_symbol :: Alteration -> Char -- | Inverse of alteration_symbol. -- --
--   mapMaybe symbol_to_alteration "♭♮♯" == [Flat,Natural,Sharp]
--   
symbol_to_alteration :: Char -> Maybe Alteration -- | ISO alteration notation. When not strict extended to allow ## for x. symbol_to_alteration_iso :: Bool -> String -> Maybe Alteration symbol_to_alteration_iso_err :: Bool -> String -> Alteration -- | symbol_to_alteration extended to allow single character ISO -- notations. symbol_to_alteration_unicode_plus_iso :: Char -> Maybe Alteration -- | ISO alteration table, strings not characters because of double flat. alteration_iso_tbl :: [(Alteration, String)] -- | The ISO ASCII spellings for alterations. Naturals are written -- as the empty string. -- --
--   mapMaybe alteration_iso_m [Flat .. Sharp] == ["b","","#"]
--   mapMaybe alteration_iso_m [DoubleFlat,DoubleSharp] == ["bb","x"]
--   
alteration_iso_m :: Alteration -> Maybe String -- | The ISO ASCII spellings for alterations. alteration_iso :: Alteration -> String -- | The Tonhöhe ASCII spellings for alterations. alteration_tonh_tbl :: [(Alteration, String)] -- | The Tonhöhe ASCII spellings for alterations. -- -- See http://www.musiccog.ohio-state.edu/Humdrum/guide04.html and -- http://lilypond.org/doc/v2.16/Documentation/notation/writing-pitches -- --
--   map alteration_tonh [Flat .. Sharp] == ["es","eh","","ih","is"]
--   
alteration_tonh :: Alteration -> String -- | Inverse of alteration_tonh. -- --
--   mapMaybe tonh_to_alteration ["es","eh","","ih","is"] == [Flat .. Sharp]
--   
tonh_to_alteration :: String -> Maybe Alteration tonh_to_alteration_err :: String -> Alteration -- | Note and alteration to pitch-class, or not. note_alteration_to_pc :: (Note, Alteration) -> Maybe Int -- | Error variant. -- --
--   map note_alteration_to_pc_err [(A,DoubleSharp),(B,Sharp),(C,Flat),(C,DoubleFlat)]
--   
note_alteration_to_pc_err :: (Note, Alteration) -> Int -- | Note & alteration sequence in key-signature spelling. note_alteration_ks :: [(Note, Alteration)] -- | Table connecting pitch class number with note_alteration_ks. pc_note_alteration_ks_tbl :: Integral i => [((Note, Alteration), i)] -- | reverse_lookup of pc_note_alteration_ks_tbl. pc_to_note_alteration_ks :: Integral i => i -> Maybe (Note, Alteration) -- | Alteration given as a rational semitone difference and a string -- representation of the alteration. type Alteration_R = (Rational, String) -- | Transform Alteration to Alteration_R. -- --
--   let r = [(-1,"♭"),(0,"♮"),(1,"♯")]
--   map alteration_r [Flat,Natural,Sharp] == r
--   
alteration_r :: Alteration -> Alteration_R -- | Parser for ISO note name, upper case. -- --
--   map (T.run_parser_error p_note_t . return) "ABCDEFG"
--   
p_note_t :: P Note -- | Note name in lower case (not ISO) p_note_t_lc :: P Note -- | Case-insensitive note name (not ISO). p_note_t_ci :: P Note -- | Parser for ISO alteration name. -- --
--   map (T.run_parser_error p_alteration_t_iso) (words "bb b # x ##")
--   
p_alteration_t_iso :: Bool -> P Alteration p_alteration_t_tonh :: P Alteration p_note_alteration_ly :: P (Note, Maybe Alteration) instance GHC.Show.Show Music.Theory.Pitch.Note.Note instance GHC.Read.Read Music.Theory.Pitch.Note.Note instance GHC.Classes.Ord Music.Theory.Pitch.Note.Note instance GHC.Enum.Bounded Music.Theory.Pitch.Note.Note instance GHC.Enum.Enum Music.Theory.Pitch.Note.Note instance GHC.Classes.Eq Music.Theory.Pitch.Note.Note instance GHC.Show.Show Music.Theory.Pitch.Note.Alteration instance GHC.Classes.Ord Music.Theory.Pitch.Note.Alteration instance GHC.Enum.Bounded Music.Theory.Pitch.Note.Alteration instance GHC.Enum.Enum Music.Theory.Pitch.Note.Alteration instance GHC.Classes.Eq Music.Theory.Pitch.Note.Alteration -- | Constants names for notes. eses indicates double flat, -- eseh three quarter tone flat, es flat, eh quarter -- tone flat, ih quarter tone sharp, is sharp, isih -- three quarter tone sharp and isis double sharp. module Music.Theory.Pitch.Note.Name ceses :: (Note, Alteration) deses :: (Note, Alteration) eeses :: (Note, Alteration) feses :: (Note, Alteration) geses :: (Note, Alteration) aeses :: (Note, Alteration) beses :: (Note, Alteration) ceseh :: (Note, Alteration) deseh :: (Note, Alteration) eeseh :: (Note, Alteration) feseh :: (Note, Alteration) geseh :: (Note, Alteration) aeseh :: (Note, Alteration) beseh :: (Note, Alteration) ces :: (Note, Alteration) des :: (Note, Alteration) ees :: (Note, Alteration) fes :: (Note, Alteration) ges :: (Note, Alteration) aes :: (Note, Alteration) bes :: (Note, Alteration) ceh :: (Note, Alteration) deh :: (Note, Alteration) eeh :: (Note, Alteration) feh :: (Note, Alteration) geh :: (Note, Alteration) aeh :: (Note, Alteration) beh :: (Note, Alteration) c :: (Note, Alteration) d :: (Note, Alteration) e :: (Note, Alteration) f :: (Note, Alteration) g :: (Note, Alteration) a :: (Note, Alteration) b :: (Note, Alteration) cih :: (Note, Alteration) dih :: (Note, Alteration) eih :: (Note, Alteration) fih :: (Note, Alteration) gih :: (Note, Alteration) aih :: (Note, Alteration) bih :: (Note, Alteration) cis :: (Note, Alteration) dis :: (Note, Alteration) eis :: (Note, Alteration) fis :: (Note, Alteration) gis :: (Note, Alteration) ais :: (Note, Alteration) bis :: (Note, Alteration) cisih :: (Note, Alteration) disih :: (Note, Alteration) eisih :: (Note, Alteration) fisih :: (Note, Alteration) gisih :: (Note, Alteration) aisih :: (Note, Alteration) bisih :: (Note, Alteration) cisis :: (Note, Alteration) disis :: (Note, Alteration) eisis :: (Note, Alteration) fisis :: (Note, Alteration) gisis :: (Note, Alteration) aisis :: (Note, Alteration) bisis :: (Note, Alteration) -- | YIJING / I-CHING module Music.Theory.Random.I_Ching -- | Line, indicated as sum. data Line L6 :: Line L7 :: Line L8 :: Line L9 :: Line -- | (sum={6,7,8,9}, (yarrow probablity={1,3,5,7}/16, three-coin -- probablity={2,6}/16, name,signification,symbol)) type Line_Stat = (Line, (Rational, Rational, String, String, String)) -- | I-CHING chart as sequence of 4 Line_Stat. i_ching_chart :: [Line_Stat] -- | Lines L6 and L7 are unbroken (since L6 is becoming L7). line_unbroken :: Line -> Bool -- | If b then L7 else L8. line_from_bit :: Bool -> Line -- | Seven character ASCII string for line. line_ascii_pp :: Line -> String -- | Is line (ie. sum) moving (ie. 6 or 9). line_is_moving :: Line -> Bool -- | Old yin (L6) becomes yang (L7), and old yang (L9) becomes yin (L8). line_complement :: Line -> Maybe Line -- | Sequence of sum values assigned to ascending four bit numbers. -- Sequence is in ascending probablity, ie: 1×6,3×9,5×7,7×8. -- --
--   import Music.Theory.Bits 
--   zip (map (gen_bitseq_pp 4) [0::Int .. 15]) (map line_ascii_pp four_coin_sequence)
--   
four_coin_sequence :: [Line] -- | Sequence of 6 Line. type Hexagram = [Line] -- | Hexagrams are drawn upwards. hexagram_pp :: Hexagram -> String -- | Generate hexagram (ie. sequence of six lines given by sum) using -- four_coin_sequence. -- --
--   four_coin_gen_hexagram >>= putStrLn . hexagram_pp
--   
four_coin_gen_hexagram :: IO Hexagram -- | any of line_is_moving. hexagram_has_complement :: Hexagram -> Bool -- | If hexagram_has_complement then derive it. -- --
--   h <- four_coin_gen_hexagram
--   putStrLn (hexagram_pp h)
--   maybe (return ()) (putStrLn . hexagram_pp) (hexagram_complement h)
--   
hexagram_complement :: Hexagram -> Maybe Hexagram -- | Names of hexagrams, in King Wen order (see also -- datacsvcombinatorics/yijing.csv) -- --
--   length hexagram_names == 64
--   
hexagram_names :: [(String, String)] -- | Unicode hexagram characters, in King Wen order. -- --
--   import Data.List.Split {- split -}
--   mapM_ putStrLn (chunksOf 8 hexagram_unicode_sequence)
--   
hexagram_unicode_sequence :: [Char] -- | Binary form of Hexagram. hexagram_to_binary :: Hexagram -> Int8 -- | Show binary form. hexagram_to_binary_str :: Hexagram -> String -- | Inverse of hexagram_to_binary. hexagram_from_binary :: Int8 -> Hexagram -- | Read binary form. -- --
--   let h = hexagram_from_binary_str "100010"
--   putStrLn (hexagram_pp h)
--   hexagram_to_binary_str h == "100010"
--   
hexagram_from_binary_str :: String -> Hexagram -- | Unicode sequence of trigrams (unicode order). -- --
--   import Data.List {- base -}
--   putStrLn (intersperse ' ' trigram_unicode_sequence)
--   
trigram_unicode_sequence :: [Char] -- | -- (INDEX,UNICODE,BIT-SEQUENCE,NAME,NAME-TRANSLITERATION,NATURE-IMAGE,DIRECTION,ANIMAL) -- --
--   map (T.read_bin_err . T.p8_third) trigram_chart == [7,6,5,4,3,2,1,0]
--   
trigram_chart :: [(Int, Char, String, Char, String, Char, String, Char)] instance GHC.Show.Show Music.Theory.Random.I_Ching.Line instance GHC.Classes.Eq Music.Theory.Random.I_Ching.Line -- | Kevin Jones. "Compositional Applications of Stochastic Processes". -- Computer Music Journal, 5(2):45-58, 1981. module Music.Theory.Random.Jones_1981 data G a T :: a -> G a P :: G a -> G a -> G a type Rule k a = k -> a -> Maybe (a, a) type Probablities k r = (r, [(k, r)]) type SFSG k a r = (Rule k a, Probablities k r) p_verify :: (Eq a, Num a) => Probablities k a -> Bool p_select :: (Ord a, Num a) => Probablities k a -> a -> Maybe (Maybe k) p_select_err :: (Ord a, Num a) => Probablities k a -> a -> Maybe k g_collect :: G a -> [a] unfold :: (RandomGen g, Random r, Ord r, Num r) => SFSG k a r -> a -> g -> (G a, g) sfsg_chain :: (RandomGen g, Random r, Ord r, Num r) => SFSG k a r -> a -> g -> [G a] sfsg_chain_n :: (RandomGen g, Random r, Ord r, Num r) => Int -> SFSG k a r -> a -> g -> [G a] instance GHC.Show.Show a => GHC.Show.Show (Music.Theory.Random.Jones_1981.G a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Music.Theory.Random.Jones_1981.G a) -- | Set operations on lists. module Music.Theory.Set.List -- | sort then nub. -- --
--   set [3,3,3,2,2,1] == [1,2,3]
--   
set :: Ord a => [a] -> [a] -- | Size of powerset of set of cardinality n, ie. 2 -- ^ n. -- --
--   map n_powerset [6..9] == [64,128,256,512]
--   
n_powerset :: Integral n => n -> n -- | Powerset, ie. set of all subsets. -- --
--   sort (powerset [1,2]) == [[],[1],[1,2],[2]]
--   map length (map (\n -> powerset [1..n]) [6..9]) == [64,128,256,512]
--   
powerset :: [a] -> [[a]] -- | Variant where result is sorted and the empty set is not given. -- --
--   powerset_sorted [1,2,3] == [[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
--   
powerset_sorted :: Ord a => [a] -> [[a]] -- | Two element subsets. -- --
--   pairs [1,2,3] == [(1,2),(1,3),(2,3)]
--   
pairs :: [a] -> [(a, a)] -- | Three element subsets. -- --
--   triples [1..4] == [(1,2,3),(1,2,4),(1,3,4),(2,3,4)]
--   
-- --
--   import Music.Theory.Combinations
--   let f n = genericLength (triples [1..n]) == nk_combinations n 3
--   all f [1..15]
--   
triples :: [a] -> [(a, a, a)] -- | Set expansion (ie. to multiset of degree n). -- --
--   expand_set 4 [1,2,3] == [[1,1,2,3],[1,2,2,3],[1,2,3,3]]
--   
expand_set :: Ord a => Int -> [a] -> [[a]] -- | All distinct multiset partitions, see partitions. -- --
--   partitions "aab" == [["aab"],["a","ab"],["b","aa"],["b","a","a"]]
--   partitions "abc" == [["abc"],["bc","a"],["b","ac"],["c","ab"],["c","b","a"]]
--   
partitions :: Eq a => [a] -> [[[a]]] -- | Cartesian product of two sets. -- --
--   cartesian_product "abc" [1,2] == [('a',1),('a',2),('b',1),('b',2),('c',1),('c',2)]
--   cartesian_product "abc" "" == []
--   
cartesian_product :: [a] -> [b] -> [(a, b)] -- | List form of n-fold cartesian product. -- --
--   length (nfold_cartesian_product [[1..13],[1..4]]) == 52
--   length (nfold_cartesian_product ["abc","de","fgh"]) == 3 * 2 * 3
--   
nfold_cartesian_product :: [[a]] -> [[a]] -- | Generate all distinct cycles, aka necklaces, with elements taken from -- a multiset. -- --
--   concatMap multiset_cycles [replicate i 0 ++ replicate (6 - i) 1 | i <- [0 .. 6]]
--   
multiset_cycles :: Ord t => [t] -> [[t]] -- | "Creating Rhythms" by Stefan Hollos and J. Richard Hollos -- http://abrazol.com/books/rhythm1/software.html module Music.Theory.Duration.Hollos2014 -- | Donald Knuth, Art of Computer Programming, Algorithm H -- http://www-cs-faculty.stanford.edu/~knuth/fasc3b.ps.gz -- --
--   partm 3 6 == [[1,1,4],[2,1,3],[2,2,2]]
--   
partm :: (Num a, Ord a) => a -> a -> [[a]] -- | Generates all partitions of n. -- --
--   compUniq 4 == [[1,1,1,1],[1,1,2],[1,3],[2,2],[4]]
--   compUniq 5 == [[1,1,1,1,1],[1,1,1,2],[1,1,3],[2,1,2],[1,4],[2,3],[5]]
--   
part :: (Num a, Ord a, Enum a) => a -> [[a]] -- | Generates all partitions of n with parts in the set e. -- --
--   parta 8 [2,3] == [[2,2,2,2],[3,2,3]]
--   
parta :: (Num a, Ord a, Enum a) => a -> [a] -> [[a]] -- | Generate all compositions of n. -- --
--   comp 4 == [[1,1,1,1],[1,1,2],[1,2,1],[2,1,1],[1,3],[3,1],[2,2],[4]]
--   length (comp 8) == 128
--   
comp :: (Num a, Ord a, Enum a) => a -> [[a]] -- | Generates all compositions of n into k parts. -- --
--   compm 3 6 == [[1,1,4],[1,4,1],[4,1,1],[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1],[2,2,2]]
--   length (compm 5 16) == 1365
--   
compm :: (Ord a, Num a) => a -> a -> [[a]] -- | Generates all compositions of n with parts in the set (p1 p2 ... pk). -- --
--   compa 8 [3,4,5,6] == [[3,5],[5,3],[4,4]]
--   
compa :: (Num a, Ord a, Enum a) => a -> [a] -> [[a]] -- | Generates all compositions of n with m parts in the set (p1 p2 ... -- pk). -- --
--   compam 4 16 [3,4,5]
--   
compam :: (Num a, Ord a, Enum a) => a -> a -> [a] -> [[a]] -- | Generates all binary necklaces of length n. -- http://combos.org/necklace -- --
--   neck 5 == [[1,1,1,1,1],[1,1,1,1,0],[1,1,0,1,0],[1,1,1,0,0],[1,0,1,0,0],[1,1,0,0,0],[1,0,0,0,0],[0,0,0,0,0]]
--   
neck :: (Ord t, Num t) => Int -> [[t]] -- | Generates all binary necklaces of length n with m ones. -- --
--   neckm 8 2 == [[1,0,0,0,1,0,0,0],[1,0,0,1,0,0,0,0],[1,0,1,0,0,0,0,0],[1,1,0,0,0,0,0,0]]
--   
neckm :: (Num a, Ord a) => Int -> Int -> [[a]] -- | Part is the length of a substring 10...0 composing the necklace. For -- example the necklace 10100 has parts of size 2 and 3. -- --
--   necklaceParts [1,0,1,0,0] == [2,3]
--   necklaceParts [0,0,0,0,0,0,0,0] == []
--   
necklaceParts :: (Eq a, Num a) => [a] -> [Int] necklaceWithParts :: (Eq a, Num a) => [Int] -> [a] -> Bool -- | Generates all binary necklaces of length n with parts in e. -- --
--   necka 8 [2,3,4] == [[1,0,1,0,1,0,1,0],[1,0,1,0,0,1,0,0],[1,0,1,0,1,0,0,0],[1,0,0,0,1,0,0,0]]
--   
necka :: (Num a, Ord a) => Int -> [Int] -> [[a]] -- | Generates all binary necklaces of length n with m ones and parts in e. neckam :: (Num a, Ord a) => Int -> Int -> [Int] -> [[a]] -- | Generates all permutations of the non-negative integers in the set. -- --
--   permi [1,2,3] == [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
--   
permi :: [a] -> [[a]] -- | Polansky, Larry and Bassein, Richard "Possible and Impossible Melody: -- Some Formal Aspects of Contour" Journal of Music Theory 36/2, -- 1992 (pp.259-284) (http://www.jstor.org/pss/843933) module Music.Theory.Contour.Polansky_1992 -- | Construct set of n - 1 adjacent indices, left -- right order. -- --
--   adjacent_indices 5 == [(0,1),(1,2),(2,3),(3,4)]
--   
adjacent_indices :: Integral i => i -> [(i, i)] -- | All (i,j) indices, in half matrix order. -- --
--   all_indices 4 == [(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)]
--   
all_indices :: Integral i => i -> [(i, i)] -- | A list notation for matrices. type Matrix a = [[a]] -- | Apply f to construct Matrix from sequence. -- --
--   matrix_f (,) [1..3] == [[(1,1),(1,2),(1,3)]
--                          ,[(2,1),(2,2),(2,3)]
--                          ,[(3,1),(3,2),(3,3)]]
--   
matrix_f :: (a -> a -> b) -> [a] -> Matrix b -- | Construct matrix_f with compare (p.263). -- --
--   contour_matrix [1..3] == [[EQ,LT,LT],[GT,EQ,LT],[GT,GT,EQ]]
--   
contour_matrix :: Ord a => [a] -> Matrix Ordering -- | Half matrix notation for contour. data Contour_Half_Matrix Contour_Half_Matrix :: Int -> Matrix Ordering -> Contour_Half_Matrix [contour_half_matrix_n] :: Contour_Half_Matrix -> Int [contour_half_matrix_m] :: Contour_Half_Matrix -> Matrix Ordering -- | Half Matrix of contour given comparison function f. -- --
--   half_matrix_f (flip (-)) [2,10,6,7] == [[8,4,5],[-4,-3],[1]]
--   half_matrix_f (flip (-)) [5,0,3,2] == [[-5,-2,-3],[3,2],[-1]]
--   half_matrix_f compare [5,0,3,2] == [[GT,GT,GT],[LT,LT],[GT]]
--   
half_matrix_f :: (a -> a -> b) -> [a] -> Matrix b -- | Construct Contour_Half_Matrix (p.264) contour_half_matrix :: Ord a => [a] -> Contour_Half_Matrix -- | Show function for Contour_Half_Matrix. contour_half_matrix_str :: Contour_Half_Matrix -> String -- | Description notation of contour. data Contour_Description Contour_Description :: Int -> Map (Int, Int) Ordering -> Contour_Description [contour_description_n] :: Contour_Description -> Int [contour_description_m] :: Contour_Description -> Map (Int, Int) Ordering -- | Construct Contour_Description of contour (p.264). -- --
--   let c = [[3,2,4,1],[3,2,1,4]]
--   in map (show.contour_description) c == ["202 02 2","220 20 0"]
--   
contour_description :: Ord a => [a] -> Contour_Description -- | Show function for Contour_Description (p.264). contour_description_str :: Contour_Description -> String -- | Convert from Contour_Half_Matrix notation to -- Contour_Description. half_matrix_to_description :: Contour_Half_Matrix -> Contour_Description -- | Ordering from ith to jth element of sequence described -- at d. -- --
--   contour_description_ix (contour_description "abdc") (0,3) == LT
--   
contour_description_ix :: Contour_Description -> (Int, Int) -> Ordering -- | True if contour is all descending, equal or ascending. -- --
--   let c = ["abc","bbb","cba"]
--   in map (uniform.contour_description) c == [True,True,True]
--   
uniform :: Contour_Description -> Bool -- | True if contour does not containt any EQ elements. -- --
--   let c = ["abc","bbb","cba"]
--   map (no_equalities.contour_description) c == [True,False,True]
--   
no_equalities :: Contour_Description -> Bool -- | Set of all contour descriptions. -- --
--   map (length.all_contours) [3,4,5] == [27,729,59049]
--   
all_contours :: Int -> [Contour_Description] -- | A sequence of orderings (i,j) and (j,k) may imply -- ordering for (i,k). -- --
--   map implication [(LT,EQ),(EQ,EQ),(EQ,GT)] == [Just LT,Just EQ,Just GT]
--   
implication :: (Ordering, Ordering) -> Maybe Ordering -- | List of all violations at a Contour_Description (p.266). violations :: Contour_Description -> [(Int, Int, Int, Ordering)] -- | Is the number of violations zero. is_possible :: Contour_Description -> Bool -- | All possible contour descriptions -- --
--   map (length.possible_contours) [3,4,5] == [13,75,541]
--   
possible_contours :: Int -> [Contour_Description] -- | All impossible contour descriptions -- --
--   map (length.impossible_contours) [3,4,5] == [14,654,58508]
--   
impossible_contours :: Int -> [Contour_Description] -- | Calculate number of contours of indicated degree (p.263). -- --
--   map contour_description_lm [2..7] == [1,3,6,10,15,21]
--   
-- --
--   let r = [3,27,729,59049,14348907]
--   in map (\n -> 3 ^ n) (map contour_description_lm [2..6]) == r
--   
contour_description_lm :: Integral a => a -> a -- | Truncate a Contour_Description to have at most n -- elements. -- --
--   let c = contour_description [3,2,4,1]
--   in contour_truncate c 3 == contour_description [3,2,4]
--   
contour_truncate :: Contour_Description -> Int -> Contour_Description -- | Is Contour_Description p a prefix of q. -- --
--   let {c = contour_description [3,2,4,1]
--       ;d = contour_description [3,2,4]}
--   in d `contour_is_prefix_of` c == True
--   
contour_is_prefix_of :: Contour_Description -> Contour_Description -> Bool -- | Are Contour_Descriptions p and q equal at column -- n. -- --
--   let {c = contour_description [3,2,4,1,5]
--       ;d = contour_description [3,2,4,1]}
--   in map (contour_eq_at c d) [0..4] == [True,True,True,True,False]
--   
contour_eq_at :: Contour_Description -> Contour_Description -> Int -> Bool -- | Derive an Integral contour that would be described by -- Contour_Description. Diverges for impossible contours. -- --
--   draw_contour (contour_description "abdc") == [0,1,3,2]
--   
draw_contour :: Integral i => Contour_Description -> [i] -- | Invert Contour_Description. -- --
--   let c = contour_description "abdc"
--   in draw_contour (contour_description_invert c) == [3,2,0,1]
--   
contour_description_invert :: Contour_Description -> Contour_Description -- | Function to perhaps generate an element and a new state from an -- initial state. This is the function provided to unfoldr. type Build_f st e = st -> Maybe (e, st) -- | Function to test is a partial sequence conforms to the target -- sequence. type Conforms_f e = Int -> [e] -> Bool -- | Transform a Build_f to produce at most n elements. -- --
--   let f i = Just (i,succ i)
--   in unfoldr (build_f_n f) (5,'a') == "abcde"
--   
build_f_n :: Build_f st e -> Build_f (Int, st) e -- | Attempt to construct a sequence of n elements given a -- Build_f to generate possible elements, a Conforms_f that -- the result sequence must conform to at each step, an Int to -- specify the maximum number of elements to generate when searching for -- a solution, and an initial state. -- --
--   let {b_f i = Just (i,i+1)
--       ;c_f i x = odd (sum x `div` i)}
--   in build_sequence 6 b_f c_f 20 0 == (Just [1,2,6,11,15,19],20)
--   
build_sequence :: Int -> Build_f st e -> Conforms_f e -> Int -> st -> (Maybe [e], st) -- | Attempt to construct a sequence that has a specified contour. The -- arguments are a Build_f to generate possible elements, a -- Contour_Description that the result sequence must conform to, -- an Int to specify the maximum number of elements to generate -- when searching for a solution, and an initial state. -- --
--   import System.Random
--   
-- --
--   let {f = Just . randomR ('a','z')
--       ;c = contour_description "atdez"
--       ;st = mkStdGen 2347}
--   in fst (build_contour f c 1024 st) == Just "nvruy"
--   
build_contour :: Ord e => Build_f st e -> Contour_Description -> Int -> st -> (Maybe [e], st) -- | A variant on build_contour that retries a specified number of -- times using the final state of the failed attempt as the state for the -- next try. -- --
--   let {f = Just . randomR ('a','z')
--       ;c = contour_description "atdezjh"
--       ;st = mkStdGen 2347}
--   in fst (build_contour_retry f c 64 8 st) == Just "nystzvu"
--   
build_contour_retry :: Ord e => Build_f st e -> Contour_Description -> Int -> Int -> st -> (Maybe [e], st) -- | A variant on build_contour_retry that returns the set of all -- sequences constructed. -- --
--   let {f = Just . randomR ('a','z')
--       ;c = contour_description "atdezjh"
--       ;st = mkStdGen 2347}
--   in length (build_contour_set f c 64 64 st) == 60
--   
build_contour_set :: Ord e => Build_f st e -> Contour_Description -> Int -> Int -> st -> [[e]] -- | Variant of build_contour_set that halts when an generated -- sequence is a duplicate of an already generated sequence. -- --
--   let {f = randomR ('a','f')
--       ;c = contour_description "cafe"
--       ;st = mkStdGen 2346836
--       ;r = build_contour_set_nodup f c 64 64 st}
--   in filter ("c" `isPrefixOf`) r == ["cafe","cbed","caed"]
--   
build_contour_set_nodup :: Ord e => Build_f st e -> Contour_Description -> Int -> Int -> st -> [[e]] -- | Example from p.262 (quarter-note durations) -- --
--   ex_1 == [2,3/2,1/2,1,2]
--   compare_adjacent ex_1 == [GT,GT,LT,LT]
--   show (contour_half_matrix ex_1) == "2221 220 00 0"
--   draw_contour (contour_description ex_1) == [3,2,0,1,3]
--   
-- --
--   let d = contour_description_invert (contour_description ex_1)
--   in (show d,is_possible d) == ("0001 002 22 2",True)
--   
ex_1 :: [Rational] -- | Example on p.265 (pitch) -- --
--   ex_2 == [0,5,3]
--   show (contour_description ex_2) == "00 2"
--   
ex_2 :: [Integer] -- | Example on p.265 (pitch) -- --
--   ex_3 == [12,7,6,7,8,7]
--   show (contour_description ex_3) == "22222 2101 000 01 2"
--   contour_description_ix (contour_description ex_3) (0,5) == GT
--   is_possible (contour_description ex_3) == True
--   
ex_3 :: [Integer] -- | Example on p.266 (impossible) -- --
--   show ex_4 == "2221 220 00 1"
--   is_possible ex_4 == False
--   violations ex_4 == [(0,3,4,GT),(1,3,4,GT)]
--   
ex_4 :: Contour_Description instance GHC.Classes.Ord Music.Theory.Contour.Polansky_1992.Contour_Half_Matrix instance GHC.Classes.Eq Music.Theory.Contour.Polansky_1992.Contour_Half_Matrix instance GHC.Classes.Eq Music.Theory.Contour.Polansky_1992.Contour_Description instance GHC.Show.Show Music.Theory.Contour.Polansky_1992.Contour_Description instance GHC.Show.Show Music.Theory.Contour.Polansky_1992.Contour_Half_Matrix -- | Larry Polansky. "Morphological Metrics". Journal of New Music -- Research, 25(4):289-368, 1996. module Music.Theory.Metric.Polansky_1996 -- | Distance function, ordinarily n below is in Num, -- Fractional or Real. type Interval a n = (a -> a -> n) -- | fromIntegral . -. dif_i :: (Integral a, Num b) => a -> a -> b -- | realToFrac . -. dif_r :: (Real a, Fractional b) => a -> a -> b -- | abs . f. abs_of :: Num n => Interval a n -> a -> a -> n -- | Square. sqr :: Num a => a -> a -- | sqr . f. sqr_of :: Num n => Interval a n -> a -> a -> n -- | sqr . abs . f. sqr_abs_of :: Num n => Interval a n -> a -> a -> n -- | sqrt . abs . f. sqrt_abs_of :: Floating c => Interval a c -> a -> a -> c -- | City block metric, p.296 -- --
--   city_block_metric (-) (1,2) (3,5) == 2+3
--   
city_block_metric :: Num n => Interval a n -> (a, a) -> (a, a) -> n -- | Two-dimensional euclidean metric, p.297. -- --
--   euclidean_metric_2 (-) (1,2) (3,5) == sqrt (4+9)
--   
euclidean_metric_2 :: Floating n => Interval a n -> (a, a) -> (a, a) -> n -- | n-dimensional euclidean metric -- --
--   euclidean_metric_l (-) [1,2] [3,5] == sqrt (4+9)
--   euclidean_metric_l (-) [1,2,3] [2,4,6] == sqrt (1+4+9)
--   
euclidean_metric_l :: Floating c => Interval b c -> [b] -> [b] -> c -- | Cube root. -- --
--   map cbrt [1,8,27] == [1,2,3]
--   
cbrt :: Floating a => a -> a -- | n-th root -- --
--   map (nthrt 4) [1,16,81] == [1,2,3]
--   
nthrt :: Floating a => a -> a -> a -- | Two-dimensional Minkowski metric, p.297 -- --
--   minkowski_metric_2 (-) 1 (1,2) (3,5) == 5
--   minkowski_metric_2 (-) 2 (1,2) (3,5) == sqrt (4+9)
--   minkowski_metric_2 (-) 3 (1,2) (3,5) == cbrt (8+27)
--   
minkowski_metric_2 :: Floating a => Interval t a -> a -> (t, t) -> (t, t) -> a -- | n-dimensional Minkowski metric -- --
--   minkowski_metric_l (-) 2 [1,2,3] [2,4,6] == sqrt (1+4+9)
--   minkowski_metric_l (-) 3 [1,2,3] [2,4,6] == cbrt (1+8+27)
--   
minkowski_metric_l :: Floating a => Interval t a -> a -> [t] -> [t] -> a -- | map abs . d_dx_by. -- --
--   d_dx_abs (-) [0,2,4,1,0] == [2,2,3,1]
--   d_dx_abs (-) [2,3,0,4,1] == [1,3,4,3]
--   
d_dx_abs :: Num n => Interval a n -> [a] -> [n] -- | Ordered linear magnitude (no delta), p.300 -- --
--   olm_no_delta' [0,2,4,1,0] [2,3,0,4,1] == 1.25
--   
olm_no_delta' :: Fractional a => [a] -> [a] -> a -- | Ordered linear magintude (general form) p.302 -- --
--   olm_general (abs_of (-)) [0,2,4,1,0] [2,3,0,4,1] == 1.25
--   olm_general (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 4.6
--   
olm_general :: Fractional n => Interval a n -> [a] -> [a] -> n -- | Delta (Δ) determines an interval given a sequence and an index. type Delta n a = ([n] -> Int -> a) -- | f at indices i and i+1 of x. -- --
--   map (ix_dif (-) [0,1,3,6,10]) [0..3] == [-1,-2,-3,-4]
--   
ix_dif :: Interval a t -> Delta a t -- | abs . ix_dif -- --
--   map (abs_ix_dif (-) [0,2,4,1,0]) [0..3] == [2,2,3,1]
--   
abs_ix_dif :: Num n => Interval a n -> Delta a n -- | sqr . abs_ix_dif -- --
--   map (sqr_abs_ix_dif (-) [0,2,4,1,0]) [0..3] == [4,4,9,1]
--   map (sqr_abs_ix_dif (-) [2,3,0,4,1]) [0..3] == [1,9,16,9]
--   
sqr_abs_ix_dif :: Num n => Interval a n -> Delta a n -- | Psi (Ψ) joins Delta equivalent intervals from -- morphologies m and n. type Psi a = (a -> a -> a) -- | Ordered linear magintude (generalised-interval form) p.305 -- --
--   olm (abs_of dif_r) (abs_ix_dif dif_r) (const 1) [1,5,12,2,9,6] [7,6,4,9,8,1] == 4.6
--   olm (abs_of dif_r) (abs_ix_dif dif_r) maximum [1,5,12,2,9,6] [7,6,4,9,8,1] == 0.46
--   
olm :: Fractional a => Psi a -> Delta n a -> ([a] -> a) -> [n] -> [n] -> a olm_no_delta :: (Real a, Real n, Fractional n) => [a] -> [a] -> n olm_no_delta_squared :: Floating a => [a] -> [a] -> a second_order :: Num n => ([n] -> [n] -> t) -> [n] -> [n] -> t olm_no_delta_second_order :: (Real a, Fractional a) => [a] -> [a] -> a olm_no_delta_squared_second_order :: Floating a => [a] -> [a] -> a -- | Second order binomial coefficient, p.307 -- --
--   map second_order_binonial_coefficient [2..10] == [1,3,6,10,15,21,28,36,45]
--   
second_order_binonial_coefficient :: Fractional a => a -> a -- | d_dx_by of flip compare. -- --
--   direction_interval [5,9,3,2] == [LT,GT,GT]
--   direction_interval [2,5,6,6] == [LT,LT,EQ]
--   
direction_interval :: Ord i => [i] -> [Ordering] -- | Histogram of list of Orderings. -- --
--   ord_hist [LT,GT,GT] == (1,0,2)
--   
ord_hist :: Integral t => [Ordering] -> (t, t, t) -- | Histogram of directions of adjacent elements, p.312. -- --
--   direction_vector [5,9,3,2] == (1,0,2)
--   direction_vector [2,5,6,6] == (2,1,0)
--   
direction_vector :: Integral i => Ord a => [a] -> (i, i, i) -- | Unordered linear direction, p.311 (Fig. 5) -- --
--   uld [5,9,3,2] [2,5,6,6] == 2/3
--   uld [5,3,6,1,4] [3,6,1,4,2] == 0
--   
uld :: (Integral n, Ord a) => [a] -> [a] -> Ratio n -- | Ordered linear direction, p.312 -- --
--   direction_interval [5,3,6,1,4] == [GT,LT,GT,LT]
--   direction_interval [3,6,1,4,2] == [LT,GT,LT,GT]
--   old [5,3,6,1,4] [3,6,1,4,2] == 1
--   
old :: (Ord i, Integral a) => [i] -> [i] -> Ratio a -- | Ordered combinatorial direction, p.314 -- --
--   ocd [5,9,3,2] [2,5,6,6] == 5/6
--   ocd [5,3,6,1,4] [3,6,1,4,2] == 4/5
--   
ocd :: (Ord a, Integral i) => [a] -> [a] -> Ratio i -- | Unordered combinatorial direction, p.314 -- --
--   ucd [5,9,3,2] [2,5,6,6] == 5/6
--   ucd [5,3,6,1,4] [3,6,1,4,2] == 0
--   ucd [5,3,7,6] [2,1,2,1] == 1/2
--   ucd [2,1,2,1] [8,3,5,4] == 1/3
--   ucd [5,3,7,6] [8,3,5,4] == 1/3
--   
ucd :: (Integral n, Ord a) => [a] -> [a] -> Ratio n -- | half_matrix_f, Fig.9, p.318 -- --
--   let r = [[2,3,1,4],[1,3,6],[4,7],[3]]
--   combinatorial_magnitude_matrix (abs_of (-)) [5,3,2,6,9] == r
--   
combinatorial_magnitude_matrix :: Interval a n -> [a] -> [[n]] -- | Unordered linear magnitude (simplified), p.320-321 -- --
--   let r = abs (sum [5,4,3,6] - sum [12,2,11,7]) / 4
--   ulm_simplified (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == r
--   
-- --
--   ulm_simplified (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 3
--   
ulm_simplified :: Fractional n => Interval a n -> [a] -> [a] -> n ocm_zcm :: Fractional n => Interval a n -> [a] -> [a] -> (n, n, [n]) -- | Ordered combinatorial magnitude (OCM), p.323 -- --
--   ocm (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == 5.2
--   ocm (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 3.6
--   
ocm :: Fractional n => Interval a n -> [a] -> [a] -> n -- | Ordered combinatorial magnitude (OCM), p.323 -- --
--   ocm_absolute_scaled (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == 0.4
--   ocm_absolute_scaled (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 54/(15*11)
--   
ocm_absolute_scaled :: (Ord n, Fractional n) => Interval a n -> [a] -> [a] -> n -- | Set operations on Sets. module Music.Theory.Set.Set set :: Ord a => [a] -> Set a powerset :: Ord a => Set a -> Set (Set a) pairs :: Ord a => Set a -> Set (a, a) module Music.Theory.Tiling.Canon -- | Sequence. type S = [Int] -- | Canon of (period,sequence,multipliers,displacements). type R = (Int, S, [Int], [Int]) -- | Voice. type V = [Int] -- | Tiling (sequence) type T = [[Int]] -- | Cycle at period. -- --
--   take 9 (p_cycle 18 [0,2,5]) == [0,2,5,18,20,23,36,38,41]
--   
p_cycle :: Int -> [Int] -> [Int] -- | Element of (sequence,multiplier,displacement). type E = (S, Int, Int) -- | Resolve sequence from E. -- --
--   e_to_seq ([0,2,5],2,1) == [1,5,11]
--   e_to_seq ([0,1],3,4) == [4,7]
--   e_to_seq ([0],1,2) == [2]
--   
e_to_seq :: E -> [Int] -- | Infer E from sequence. -- --
--   e_from_seq [1,5,11] == ([0,2,5],2,1)
--   e_from_seq [4,7] == ([0,1],3,4)
--   e_from_seq [2] == ([0],1,2)
--   
e_from_seq :: [Int] -> E -- | Set of V from R. r_voices :: R -> [V] -- | concatMap of r_voices. rr_voices :: [R] -> [V] -- | Retrograde of T, the result T is sorted. -- --
--   let r = [[0,7,14],[1,5,9],[2,4,6],[3,8,13],[10,11,12]]
--   t_retrograde [[0,7,14],[1,6,11],[2,3,4],[5,9,13],[8,10,12]] == r
--   
t_retrograde :: T -> T -- | The normal form of T is the min of t and it's -- t_retrograde. -- --
--   let r = [[0,7,14],[1,5,9],[2,4,6],[3,8,13],[10,11,12]]
--   t_normal [[0,7,14],[1,6,11],[2,3,4],[5,9,13],[8,10,12]] == r
--   
t_normal :: T -> T -- | Derive set of R from T. -- --
--   let r = [(21,[0,1,2],[10,8,2,4,7,5,1],[0,1,2,3,5,8,14])]
--   let t = [[0,10,20],[1,9,17],[2,4,6],[3,7,11],[5,12,19],[8,13,18],[14,15,16]]
--   r_from_t t == r
--   
r_from_t :: T -> [R] -- | msum . map return. -- --
--   L.observeAll (fromList [1..7]) == [1..7]
--   
fromList :: MonadPlus m => [a] -> m a -- | Search for perfect tilings of the sequence S using -- multipliers from m to degree n with k parts. perfect_tilings_m :: MonadPlus m => [S] -> [Int] -> Int -> Int -> m T -- | t_normal of observeAll of perfect_tilings_m. -- --
--   perfect_tilings [[0,1]] [1..3] 6 3 == []
--   
-- --
--   let r = [[[0,7,14],[1,5,9],[2,4,6],[3,8,13],[10,11,12]]]
--   perfect_tilings [[0,1,2]] [1,2,4,5,7] 15 5 == r
--   
-- --
--   length (perfect_tilings [[0,1,2]] [1..12] 15 5) == 1
--   
-- --
--   let r = [[[0,1],[2,5],[3,7],[4,6]], [[0,1],[2,6],[3,5],[4,7]] ,[[0,2],[1,4],[3,7],[5,6]]]
--   perfect_tilings [[0,1]] [1..4] 8 4 == r
--   
-- --
--   let r = [[[0,1],[2,5],[3,7],[4,9],[6,8]]
--           ,[[0,1],[2,7],[3,5],[4,8],[6,9]]
--           ,[[0,2],[1,4],[3,8],[5,9],[6,7]]
--           ,[[0,2],[1,5],[3,6],[4,9],[7,8]]
--           ,[[0,3],[1,6],[2,4],[5,9],[7,8]]]
--   in perfect_tilings [[0,1]] [1..5] 10 5 == r
--   
-- -- Johnson 2004, p.2 -- --
--   let r = [[0,6,12],[1,8,15],[2,11,20],[3,5,7],[4,9,14],[10,13,16],[17,18,19]]
--   perfect_tilings [[0,1,2]] [1,2,3,5,6,7,9] 21 7 == [r]
--   
-- --
--   let r = [[0,10,20],[1,9,17],[2,4,6],[3,7,11],[5,12,19],[8,13,18],[14,15,16]]
--   perfect_tilings [[0,1,2]] [1,2,4,5,7,8,10] 21 7 == [t_retrograde r]
--   
perfect_tilings :: [S] -> [Int] -> Int -> Int -> [T] -- | Variant of elem for ordered sequences, which can therefore -- return False when searching infinite sequences. -- --
--   5 `elemOrd` [0,2..] == False && 10 `elemOrd` [0,2..] == True
--   
elemOrd :: Ord a => a -> [a] -> Bool -- | A .* diagram of n places of V. -- --
--   v_dot_star 18 [0,2..] == "*.*.*.*.*.*.*.*.*."
--   
v_dot_star :: Int -> V -> String -- | A white space and index diagram of n places of V. -- --
--   >>> mapM_ (putStrLn . v_space_ix 9) [[0,2..],[1,3..]]
--   >
--   >  0   2   4   6   8
--   >    1   3   5   7
--   
v_space_ix :: Int -> V -> String -- | Insert | every n places. -- --
--   with_bars 6 (v_dot_star 18 [0,2..]) == "*.*.*.|*.*.*.|*.*.*."
--   
with_bars :: Int -> String -> String -- | Variant with measure length m and number of measures n. -- --
--   v_dot_star_m 6 3 [0,2..] == "*.*.*.|*.*.*.|*.*.*."
--   
v_dot_star_m :: Int -> Int -> V -> String -- | Print .* diagram. v_print :: Int -> [V] -> IO () -- | Variant to print | at measures. v_print_m :: Int -> Int -> [V] -> IO () -- | Variant that discards first k measures. v_print_m_from :: Int -> Int -> Int -> [V] -> IO () -- | Tom Johnson. "Perfect Rhythmic Tilings". Technical report, IRCAM, 24 -- January 2004. MaMuX Lecture. module Music.Theory.Tiling.Johnson_2004 -- | {0,1,2} order 5, p.1 -- --
--   >>> v_print 15 (r_voices p1)
--   >
--   > ..***..........
--   > ........*.*.*..
--   > .....*...*...*.
--   > .*....*....*...
--   > *......*......*
--   
p1 :: R -- | {0,1,2} order 7, p.2 -- --
--   >>> v_print 21 (r_voices p2)
--   >
--   > ..............***....
--   > ..*.*.*..............
--   > ...*...*...*.........
--   > ........*....*....*..
--   > .....*......*......*.
--   > .*.......*.......*...
--   > *.........*.........*
--   
p2 :: R -- | {0,1} order 4, p.3 -- --
--   >>> v_print 8 (r_voices p3)
--   >
--   > *...*...
--   > .**.....
--   > ...*..*.
--   > .....*.*
--   
p3 :: R -- | {0,1} order 5, p.4 -- --
--   >>> mapM_ (v_print 10 . r_voices) p4
--   >
--   > *...*.....
--   > .**.......
--   > ...*....*.
--   > .....*.*..
--   > ......*..*
--   >
--   > *....*....
--   > .**.......
--   > ...*..*...
--   > ....*...*.
--   > .......*.*
--   >
--   > *...*.....
--   > .*....*...
--   > ..**......
--   > .....*..*.
--   > .......*.*
--   
p4 :: [R] -- | Open {1,2,3} order 5, p.4 -- --
--   >>> v_print 18 (r_voices p4_b)
--   >
--   > ...***............
--   > ........*.*.*.....
--   > .........*...*...*
--   > .*....*....*......
--   > *......*......*...
--   
p4_b :: R -- | Tom Johnson. "Tiling in my Music". The Experimental Music -- Yearbook, 1, 2009. module Music.Theory.Tiling.Johnson_2009 -- | Tilework for Clarinet, p.3 -- --
--   >>> v_print 36 (rr_voices p3)
--   >
--   > *.*..*............*.*..*............
--   > .*.*..*............*.*..*...........
--   > ........*.*..*............*.*..*....
--   > ....*..*.*............*..*.*........
--   > ...........*..*.*............*..*.*.
--   > ............*..*.*............*..*.*
--   
p3 :: [R] -- | Tilework for String Quartet, p.5 -- --
--   >>> mapM_ (v_print 24 . r_voices) p5
--   >
--   > ******......******......
--   > ......******......******
--   >
--   > *.****.*....*.****.*....
--   > ......*.****.*....*.****
--   >
--   > **.***..*...**.***..*...
--   > ......**.***..*...**.***
--   >
--   > *..***.**...*..***.**...
--   > ......*..***.**...*..***
--   
p5 :: [R] -- | Extra Perfect (p.7) -- --
--   >>> v_print_m_from 18 6 6 (r_voices p7)
--   >
--   > **.*..|......|......|......|......|......
--   > ......|.*.*..|.*....|......|......|......
--   > ......|......|......|......|.*..*.|....*.
--   > ......|......|...*..|.*....|...*..|......
--   > ......|......|....*.|...*..|......|.*....
--   > ......|*.....|*.....|......|*.....|......
--   > ....*.|......|......|*.....|......|...*..
--   > ......|......|......|....*.|......|*.....
--   
p7 :: R -- | Tilework for Log Drums (2005), p.10 -- --
--   >>> v_print 18 (r_voices p10)
--   >
--   > *.*.*.............
--   > .*...*...*........
--   > ...*...*...*......
--   > ......*...*...*...
--   > ........*...*...*.
--   > .............*.*.*
--   
p10 :: R -- | Self-Similar Melodies (1996), p.11 -- --
--   >>> v_print_m 20 5 (r_voices p11)
--   >
--   > *.....*.....*..*..*.|....*.....*.....*...|..*..*..*.....*.....|*.....*.....*..*..*.|....*.....*.....*...
--   > ....................|*.....*.....*..*..*.|....*.....*.....*...|..*..*..*.....*.....|*.....*.....*..*..*.
--   > ....................|....................|*.....*.....*..*..*.|....*.....*.....*...|..*..*..*.....*.....
--   
p11 :: R -- | Bel(R) is a simplified form of the Bel notation -- described in: -- -- -- -- For details see http://rohandrape.net/?t=hmt-texts. module Music.Theory.Time.Bel1990.R -- | Types of Par nodes. data Par_Mode Par_Left :: Par_Mode Par_Right :: Par_Mode Par_Min :: Par_Mode Par_Max :: Par_Mode Par_None :: Par_Mode -- | The different Par modes are indicated by bracket types. par_mode_brackets :: Par_Mode -> (String, String) -- | Inverse of par_mode_brackets par_mode_kind :: (String, String) -> Par_Mode bel_brackets_match :: (Char, Char) -> Bool -- | Tempo is rational. The duration of a Term is the reciprocal of -- the Tempo that is in place at the Term. type Tempo = Rational -- | Terms are the leaf nodes of the temporal structure. data Term a Value :: a -> Term a Rest :: Term a Continue :: Term a -- | Value of Term, else Nothing term_value :: Term t -> Maybe t -- | Recursive temporal structure. data Bel a -- | Leaf node Node :: Term a -> Bel a -- | Isolate Iso :: Bel a -> Bel a -- | Sequence Seq :: Bel a -> Bel a -> Bel a -- | Parallel Par :: Par_Mode -> Bel a -> Bel a -> Bel a -- | Tempo multiplier Mul :: Tempo -> Bel a -- | Given a Par mode, generate either: 1. an Iso, 2. a Par, 3. a series of -- nested Par. par_of :: Par_Mode -> [Bel a] -> Bel a -- | Pretty printer for Bel, given pretty printer for the term type. -- Note this does not write nested Par nodes in their simplified form. bel_pp :: (a -> String) -> Bel a -> String -- | bel_pp of return. bel_char_pp :: Bel Char -> String -- | Analyse a Par node giving (duration,LHS-tempo-*,RHS-tempo-*). -- --
--   par_analyse 1 Par_Left (nseq "cd") (nseq "efg") == (2,1,3/2)
--   par_analyse 1 Par_Right (nseq "cd") (nseq "efg") == (3,2/3,1)
--   par_analyse 1 Par_Min (nseq "cd") (nseq "efg") == (2,1,3/2)
--   par_analyse 1 Par_Max (nseq "cd") (nseq "efg") == (3,2/3,1)
--   par_analyse 1 Par_None (nseq "cd") (nseq "efg") == (3,1,1)
--   
par_analyse :: Tempo -> Par_Mode -> Bel a -> Bel a -> (Rational, Rational, Rational) -- | Duration element of par_analyse. par_dur :: Tempo -> Par_Mode -> Bel a -> Bel a -> Rational -- | Calculate final tempo and duration of Bel. bel_tdur :: Tempo -> Bel a -> (Tempo, Rational) -- | snd of bel_tdur. bel_dur :: Tempo -> Bel a -> Rational -- | Time point. type Time = Rational -- | Voices are named as a sequence of left and right directions within -- nested Par structures. l is left and r is right. type Voice = [Char] -- | Linear state. Time is the start time of the term. Tempo -- is the active tempo & therefore the reciprocal of the duration. -- Voice is the part label. type L_St = (Time, Tempo, Voice) -- | Linear term. type L_Term a = (L_St, Term a) -- | Start time of L_Term. lterm_time :: L_Term a -> Time -- | Duration of L_Term (reciprocal of tempo). lterm_duration :: L_Term a -> Time -- | End time of L_Term. lterm_end_time :: L_Term a -> Time -- | Voice of L_Term. lterm_voice :: L_Term t -> Voice -- | Term of L_Term lterm_term :: L_Term t -> Term t -- | Value of Term of L_Term lterm_value :: L_Term t -> Maybe t -- | Linear form of Bel, an ascending sequence of L_Term. type L_Bel a = [L_Term a] -- | Linearise Bel given initial L_St, ascending by -- construction. bel_linearise :: L_St -> Bel a -> (L_Bel a, L_St) -- | Merge two ascending L_Bel. lbel_merge :: L_Bel a -> L_Bel a -> L_Bel a -- | Set of unique Tempo at L_Bel. lbel_tempi :: L_Bel a -> [Tempo] -- | Multiply Tempo by n, and divide Time by n. lbel_tempo_mul :: Rational -> L_Bel a -> L_Bel a -- | The multiplier that will normalise an L_Bel value. After normalisation -- all start times and durations are integral. lbel_normalise_multiplier :: L_Bel t -> Rational -- | Calculate and apply L_Bel normalisation multiplier. lbel_normalise :: L_Bel a -> L_Bel a -- | All leftmost voices are re-written to the last non-left turning point. -- --
--   map voice_normalise ["","l","ll","lll"] == replicate 4 ""
--   voice_normalise "lllrlrl" == "rlrl"
--   
voice_normalise :: Voice -> Voice -- | == on voice_normalise voice_eq :: Voice -> Voice -> Bool -- | Unique Voices at L_Bel. lbel_voices :: L_Bel a -> [Voice] -- | The duration of L_Bel. lbel_duration :: L_Bel a -> Time -- | Locate an L_Term that is active at the indicated Time -- and in the indicated Voice. lbel_lookup :: (Time, Voice) -> L_Bel a -> Maybe (L_Term a) -- | Calculate grid (phase diagram) for L_Bel. lbel_grid :: L_Bel a -> [[Maybe (Term a)]] -- | lbel_grid of bel_linearise. bel_grid :: Bel a -> [[Maybe (Term a)]] -- | Bel type phase diagram for Bel of Char. -- Optionally print whitespace between columns. bel_ascii :: Bool -> Bel Char -> String -- | putStrLn of bel_ascii. bel_ascii_pr :: Bel Char -> IO () -- | Infix form for Seq. (~>) :: Bel a -> Bel a -> Bel a -- | foldl1 of Seq. -- --
--   lseq [Node Rest] == Node Rest
--   lseq [Node Rest,Node Continue] == Seq (Node Rest) (Node Continue)
--   
lseq :: [Bel a] -> Bel a -- | Node of Value. node :: a -> Bel a -- | lseq of Node nseq :: [a] -> Bel a -- | Variant of nseq where _ is read as Continue and -- - as Rest. cseq :: String -> Bel Char -- | Par of Par_Max, this is the default Par_Mode. par :: Bel a -> Bel a -> Bel a -- | Node of Rest. rest :: Bel a -- | lseq of replicate of rest. nrests :: Integral n => n -> Bel a -- | Verify that bel_char_pp of bel_char_parse is id. bel_parse_pp_ident :: String -> Bool -- | Run bel_char_parse, and print both bel_char_pp and -- bel_ascii. -- --
--   bel_ascii_pp "{i{ab,c[d,oh]e,sr{p,qr}},{jk,ghjkj}}"
--   
bel_ascii_pp :: String -> IO () -- | Parse Rest Term. -- --
--   P.parse p_rest "" "-"
--   
p_rest :: P (Term a) -- | Parse Rest Term. -- --
--   P.parse p_nrests "" "3"
--   
p_nrests :: P (Bel a) -- | Parse Continue Term. -- --
--   P.parse p_continue "" "_"
--   
p_continue :: P (Term a) -- | Parse Char Value Term. -- --
--   P.parse p_char_value "" "a"
--   
p_char_value :: P (Term Char) -- | Parse Char Term. -- --
--   P.parse (P.many1 p_char_term) "" "-_a"
--   
p_char_term :: P (Term Char) -- | Parse Char Node. -- --
--   P.parse (P.many1 p_char_node) "" "-_a"
--   
p_char_node :: P (Bel Char) -- | Parse non-negative Integer. -- --
--   P.parse p_non_negative_integer "" "3"
--   
p_non_negative_integer :: P Integer -- | Parse non-negative Rational. -- --
--   P.parse (p_non_negative_rational `P.sepBy` (P.char ',')) "" "3%5,2/3"
--   
p_non_negative_rational :: P Rational -- | Parse non-negative Double. -- --
--   P.parse p_non_negative_double "" "3.5"
--   P.parse (p_non_negative_double `P.sepBy` (P.char ',')) "" "3.5,7.2,1.0"
--   
p_non_negative_double :: P Double -- | Parse non-negative number as Rational. -- --
--   P.parse (p_non_negative_number `P.sepBy` (P.char ',')) "" "7%2,3.5,3"
--   
p_non_negative_number :: P Rational -- | Parse Mul. -- --
--   P.parse (P.many1 p_mul) "" "/3*3/2"
--   
p_mul :: P (Bel a) -- | Given parser for Bel a, generate Iso parser. p_iso :: P (Bel a) -> P (Bel a) -- | p_iso of p_char_bel. -- --
--   P.parse p_char_iso "" "{abcde}"
--   
p_char_iso :: P (Bel Char) -- | Given parser for Bel a, generate Par parser. p_par :: P (Bel a) -> P (Bel a) -- | p_par of p_char_bel. -- --
--   p = P.parse p_char_par ""
--   p "{ab,{c,de}}" == p "{ab,c,de}"
--   p "{ab,~(c,de)}"
--   
p_char_par :: P (Bel Char) -- | Parse Bel Char. -- --
--   P.parse (P.many1 p_char_bel) "" "-_a*3"
--   
p_char_bel :: P (Bel Char) -- | Run parser for Bel of Char. bel_char_parse :: String -> Bel Char instance GHC.Show.Show Music.Theory.Time.Bel1990.R.Par_Mode instance GHC.Classes.Eq Music.Theory.Time.Bel1990.R.Par_Mode instance GHC.Show.Show a => GHC.Show.Show (Music.Theory.Time.Bel1990.R.Term a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Music.Theory.Time.Bel1990.R.Term a) instance GHC.Show.Show a => GHC.Show.Show (Music.Theory.Time.Bel1990.R.Bel a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Music.Theory.Time.Bel1990.R.Bel a) -- | KeyKit phrase literal (constant) parser and printer. module Music.Theory.Time.KeyKit.Parser -- | A Char parser with no user state. type P a = GenParser Char () a -- | Run parser and return either an error string or an answer. kk_parse_either :: P t -> String -> Either String t -- | Run parser and report any error. Does not delete leading spaces. kk_parse :: P t -> String -> t -- | Run p then q, returning result of p. (>>~) :: Monad m => m t -> m u -> m t kk_lexeme :: P t -> P t kk_uint :: P Int kk_int :: P Int kk_note_name_p :: P Char kk_midi_note_p :: P Int kk_rest_p :: P Char kk_accidental_p :: P Char kk_char_to_note_number :: Char -> Int kk_char_to_alteration :: Char -> Int kk_note_number_to_name :: Int -> String kk_named_note_number_p :: P Int kk_note_number_p :: P Int -- | The octave key can be elided, ordinarily directly after the note name, -- ie. c2. kk_modifier_p :: P (Char, Int) kk_modifiers_p :: P [(Char, Int)] -- | A note where all fields are optional. If the note number is absent it -- indicates a rest. All other fields infer values from the phrase -- context. data Kk_Contextual_Note Kk_Contextual_Note :: Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Kk_Contextual_Note [kk_contextual_note_number] :: Kk_Contextual_Note -> Maybe Int [kk_contextual_note_octave] :: Kk_Contextual_Note -> Maybe Int [kk_contextual_note_volume] :: Kk_Contextual_Note -> Maybe Int [kk_contextual_note_duration] :: Kk_Contextual_Note -> Maybe Int [kk_contextual_note_channel] :: Kk_Contextual_Note -> Maybe Int [kk_contextual_note_time] :: Kk_Contextual_Note -> Maybe Int kk_empty_contextual_note :: Kk_Contextual_Note kk_empty_contextual_rest :: Int -> Kk_Contextual_Note -- | If t is set and is at the end time of the previous note print a -- preceding comma, else print t annotation. -- --
--   c = kk_empty_contextual_note {kk_contextual_note_number = Just 0, kk_contextual_time = Just 96}
--   map (\t -> kk_contextual_note_pp (t, c)) [0, 96] == ["ct96",", c"]
--   
kk_contextual_note_pp :: (Int, Kk_Contextual_Note) -> String -- | If the note number is given as p60, then derive octave of and set it, -- ignoring any modifier. Note that in KeyKit c3 is p60 or middle c. kk_contextual_note_p :: P Kk_Contextual_Note kk_contextual_note_is_rest :: Kk_Contextual_Note -> Bool kk_comma_p :: P Char -- | A contextual note and an is_parallel? indicator. kk_contextual_phrase_element_p :: P (Kk_Contextual_Note, Bool) kk_contextual_phrase_p :: P [(Kk_Contextual_Note, Bool)] -- | A note with all fields required. data Kk_Note Kk_Note :: Int -> Int -> Int -> Int -> Int -> Int -> Kk_Note [kk_note_number] :: Kk_Note -> Int [kk_note_octave] :: Kk_Note -> Int [kk_note_volume] :: Kk_Note -> Int [kk_note_duration] :: Kk_Note -> Int [kk_note_channel] :: Kk_Note -> Int [kk_note_time] :: Kk_Note -> Int kk_default_note :: Kk_Note kk_note_to_initial_contextual_note :: Kk_Note -> Kk_Contextual_Note kk_note_to_contextual_note :: Kk_Note -> Kk_Note -> (Int, Kk_Contextual_Note) -- | Elide octave modifier character. kk_note_pp :: Kk_Note -> String kk_decontextualise_note :: Kk_Note -> Bool -> Kk_Contextual_Note -> Either Kk_Note Int data Kk_Phrase Kk_Phrase :: [Kk_Note] -> Int -> Kk_Phrase [kk_phrase_notes] :: Kk_Phrase -> [Kk_Note] [kk_phrase_length] :: Kk_Phrase -> Int -- | This should, but does not, append a trailing rest as required. kk_phrase_pp :: Kk_Phrase -> String -- | Rests are elided, their duration is accounted for in the time of the -- following notetaken into account. kk_decontextualise_phrase :: [(Kk_Contextual_Note, Bool)] -> Kk_Phrase -- | In addition to contextual note give end time of previous note, to -- allow for sequence (comma) notation. kk_recontextualise_phrase :: Kk_Phrase -> [(Int, Kk_Contextual_Note)] -- | Read KeyKit phrase constant. -- --
--   let rw = (\p -> (kk_phrase_pp p, kk_phrase_length p)) . kk_phrase_read
--   rw "c" == ("c3v63d96c1t0",96)
--   rw "c, r" == ("c3v63d96c1t0",192)
--   rw "c, r, c3, r, p60" == ("c3v63d96c1t0 c3v63d96c1t192 c3v63d96c1t384",480)
--   rw "c, e, g" == ("c3v63d96c1t0 e3v63d96c1t96 g3v63d96c1t192",288)
--   rw "c2" == rw "co2"
--   
kk_phrase_read :: String -> Kk_Phrase -- | Re-contextualise and print phrase. -- --
--   rw = kk_phrase_print . kk_phrase_read
--   rw_id i = rw i == i
--   rw_id "c"
--   rw_id "c e g"
--   rw_id "c , e , g"
--   rw_id "c e g , c f a , c e g , c e- g"
--   rw_id "c , e , g c4t384"
--   rw "c, r, c3, r, p60" == "c ct192 ct384"
--   rw "c , e , g c4t288" == "c , e , g , c4"
--   rw "c r" == "c" -- ?
--   
kk_phrase_print :: Kk_Phrase -> String instance GHC.Show.Show Music.Theory.Time.KeyKit.Parser.Kk_Contextual_Note instance GHC.Classes.Ord Music.Theory.Time.KeyKit.Parser.Kk_Contextual_Note instance GHC.Classes.Eq Music.Theory.Time.KeyKit.Parser.Kk_Contextual_Note instance GHC.Show.Show Music.Theory.Time.KeyKit.Parser.Kk_Note instance GHC.Classes.Ord Music.Theory.Time.KeyKit.Parser.Kk_Note instance GHC.Classes.Eq Music.Theory.Time.KeyKit.Parser.Kk_Note instance GHC.Show.Show Music.Theory.Time.KeyKit.Parser.Kk_Phrase instance GHC.Classes.Eq Music.Theory.Time.KeyKit.Parser.Kk_Phrase -- | Basic temporal sequence functions. module Music.Theory.Time.Seq -- | Sequence of elements with uniform duration. type Useq t a = (t, [a]) -- | Duration sequence. t indicates the forward duration of -- the value, ie. the interval to the next value. If there are other -- durations they must be encoded at a. If the sequence does not -- begin at time zero there must be an empty value for a. type Dseq t a = [(t, a)] -- | Inter-offset sequence. t is the interval before the -- value. Duration can be encoded at a, or if implicit a -- must include an end of sequence value. type Iseq t a = [(t, a)] -- | Pattern sequence. The duration is a triple of logical, -- sounding and forward durations. These indicate the time -- the value conceptually takes, the time it actually takes, and the time -- to the next event. If the sequence does not begin at time zero there -- must be an empty value for a. type Pseq t a = [((t, t, t), a)] -- | Time-point sequence. t is the start time of the value. To -- express holes a must have an empty value. Duration can -- be encoded at a, or if implicit a must include an end of -- sequence value. type Tseq t a = [(t, a)] -- | Window sequence. t is a duple of start-time and -- duration. Holes exist where start-time(n) + duration(n) < -- start-time(n + 1). Overlaps exist where the same relation is -- >. type Wseq t a = [((t, t), a)] -- | Event sequence. t is a triple of start-time, -- duration and length. length isn't necessarily the -- time to the next event, though ordinarily it should not be greater -- than that interval. type Eseq t a = [((t, t, t), a)] -- | Construct Pseq. pseq_zip :: [t] -> [t] -> [t] -> [a] -> Pseq t a -- | Construct Wseq. wseq_zip :: [t] -> [t] -> [a] -> Wseq t a -- | Given functions for deriving start and end times calculate time span -- of sequence. Requires sequence be finite. -- --
--   seq_tspan id id [] == (0,0)
--   seq_tspan id id (zip [0..9] ['a'..]) == (0,9)
--   
seq_tspan :: Num n => (t -> n) -> (t -> n) -> [(t, a)] -> (n, n) -- | seq_tspan for Tseq. tseq_tspan :: Num t => Tseq t a -> (t, t) -- | seq_tspan for Wseq. wseq_tspan :: Num t => Wseq t a -> (t, t) -- | Start time of sequence. -- --
--   wseq_start [((1,2),'a')] == 1
--   wseq_start [] == 0
--   
wseq_start :: Num t => Wseq t a -> t -- | End time of sequence. -- --
--   wseq_end [((1,2),'a')] == 3
--   wseq_end (useq_to_wseq 0 (1,"linear")) == 6
--   
wseq_end :: Num t => Wseq t a -> t -- | Sum durations at Dseq, result is the end time of the last -- element. dseq_dur :: Num t => Dseq t a -> t -- | Sum durations at Iseq, result is the start time of the last -- element. iseq_dur :: Num t => Iseq t a -> t -- | Sum durations at Pseq, result is the end time of the last -- element. pseq_dur :: Num t => Pseq t a -> t -- | The interval of tseq_tspan, ie. from the start of the first -- element to the start of the last. -- --
--   tseq_dur (zip [0..] "abcde|") == 5
--   
tseq_dur :: Num t => Tseq t a -> t -- | The interval of wseq_tspan, ie. from the start of the first -- element to the end of the last. -- --
--   wseq_dur (zip (zip [0..] (repeat 2)) "abcde") == 6
--   
wseq_dur :: Num t => Wseq t a -> t -- | Prefix of sequence where the start time precedes or is at the -- indicated time. wseq_until :: Ord t => t -> Wseq t a -> Wseq t a -- | Keep only elements that are entirely contained within the indicated -- temporal window, which is inclusive at the left & right edges, ie. -- [t0,t1]. Halts processing at end of window. -- --
--   let r = [((5,1),'e'),((6,1),'f'),((7,1),'g'),((8,1),'h')]
--   wseq_twindow (5,9) (zip (zip [1..] (repeat 1)) ['a'..]) == r
--   
-- --
--   wseq_twindow (1,2) [((1,1),'a'),((1,2),'b')] == [((1,1),'a')]
--   
wseq_twindow :: (Num t, Ord t) => (t, t) -> Wseq t a -> Wseq t a -- | Select nodes that are active at indicated time, comparison is -- inclusive at left and exclusive at right. Halts processing at end of -- window. -- --
--   let sq = [((1,1),'a'),((1,2),'b')]
--   map (wseq_at sq) [1,2] == [sq,[((1,2),'b')]]
--   
-- --
--   wseq_at (zip (zip [1..] (repeat 1)) ['a'..]) 3 == [((3,1),'c')]
--   
wseq_at :: (Num t, Ord t) => Wseq t a -> t -> Wseq t a -- | Select nodes that are active within the indicated window, comparison -- is inclusive at left and exclusive at right. Halts processing at end -- of window. -- --
--   let sq = [((0,2),'a'),((0,4),'b'),((2,4),'c')]
--   wseq_at_window sq (1,3) == sq
--   
-- --
--   wseq_at_window (zip (zip [1..] (repeat 1)) ['a'..]) (3,4) == [((3,1),'c'),((4,1),'d')]
--   
wseq_at_window :: (Num t, Ord t) => Wseq t a -> (t, t) -> Wseq t a -- | Type specialised ++ dseq_append :: Dseq t a -> Dseq t a -> Dseq t a -- | Type specialised ++ iseq_append :: Iseq t a -> Iseq t a -> Iseq t a -- | Type specialised ++ pseq_append :: Pseq t a -> Pseq t a -> Pseq t a -- | Merge comparing only on time. tseq_merge :: Ord t => Tseq t a -> Tseq t a -> Tseq t a -- | Merge, where times are equal compare values. tseq_merge_by :: Ord t => Compare_F a -> Tseq t a -> Tseq t a -> Tseq t a -- | Merge, where times are equal apply f to form a single value. -- --
--   let {p = zip [1,3,5] "abc"
--       ;q = zip [1,2,3] "ABC"
--       ;left_r = [(1,'a'),(2,'B'),(3,'b'),(5,'c')]
--       ;right_r = [(1,'A'),(2,'B'),(3,'C'),(5,'c')]}
--   in tseq_merge_resolve (\x _ -> x) p q == left_r &&
--      tseq_merge_resolve (\_ x -> x) p q == right_r
--   
tseq_merge_resolve :: Ord t => (a -> a -> a) -> Tseq t a -> Tseq t a -> Tseq t a -- | Compare first by start time, then by duration. w_compare :: Ord t => ((t, t), a) -> ((t, t), a) -> Ordering -- | Merge considering only start times. wseq_merge :: Ord t => Wseq t a -> Wseq t a -> Wseq t a -- | Merge set considering both start times & durations. wseq_merge_set :: Ord t => [Wseq t a] -> Wseq t a -- | Merge considering only start times. eseq_merge :: Ord t => Eseq t a -> Eseq t a -> Eseq t a -- | Locate nodes to the left and right of indicated time. tseq_lookup_window_by :: (t -> t -> Ordering) -> Tseq t e -> t -> (Maybe (t, e), Maybe (t, e)) tseq_lookup_active_by :: (t -> t -> Ordering) -> Tseq t e -> t -> Maybe e tseq_lookup_active :: Ord t => Tseq t e -> t -> Maybe e tseq_lookup_active_by_def :: e -> (t -> t -> Ordering) -> Tseq t e -> t -> e tseq_lookup_active_def :: Ord t => e -> Tseq t e -> t -> e -- | Iterpolation type enumeration. data Interpolation_T None :: Interpolation_T Linear :: Interpolation_T -- | Variant of Tseq where nodes have an Intepolation_T -- value. type Lseq t a = Tseq (t, Interpolation_T) a -- | Linear interpolation. The Real constraint on t is to allow conversion -- from t to e (realToFrac). lerp :: (Fractional t, Real t, Fractional e) => (t, e) -> (t, e) -> t -> e -- | Temporal map. lseq_tmap :: (t -> t') -> Lseq t a -> Lseq t' a -- | This can give Nothing if t precedes the Lseq or -- if t is after the final element of Lseq and that element -- has an interpolation type other than None. lseq_lookup :: (Fractional t, Real t, Fractional e) => (t -> t -> Ordering) -> Lseq t e -> t -> Maybe e -- | erroring variant. lseq_lookup_err :: (Fractional t, Real t, Fractional e) => (t -> t -> Ordering) -> Lseq t e -> t -> e -- | map over time (t) data. seq_tmap :: (t1 -> t2) -> [(t1, a)] -> [(t2, a)] -- | map over element (e) data. seq_map :: (e1 -> e2) -> [(t, e1)] -> [(t, e2)] -- | map t and e simultaneously. -- --
--   seq_bimap negate succ (zip [1..5] [0..4]) == [(-1,1),(-2,2),(-3,3),(-4,4),(-5,5)]
--   
seq_bimap :: (t1 -> t2) -> (e1 -> e2) -> [(t1, e1)] -> [(t2, e2)] -- | filter over time (t) data. seq_tfilter :: (t -> Bool) -> [(t, a)] -> [(t, a)] -- | filter over element (e) data. seq_filter :: (b -> Bool) -> [(a, b)] -> [(a, b)] -- | find over element (e) data. seq_find :: (e -> Bool) -> [(t, e)] -> Maybe (t, e) -- | mapMaybe variant. seq_map_maybe :: (p -> Maybe q) -> [(t, p)] -> [(t, q)] -- | Variant of catMaybes. seq_cat_maybes :: [(t, Maybe q)] -> [(t, q)] -- | If value is unchanged at subsequent entry, according to f, -- replace with Nothing. seq_changed_by :: (a -> a -> Bool) -> [(t, a)] -> [(t, Maybe a)] -- | seq_changed_by ==. -- --
--   let r = [(1,'s'),(2,'t'),(4,'r'),(6,'i'),(7,'n'),(9,'g')]
--   seq_cat_maybes (seq_changed (zip [1..] "sttrrinng")) == r
--   
seq_changed :: Eq a => [(t, a)] -> [(t, Maybe a)] -- | Apply f at time points of Wseq. wseq_tmap_st :: (t -> t) -> Wseq t a -> Wseq t a -- | Apply f at durations of elements of Wseq. wseq_tmap_dur :: (t -> t) -> Wseq t a -> Wseq t a -- | Given a function that determines a voice for a value, partition -- a sequence into voices. seq_partition :: Ord v => (a -> v) -> [(t, a)] -> [(v, [(t, a)])] -- | Type specialised seq_partition. -- --
--   let p = zip [0,1,3,5] (zip (repeat 0) "abcd")
--   let q = zip [2,4,6,7] (zip (repeat 1) "ABCD")
--   let sq = tseq_merge p q
--   tseq_partition fst sq == [(0,p),(1,q)]
--   
tseq_partition :: Ord v => (a -> v) -> Tseq t a -> [(v, Tseq t a)] -- | Type specialised seq_partition. wseq_partition :: Ord v => (a -> v) -> Wseq t a -> [(v, Wseq t a)] -- | Given a decision predicate and a join function, recursively join -- adjacent elements. -- --
--   coalesce_f undefined undefined [] == []
--   coalesce_f (==) const "abbcccbba" == "abcba"
--   coalesce_f (==) (+) [1,2,2,3,3,3] == [1,4,6,3]
--   
coalesce_f :: (t -> t -> Bool) -> (t -> t -> t) -> [t] -> [t] -- | coalesce_f using mappend for the join function. coalesce_m :: Monoid t => (t -> t -> Bool) -> [t] -> [t] -- | Form of coalesce_t where the join predicate is on the -- element only, the times are summed. coalesce_t :: Num t => ((t, a) -> (t, a) -> Bool) -> (a -> a -> a) -> [(t, a)] -> [(t, a)] -- | Form of coalesce_f where both the decision and join predicates -- are on theelement, the times are summed. -- --
--   let r = [(1,'a'),(2,'b'),(3,'c'),(2,'d'),(1,'e')]
--   seq_coalesce (==) const (useq_to_dseq (1,"abbcccdde")) == r
--   
seq_coalesce :: Num t => (a -> a -> Bool) -> (a -> a -> a) -> [(t, a)] -> [(t, a)] dseq_coalesce :: Num t => (a -> a -> Bool) -> (a -> a -> a) -> Dseq t a -> Dseq t a -- | Given equality predicate, simplify sequence by summing -- durations of adjacent equal elements. This is a special case of -- dseq_coalesce where the join function is const. -- The implementation is simpler and non-recursive. -- --
--   let d = useq_to_dseq (1,"abbcccdde")
--   let r = dseq_coalesce (==) const d
--   dseq_coalesce' (==) d == r
--   
dseq_coalesce' :: Num t => (a -> a -> Bool) -> Dseq t a -> Dseq t a iseq_coalesce :: Num t => (a -> a -> Bool) -> (a -> a -> a) -> Iseq t a -> Iseq t a seq_tcoalesce :: (t -> t -> Bool) -> (a -> a -> a) -> [(t, a)] -> [(t, a)] tseq_tcoalesce :: Eq t => (a -> a -> a) -> Tseq t a -> Tseq t a -- | Type specialised seq_tcoalesce. wseq_tcoalesce :: ((t, t) -> (t, t) -> Bool) -> (a -> a -> a) -> Wseq t a -> Wseq t a -- | Post-process groupBy of cmp on fst. -- --
--   let r = [(0,"a"),(1,"bc"),(2,"de"),(3,"f")]
--   group_f (==) (zip [0,1,1,2,2,3] ['a'..]) == r
--   
group_f :: (Eq t, Num t) => (t -> t -> Bool) -> [(t, a)] -> [(t, [a])] -- | Group values at equal time points. -- --
--   let r = [(0,"a"),(1,"bc"),(2,"de"),(3,"f")]
--   tseq_group (zip [0,1,1,2,2,3] ['a'..]) == r
--   
-- --
--   tseq_group [(1,'a'),(1,'b')] == [(1,"ab")]
--   tseq_group [(1,'a'),(2,'b'),(2,'c')] == [(1,"a"),(2,"bc")]
--   
tseq_group :: (Eq t, Num t) => Tseq t a -> Tseq t [a] -- | Group values where the inter-offset time is 0 to the left. -- --
--   let r = [(0,"a"),(1,"bcd"),(1,"ef")]
--   iseq_group (zip [0,1,0,0,1,0] ['a'..]) == r
--   
iseq_group :: (Eq t, Num t) => Iseq t a -> Iseq t [a] -- | Set durations so that there are no gaps or overlaps. For entries with -- the same start time this leads to zero durations. -- --
--   let r = wseq_zip [0,3,3,5] [3,0,2,1] "abcd"
--   wseq_fill_dur (wseq_zip [0,3,3,5] [2,1,2,1] "abcd") == r
--   
wseq_fill_dur :: Num t => Wseq t a -> Wseq t a dseq_lcm :: Dseq Rational e -> Integer -- | Scale by lcm so that all durations are integral. dseq_set_whole :: [Dseq Rational e] -> [Dseq Integer e] -- | End-time of sequence (ie. sum of durations). dseq_end :: Num t => Dseq t a -> t -- | Given a a default value, a Tseq sq and a list of -- time-points t, generate a Tseq that is a union of the -- timepoints at sq and t where times in t not at -- sq are given the current value, or def if there -- is no value. -- --
--   tseq_latch 'a' [(2,'b'),(4,'c')] [1..5] == zip [1..5] "abbcc"
--   
tseq_latch :: Ord t => a -> Tseq t a -> [t] -> Tseq t a -- | End-time of sequence (ie. time of last event). tseq_end :: Tseq t a -> t -- | Append the value nil at n seconds after the end of the -- sequence. tseq_add_nil_after :: Num t => a -> t -> Tseq t a -> Tseq t a -- | Sort Wseq by start time, Wseq ought never to be out of -- order. -- --
--   wseq_sort [((3,1),'a'),((1,3),'b')] == [((1,3),'b'),((3,1),'a')]
--   
wseq_sort :: Ord t => Wseq t a -> Wseq t a -- | Transform Wseq to Tseq by discarding durations. wseq_discard_dur :: Wseq t a -> Tseq t a -- | Are e equal and do nodes overlap? Nodes are ascending, and so -- overlap if: 1. they begin at the same time and the first has non-zero -- duration, or 2. the second begins before the first ends. wseq_nodes_overlap :: (Ord t, Num t) => (e -> e -> Bool) -> ((t, t), e) -> ((t, t), e) -> Bool -- | Find first node at sq that overlaps with e0, if there is -- one. Note: this could, but does not, halt early, ie. when t2 > (t1 -- + d1). wseq_find_overlap_1 :: (Ord t, Num t) => (e -> e -> Bool) -> ((t, t), e) -> Wseq t e -> Bool -- | Determine if sequence has any overlapping equal nodes, stops after -- finding first instance. -- --
--   wseq_has_overlaps (==) [] == False
--   wseq_has_overlaps (==) [((0,1),'x')]
--   
wseq_has_overlaps :: (Ord t, Num t) => (e -> e -> Bool) -> Wseq t e -> Bool -- | Remove overlaps by deleting any overlapping nodes. -- --
--   let sq = [((0,1),'a'),((0,5),'a'),((1,5),'a'),((3,1),'a')]
--   wseq_has_overlaps (==) sq == True
--   let sq_rw = wseq_remove_overlaps_rm (==) sq
--   sq_rw == [((0,1),'a'),((1,5),'a')]
--   wseq_has_overlaps (==) sq_rw
--   
wseq_remove_overlaps_rm :: (Ord t, Num t) => (e -> e -> Bool) -> Wseq t e -> Wseq t e -- | Find first instance of overlap of e at sq and re-write -- durations so nodes don't overlap. If equal nodes begin simultaneously -- delete the shorter node (eithe LHS or RHS). If a node extends into a -- later node shorten the initial (LHS) duration (apply dur_fn to -- iot). wseq_remove_overlap_rw_1 :: (Ord t, Num t) => (e -> e -> Bool) -> (t -> t) -> ((t, t), e) -> Wseq t e -> Maybe (Wseq t e) -- | Run wseq_remove_overlap_rw_1 until sequence has no overlaps. -- --
--   let sq = [((0,1),'a'),((0,5),'a'),((1,5),'a'),((3,1),'a')]
--   wseq_has_overlaps (==) sq == True
--   let sq_rw = wseq_remove_overlaps_rw (==) id sq
--   sq_rw == [((0,1),'a'),((1,2),'a'),((3,1),'a')]
--   wseq_has_overlaps (==) sq_rw == False
--   
-- --
--   import qualified Music.Theory.Array.Csv.Midi.Mnd as T 
--   let csv_fn = "/home/rohan/uc/the-center-is-between-us/visitants/csv/midi/air.B.1.csv"
--   sq <- T.csv_midi_read_wseq csv_fn :: IO (Wseq Double (T.Event Double))
--   length sq == 186
--   length (wseq_remove_overlaps_rw (==) id sq) == 183
--   
wseq_remove_overlaps_rw :: (Ord t, Num t) => (e -> e -> Bool) -> (t -> t) -> Wseq t e -> Wseq t e -- | Unjoin elements (assign equal time stamps to all elements). seq_unjoin :: [(t, [e])] -> [(t, e)] -- | Type specialised seq_unjoin. wseq_unjoin :: Wseq t [e] -> Wseq t e -- | Shift (displace) onset times by i. -- --
--   wseq_shift 3 [((1,2),'a')] == [((4,2),'a')]
--   
wseq_shift :: Num t => t -> Wseq t a -> Wseq t a -- | Shift q to end of p and append. -- --
--   wseq_append [((1,2),'a')] [((1,2),'b')] == [((1,2),'a'),((4,2),'b')]
--   
wseq_append :: Num t => Wseq t a -> Wseq t a -> Wseq t a -- | foldl1 of wseq_append -- --
--   wseq_concat [[((1,2),'a')],[((1,2),'b')]] == [((1,2),'a'),((4,2),'b')]
--   
wseq_concat :: Num t => [Wseq t a] -> Wseq t a -- | Transform sequence to start at time zero. wseq_zero :: Num t => Wseq t a -> Wseq t a -- | Container to mark the begin and end of a value. data Begin_End a Begin :: a -> Begin_End a End :: a -> Begin_End a -- | Functor instance. begin_end_map :: (t -> u) -> Begin_End t -> Begin_End u -- | Structural comparison at Begin_End, Begin compares less -- than End. cmp_begin_end :: Begin_End a -> Begin_End b -> Ordering -- | Translate container types. either_to_begin_end :: Either a a -> Begin_End a -- | Translate container types. begin_end_to_either :: Begin_End a -> Either a a -- | Equivalent to partitionEithers. begin_end_partition :: [Begin_End a] -> ([a], [a]) -- | Add or delete element from accumulated state given equality function. begin_end_track_by :: (a -> a -> Bool) -> [a] -> Begin_End a -> [a] -- | begin_end_track_by of ==. begin_end_track :: Eq a => [a] -> Begin_End a -> [a] -- | Convert Wseq to Tseq transforming elements to -- Begin_End. When merging, end elements precede -- begin elements at equal times. -- --
--   let sq = [((0,5),'a'),((2,2),'b')]
--   let r = [(0,Begin 'a'),(2,Begin 'b'),(4,End 'b'),(5,End 'a')]
--   wseq_begin_end sq == r
--   
-- --
--   let sq = [((0,1),'a'),((1,1),'b'),((2,1),'c')]
--   let r = [(0,Begin 'a'),(1,End 'a'),(1,Begin 'b'),(2,End 'b'),(2,Begin 'c'),(3,End 'c')]
--   wseq_begin_end sq == r
--   
wseq_begin_end :: (Num t, Ord t) => Wseq t a -> Tseq t (Begin_End a) -- | begin_end_to_either of wseq_begin_end. wseq_begin_end_either :: (Num t, Ord t) => Wseq t a -> Tseq t (Either a a) -- | Variant that applies begin and end functions to nodes. -- --
--   let sq = [((0,5),'a'),((2,2),'b')]
--   let r = [(0,'A'),(2,'B'),(4,'b'),(5,'a')]
--   wseq_begin_end_f Data.Char.toUpper id sq == r
--   
wseq_begin_end_f :: (Ord t, Num t) => (a -> b) -> (a -> b) -> Wseq t a -> Tseq t b -- | Generate for each time-point the triple -- (begin-list,end-list,hold-list). The elements of the end-list have -- been deleted from the hold list. tseq_begin_end_accum :: Eq a => Tseq t [Begin_End a] -> Tseq t ([a], [a], [a]) -- | Variant that initially transforms Wseq into non-overlapping -- begin-end sequence. If the sequence was edited for overlaps this is -- indicated. wseq_begin_end_accum :: (Eq e, Ord t, Num t) => Wseq t e -> (Bool, Tseq t ([e], [e], [e])) tseq_accumulate :: Eq a => Tseq t [Begin_End a] -> Tseq t [a] -- | The transition sequence of active elements. -- --
--   let w = [((0,3),'a'),((1,2),'b'),((2,1),'c'),((3,3),'d')]
--   wseq_accumulate w == [(0,"a"),(1,"ba"),(2,"cba"),(3,"d"),(6,"")]
--   
wseq_accumulate :: (Eq a, Ord t, Num t) => Wseq t a -> Tseq t [a] -- | Inverse of wseq_begin_end given a predicate function for -- locating the end node of a begin node. -- --
--   let sq = [(0,Begin 'a'),(2,Begin 'b'),(4,End 'b'),(5,End 'a')]
--   let r = [((0,5),'a'),((2,2),'b')]
--   tseq_begin_end_to_wseq (==) sq == r
--   
tseq_begin_end_to_wseq :: Num t => (a -> a -> Bool) -> Tseq t (Begin_End a) -> Wseq t a useq_to_dseq :: Useq t a -> Dseq t a useq_to_wseq :: Num t => t -> Useq t a -> Wseq t a -- | The conversion requires a start time and a nil value used as an -- eof marker. Productive given indefinite input sequence. -- --
--   let r = zip [0,1,3,6,8,9] "abcde|"
--   dseq_to_tseq 0 '|' (zip [1,2,3,2,1] "abcde") == r
--   
-- --
--   let d = zip [1,2,3,2,1] "abcde"
--   let r = zip [0,1,3,6,8,9,10] "abcdeab"
--   take 7 (dseq_to_tseq 0 undefined (cycle d)) == r
--   
dseq_to_tseq :: Num t => t -> a -> Dseq t a -> Tseq t a -- | Variant where the nil value is taken from the last element of -- the sequence. -- --
--   let r = zip [0,1,3,6,8,9] "abcdee"
--   dseq_to_tseq_last 0 (zip [1,2,3,2,1] "abcde") == r
--   
dseq_to_tseq_last :: Num t => t -> Dseq t a -> Tseq t a -- | Variant where the final duration is discarded. -- --
--   dseq_to_tseq_discard 0 (zip [1,2,3,2,1] "abcde") == zip [0,1,3,6,8] "abcde"
--   
dseq_to_tseq_discard :: Num t => t -> Dseq t a -> Tseq t a -- | Iseq to Tseq, requires t0. -- --
--   let r = zip [1,3,6,8,9] "abcde"
--   iseq_to_tseq 0 (zip [1,2,3,2,1] "abcde") == r
--   
iseq_to_tseq :: Num t => t -> Iseq t a -> Tseq t a -- | The conversion requires a start time and does not consult the -- logical duration. -- --
--   let p = pseq_zip (repeat undefined) (cycle [1,2]) (cycle [1,1,2]) "abcdef"
--   pseq_to_wseq 0 p == wseq_zip [0,1,2,4,5,6] (cycle [1,2]) "abcdef"
--   
pseq_to_wseq :: Num t => t -> Pseq t a -> Wseq t a -- | The last element of Tseq is required to be an eof marker -- that has no duration and is not represented in the Dseq. A -- nil value is required in case the Tseq does not begin -- at 0. -- --
--   let r = zip [1,2,3,2,1] "abcde"
--   tseq_to_dseq undefined (zip [0,1,3,6,8,9] "abcde|") == r
--   
-- --
--   let r = zip [1,2,3,2,1] "-abcd"
--   tseq_to_dseq '-' (zip [1,3,6,8,9] "abcd|") == r
--   
tseq_to_dseq :: (Ord t, Num t) => a -> Tseq t a -> Dseq t a -- | Variant that requires a final duration be provided, and that the Tseq -- have no end marker. -- --
--   let r = zip [1,2,3,2,9] "abcde"
--   tseq_to_dseq_final_dur undefined 9 (zip [0,1,3,6,8] "abcde") == r
--   
tseq_to_dseq_final_dur :: (Ord t, Num t) => a -> t -> Tseq t a -> Dseq t a -- | Variant that requires a total duration be provided, and that the Tseq -- have no end marker. -- --
--   let r = zip [1,2,3,2,7] "abcde"
--   tseq_to_dseq_total_dur undefined 15 (zip [0,1,3,6,8] "abcde")
--   
tseq_to_dseq_total_dur :: (Ord t, Num t) => a -> t -> Tseq t a -> Dseq t a -- | The last element of Tseq is required to be an eof marker -- that has no duration and is not represented in the Wseq. The -- duration of each value is either derived from the value, if a -- dur function is given, or else the inter-offset time. -- --
--   let r = wseq_zip [0,1,3,6,8] [1,2,3,2,1] "abcde"
--   tseq_to_wseq Nothing (zip [0,1,3,6,8,9] "abcde|") == r
--   
-- --
--   let r = wseq_zip [0,1,3,6,8] (map fromEnum "abcde") "abcde"
--   tseq_to_wseq (Just fromEnum) (zip [0,1,3,6,8,9] "abcde|") == r
--   
tseq_to_wseq :: Num t => Maybe (a -> t) -> Tseq t a -> Wseq t a -- | Translate Tseq to Wseq using inter-offset times, up to indicated total -- duration, as element durations. -- --
--   let r = [((0,1),'a'),((1,2),'b'),((3,3),'c'),((6,2),'d'),((8,3),'e')]
--   tseq_to_wseq_iot 11 (zip [0,1,3,6,8] "abcde") == r
--   
tseq_to_wseq_iot :: Num t => t -> Tseq t a -> Wseq t a -- | Tseq to Iseq. -- --
--   tseq_to_iseq (zip [0,1,3,6,8,9] "abcde|") == zip [0,1,2,3,2,1] "abcde|"
--   
tseq_to_iseq :: Num t => Tseq t a -> Iseq t a -- | Requires start time. -- --
--   let r = zip (zip [0,1,3,6,8,9] [1,2,3,2,1]) "abcde"
--   dseq_to_wseq 0 (zip [1,2,3,2,1] "abcde") == r
--   
dseq_to_wseq :: Num t => t -> Dseq t a -> Wseq t a -- | Inverse of dseq_to_wseq. The empty value is used to fill -- holes in Wseq. If values overlap at Wseq durations are -- truncated. -- --
--   let w = wseq_zip [0,1,3,6,8,9] [1,2,3,2,1] "abcde"
--   wseq_to_dseq '-' w == zip [1,2,3,2,1] "abcde"
--   
-- --
--   let w = wseq_zip [3,10] [6,2] "ab"
--   wseq_to_dseq '-' w == zip [3,6,1,2] "-a-b"
--   
-- --
--   let w = wseq_zip [0,1] [2,2] "ab"
--   wseq_to_dseq '-' w == zip [1,2] "ab"
--   
-- --
--   let w = wseq_zip [0,0,0] [2,2,2] "abc"
--   wseq_to_dseq '-' w == zip [0,0,2] "abc"
--   
wseq_to_dseq :: (Num t, Ord t) => a -> Wseq t a -> Dseq t a eseq_to_wseq :: Eseq t a -> Wseq t a -- | Given a list of Dseq (measures) convert to a list of -- Tseq and the end time of the overall sequence. -- --
--   let r = [[(0,'a'),(1,'b'),(3,'c')],[(4,'d'),(7,'e'),(9,'f')]]
--   dseql_to_tseql 0 [zip [1,2,1] "abc",zip [3,2,1] "def"] == (10,r)
--   
dseql_to_tseql :: Num t => t -> [Dseq t a] -> (t, [Tseq t a]) -- | List of cycles of Wseq. wseq_cycle_ls :: Num t => Wseq t a -> [Wseq t a] -- | Only finite Wseq can be cycled, the resulting Wseq is infinite. -- --
--   take 5 (wseq_cycle [((0,1),'a'),((3,3),'b')])
--   
wseq_cycle :: Num t => Wseq t a -> Wseq t a -- | Variant cycling only n times. -- --
--   wseq_cycle_n 3 [((0,1),'a'),((3,3),'b')]
--   
wseq_cycle_n :: Num t => Int -> Wseq t a -> Wseq t a -- | wseq_until of wseq_cycle. wseq_cycle_until :: (Num t, Ord t) => t -> Wseq t a -> Wseq t a dseq_tmap :: (t -> t') -> Dseq t a -> Dseq t' a pseq_tmap :: ((t, t, t) -> (t', t', t')) -> Pseq t a -> Pseq t' a tseq_tmap :: (t -> t') -> Dseq t a -> Dseq t' a tseq_bimap :: (t -> t') -> (e -> e') -> Tseq t e -> Tseq t' e' wseq_tmap :: ((t, t) -> (t', t')) -> Wseq t a -> Wseq t' a dseq_map :: (a -> b) -> Dseq t a -> Dseq t b pseq_map :: (a -> b) -> Pseq t a -> Pseq t b tseq_map :: (a -> b) -> Tseq t a -> Tseq t b wseq_map :: (a -> b) -> Wseq t a -> Wseq t b dseq_tfilter :: (t -> Bool) -> Dseq t a -> Dseq t a iseq_tfilter :: (t -> Bool) -> Iseq t a -> Iseq t a pseq_tfilter :: ((t, t, t) -> Bool) -> Pseq t a -> Pseq t a tseq_tfilter :: (t -> Bool) -> Tseq t a -> Tseq t a wseq_tfilter :: ((t, t) -> Bool) -> Wseq t a -> Wseq t a dseq_filter :: (a -> Bool) -> Dseq t a -> Dseq t a iseq_filter :: (a -> Bool) -> Iseq t a -> Iseq t a pseq_filter :: (a -> Bool) -> Pseq t a -> Pseq t a tseq_filter :: (a -> Bool) -> Tseq t a -> Tseq t a wseq_filter :: (a -> Bool) -> Wseq t a -> Wseq t a wseq_map_maybe :: (a -> Maybe b) -> Wseq t a -> Wseq t b wseq_cat_maybes :: Wseq t (Maybe a) -> Wseq t a -- | Requires but does not check that there are no duplicate time points in -- Tseq. -- --
--   tseq_to_map [(0, 'a'), (0, 'b')] == tseq_to_map [(0, 'b')]
--   
tseq_to_map :: Ord t => Tseq t e -> Map t e instance GHC.Show.Show Music.Theory.Time.Seq.Interpolation_T instance GHC.Enum.Enum Music.Theory.Time.Seq.Interpolation_T instance GHC.Classes.Eq Music.Theory.Time.Seq.Interpolation_T instance GHC.Show.Show a => GHC.Show.Show (Music.Theory.Time.Seq.Begin_End a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Music.Theory.Time.Seq.Begin_End a) instance GHC.Base.Functor Music.Theory.Time.Seq.Begin_End -- | A sequence structure, courtesy -- https://github.com/nosuchtim/keykit. -- -- A note has a time, a duration and a value. A phrase is a -- time-ascending sequence of notes and a length. The length of a -- phrase is independent of the contents. The sequence operator, -- phrase_append, sums phrase lengths. The parallel operator, -- phrase_merge, selects the longer length. -- -- Operations are ordinarily on phrases, notes are operated on -- indirectly. The phrase indexing operation, phrase_at returns a -- phrase of degree one. module Music.Theory.Time.KeyKit type Time = Rational type Duration = Time type Length = Time data Note t Note :: Time -> Duration -> t -> Note t [note_start_time] :: Note t -> Time [note_duration] :: Note t -> Duration [note_value] :: Note t -> t note_end_time :: Note t -> Time note_region :: Note t -> (Time, Time) note_shift_time :: Time -> Note t -> Note t note_scale_duration :: Time -> Note t -> Note t note_scale_duration_and_time :: Time -> Note t -> Note t note_is_start_in_region :: (Time, Time) -> Note t -> Bool note_is_entirely_in_region :: (Time, Time) -> Note t -> Bool -- | It is an un-checked invariant that the note list is in ascending -- order. data Phrase t Phrase :: [Note t] -> Length -> Phrase t [phrase_notes] :: Phrase t -> [Note t] [phrase_length] :: Phrase t -> Length phrase_values :: Phrase t -> [t] phrase_set_length :: Phrase t -> Length -> Phrase t phrase_degree :: Phrase t -> Int phrase_start_time :: Phrase t -> Time phrase_end_time :: Phrase t -> Time phrase_duration :: Phrase t -> Duration phrase_maximum :: Ord t => Phrase t -> Note t phrase_minimum :: Ord t => Phrase t -> Note t -- | Keykit sets the length to the duration, i.e. ('c,e,g'%2).length is -- 192. phrase_at :: Phrase t -> Int -> Phrase t phrase_time_at :: Phrase t -> Int -> Time phrase_clear_at :: Phrase t -> Int -> Phrase t phrase_at_put :: Ord t => Phrase t -> Int -> Phrase t -> Phrase t phrase_is_empty :: Phrase t -> Bool -- | KeyKits p+q phrase_append :: Ord t => Phrase t -> Phrase t -> Phrase t phrase_append_list :: Ord t => [Phrase t] -> Phrase t -- | KeyKits p|q phrase_merge :: Ord t => Phrase t -> Phrase t -> Phrase t phrase_merge_list :: Ord t => [Phrase t] -> Phrase t phrase_select :: Phrase t -> (Note t -> Bool) -> Phrase t phrase_partition :: Phrase t -> (Note t -> Bool) -> (Phrase t, Phrase t) phrase_select_region :: Phrase t -> (Time, Time) -> Phrase t phrase_clear_region :: Phrase t -> (Time, Time) -> Phrase t phrase_select_indices :: Phrase t -> (Int, Int) -> Phrase t phrase_clear_indices :: Phrase t -> (Int, Int) -> Phrase t phrase_extract_region :: Phrase t -> (Time, Time) -> Phrase t phrase_delete_region :: Ord t => Phrase t -> (Time, Time) -> Phrase t phrase_separate :: Phrase t -> Time -> (Phrase t, Phrase t) phrase_reverse :: Phrase t -> Phrase t phrase_reorder :: Phrase t -> [Int] -> Phrase t phrase_truncate :: Phrase t -> Phrase t phrase_trim :: Phrase t -> Phrase t note_map :: (t -> u) -> Note t -> Note u phrase_value_map :: (t -> u) -> Phrase t -> Phrase u phrase_note_map :: (Note t -> Note u) -> Phrase t -> Phrase u phrase_phrase_map :: Ord u => (Phrase t -> Phrase u) -> Phrase t -> Phrase u phrase_map :: Ord u => (Note t -> Phrase u) -> Phrase t -> Phrase u phrase_shift :: Phrase t -> Time -> Phrase t phrase_scale_duration :: Phrase t -> Time -> Phrase t phrase_scale_duration_and_time :: Phrase t -> Time -> Phrase t phrase_scale_to_duration :: Phrase t -> Duration -> Phrase t phrase_scale_to_region :: Phrase t -> (Time, Duration) -> Phrase t phrase_to_wseq :: Phrase t -> Wseq Time t useq_to_phrase :: Useq Time t -> Phrase t dseq_to_phrase :: Dseq Time t -> Phrase t wseq_to_phrase :: Wseq Time t -> Phrase t instance GHC.Show.Show t => GHC.Show.Show (Music.Theory.Time.KeyKit.Note t) instance GHC.Classes.Ord t => GHC.Classes.Ord (Music.Theory.Time.KeyKit.Note t) instance GHC.Classes.Eq t => GHC.Classes.Eq (Music.Theory.Time.KeyKit.Note t) instance GHC.Show.Show t => GHC.Show.Show (Music.Theory.Time.KeyKit.Phrase t) instance GHC.Classes.Ord t => GHC.Classes.Ord (Music.Theory.Time.KeyKit.Phrase t) instance GHC.Classes.Eq t => GHC.Classes.Eq (Music.Theory.Time.KeyKit.Phrase t) -- | Translations of some functions from -- https://github.com/nosuchtim/keykit/blob/master/lib/basic1.k module Music.Theory.Time.KeyKit.Basic -- | Returns an arpeggiated version of the phrase. One way of describing -- desc it is that all the notes have been separated and then put back -- together, back-to-back. -- --
--   phrase_arpeggio (wseq_to_phrase (zip (repeat (0,1)) [60, 64, 67]))
--   
phrase_arpeggio :: Phrase t -> Phrase t -- | Return phrase ph echoed num times, with rtime delay between each echo. phrase_echo :: Ord t => Phrase t -> Int -> Time -> Phrase t -- | Convert a phrase to be in step time, ie. all notes with the same -- spacing and duration. Overlapped notes (no matter how small the -- overlap) are played at the same time. -- --
--   phrase_step (wseq_to_phrase [((0, 1), 60), ((5, 2), 64), ((23, 3), 67)]) 1
--   
phrase_step :: Phrase t -> Duration -> Phrase t -- | This function takes a phrase, splits in in 2 halves (along time) and -- shuffles the result (ie. first a note from the first half, then a note -- from the second half, etc.). The timing of the original phrase is -- applied to the result. -- --
--   phrase_to_wseq (phrase_shuffle (useq_to_phrase (1,[1..9])))
--   
phrase_shuffle :: Phrase t -> Phrase t -- | Functions for reading midi note data (Mnd) from Csv files. -- -- This is not a generic text midi notation. The required columns -- are documented at Mnd and Mndd. The defined commands are -- on and off, but others may be present. Non-integral -- note number and key velocity data are allowed. module Music.Theory.Array.Csv.Midi.Mnd type Param = [(String, Double)] param_parse :: (Char, Char) -> String -> Param param_pp :: (Char, Char) -> Int -> Param -> String -- | If r is whole to k places then show as integer, else as -- float to k places. data_value_pp :: Real t => Int -> t -> String -- | Channel values are 4-bit (0-15). type Channel = Int -- | The required header (column names) field. csv_mnd_hdr :: [String] -- | Midi note data, the type parameters are to allow for fractional note -- & velocity values. -- -- The command is a string, on and off are standard, -- other commands may be present. note and velocity data is (0-127), -- channel is (0-15), param are ;-separated key:string=value:float. -- --
--   unwords csv_mnd_hdr == "time on/off note velocity channel param"
--   
-- --
--   all_notes_off = zipWith (\t k -> (t,"off",k,0,0,[])) [0.0,0.01 ..] [0 .. 127]
--   csv_mnd_write 4 "/home/rohan/sw/hmt/data/csv/mnd/all-notes-off.csv" all_notes_off
--   
type Mnd t n = (t, String, n, n, Channel, Param) csv_mnd_parse_f :: (Read t, Real t, Read n, Real n) => (n -> m) -> Csv_Table String -> [Mnd t m] csv_mnd_parse :: (Read t, Real t, Read n, Real n) => Csv_Table String -> [Mnd t n] load_csv :: FilePath -> IO (Csv_Table String) -- | Midi note data. -- --
--   let fn = "/home/rohan/cvs/uc/uc-26/daily-practice/2014-08-13.1.csv"
--   let fn = "/home/rohan/sw/hmt/data/csv/mnd/1080-C01.csv"
--   m <- csv_mnd_read fn :: IO [Mnd Double Int]
--   length m -- 1800 17655
--   csv_mnd_write 4 "/tmp/t.csv" m
--   
csv_mnd_read :: (Read t, Real t, Read n, Real n) => FilePath -> IO [Mnd t n] -- | Writer. csv_mnd_write :: (Real t, Real n) => Int -> FilePath -> [Mnd t n] -> IO () -- | (p0=midi-note,p1=velocity,channel,param) type Event n = (n, n, Channel, Param) -- | mnn = midi-note-number event_mnn :: Event t -> t -- | ch = channel event_ch :: Event t -> Channel -- | Are events equal at mnn field? event_eq_mnn :: Eq t => Event t -> Event t -> Bool -- | Are events equal at mnn and ch fields? event_eq_ol :: Eq t => Event t -> Event t -> Bool -- | Apply (mnn-f,vel-f,ch-f,param-f) to Event. event_map :: (t -> u, t -> u, Channel -> Channel, Param -> Param) -> Event t -> Event u -- | Apply f at mnn and vel fields. event_cast :: (t -> u) -> Event t -> Event u -- | Add x to mnn field. event_transpose :: Num a => a -> Event a -> Event a -- | Translate from Tseq form to Wseq form. midi_tseq_to_midi_wseq :: (Num t, Eq n) => Tseq t (Begin_End (Event n)) -> Wseq t (Event n) midi_wseq_to_midi_tseq :: (Num t, Ord t) => Wseq t x -> Tseq t (Begin_End x) -- | Ignores non on/off messages. mnd_to_tseq :: Num n => [Mnd t n] -> Tseq t (Begin_End (Event n)) -- | Tseq form of csv_mnd_read, channel information is -- retained, off-velocity is zero. csv_mnd_read_tseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Tseq t (Begin_End (Event n))) -- | Tseq form of csv_mnd_write, data is . csv_mnd_write_tseq :: (Real t, Real n) => Int -> FilePath -> Tseq t (Begin_End (Event n)) -> IO () -- | Message should be note for note data. csv_mndd_hdr :: [String] -- | Midi note/duration data. The type parameters are to allow for -- fractional note & velocity values. The command is a string, -- note is standard, other commands may be present. -- --
--   unwords csv_mndd_hdr == "time duration message note velocity channel param"
--   
type Mndd t n = (t, t, String, n, n, Channel, Param) -- | Compare sequence is: -- start-time,channel-number,note-number,velocity,duration,param. mndd_compare :: (Ord t, Ord n) => Mndd t n -> Mndd t n -> Ordering csv_mndd_parse_f :: (Read t, Real t, Read n, Real n) => (n -> m) -> Csv_Table String -> [Mndd t m] -- | Pars midi note/duration data from Csv table. csv_mndd_parse :: (Read t, Real t, Read n, Real n) => Csv_Table String -> [Mndd t n] -- | csv_mndd_parse of load_csv csv_mndd_read :: (Read t, Real t, Read n, Real n) => FilePath -> IO [Mndd t n] -- | Writer. csv_mndd_write :: (Real t, Real n) => Int -> FilePath -> [Mndd t n] -> IO () -- | Ignores non note messages. mndd_to_wseq :: [Mndd t n] -> Wseq t (Event n) -- | Wseq form of csv_mndd_read. csv_mndd_read_wseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Wseq t (Event n)) -- | Wseq form of csv_mndd_write. csv_mndd_write_wseq :: (Real t, Real n) => Int -> FilePath -> Wseq t (Event n) -> IO () -- | Parse either Mnd or Mndd data to Wseq, Csv type is decided by header. csv_midi_parse_wseq_f :: (Read t, Real t, Read n, Real n, Num m, Eq m) => (n -> m) -> Csv_Table String -> Wseq t (Event m) csv_midi_parse_wseq :: (Read t, Real t, Read n, Real n) => Csv_Table String -> Wseq t (Event n) csv_midi_read_wseq :: (Read t, Real t, Read n, Real n) => FilePath -> IO (Wseq t (Event n)) -- | Functions (partial) for reading & writing Skini data files. -- -- https://ccrma.stanford.edu/software/stk/skini.html module Music.Theory.Array.Csv.Midi.Skini -- | Skini allows delta or absolute time-stamps. data Time t Delta :: t -> Time t Absolute :: t -> Time t -- | Skini data type of (message,time-stamp,channel,data-one,data-two) type Skini t n = (String, Time t, Channel, n, n) mnd_msg_to_skini_msg :: String -> String mnd_to_skini_f :: (t -> Time t) -> Mnd t n -> Skini t n mnd_to_skini_abs :: Mnd t n -> Skini t n midi_tseq_to_skini_seq :: (Num t, Eq n) => Tseq t (Begin_End (Event n)) -> [Skini t n] time_pp :: Real t => Int -> Time t -> String skini_pp_csv :: (Real t, Real n) => Int -> Skini t n -> String skini_write_csv :: (Real t, Real n) => Int -> FilePath -> [Skini t n] -> IO () module Music.Theory.Array.Csv.Midi.Cli usage :: [String] read_wseq_i :: FilePath -> IO (Wseq Double (Event Int)) read_wseq_r :: FilePath -> IO (Wseq Double (Event Double)) mnd_to_mndd_i :: Int -> FilePath -> FilePath -> IO () mndd_transpose_r :: Int -> Double -> FilePath -> FilePath -> IO () csv_midi_concat_r :: FilePath -> [FilePath] -> IO () csv_midi_cli :: [String] -> IO () -- | Time Signatures. module Music.Theory.Time_Signature -- | A Time Signature is a (numerator,denominator) pair. type Time_Signature = (Integer, Integer) -- | Tied, non-multiplied durations to fill a whole measure. -- --
--   ts_whole_note (3,8) == [dotted_quarter_note]
--   ts_whole_note (2,2) == [whole_note]
--   
ts_whole_note :: Time_Signature -> [Duration] -- | Duration of measure in Rq. -- --
--   map ts_whole_note_rq [(3,8),(2,2)] == [3/2,4]
--   
ts_whole_note_rq :: Time_Signature -> Rq -- | Duration, in Rq, of a measure of indicated -- Time_Signature. -- --
--   map ts_rq [(3,4),(5,8)] == [3,5/2]
--   
ts_rq :: Time_Signature -> Rq -- | compare on ts_rq. ts_compare :: Time_Signature -> Time_Signature -> Ordering -- | Time_Signature derived from whole note duration in Rq -- form. -- --
--   map rq_to_ts [4,3/2,7/4,6] == [(4,4),(3,8),(7,16),(6,4)]
--   
rq_to_ts :: Rq -> Time_Signature -- | Uniform division of time signature. -- --
--   ts_divisions (3,4) == [1,1,1]
--   ts_divisions (3,8) == [1/2,1/2,1/2]
--   ts_divisions (2,2) == [2,2]
--   ts_divisions (1,1) == [4]
--   ts_divisions (7,4) == [1,1,1,1,1,1,1]
--   
ts_divisions :: Time_Signature -> [Rq] -- | Convert a duration to a pulse count in relation to the indicated time -- signature. -- --
--   ts_duration_pulses (3,8) quarter_note == 2
--   
ts_duration_pulses :: Time_Signature -> Duration -> Rational -- | Rewrite time signature to indicated denominator. -- --
--   ts_rewrite 8 (3,4) == (6,8)
--   
ts_rewrite :: Integer -> Time_Signature -> Time_Signature -- | Sum time signatures. -- --
--   ts_sum [(3,16),(1,2)] == (11,16)
--   
ts_sum :: [Time_Signature] -> Time_Signature -- | A composite time signature is a sequence of Time_Signatures. type Composite_Time_Signature = [Time_Signature] -- | The Rq is the sum of ts_rq of the elements. -- --
--   cts_rq [(3,4),(1,8)] == 3 + 1/2
--   
cts_rq :: Composite_Time_Signature -> Rq -- | The divisions are the concat of the ts_divisions of the -- elements. -- --
--   cts_divisions [(3,4),(1,8)] == [1,1,1,1/2]
--   
cts_divisions :: Composite_Time_Signature -> [Rq] -- | Pulses are 1-indexed, Rq locations are 0-indexed. -- --
--   map (cts_pulse_to_rq [(2,4),(1,8),(1,4)]) [1 .. 4] == [0,1,2,2 + 1/2]
--   
cts_pulse_to_rq :: Composite_Time_Signature -> Int -> Rq -- | Variant that gives the window of the pulse (ie. the start -- location and the duration). -- --
--   let r = [(0,1),(1,1),(2,1/2),(2 + 1/2,1)]
--   in map (cts_pulse_to_rqw [(2,4),(1,8),(1,4)]) [1 .. 4] == r
--   
cts_pulse_to_rqw :: Composite_Time_Signature -> Int -> (Rq, Rq) -- | A rational time signature is a Composite_Time_Signature where -- the parts are Rational. type Rational_Time_Signature = [(Rational, Rational)] -- | The sum of the Rq of the elements. -- --
--   rts_rq [(3,4),(1,8)] == 3 + 1/2
--   rts_rq [(3/2,4),(1/2,8)] == 3/2 + 1/4
--   
rts_rq :: Rational_Time_Signature -> Rq -- | The divisions of the elements. -- --
--   rts_divisions [(3,4),(1,8)] == [1,1,1,1/2]
--   rts_divisions [(3/2,4),(1/2,8)] == [1,1/2,1/4]
--   
rts_divisions :: Rational_Time_Signature -> [[Rq]] rts_derive :: [Rq] -> Rational_Time_Signature -- | Pulses are 1-indexed, Rq locations are 0-indexed. -- --
--   map (rts_pulse_to_rq [(2,4),(1,8),(1,4)]) [1 .. 4] == [0,1,2,2 + 1/2]
--   map (rts_pulse_to_rq [(3/2,4),(1/2,8),(1/4,4)]) [1 .. 4] == [0,1,3/2,7/4]
--   
rts_pulse_to_rq :: Rational_Time_Signature -> Int -> Rq -- | Variant that gives the window of the pulse (ie. the start -- location and the duration). -- --
--   let r = [(0,1),(1,1),(2,1/2),(2 + 1/2,1)]
--   in map (rts_pulse_to_rqw [(2,4),(1,8),(1,4)]) [1 .. 4] == r
--   
rts_pulse_to_rqw :: Rational_Time_Signature -> Int -> (Rq, Rq) -- | Common music notation tempo indications. module Music.Theory.Tempo_Marking -- | A tempo marking is in terms of a common music notation -- Duration. type Tempo_Marking = (Duration, Rational) -- | Duration of a Rq value, in seconds, given indicated tempo. -- --
--   rq_to_seconds (quarter_note,90) 1 == 60/90
--   
rq_to_seconds :: Tempo_Marking -> Rq -> Rational -- | The duration, in seconds, of a pulse at the indicated time signature -- and tempo marking. -- --
--   import Music.Theory.Duration.Name
--   pulse_duration (6,8) (quarter_note,60) == 1/2
--   
pulse_duration :: Time_Signature -> Tempo_Marking -> Rational -- | The duration, in seconds, of a measure at the indicated time signaure -- and tempo marking. -- --
--   measure_duration (3,4) (quarter_note,90) == 2
--   measure_duration (6,8) (quarter_note,120) == 3/2
--   
measure_duration :: Time_Signature -> Tempo_Marking -> Rational -- | Fractional variant of measure_duration. measure_duration_f :: Fractional c => Time_Signature -> Tempo_Marking -> c -- | Italian terms and markings from Wittner metronome (W.-Germany). -- http://wittner-gmbh.de/ metronome_table_wittner :: Num n => [(String, (n, n))] -- | Italian terms and markings from Nikko Seiki metronome (Japan). -- http://nikkoseiki.com/ metronome_table_nikko :: Num n => [(String, (n, n))] -- | Lookup metronome mark in table. -- --
--   mm_name metronome_table_nikko 72 == Just "Andante"
--   
mm_name :: Ord a => [(String, (a, a))] -> a -> Maybe String -- | Notation of a sequence of Rq values as annotated -- Duration values. -- --
    --
  1. Separate input sequence into measures, adding tie annotations as -- required (see to_measures_ts). Ensure all Rq_Tied values -- can be notated as common music notation durations.
  2. --
  3. Separate each measure into pulses (see m_divisions_ts). -- Further subdivides pulses to ensure cmn tuplet notation. See -- to_divisions_ts for a composition of to_measures_ts and -- m_divisions_ts.
  4. --
  5. Simplify each measure (see m_simplify and -- default_rule). Coalesces tied durations where appropriate.
  6. --
  7. Notate measures (see m_notate or mm_notate).
  8. --
  9. Ascribe values to notated durations, see ascribe.
  10. --
module Music.Theory.Duration.Sequence.Notate -- | Applies a join function to the first two elements of the list. -- If the join function succeeds the joined element is considered -- for further coalescing. -- --
--   coalesce (\p q -> Just (p + q)) [1..5] == [15]
--   
-- --
--   let jn p q = if even p then Just (p + q) else Nothing
--   coalesce jn [1..5] == map sum [[1],[2,3],[4,5]]
--   
coalesce :: (a -> a -> Maybe a) -> [a] -> [a] -- | Variant of coalesce with accumulation parameter. -- --
--   coalesce_accum (\_ p q -> Left (p + q)) 0 [1..5] == [(0,15)]
--   
-- --
--   let jn i p q = if even p then Left (p + q) else Right (p + i)
--   coalesce_accum jn 0 [1..7] == [(0,1),(1,5),(6,9),(15,13)]
--   
-- --
--   let jn i p q = if even p then Left (p + q) else Right [p,q]
--   coalesce_accum jn [] [1..5] == [([],1),([1,2],5),([5,4],9)]
--   
coalesce_accum :: (b -> a -> a -> Either a b) -> b -> [a] -> [(b, a)] -- | Variant of coalesce_accum that accumulates running sum. -- --
--   let f i p q = if i == 1 then Just (p + q) else Nothing
--   coalesce_sum (+) 0 f [1,1/2,1/4,1/4] == [1,1]
--   
coalesce_sum :: (b -> a -> b) -> b -> (b -> a -> a -> Maybe a) -> [a] -> [a] -- | Take elements while the sum of the prefix is less than or equal to the -- indicated value. Returns also the difference between the prefix sum -- and the requested sum. Note that zero elements are kept left. -- --
--   take_sum_by id 3 [2,1] == ([2,1],0,[])
--   take_sum_by id 3 [2,2] == ([2],1,[2])
--   take_sum_by id 3 [2,1,0,1] == ([2,1,0],0,[1])
--   take_sum_by id 3 [4] == ([],3,[4])
--   take_sum_by id 0 [1..5] == ([],0,[1..5])
--   
take_sum_by :: (Ord n, Num n) => (a -> n) -> n -> [a] -> ([a], n, [a]) -- | Variant of take_sum_by with id function. take_sum :: (Ord a, Num a) => a -> [a] -> ([a], a, [a]) -- | Variant of take_sum that requires the prefix to sum to value. -- --
--   take_sum_by_eq id 3 [2,1,0,1] == Just ([2,1,0],[1])
--   take_sum_by_eq id 3 [2,2] == Nothing
--   
take_sum_by_eq :: (Ord n, Num n) => (a -> n) -> n -> [a] -> Maybe ([a], [a]) -- | Recursive variant of take_sum_by_eq. -- --
--   split_sum_by_eq id [3,3] [2,1,0,3] == Just [[2,1,0],[3]]
--   split_sum_by_eq id [3,3] [2,2,2] == Nothing
--   
split_sum_by_eq :: (Ord n, Num n) => (a -> n) -> [n] -> [a] -> Maybe [[a]] -- | Split sequence l such that the prefix sums to precisely -- m. The third element of the result indicates if it was required -- to divide an element. Note that zero elements are kept left. If the -- required sum is non positive, or the input list does not sum to at -- least the required sum, gives nothing. -- --
--   split_sum 5 [2,3,1] == Just ([2,3],[1],Nothing)
--   split_sum 5 [2,1,3] == Just ([2,1,2],[1],Just (2,1))
--   split_sum 2 [3/2,3/2,3/2] == Just ([3/2,1/2],[1,3/2],Just (1/2,1))
--   split_sum 6 [1..10] == Just ([1..3],[4..10],Nothing)
--   fmap (\(a,_,c)->(a,c)) (split_sum 5 [1..]) == Just ([1,2,2],Just (2,1))
--   split_sum 0 [1..] == Nothing
--   split_sum 3 [1,1] == Nothing
--   split_sum 3 [2,1,0] == Just ([2,1,0],[],Nothing)
--   split_sum 3 [2,1,0,1] == Just ([2,1,0],[1],Nothing)
--   
split_sum :: (Ord a, Num a) => a -> [a] -> Maybe ([a], [a], Maybe (a, a)) -- | Variant of split_sum that operates at Rq_Tied sequences. -- --
--   t = True
--   f = False
--   
-- --
--   r = Just ([(3,f),(2,t)],[(1,f)])
--   rqt_split_sum 5 [(3,f),(2,t),(1,f)] == r
--   
-- --
--   r = Just ([(3,f),(1,t)],[(1,t),(1,f)])
--   rqt_split_sum 4 [(3,f),(2,t),(1,f)] == r
--   
-- --
--   rqt_split_sum 4 [(5/2,False)] == Nothing
--   
rqt_split_sum :: Rq -> [Rq_Tied] -> Maybe ([Rq_Tied], [Rq_Tied]) -- | Separate Rq_Tied values in sequences summing to Rq -- values. This is a recursive variant of rqt_split_sum. Note that -- is does not ensure cmn notation of values. -- --
--   t = True
--   f = False
--   
-- --
--   d = [(2,f),(2,f),(2,f)]
--   r = [[(2,f),(1,t)],[(1,f),(2,f)]]
--   rqt_separate [3,3] d == Right r
--   
-- --
--   d = [(5/8,f),(1,f),(3/8,f)]
--   r = [[(5/8,f),(3/8,t)],[(5/8,f),(3/8,f)]]
--   rqt_separate [1,1] d == Right r
--   
-- --
--   d = [(4/7,t),(1/7,f),(1,f),(6/7,f),(3/7,f)]
--   r = [[(4/7,t),(1/7,f),(2/7,t)],[(5/7,f),(2/7,t)],[(4/7,f),(3/7,f)]]
--   rqt_separate [1,1,1] d == Right r
--   
rqt_separate :: [Rq] -> [Rq_Tied] -> Either String [[Rq_Tied]] -- | Maybe form ot rqt_separate rqt_separate_m :: [Rq] -> [Rq_Tied] -> Maybe [[Rq_Tied]] -- | If the input Rq_Tied sequence cannot be notated (see -- rqt_can_notate) separate into equal parts, so long as each part -- is not less than i. -- --
--   rqt_separate_tuplet undefined [(1/3,f),(1/6,f)]
--   rqt_separate_tuplet undefined [(4/7,t),(1/7,f),(2/7,f)]
--   
-- --
--   let d = map rq_rqt [1/3,1/6,2/5,1/10]
--   in rqt_separate_tuplet (1/8) d == Right [[(1/3,f),(1/6,f)]
--                                           ,[(2/5,f),(1/10,f)]]
--   
-- --
--   let d = [(1/5,True),(1/20,False),(1/2,False),(1/4,True)]
--   in rqt_separate_tuplet (1/16) d
--   
-- --
--   let d = [(2/5,f),(1/5,f),(1/5,f),(1/5,t),(1/2,f),(1/2,f)]
--   in rqt_separate_tuplet (1/2) d
--   
-- --
--   let d = [(4/10,True),(1/10,False),(1/2,True)]
--   in rqt_separate_tuplet (1/2) d
--   
rqt_separate_tuplet :: Rq -> [Rq_Tied] -> Either String [[Rq_Tied]] -- | Recursive variant of rqt_separate_tuplet. -- --
--   let d = map rq_rqt [1,1/3,1/6,2/5,1/10]
--   in rqt_tuplet_subdivide (1/8) d == [[(1/1,f)]
--                                      ,[(1/3,f),(1/6,f)]
--                                      ,[(2/5,f),(1/10,f)]]
--   
rqt_tuplet_subdivide :: Rq -> [Rq_Tied] -> [[Rq_Tied]] -- | Sequence variant of rqt_tuplet_subdivide. -- --
--   let d = [(1/5,True),(1/20,False),(1/2,False),(1/4,True)]
--   in rqt_tuplet_subdivide_seq (1/2) [d]
--   
rqt_tuplet_subdivide_seq :: Rq -> [[Rq_Tied]] -> [[Rq_Tied]] -- | If a tuplet is all tied, it ought to be a plain value?! -- --
--   rqt_tuplet_sanity_ [(4/10,t),(1/10,f)] == [(1/2,f)]
--   
rqt_tuplet_sanity_ :: [Rq_Tied] -> [Rq_Tied] rqt_tuplet_subdivide_seq_sanity_ :: Rq -> [[Rq_Tied]] -> [[Rq_Tied]] -- | Separate Rq sequence into measures given by Rq length. -- --
--   to_measures_rq [3,3] [2,2,2] == Right [[(2,f),(1,t)],[(1,f),(2,f)]]
--   to_measures_rq [3,3] [6] == Right [[(3,t)],[(3,f)]]
--   to_measures_rq [1,1,1] [3] == Right [[(1,t)],[(1,t)],[(1,f)]]
--   to_measures_rq [3,3] [2,2,1]
--   to_measures_rq [3,2] [2,2,2]
--   
-- --
--   let d = [4/7,33/28,9/20,4/5]
--   in to_measures_rq [3] d == Right [[(4/7,f),(33/28,f),(9/20,f),(4/5,f)]]
--   
to_measures_rq :: [Rq] -> [Rq] -> Either String [[Rq_Tied]] -- | Variant that is applicable only at sequence that do not require -- splitting and ties, else error. to_measures_rq_untied_err :: [Rq] -> [Rq] -> [[Rq]] -- | Variant of to_measures_rq that ensures Rq_Tied are -- cmn durations. This is not a good composition. -- --
--   to_measures_rq_cmn [6,6] [5,5,2] == Right [[(4,t),(1,f),(1,t)]
--                                             ,[(4,f),(2,f)]]
--   
-- --
--   let r = [[(4/7,t),(1/7,f),(1,f),(6/7,f),(3/7,f)]]
--   in to_measures_rq_cmn [3] [5/7,1,6/7,3/7] == Right r
--   
-- --
--   to_measures_rq_cmn [1,1,1] [5/7,1,6/7,3/7] == Right [[(4/7,t),(1/7,f),(2/7,t)]
--                                                       ,[(4/7,t),(1/7,f),(2/7,t)]
--                                                       ,[(4/7,f),(3/7,f)]]
--   
to_measures_rq_cmn :: [Rq] -> [Rq] -> Either String [[Rq_Tied]] -- | Variant of to_measures_rq with measures given by -- Time_Signature values. Does not ensure Rq_Tied are -- cmn durations. -- --
--   to_measures_ts [(1,4)] [5/8,3/8] /= Right [[(1/2,t),(1/8,f),(3/8,f)]]
--   to_measures_ts [(1,4)] [5/7,2/7] /= Right [[(4/7,t),(1/7,f),(2/7,f)]]
--   
-- --
--   let {m = replicate 18 (1,4)
--       ;x = [3/4,2,5/4,9/4,1/4,3/2,1/2,7/4,1,5/2,11/4,3/2]}
--   in to_measures_ts m x == Right [[(3/4,f),(1/4,t)],[(1/1,t)]
--                                  ,[(3/4,f),(1/4,t)],[(1/1,f)]
--                                  ,[(1/1,t)],[(1/1,t)]
--                                  ,[(1/4,f),(1/4,f),(1/2,t)],[(1/1,f)]
--                                  ,[(1/2,f),(1/2,t)],[(1/1,t)]
--                                  ,[(1/4,f),(3/4,t)],[(1/4,f),(3/4,t)]
--                                  ,[(1/1,t)],[(3/4,f),(1/4,t)]
--                                  ,[(1/1,t)],[(1/1,t)]
--                                  ,[(1/2,f),(1/2,t)],[(1/1,f)]]
--   
-- --
--   to_measures_ts [(3,4)] [4/7,33/28,9/20,4/5]
--   to_measures_ts (replicate 3 (1,4)) [4/7,33/28,9/20,4/5]
--   
to_measures_ts :: [Time_Signature] -> [Rq] -> Either String [[Rq_Tied]] -- | Variant of to_measures_ts that allows for duration field -- operation but requires that measures be well formed. This is useful -- for re-grouping measures after notation and ascription. to_measures_ts_by_eq :: (a -> Rq) -> [Time_Signature] -> [a] -> Maybe [[a]] -- | Divide measure into pulses of indicated Rq durations. Measure -- must be of correct length but need not contain only cmn -- durations. Pulses are further subdivided if required to notate tuplets -- correctly, see rqt_tuplet_subdivide_seq. -- --
--   let d = [(1/4,f),(1/4,f),(2/3,t),(1/6,f),(16/15,f),(1/5,f)
--           ,(1/5,f),(2/5,t),(1/20,f),(1/2,f),(1/4,t)]
--   in m_divisions_rq [1,1,1,1] d
--   
-- --
--   m_divisions_rq [1,1,1] [(4/7,f),(33/28,f),(9/20,f),(4/5,f)]
--   
m_divisions_rq :: [Rq] -> [Rq_Tied] -> Either String [[Rq_Tied]] -- | Variant of m_divisions_rq that determines pulse divisions from -- Time_Signature. -- --
--   let d = [(4/7,t),(1/7,f),(2/7,f)]
--   in m_divisions_ts (1,4) d == Just [d]
--   
-- --
--   let d = map rq_rqt [1/3,1/6,2/5,1/10]
--   in m_divisions_ts (1,4) d == Just [[(1/3,f),(1/6,f)]
--                                     ,[(2/5,f),(1/10,f)]]
--   
-- --
--   let d = map rq_rqt [4/7,33/28,9/20,4/5]
--   in m_divisions_ts (3,4) d == Just [[(4/7,f),(3/7,t)]
--                                     ,[(3/4,f),(1/4,t)]
--                                     ,[(1/5,f),(4/5,f)]]
--   
m_divisions_ts :: Time_Signature -> [Rq_Tied] -> Either String [[Rq_Tied]] -- | Composition of to_measures_rq and m_divisions_rq, where -- measures are initially given as sets of divisions. -- --
--   let m = [[1,1,1],[1,1,1]]
--   in to_divisions_rq m [2,2,2] == Right [[[(1,t)],[(1,f)],[(1,t)]]
--                                        ,[[(1,f)],[(1,t)],[(1,f)]]]
--   
-- --
--   let d = [2/7,1/7,4/7,5/7,8/7,1,1/7]
--   in to_divisions_rq [[1,1,1,1]] d == Right [[[(2/7,f),(1/7,f),(4/7,f)]
--                                             ,[(4/7,t),(1/7,f),(2/7,t)]
--                                             ,[(6/7,f),(1/7,t)]
--                                             ,[(6/7,f),(1/7,f)]]]
--   
-- --
--   let d = [5/7,1,6/7,3/7]
--   in to_divisions_rq [[1,1,1]] d == Right [[[(4/7,t),(1/7,f),(2/7,t)]
--                                           ,[(4/7,t),(1/7,f),(2/7,t)]
--                                           ,[(4/7,f),(3/7,f)]]]
--   
-- --
--   let d = [2/7,1/7,4/7,5/7,1,6/7,3/7]
--   in to_divisions_rq [[1,1,1,1]] d == Right [[[(2/7,f),(1/7,f),(4/7,f)]
--                                             ,[(4/7,t),(1/7,f),(2/7,t)]
--                                             ,[(4/7,t),(1/7,f),(2/7,t)]
--                                             ,[(4/7,f),(3/7,f)]]]
--   
-- --
--   let d = [4/7,33/28,9/20,4/5]
--   in to_divisions_rq [[1,1,1]] d == Right [[[(4/7,f),(3/7,t)]
--                                            ,[(3/4,f),(1/4,t)]
--                                            ,[(1/5,f),(4/5,f)]]]
--   
-- --
--   let {p = [[1/2,1,1/2],[1/2,1]]
--       ;d = map (/6) [1,1,1,1,1,1,4,1,2,1,1,2,1,3]}
--   in to_divisions_rq p d == Right [[[(1/6,f),(1/6,f),(1/6,f)]
--                                    ,[(1/6,f),(1/6,f),(1/6,f),(1/2,True)]
--                                    ,[(1/6,f),(1/6,f),(1/6,True)]]
--                                   ,[[(1/6,f),(1/6,f),(1/6,f)]
--                                    ,[(1/3,f),(1/6,f),(1/2,f)]]]
--   
to_divisions_rq :: [[Rq]] -> [Rq] -> Either String [[[Rq_Tied]]] -- | Variant of to_divisions_rq with measures given as set of -- Time_Signature. -- --
--   let d = [3/5,2/5,1/3,1/6,7/10,17/15,1/2,1/6]
--   in to_divisions_ts [(4,4)] d == Just [[[(3/5,f),(2/5,f)]
--                                         ,[(1/3,f),(1/6,f),(1/2,t)]
--                                         ,[(1/5,f),(4/5,t)]
--                                         ,[(1/3,f),(1/2,f),(1/6,f)]]]
--   
-- --
--   let d = [3/5,2/5,1/3,1/6,7/10,29/30,1/2,1/3]
--   in to_divisions_ts [(4,4)] d == Just [[[(3/5,f),(2/5,f)]
--                                         ,[(1/3,f),(1/6,f),(1/2,t)]
--                                         ,[(1/5,f),(4/5,t)]
--                                         ,[(1/6,f),(1/2,f),(1/3,f)]]]
--   
-- --
--   let d = [3/5,2/5,1/3,1/6,7/10,4/5,1/2,1/2]
--   in to_divisions_ts [(4,4)] d == Just [[[(3/5,f),(2/5,f)]
--                                         ,[(1/3,f),(1/6,f),(1/2,t)]
--                                         ,[(1/5,f),(4/5,f)]
--                                         ,[(1/2,f),(1/2,f)]]]
--   
-- --
--   let d = [4/7,33/28,9/20,4/5]
--   in to_divisions_ts [(3,4)] d == Just [[[(4/7,f),(3/7,t)]
--                                         ,[(3/4,f),(1/4,t)]
--                                         ,[(1/5,f),(4/5,f)]]]
--   
to_divisions_ts :: [Time_Signature] -> [Rq] -> Either String [[[Rq_Tied]]] -- | Pulse tuplet derivation. -- --
--   p_tuplet_rqt [(2/3,f),(1/3,t)] == Just ((3,2),[(1,f),(1/2,t)])
--   p_tuplet_rqt (map rq_rqt [1/3,1/6]) == Just ((3,2),[(1/2,f),(1/4,f)])
--   p_tuplet_rqt (map rq_rqt [2/5,1/10]) == Just ((5,4),[(1/2,f),(1/8,f)])
--   p_tuplet_rqt (map rq_rqt [1/3,1/6,2/5,1/10])
--   
p_tuplet_rqt :: [Rq_Tied] -> Maybe ((Integer, Integer), [Rq_Tied]) -- | Notate pulse, ie. derive tuplet if neccesary. The flag indicates if -- the initial value is tied left. -- --
--   p_notate False [(2/3,f),(1/3,t)]
--   p_notate False [(2/5,f),(1/10,t)]
--   p_notate False [(1/4,t),(1/8,f),(1/8,f)]
--   p_notate False (map rq_rqt [1/3,1/6])
--   p_notate False (map rq_rqt [2/5,1/10])
--   p_notate False (map rq_rqt [1/3,1/6,2/5,1/10]) == Nothing
--   
p_notate :: Bool -> [Rq_Tied] -> Either String [Duration_A] -- | Notate measure. -- --
--   m_notate True [[(2/3,f),(1/3,t)],[(1,t)],[(1,f)]]
--   
-- --
--   let f = m_notate False . concat
--   
-- --
--   fmap f (to_divisions_ts [(4,4)] [3/5,2/5,1/3,1/6,7/10,17/15,1/2,1/6])
--   fmap f (to_divisions_ts [(4,4)] [3/5,2/5,1/3,1/6,7/10,29/30,1/2,1/3])
--   
m_notate :: Bool -> [[Rq_Tied]] -> Either String [Duration_A] -- | Multiple measure notation. -- --
--   let d = [2/7,1/7,4/7,5/7,8/7,1,1/7]
--   in fmap mm_notate (to_divisions_ts [(4,4)] d)
--   
-- --
--   let d = [2/7,1/7,4/7,5/7,1,6/7,3/7]
--   in fmap mm_notate (to_divisions_ts [(4,4)] d)
--   
-- --
--   let d = [3/5,2/5,1/3,1/6,7/10,4/5,1/2,1/2]
--   in fmap mm_notate (to_divisions_ts [(4,4)] d)
--   
-- --
--   let {p = [[1/2,1,1/2],[1/2,1]]
--       ;d = map (/6) [1,1,1,1,1,1,4,1,2,1,1,2,1,3]}
--   in fmap mm_notate (to_divisions_rq p d)
--   
mm_notate :: [[[Rq_Tied]]] -> Either String [[Duration_A]] -- | Structure given to Simplify_P to decide simplification. The -- structure is (ts,start-rq,(left-rq,right-rq)). type Simplify_T = (Time_Signature, Rq, (Rq, Rq)) -- | Predicate function at Simplify_T. type Simplify_P = Simplify_T -> Bool -- | Variant of Simplify_T allowing multiple rules. type Simplify_M = ([Time_Signature], [Rq], [(Rq, Rq)]) -- | Transform Simplify_M to Simplify_P. meta_table_p :: Simplify_M -> Simplify_P -- | Transform Simplify_M to set of Simplify_T. meta_table_t :: Simplify_M -> [Simplify_T] -- | The default table of simplifiers. -- --
--   default_table ((3,4),1,(1,1)) == True
--   
default_table :: Simplify_P -- | The default eighth-note pulse simplifier rule. -- --
--   default_8_rule ((3,8),0,(1/2,1/2)) == True
--   default_8_rule ((3,8),1/2,(1/2,1/2)) == True
--   default_8_rule ((3,8),1,(1/2,1/2)) == True
--   default_8_rule ((2,8),0,(1/2,1/2)) == True
--   default_8_rule ((5,8),0,(1,1/2)) == True
--   default_8_rule ((5,8),0,(2,1/2)) == True
--   
default_8_rule :: Simplify_P -- | The default quarter note pulse simplifier rule. -- --
--   default_4_rule ((3,4),0,(1,1/2)) == True
--   default_4_rule ((3,4),0,(1,3/4)) == True
--   default_4_rule ((4,4),1,(1,1)) == False
--   default_4_rule ((4,4),2,(1,1)) == True
--   default_4_rule ((4,4),2,(1,2)) == True
--   default_4_rule ((4,4),0,(2,1)) == True
--   default_4_rule ((3,4),1,(1,1)) == False
--   
default_4_rule :: Simplify_P -- | The default simplifier rule. To extend provide a list of -- Simplify_T. default_rule :: [Simplify_T] -> Simplify_P -- | Measure simplifier. Apply given Simplify_P. m_simplify :: Simplify_P -> Time_Signature -> [Duration_A] -> [Duration_A] -- | Run simplifier until it reaches a fix-point, or for at most -- limit passes. m_simplify_fix :: Int -> Simplify_P -> Time_Signature -> [Duration_A] -> [Duration_A] -- | Pulse simplifier predicate, which is const True. p_simplify_rule :: Simplify_P -- | Pulse simplifier. -- --
--   import Music.Theory.Duration.Name.Abbreviation
--   p_simplify [(q,[Tie_Right]),(e,[Tie_Left])] == [(q',[])]
--   p_simplify [(e,[Tie_Right]),(q,[Tie_Left])] == [(q',[])]
--   p_simplify [(q,[Tie_Right]),(e',[Tie_Left])] == [(q'',[])]
--   p_simplify [(q'',[Tie_Right]),(s,[Tie_Left])] == [(h,[])]
--   p_simplify [(e,[Tie_Right]),(s,[Tie_Left]),(e',[])] == [(e',[]),(e',[])]
--   
-- --
--   let f = rqt_to_duration_a False
--   in p_simplify (f [(1/8,t),(1/4,t),(1/8,f)]) == f [(1/2,f)]
--   
p_simplify :: [Duration_A] -> [Duration_A] -- | Notate Rq duration sequence. Derive pulse divisions from -- Time_Signature if not given directly. Composition of -- to_divisions_ts, mm_notate m_simplify. -- --
--   let ts = [(4,8),(3,8)]
--       ts_p = [[1/2,1,1/2],[1/2,1]]
--       rq = map (/6) [1,1,1,1,1,1,4,1,2,1,1,2,1,3]
--       sr x = T.default_rule [] x
--   in T.notate_rqp 4 sr ts (Just ts_p) rq
--   
notate_rqp :: Int -> Simplify_P -> [Time_Signature] -> Maybe [[Rq]] -> [Rq] -> Either String [[Duration_A]] -- | Variant of notate_rqp without pulse divisions (derive). -- --
--   notate 4 (default_rule [((3,2),0,(2,2)),((3,2),0,(4,2))]) [(3,2)] [6]
--   
notate :: Int -> Simplify_P -> [Time_Signature] -> [Rq] -> Either String [[Duration_A]] -- | Variant of zip that retains elements of the right hand (rhs) -- list where elements of the left hand (lhs) list meet the given lhs -- predicate. If the right hand side is longer the remaining elements to -- be processed are given. It is an error for the right hand side to be -- short. -- --
--   zip_hold_lhs even [1..5] "abc" == ([],zip [1..6] "abbcc")
--   zip_hold_lhs odd [1..6] "abc" == ([],zip [1..6] "aabbcc")
--   zip_hold_lhs even [1] "ab" == ("b",[(1,'a')])
--   zip_hold_lhs even [1,2] "a" == undefined
--   
zip_hold_lhs :: (Show t, Show x) => (x -> Bool) -> [x] -> [t] -> ([t], [(x, t)]) -- | Variant of zip_hold that requires the right hand side to be -- precisely the required length. -- --
--   zip_hold_lhs_err even [1..5] "abc" == zip [1..6] "abbcc"
--   zip_hold_lhs_err odd [1..6] "abc" == zip [1..6] "aabbcc"
--   zip_hold_lhs_err id [False,False] "a" == undefined
--   zip_hold_lhs_err id [False] "ab" == undefined
--   
zip_hold_lhs_err :: (Show t, Show x) => (x -> Bool) -> [x] -> [t] -> [(x, t)] -- | Variant of zip that retains elements of the right hand (rhs) -- list where elements of the left hand (lhs) list meet the given lhs -- predicate, and elements of the lhs list where elements of the rhs meet -- the rhs predicate. If the right hand side is longer the remaining -- elements to be processed are given. It is an error for the right hand -- side to be short. -- --
--   zip_hold even (const False) [1..5] "abc" == ([],zip [1..6] "abbcc")
--   zip_hold odd (const False) [1..6] "abc" == ([],zip [1..6] "aabbcc")
--   zip_hold even (const False) [1] "ab" == ("b",[(1,'a')])
--   zip_hold even (const False) [1,2] "a" == undefined
--   
-- --
--   zip_hold odd even [1,2,6] [1..5] == ([4,5],[(1,1),(2,1),(6,2),(6,3)])
--   
zip_hold :: (Show t, Show x) => (x -> Bool) -> (t -> Bool) -> [x] -> [t] -> ([t], [(x, t)]) -- | Zip a list of Duration_A elements duplicating elements of the -- right hand sequence for tied durations. -- --
--   let {Just d = to_divisions_ts [(4,4),(4,4)] [3,3,2]
--       ;f = map snd . snd . flip m_ascribe "xyz"}
--   in fmap f (notate d) == Just "xxxyyyzz"
--   
m_ascribe :: Show x => [Duration_A] -> [x] -> ([x], [(Duration_A, x)]) -- | snd . m_ascribe. ascribe :: Show x => [Duration_A] -> [x] -> [(Duration_A, x)] -- | Variant of m_ascribe for a set of measures. mm_ascribe :: Show x => [[Duration_A]] -> [x] -> [[(Duration_A, x)]] -- | 'mm_ascribe of notate. notate_mm_ascribe :: Show a => Int -> [Simplify_T] -> [Time_Signature] -> Maybe [[Rq]] -> [Rq] -> [a] -> Either String [[(Duration_A, a)]] notate_mm_ascribe_err :: Show a => Int -> [Simplify_T] -> [Time_Signature] -> Maybe [[Rq]] -> [Rq] -> [a] -> [[(Duration_A, a)]] -- | Group elements as chords where a chord element is indicated by -- the given predicate. -- --
--   group_chd even [1,2,3,4,4,5,7,8] == [[1,2],[3,4,4],[5],[7,8]]
--   
group_chd :: (x -> Bool) -> [x] -> [[x]] -- | Variant of ascribe that groups the rhs elements using -- group_chd and with the indicated chord function, then -- rejoins the resulting sequence. ascribe_chd :: Show x => (x -> Bool) -> [Duration_A] -> [x] -> [(Duration_A, x)] -- | Variant of mm_ascribe using group_chd mm_ascribe_chd :: Show x => (x -> Bool) -> [[Duration_A]] -> [x] -> [[(Duration_A, x)]] -- | Functions to generate a click track from a metric structure. module Music.Theory.Duration.ClickTrack -- | 1-indexed. type Measure = Int -- | 1-indexed. type Pulse = Int -- | Measures given as Rq divisions, Mdv abbreviates measure -- divisions. type Mdv = [[Rq]] -- | Absolute Rq locations grouped in measures. mrq abbreviates -- measure rational quarter-notes. Locations are zero-indexed. type Mrq = [[Rq]] -- | Transform Mdv to Mrq. -- --
--   mdv_to_mrq [[1,2,1],[3,2,1]] == [[0,1,3],[4,7,9]]
--   
mdv_to_mrq :: Mdv -> Mrq -- | Lookup function for (Measure,Pulse) indexed structure. -- mp abbreviates Measure Pulse. mp_lookup_err :: [[t]] -> (Measure, Pulse) -> t -- | Comparison for (Measure,Pulse) indices. mp_compare :: (Measure, Pulse) -> (Measure, Pulse) -> Ordering -- | Latch measures (ie. make measures contiguous, hold previous value). -- Arguments are the number of measures and the default (intial) value. -- --
--   unzip (ct_ext 10 'a' [(3,'b'),(8,'c')]) == ([1..10],"aabbbbbccc")
--   
ct_ext :: Int -> t -> Tseq Measure t -> Tseq Measure t -- | Variant that requires a value at measure one (first measure). ct_ext1 :: Int -> Tseq Measure t -> Tseq Measure t -- | rts_divisions of ct_ext1. ct_dv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [(Measure, [[Rq]])] -- | ct_dv_seq without measures numbers (which are 1..n) ct_mdv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [[Rq]] -- | mdv_to_mrq of ct_mdv_seq. ct_rq :: Int -> Tseq Measure Rational_Time_Signature -> [[Rq]] ct_mp_lookup :: [[Rq]] -> (Measure, Pulse) -> Rq ct_m_to_rq :: [[Rq]] -> [(Measure, t)] -> [(Rq, t)] -- | Latch rehearsal mark sequence, only indicating marks. Initial mark is -- .. -- --
--   ct_mark_seq 2 [] == [(1,Just '.'),(2,Nothing)]
--   
-- --
--   let r = [(1,Just '.'),(3,Just 'A'),(8,Just 'B')]
--   in filter (isJust . snd) (ct_mark_seq 10 [(3,'A'),(8,'B')]) == r
--   
ct_mark_seq :: Int -> Tseq Measure Char -> Tseq Measure (Maybe Char) -- | Indicate measures prior to marks. -- --
--   ct_pre_mark [] == []
--   ct_pre_mark [(1,'A')] == []
--   ct_pre_mark [(3,'A'),(8,'B')] == [(2,Just ()),(7,Just ())]
--   
ct_pre_mark :: [(Measure, a)] -> [(Measure, Maybe ())] -- | Contiguous pre-mark sequence. -- --
--   ct_pre_mark_seq 1 [(1,'A')] == [(1,Nothing)]
--   ct_pre_mark_seq 10 [(3,'A'),(8,'B')]
--   
ct_pre_mark_seq :: Measure -> Tseq Measure Char -> Tseq Measure (Maybe ()) ct_tempo_lseq_rq :: [[Rq]] -> Lseq (Measure, Pulse) Rq -> Lseq Rq Rq -- | Interpolating lookup of tempo sequence (lseq_lookup_err). ct_tempo_at :: Lseq Rq Rq -> Rq -> Rational -- | Types of nodes. data Ct_Node -- | The start of a measure with a rehearsal mark. Ct_Mark :: Rq -> Ct_Node -- | The start of a regular measure. Ct_Start :: Rq -> Ct_Node -- | A regular pulse. Ct_Normal :: Rq -> Ct_Node -- | The start of a pulse group within a measure. Ct_Edge :: Rq -> Ct_Node -- | A regular pulse in a measure prior to a rehearsal mark. Ct_Pre :: Rq -> Ct_Node -- | The end of the track. Ct_End :: Ct_Node -- | Lead-in of (pulse,tempo,count). ct_leadin :: (Rq, Double, Int) -> Dseq Double Ct_Node -- | Prepend initial element to start of list. -- --
--   delay1 "abc" == "aabc"
--   
delay1 :: [a] -> [a] -- | Generate Ct measure. Calculates durations of events considering only -- the tempo at the start of the event. To be correct it should consider -- the tempo envelope through the event. ct_measure :: Lseq Rq Rq -> ([Rq], Maybe Char, Maybe (), [[Rq]]) -> [(Rational, Ct_Node)] -- | Click track definition. data Ct Ct :: Int -> [(Measure, Rational_Time_Signature)] -> [(Measure, Char)] -> Lseq (Measure, Pulse) Rq -> (Rq, Int) -> Ct [ct_len] :: Ct -> Int [ct_ts] :: Ct -> [(Measure, Rational_Time_Signature)] [ct_mark] :: Ct -> [(Measure, Char)] [ct_tempo] :: Ct -> Lseq (Measure, Pulse) Rq [ct_count] :: Ct -> (Rq, Int) -- | Initial tempo, if given. ct_tempo0 :: Ct -> Maybe Rq -- | Erroring variant. ct_tempo0_err :: Ct -> Rq ct_measures :: Ct -> [Dseq Rational Ct_Node] ct_dseq' :: Ct -> Dseq Rational Ct_Node ct_dseq :: Ct -> Dseq Double Ct_Node ct_rq_measure :: [[Rq]] -> Rq -> Maybe Measure ct_rq_mp :: [[Rq]] -> Rq -> Maybe (Measure, Pulse) ct_rq_mp_err :: [[Rq]] -> Rq -> (Measure, Pulse) ct_mp_to_rq :: [[Rq]] -> [((Measure, Pulse), t)] -> [(Rq, t)] instance GHC.Show.Show Music.Theory.Duration.ClickTrack.Ct_Node instance GHC.Classes.Eq Music.Theory.Duration.ClickTrack.Ct_Node instance GHC.Show.Show Music.Theory.Duration.ClickTrack.Ct -- | Tuning theory module Music.Theory.Tuning -- | Fractional midi note number to cycles per second, given (k0,f0) -- pair. -- --
--   fmidi_to_cps_k0 (60,256) 69 == 430.5389646099018
--   
fmidi_to_cps_k0 :: Floating a => (a, a) -> a -> a -- | fmidi_to_cps_k0 with k0 of 69. -- --
--   fmidi_to_cps_f0 440 60 == 261.6255653005986
--   
fmidi_to_cps_f0 :: Floating a => a -> a -> a -- | fmidi_to_cps_k0 (69,440) -- --
--   map fmidi_to_cps [69,69.1] == [440.0,442.5488940698553]
--   
fmidi_to_cps :: Floating a => a -> a -- | Midi note number to cycles per second, given frequency of ISO -- A4. midi_to_cps_k0 :: (Integral i, Floating f) => (f, f) -> i -> f -- | midi_to_cps_k0 (69,440). -- --
--   map (round . midi_to_cps) [59,60,69] == [247,262,440]
--   
midi_to_cps :: (Integral i, Floating f) => i -> f -- | Convert from interval in cents to frequency ratio. -- --
--   map cents_to_fratio [0,701.9550008653874,1200] == [1,3/2,2]
--   map cents_to_fratio [-1800,1800] -- three octaves about zero
--   
cents_to_fratio :: Floating a => a -> a -- | Convert from a Floating ratio to cents. -- --
--   let r = [0,498,702,1200]
--   map (round . fratio_to_cents) [1,4/3,3/2,2] == r
--   
fratio_to_cents :: (Real r, Floating n) => r -> n -- | Frequency n cents from f. -- --
--   import Music.Theory.Pitch {- hmt -}
--   map (cps_shift_cents 440) [-100,100] == map octpc_to_cps [(4,8),(4,10)]
--   
cps_shift_cents :: Floating a => a -> a -> a -- | Interval in cents from p to q, ie. -- ratio_to_cents of p / q. -- --
--   map (round . cps_difference_cents 440) [412,415,octpc_to_cps (5,2)] == [-114,-101,500]
--   
-- --
--   let abs_dif i j = abs (i - j)
--   cps_difference_cents 440 (fmidi_to_cps 69.1) `abs_dif` 10 < 1e9
--   
cps_difference_cents :: (Real r, Fractional r, Floating n) => r -> r -> n -- | Convert a (signed) number of octaves difference of given ratio to a -- ratio. -- --
--   map (oct_diff_to_ratio 2) [-3 .. 3] == [1/8,1/4,1/2,1,2,4,8]
--   map (oct_diff_to_ratio (9/8)) [-3 .. 3] == [512/729,64/81,8/9,1/1,9/8,81/64,729/512]
--   
oct_diff_to_ratio :: Integral a => Ratio a -> Int -> Ratio a -- | ratio_to_cents rounded to nearest multiple of 100, modulo 12. -- --
--   map (ratio_to_pc 0) [1,4/3,3/2,2] == [0,5,7,0]
--   
ratio_to_pc :: Int -> Rational -> Int -- | Fold ratio to lie within an octave, ie. 1 < -- n <= 2. It is an error for n to be -- more than one octave outside of this range. -- --
--   map fold_ratio_to_octave_nonrec [2/3,3/4,4/5,4/7] == [4/3,3/2,8/5,8/7]
--   
fold_ratio_to_octave_nonrec :: (Ord n, Fractional n) => n -> n -- | Fold ratio until within an octave, ie. 1 < n -- <= 2. It is an error if n is less than or -- equal to zero. -- --
--   map fold_ratio_to_octave_err [2/2,2/3,3/4,4/5,4/7] == [1/1,4/3,3/2,8/5,8/7]
--   
fold_ratio_to_octave_err :: (Ord n, Fractional n) => n -> n -- | In n is greater than zero, fold_ratio_to_octave_err, -- else Nothing. -- --
--   map fold_ratio_to_octave [0,1] == [Nothing,Just 1]
--   
fold_ratio_to_octave :: (Ord n, Fractional n) => n -> Maybe n -- | The interval between two pitches p and q given as ratio -- multipliers of a fundamental is q / p. The -- classes over such intervals consider the fold_ratio_to_octave -- of both p to q and q to p and select the -- minima at the cmp_f. -- --
--   map (ratio_interval_class_by id) [3/2,5/4] == [4/3,5/4]
--   
ratio_interval_class_by :: (Ord t, Integral i) => (Ratio i -> t) -> Ratio i -> Ratio i -- | ratio_interval_class_by ratio_nd_sum -- --
--   map ratio_interval_class [2/3,3/2,3/4,4/3] == [3/2,3/2,3/2,3/2]
--   map ratio_interval_class [7/6,12/7] == [7/6,7/6]
--   
ratio_interval_class :: Integral i => Ratio i -> Ratio i -- | An approximation of a ratio. type Approximate_Ratio = Double -- | Type specialised fromRational. approximate_ratio :: Rational -> Approximate_Ratio -- | A real valued division of a semi-tone into one hundred parts, and -- hence of the octave into 1200 parts. type Cents = Double -- | Integral cents value. type Cents_I = Int -- | Type specialised fratio_to_cents. approximate_ratio_to_cents :: Approximate_Ratio -> Cents -- | approximate_ratio_to_cents . approximate_ratio. -- --
--   import Data.Ratio {- base -}
--   map (\n -> (n,round (ratio_to_cents (fold_ratio_to_octave_err (n % 1))))) [1..21]
--   
ratio_to_cents :: Integral i => Ratio i -> Cents -- | Construct an exact Rational that approximates Cents to -- within epsilon. -- --
--   map (reconstructed_ratio 1e-5) [0,700,1200,1800] == [1,442/295,2,577/204]
--   
-- --
--   ratio_to_cents (442/295) == 699.9976981706735
--   
reconstructed_ratio :: Double -> Cents -> Rational -- | The Syntonic comma. -- --
--   syntonic_comma == 81/80
--   
syntonic_comma :: Rational -- | The Pythagorean comma. -- --
--   pythagorean_comma == 3^12 / 2^19
--   
pythagorean_comma :: Rational -- | Mercators comma. -- --
--   mercators_comma == 3^53 / 2^84
--   
mercators_comma :: Rational -- | 12-tone equal temperament comma (ie. 12th root of 2). -- --
--   twelve_tone_equal_temperament_comma == 1.0594630943592953
--   
twelve_tone_equal_temperament_comma :: (Floating a, Eq a) => a -- | Give cents difference from nearest 12ET tone. -- --
--   let r = [50,-49,-2,0,2,49,50]
--   map cents_et12_diff [650,651,698,700,702,749,750] == r
--   
cents_et12_diff :: Integral n => n -> n -- | Fractional form of cents_et12_diff. fcents_et12_diff :: Real n => n -> n -- | The class of cents intervals has range (0,600). -- --
--   map cents_interval_class [50,1150,1250] == [50,50,50]
--   
-- --
--   let r = concat [[0,50 .. 550],[600],[550,500 .. 0]]
--   map cents_interval_class [1200,1250 .. 2400] == r
--   
cents_interval_class :: Integral a => a -> a -- | Fractional form of cents_interval_class. fcents_interval_class :: Real a => a -> a -- | Always include the sign, elide 0. cents_diff_pp :: (Num a, Ord a, Show a) => a -> String -- | Given brackets, print cents difference. cents_diff_br :: (Num a, Ord a, Show a) => (String, String) -> a -> String -- | cents_diff_br with parentheses. -- --
--   map cents_diff_text [-1,0,1] == ["(-1)","","(+1)"]
--   
cents_diff_text :: (Num a, Ord a, Show a) => a -> String -- | cents_diff_br with markdown superscript (^). cents_diff_md :: (Num a, Ord a, Show a) => a -> String -- | cents_diff_br with HTML superscript (sup). cents_diff_html :: (Num a, Ord a, Show a) => a -> String -- | Felix Savart (1791-1841), the ratio of 10:1 is assigned a value of -- 1000 savarts. type Savarts = Double -- | Ratio to savarts. -- --
--   fratio_to_savarts 10 == 1000
--   fratio_to_savarts 2 == 301.02999566398114
--   
fratio_to_savarts :: Floating a => a -> a -- | Savarts to ratio. -- --
--   savarts_to_fratio 1000 == 10
--   savarts_to_fratio 301.02999566398118 == 2
--   
savarts_to_fratio :: Floating a => a -> a -- | Savarts to cents. -- --
--   savarts_to_cents 1 == 3.9863137138648352
--   
savarts_to_cents :: Floating a => a -> a -- | Cents to savarts. -- --
--   cents_to_savarts 3.9863137138648352 == 1
--   cents_to_savarts 1200 == ratio_to_savarts 2
--   
cents_to_savarts :: Floating a => a -> a -- | Common music notation pitch values. module Music.Theory.Pitch -- | Octave and PitchClass duple. type Octave_PitchClass i = (i, i) -- | Normalise Octave_PitchClass value, ie. ensure pitch-class is in -- (0,11). octave_pitchclass_nrm :: (Ord i, Num i) => Octave_PitchClass i -> Octave_PitchClass i -- | Transpose Octave_PitchClass value. octave_pitchclass_trs :: Integral i => i -> Octave_PitchClass i -> Octave_PitchClass i -- | Octave_PitchClass value to integral midi note number. -- --
--   map octave_pitchclass_to_midi [(-1,9),(8,0)] == map (+ 9) [0,99]
--   
octave_pitchclass_to_midi :: Num i => Octave_PitchClass i -> i -- | Inverse of octave_pitchclass_to_midi. -- --
--   map midi_to_octave_pitchclass [0,36,60,84,91] == [(-1,0),(2,0),(4,0),(6,0),(6,7)]
--   
midi_to_octave_pitchclass :: (Integral m, Integral i) => m -> Octave_PitchClass i -- | One-indexed piano key number (for standard 88 key piano) to pitch -- class. This has the mnemonic that 49 maps to (4,9). -- --
--   map pianokey_to_octave_pitchclass [1,49,88] == [(0,9),(4,9),(8,0)]
--   
pianokey_to_octave_pitchclass :: (Integral m, Integral i) => m -> Octave_PitchClass i -- | Pitch classes are modulo twelve integers (0-11) type PitchClass = Int -- | Octaves are integers, the octave of middle C is 4. type Octave = Int -- | Octave and PitchClass duple. type OctPc = (Octave, PitchClass) -- | Translate from generic octave & pitch-class duple. octave_pitchclass_to_octpc :: (Integral pc, Integral oct) => (oct, pc) -> OctPc -- | Normalise OctPc. -- --
--   octpc_nrm (4,16) == (5,4)
--   
octpc_nrm :: OctPc -> OctPc -- | Transpose OctPc. -- --
--   octpc_trs 7 (4,9) == (5,4)
--   octpc_trs (-11) (4,9) == (3,10)
--   
octpc_trs :: Int -> OctPc -> OctPc -- | Enumerate range, inclusive. -- --
--   octpc_range ((3,8),(4,1)) == [(3,8),(3,9),(3,10),(3,11),(4,0),(4,1)]
--   
octpc_range :: (OctPc, OctPc) -> [OctPc] -- | Midi note number (0 - 127). Midi data values are unsigned 7-bit -- integers, however using an unsigned type would be problematic. It -- would make transposition, for instance, awkward. x - 12 would -- transpose down an octave, but the transposition interval itself could -- not be negative. type Midi = Int -- | Type conversion midi_to_int :: Midi -> Int -- | Type-specialise f, ie. round, ceiling, truncate double_to_midi :: (Double -> Midi) -> Double -> Midi -- | OctPc value to integral midi note number. -- --
--   map octpc_to_midi [(0,0),(2,6),(4,9),(6,2),(9,0)] == [12,42,69,86,120]
--   map octpc_to_midi [(0,9),(8,0)] == [21,108]
--   
octpc_to_midi :: OctPc -> Midi -- | Inverse of octpc_to_midi. -- --
--   map midi_to_octpc [40,69] == [(2,4),(4,9)]
--   
midi_to_octpc :: Midi -> OctPc -- | (octave,pitch-class) to fractional octave. This is an odd notation, -- but can be useful for writing pitch data where a float is required. -- Note this is not a linear octave, for that see oct_to_cps. -- --
--   map octpc_to_foct [(4,0),(4,7),(5,11)] == [4.00,4.07,5.11]
--   
octpc_to_foct :: (Integral i, Fractional r) => (i, i) -> r -- | Inverse of octpc_to_foct. -- --
--   map foct_to_octpc [3.11,4.00,4.07,5.11] == [(3,11),(4,0),(4,7),(5,11)]
--   
foct_to_octpc :: (Integral i, RealFrac r) => r -> (i, i) -- | octpc_to_midi of foct_to_octpc. foct_to_midi :: (Integral i, RealFrac r) => r -> i -- | Fractional midi note number. type FMidi = Double -- | Fractional octave pitch-class (octave is integral, pitch-class is -- fractional). type FOctPc = (Int, Double) -- | fromIntegral of octpc_to_midi. octpc_to_fmidi :: (Integral i, Num n) => Octave_PitchClass i -> n -- | Fractional midi to fractional octave pitch-class. -- --
--   fmidi_to_foctpc 69.5 == (4,9.5)
--   
fmidi_to_foctpc :: RealFrac f => f -> (Octave, f) -- | Octave of fractional midi note number. fmidi_octave :: RealFrac f => f -> Octave foctpc_to_fmidi :: RealFrac f => (Octave, f) -> f -- | Move fractional midi note number to indicated octave. -- --
--   map (fmidi_in_octave 1) [59.5,60.5] == [35.5,24.5]
--   
fmidi_in_octave :: RealFrac f => Octave -> f -> f -- | Print fractional midi note number as ET12 pitch with cents detune in -- parentheses. -- --
--   fmidi_et12_cents_pp T.pc_spell_ks 66.5 == "F♯4(+50)"
--   
fmidi_et12_cents_pp :: Spelling PitchClass -> FMidi -> String -- | Common music notation pitch value. data Pitch Pitch :: Note -> Alteration -> Octave -> Pitch [note] :: Pitch -> Note [alteration] :: Pitch -> Alteration [octave] :: Pitch -> Octave -- | Simplify Pitch to standard 12ET by deleting quarter tones. -- --
--   let p = Pitch T.A T.QuarterToneSharp 4
--   alteration (pitch_clear_quarter_tone p) == T.Sharp
--   
pitch_clear_quarter_tone :: Pitch -> Pitch -- | Pitch to Octave and PitchClass notation. -- --
--   pitch_to_octpc (Pitch F Sharp 4) == (4,6)
--   
pitch_to_octpc :: Integral i => Pitch -> Octave_PitchClass i -- | Is Pitch 12-ET. pitch_is_12et :: Pitch -> Bool -- | Pitch to midi note number notation. -- --
--   pitch_to_midi (Pitch A Natural 4) == 69
--   
pitch_to_midi :: Integral i => Pitch -> i -- | Pitch to fractional midi note number notation. -- --
--   pitch_to_fmidi (Pitch A QuarterToneSharp 4) == 69.5
--   
pitch_to_fmidi :: Fractional n => Pitch -> n -- | Extract PitchClass of Pitch -- --
--   map pitch_to_pc [Pitch A Natural 4,Pitch F Sharp 4] == [9,6]
--   map pitch_to_pc [Pitch C Flat 4,Pitch B Sharp 5] == [11,0]
--   
pitch_to_pc :: Pitch -> PitchClass -- | Pitch comparison, implemented via pitch_to_fmidi. -- --
--   pitch_compare (Pitch A Natural 4) (Pitch A QuarterToneSharp 4) == LT
--   
pitch_compare :: Pitch -> Pitch -> Ordering -- | Function to spell a PitchClass. type Spelling n = n -> (Note, Alteration) -- | Variant of Spelling for incomplete functions. type Spelling_M i = i -> Maybe (Note, Alteration) -- | Given Spelling function translate from OctPc notation to -- Pitch. -- --
--   octpc_to_pitch T.pc_spell_sharp (4,6) == Pitch T.F T.Sharp 4
--   
octpc_to_pitch :: Integral i => Spelling i -> Octave_PitchClass i -> Pitch -- | Midi note number to Pitch. -- --
--   import Music.Theory.Pitch.Spelling.Table as T
--   let r = ["C4","E♭4","F♯4"]
--   map (pitch_pp . midi_to_pitch T.pc_spell_ks) [60,63,66] == r
--   
midi_to_pitch :: (Integral i, Integral k) => Spelling k -> i -> Pitch -- | Fractional midi note number to Pitch. -- --
--   p = Pitch T.B T.ThreeQuarterToneFlat 4
--   map (fmidi_to_pitch T.pc_spell_ks) [69.25,69.5] == [Nothing,Just p]
--   
fmidi_to_pitch :: RealFrac n => Spelling PitchClass -> n -> Maybe Pitch -- | Erroring variant. -- --
--   import Music.Theory.Pitch.Spelling as T
--   pitch_pp (fmidi_to_pitch_err T.pc_spell_ks 65.5) == "F𝄲4"
--   pitch_pp (fmidi_to_pitch_err T.pc_spell_ks 66.5) == "F𝄰4"
--   pitch_pp (fmidi_to_pitch_err T.pc_spell_ks 67.5) == "A𝄭4"
--   pitch_pp (fmidi_to_pitch_err T.pc_spell_ks 69.5) == "B𝄭4"
--   
fmidi_to_pitch_err :: (Show n, RealFrac n) => Spelling Int -> n -> Pitch -- | Composition of pitch_to_fmidi and then fmidi_to_pitch. -- --
--   import Music.Theory.Pitch.Name as T
--   import Music.Theory.Pitch.Spelling as T
--   pitch_transpose_fmidi T.pc_spell_ks 2 T.ees5 == T.f5
--   
pitch_transpose_fmidi :: (RealFrac n, Show n) => Spelling Int -> n -> Pitch -> Pitch -- | Displacement of q into octave of p. fmidi_in_octave_of :: RealFrac f => f -> f -> f -- | Octave displacement of m2 that is nearest m1. -- --
--   let p = octpc_to_fmidi (2,1)
--   let q = map octpc_to_fmidi [(4,11),(4,0),(4,1)]
--   map (fmidi_in_octave_nearest p) q == [35,36,37]
--   
fmidi_in_octave_nearest :: RealFrac n => n -> n -> n -- | Displacement of q into octave above p. -- --
--   fmidi_in_octave_of 69 51 == 63
--   fmidi_in_octave_nearest 69 51 == 63
--   fmidi_in_octave_above 69 51 == 75
--   
fmidi_in_octave_above :: RealFrac a => a -> a -> a -- | Displacement of q into octave below p. -- --
--   fmidi_in_octave_of 69 85 == 61
--   fmidi_in_octave_nearest 69 85 == 73
--   fmidi_in_octave_below 69 85 == 61
--   
fmidi_in_octave_below :: RealFrac a => a -> a -> a -- | CPS form of binary fmidi function f. lift_fmidi_binop_to_cps :: Floating f => (f -> f -> f) -> f -> f -> f -- | CPS form of fmidi_in_octave_nearest. -- --
--   map cps_octave [440,256] == [4,4]
--   round (cps_in_octave_nearest 440 256) == 512
--   
cps_in_octave_nearest :: (Floating f, RealFrac f) => f -> f -> f -- | CPS form of fmidi_in_octave_above. -- --
--   cps_in_octave_above 55.0 392.0 == 97.99999999999999
--   
cps_in_octave_above :: (Floating f, RealFrac f) => f -> f -> f -- | CPS form of fmidi_in_octave_above. cps_in_octave_below :: (Floating f, RealFrac f) => f -> f -> f -- | Direct implementation of cps_in_octave_above. Raise or lower -- the frequency q by octaves until it is in the octave starting -- at p. -- --
--   cps_in_octave_above_direct 55.0 392.0 == 98.0
--   
cps_in_octave_above_direct :: (Ord a, Fractional a) => a -> a -> a -- | Set octave of p2 so that it nearest to p1. -- --
--   import Music.Theory.Pitch
--   import Music.Theory.Pitch.Name as T
--   let r = ["B1","C2","C#2"]
--   let f = pitch_in_octave_nearest T.cis2
--   map (pitch_pp_iso . f) [T.b4,T.c4,T.cis4] == r
--   
pitch_in_octave_nearest :: Pitch -> Pitch -> Pitch -- | Raise Note of Pitch, account for octave transposition. -- --
--   pitch_note_raise (Pitch B Natural 3) == Pitch C Natural 4
--   
pitch_note_raise :: Pitch -> Pitch -- | Lower Note of Pitch, account for octave transposition. -- --
--   pitch_note_lower (Pitch C Flat 4) == Pitch B Flat 3
--   
pitch_note_lower :: Pitch -> Pitch -- | Rewrite Pitch to not use 3/4 tone alterations, ie. -- re-spell to 1/4 alteration. -- --
--   let p = Pitch T.A T.ThreeQuarterToneFlat 4
--   let q = Pitch T.G T.QuarterToneSharp 4
--   pitch_rewrite_threequarter_alteration p == q
--   
pitch_rewrite_threequarter_alteration :: Pitch -> Pitch -- | Apply function to octave of PitchClass. -- --
--   pitch_edit_octave (+ 1) (Pitch T.A T.Natural 4) == Pitch T.A T.Natural 5
--   
pitch_edit_octave :: (Octave -> Octave) -> Pitch -> Pitch -- | fmidi_to_cps of pitch_to_fmidi, given (k0,f0). pitch_to_cps_k0 :: Floating n => (n, n) -> Pitch -> n -- | fmidi_to_cps of pitch_to_fmidi, given frequency of ISO -- A4. pitch_to_cps_f0 :: Floating n => n -> Pitch -> n -- | pitch_to_cps_k0 (60,440). pitch_to_cps :: Floating n => Pitch -> n -- | Frequency (cps = cycles per second) to fractional midi note -- number, given frequency of ISO A4 (mnn = 69). cps_to_fmidi_k0 :: Floating a => (a, a) -> a -> a -- | cps_to_fmidi_k0 (69,440). -- --
--   cps_to_fmidi 440 == 69
--   cps_to_fmidi (fmidi_to_cps 60.25) == 60.25
--   
cps_to_fmidi :: Floating a => a -> a -- | Frequency (cycles per second) to midi note number, ie. -- round of cps_to_fmidi. -- --
--   map cps_to_midi [261.6,440] == [60,69]
--   
cps_to_midi :: (Integral i, Floating f, RealFrac f) => f -> i -- | midi_to_cps_f0 of octpc_to_midi, given (k0,f0) octpc_to_cps_k0 :: (Integral i, Floating n) => (n, n) -> Octave_PitchClass i -> n -- | octpc_to_cps_k0 (69,440). -- --
--   map (round . octpc_to_cps) [(-1,0),(0,0),(4,9),(9,0)] == [8,16,440,8372]
--   
octpc_to_cps :: (Integral i, Floating n) => Octave_PitchClass i -> n -- | midi_to_octpc of cps_to_midi. cps_to_octpc :: (Floating f, RealFrac f, Integral i) => f -> Octave_PitchClass i cps_octave :: (Floating f, RealFrac f) => f -> Octave -- | Is cents in (-50,+50]. -- --
--   map cents_is_normal [-250,-75,75,250] == replicate 4 False
--   
cents_is_normal :: (Num c, Ord c) => c -> Bool -- | cents_is_normal of snd. midi_detune_is_normal :: (Num c, Ord c) => (x, c) -> Bool -- | In normal form the detune is in the range (-50,+50] instead of [0,100) -- or wider. -- --
--   map midi_detune_normalise [(60,-250),(60,-75),(60,75),(60,250)]
--   
midi_detune_normalise :: (Num m, Ord c, Num c) => (m, c) -> (m, c) -- | In normal-positive form the detune is in the range (0,+100]. -- --
--   map midi_detune_normalise_positive [(60,-250),(60,-75),(60,75),(60,250)]
--   
midi_detune_normalise_positive :: (Num m, Ord m, Ord c, Num c) => (m, c) -> (m, c) -- | Inverse of cps_to_midi_detune, given frequency of ISO -- A4. midi_detune_to_cps_f0 :: (Integral m, Real c) => Double -> (m, c) -> Double -- | Inverse of cps_to_midi_detune. -- --
--   map midi_detune_to_cps [(69,0),(68,100)] == [440,440]
--   
midi_detune_to_cps :: (Integral m, Real c) => (m, c) -> Double -- | Midi_Detune to fractional midi note number. -- --
--   midi_detune_to_fmidi (60,50.0) == 60.50
--   
midi_detune_to_fmidi :: (Integral m, Real c) => (m, c) -> Double -- | Midi_Detune to Pitch, detune must be precisely at a -- notateable Pitch. -- --
--   let p = Pitch {note = T.C, alteration = T.QuarterToneSharp, octave = 4}
--   midi_detune_to_pitch T.pc_spell_ks (midi_detune_nearest_24et (60,35)) == p
--   
midi_detune_to_pitch :: (Integral m, Real c) => Spelling Int -> (m, c) -> Pitch -- | Midi note number with real-valued cents detune. type Midi_Detune = (Midi, Double) -- | Fractional midi note number to Midi_Detune. -- --
--   fmidi_to_midi_detune 60.50 == (60,50.0)
--   
fmidi_to_midi_detune :: Double -> Midi_Detune -- | Frequency (in hertz) to Midi_Detune. -- --
--   map (fmap round . cps_to_midi_detune) [440.00,508.35] == [(69,0),(71,50)]
--   
cps_to_midi_detune :: Double -> Midi_Detune -- | Round detune value to nearest multiple of 50, -- normalised. -- --
--   map midi_detune_nearest_24et [(59,70),(59,80)] == [(59,50),(60,00)]
--   
midi_detune_nearest_24et :: Midi_Detune -> Midi_Detune -- | Midi note number with integral cents detune. type Midi_Cents = (Midi, Int) midi_detune_to_midi_cents :: Midi_Detune -> Midi_Cents -- | Printed as fmidi value with cents to two places. Must be -- normal. -- --
--   map midi_cents_pp [(60,0),(60,25)] == ["60.00","60.25"]
--   
midi_cents_pp :: Midi_Cents -> String -- | The 24ET pitch-class universe, with sharp spellings, in octave -- '4'. -- --
--   length pc24et_univ == 24
--   
-- --
--   let r = "C C𝄲 C♯ C𝄰 D D𝄲 D♯ D𝄰 E E𝄲 F F𝄲 F♯ F𝄰 G G𝄲 G♯ G𝄰 A A𝄲 A♯ A𝄰 B B𝄲"
--   unwords (map pitch_class_pp pc24et_univ) == r
--   
pc24et_univ :: [Pitch] -- | genericIndex into pc24et_univ. -- --
--   pitch_class_pp (pc24et_to_pitch 13) == "F𝄰"
--   
pc24et_to_pitch :: Integral i => i -> Pitch -- | Generalised pitch, given by a generalised alteration. data Pitch_R Pitch_R :: Note -> Alteration_R -> Octave -> Pitch_R -- | Pretty printer for Pitch_R. pitch_r_pp :: Pitch_R -> String -- | Pitch_R printed without octave. pitch_r_class_pp :: Pitch_R -> String -- | Parser for single digit ISO octave (C4 = middle-C) p_octave_iso :: P Octave -- | Parser for single digit ISO octave with default value in case of no -- parse. p_octave_iso_opt :: Octave -> P Octave -- | Parser for ISO pitch notation. p_iso_pitch_strict :: P Pitch -- | Parser for extended form of ISO pitch notation. p_iso_pitch_oct :: Octave -> P Pitch -- | Parse possible octave from single integer. -- --
--   map (parse_octave 2) ["","4","x","11"] == [2,4,2,1]x
--   
parse_octave :: Octave -> String -> Octave -- | Generalisation of ISO pitch representation. Allows octave to be -- elided, pitch names to be lower case, and double sharps written as -- ##. -- -- See http://www.musiccog.ohio-state.edu/Humdrum/guide04.html -- --
--   let r = [Pitch T.C T.Natural 4,Pitch T.A T.Flat 5,Pitch T.F T.DoubleSharp 6]
--   mapMaybe (parse_iso_pitch_oct 4) ["C","Ab5","f##6",""] == r
--   
parse_iso_pitch_oct :: Octave -> String -> Maybe Pitch -- | Variant of parse_iso_pitch_oct requiring octave. parse_iso_pitch :: String -> Maybe Pitch -- | error variant. parse_iso_pitch_err :: String -> Pitch -- | Pretty printer for Pitch (unicode, see -- alteration_symbol). Option selects if Naturals are -- printed. -- --
--   pitch_pp_opt (True,True) (Pitch T.E T.Natural 4) == "E♮4"
--   
pitch_pp_opt :: (Bool, Bool) -> Pitch -> String -- | pitch_pp_opt with default options, ie. (False,True). -- --
--   pitch_pp (Pitch T.E T.Natural 4) == "E4"
--   pitch_pp (Pitch T.E T.Flat 4) == "E♭4"
--   pitch_pp (Pitch T.F T.QuarterToneSharp 3) == "F𝄲3"
--   
pitch_pp :: Pitch -> String -- | pitch_pp_opt with options (False,False). -- --
--   pitch_class_pp (Pitch T.C T.ThreeQuarterToneSharp 0) == "C𝄰"
--   
pitch_class_pp :: Pitch -> String -- | Sequential list of n pitch class names starting from k. -- --
--   import Music.Theory.Pitch.Spelling.Table
--   unwords (pitch_class_names_12et pc_spell_ks 0 12) == "C C♯ D E♭ E F F♯ G A♭ A B♭ B"
--   pitch_class_names_12et pc_spell_ks 11 2 == ["B","C"]
--   
pitch_class_names_12et :: Integral n => Spelling n -> n -> n -> [String] -- | Pretty printer for Pitch (ISO, ASCII, see -- alteration_iso). -- --
--   pitch_pp_iso (Pitch E Flat 4) == "Eb4"
--   pitch_pp_iso (Pitch F DoubleSharp 3) == "Fx3"
--   pitch_pp_iso (Pitch C ThreeQuarterToneSharp 4) -- error
--   
pitch_pp_iso :: Pitch -> String -- | Lilypond octave syntax. ly_octave_tbl :: [(Octave, String)] -- | Lookup ly_octave_tbl. octave_pp_ly :: Octave -> String -- | Parse lilypond octave indicator. octave_parse_ly :: String -> Maybe Octave -- | Pretty printer for Pitch (ASCII, see alteration_tonh). -- --
--   pitch_pp_hly (Pitch E Flat 4) == "ees4"
--   pitch_pp_hly (Pitch F QuarterToneSharp 3) == "fih3"
--   pitch_pp_hly (Pitch B Natural 6) == "b6"
--   
pitch_pp_hly :: Pitch -> String -- | Pretty printer for Pitch (Tonhöhe, see -- alteration_tonh). -- --
--   pitch_pp_tonh (Pitch E Flat 4) == "Es4"
--   pitch_pp_tonh (Pitch F QuarterToneSharp 3) == "Fih3"
--   pitch_pp_tonh (Pitch B Natural 6) == "H6"
--   
pitch_pp_tonh :: Pitch -> String p_octave_ly :: P Octave p_pitch_ly :: P Pitch -- | Run p_pitch_ly. -- --
--   map (pitch_pp . pitch_parse_ly_err) ["c","d'","ees,","fisis''"] == ["C3","D4","E♭2","F𝄪5"]
--   
pitch_parse_ly_err :: String -> Pitch -- | Parser for hly notation. p_pitch_hly :: P Pitch -- | Run p_pitch_hly. -- --
--   map (pitch_pp . pitch_parse_hly) ["ees4","fih3","b6"] == ["E♭4","F𝄲3","B6"]
--   
pitch_parse_hly :: String -> Pitch instance GHC.Show.Show Music.Theory.Pitch.Pitch instance GHC.Classes.Eq Music.Theory.Pitch.Pitch instance GHC.Show.Show Music.Theory.Pitch.Pitch_R instance GHC.Classes.Eq Music.Theory.Pitch.Pitch_R instance GHC.Classes.Ord Music.Theory.Pitch.Pitch -- | Simple table based spelling rules for common music notation. module Music.Theory.Pitch.Spelling.Table type Spelling_Table i = [(i, (Note, Alteration))] -- | Spelling table for natural (♮) notes only. pc_spell_natural_tbl :: Integral i => Spelling_Table i -- | Spelling table for sharp (♯) notes only. pc_spell_sharp_tbl :: Integral i => Spelling_Table i -- | Spelling table for flat (♭) notes only. pc_spell_flat_tbl :: Integral i => Spelling_Table i -- | Spelling table from simplest key-signature. Note that this is -- ambiguous for 8, which could be either G Sharp (♯) in A -- Major or A Flat (♭) in E Flat (♭) Major. pc_spell_ks_tbl :: Integral i => Spelling_Table i pc_spell_tbl :: Integral i => Spelling_Table i -> Spelling i -- | Spell using indicated table prepended to and -- pc_spell_natural_tbl and pc_spell_ks_tbl pc_spell_tbl_ks :: Integral i => Spelling_Table i -> Spelling i -- | Spelling for natural (♮) notes only. -- --
--   map pc_spell_natural_m [0,1] == [Just (C,Natural),Nothing]
--   
pc_spell_natural_m :: Integral i => Spelling_M i -- | Erroring variant of pc_spell_natural_m. -- --
--   map pc_spell_natural [0,5,7] == [(C,Natural),(F,Natural),(G,Natural)]
--   
pc_spell_natural :: Integral i => Spelling i -- | Lookup pc_spell_ks_tbl. -- --
--   map pc_spell_ks [6,8] == [(F,Sharp),(A,Flat)]
--   
pc_spell_ks :: Integral i => Spelling i -- | Use always sharp (♯) spelling. -- --
--   map pc_spell_sharp [6,8] == [(F,Sharp),(G,Sharp)]
--   Data.List.nub (map (snd . pc_spell_sharp) [1,3,6,8,10]) == [Sharp]
--   
pc_spell_sharp :: Integral i => Spelling i -- | Use always flat (♭) spelling. -- --
--   map pc_spell_flat [6,8] == [(G,Flat),(A,Flat)]
--   Data.List.nub (map (snd . pc_spell_flat) [1,3,6,8,10]) == [Flat]
--   
pc_spell_flat :: Integral i => Spelling i octpc_to_pitch_ks :: Integral i => Octave_PitchClass i -> Pitch -- | midi_to_pitch pc_spell_ks. midi_to_pitch_ks :: Integral i => i -> Pitch fmidi_to_pitch_ks :: (Show n, RealFrac n) => n -> Pitch midi_detune_to_pitch_ks :: (Integral m, Real c) => (m, c) -> Pitch -- | midi_to_pitch pc_spell_sharp midi_to_pitch_sharp :: Integral i => i -> Pitch -- | Spelling for chromatic clusters. module Music.Theory.Pitch.Spelling.Cluster -- | Form of cluster with smallest outer boundary interval. -- --
--   cluster_normal_order [0,1,11] == [11,0,1]
--   
cluster_normal_order :: [PitchClass] -> [PitchClass] -- | Normal order starting in indicated octave. -- --
--   cluster_normal_order_octpc 3 [0,1,11] == [(3,11),(4,0),(4,1)]
--   
cluster_normal_order_octpc :: Octave -> [PitchClass] -> [OctPc] -- | True if sort of cluster is not equal to -- cluster_normal_order. -- --
--   map cluster_is_multiple_octave [[0,1,11],[1,2,3],[1,2,11]] == [True,False,True]
--   
cluster_is_multiple_octave :: [PitchClass] -> Bool -- | Spelling table for chromatic and near-chromatic clusters, -- pitch-classes are in cluster order. -- --
--   let f (p,q) = (p == map T.note_alteration_to_pc_err q)
--   in all f spell_cluster_table
--   
spell_cluster_table :: [([PitchClass], [(Note, Alteration)])] spell_cluster :: [PitchClass] -> Maybe [(Note, Alteration)] -- | Spell an arbitrary sequence of OctPc values. -- --
--   fmap (map T.pitch_pp_iso) (spell_cluster_octpc [(3,11),(4,3),(4,11),(5,1)])
--   
spell_cluster_octpc :: [OctPc] -> Maybe [Pitch] -- | Spelling for chromatic clusters. Sequence must be ascending. Pitch -- class 0 maps to c4, if there is no 0 then -- all notes are in octave 4. -- --
--   let f = (fmap (map T.pitch_pp) . spell_cluster_c4)
--   map f [[11,0],[11],[0,11]] == [Just ["B3","C4"],Just ["B4"],Nothing]
--   
-- --
--   fmap (map T.pitch_pp) (spell_cluster_c4 [10,11]) == Just ["A♯4","B4"]
--   
spell_cluster_c4 :: [PitchClass] -> Maybe [Pitch] -- | Variant of spell_cluster_c4 that runs -- pitch_edit_octave. An octave of 4 is the identitiy, -- 3 an octave below, 5 an octave above. -- --
--   fmap (map T.pitch_pp) (spell_cluster_c 3 [11,0]) == Just ["B2","C3"]
--   fmap (map T.pitch_pp) (spell_cluster_c 3 [10,11]) == Just ["A♯3","B3"]
--   
spell_cluster_c :: Octave -> [PitchClass] -> Maybe [Pitch] -- | Variant of spell_cluster_c4 that runs -- pitch_edit_octave so that the left-most note is in the octave -- given by f. -- --
--   import Data.Maybe
--   
-- --
--   let f n = if n >= 11 then 3 else 4
--   let g = map T.pitch_pp .fromJust . spell_cluster_f f
--   let r = [["B3","C4"],["B3"],["C4"],["A♯4","B4"]]
--   map g [[11,0],[11],[0],[10,11]] == r
--   
-- --
--   map (spell_cluster_f (const 4)) [[0,11],[11,0],[6,7],[7,6]]
--   
spell_cluster_f :: (PitchClass -> Octave) -> [PitchClass] -> Maybe [Pitch] -- | Variant of spell_cluster_c4 that runs -- pitch_edit_octave so that the left-most note is in octave -- o. -- --
--   fmap (map T.pitch_pp) (spell_cluster_left 3 [11,0]) == Just ["B3","C4"]
--   fmap (map T.pitch_pp) (spell_cluster_left 3 [10,11]) == Just ["A♯3","B3"]
--   
spell_cluster_left :: Octave -> [PitchClass] -> Maybe [Pitch] -- | Constants names for Pitch values. eses indicates double -- flat, eseh three quarter tone flat, es flat, eh -- quarter tone flat, ih quarter tone sharp, is sharp, -- isih three quarter tone sharp and isis double sharp. module Music.Theory.Pitch.Name a0 :: Pitch b0 :: Pitch bes0 :: Pitch ais0 :: Pitch bis0 :: Pitch c1 :: Pitch d1 :: Pitch e1 :: Pitch f1 :: Pitch g1 :: Pitch a1 :: Pitch b1 :: Pitch ces1 :: Pitch des1 :: Pitch ees1 :: Pitch fes1 :: Pitch ges1 :: Pitch aes1 :: Pitch bes1 :: Pitch cis1 :: Pitch dis1 :: Pitch eis1 :: Pitch fis1 :: Pitch gis1 :: Pitch ais1 :: Pitch bis1 :: Pitch c2 :: Pitch d2 :: Pitch e2 :: Pitch f2 :: Pitch g2 :: Pitch a2 :: Pitch b2 :: Pitch ces2 :: Pitch des2 :: Pitch ees2 :: Pitch fes2 :: Pitch ges2 :: Pitch aes2 :: Pitch bes2 :: Pitch cis2 :: Pitch dis2 :: Pitch eis2 :: Pitch fis2 :: Pitch gis2 :: Pitch ais2 :: Pitch bis2 :: Pitch cisis2 :: Pitch disis2 :: Pitch eisis2 :: Pitch fisis2 :: Pitch gisis2 :: Pitch aisis2 :: Pitch bisis2 :: Pitch ceseh2 :: Pitch deseh2 :: Pitch eeseh2 :: Pitch feseh2 :: Pitch geseh2 :: Pitch aeseh2 :: Pitch beseh2 :: Pitch ceh2 :: Pitch deh2 :: Pitch eeh2 :: Pitch feh2 :: Pitch geh2 :: Pitch aeh2 :: Pitch beh2 :: Pitch cih2 :: Pitch dih2 :: Pitch eih2 :: Pitch fih2 :: Pitch gih2 :: Pitch aih2 :: Pitch bih2 :: Pitch cisih2 :: Pitch disih2 :: Pitch eisih2 :: Pitch fisih2 :: Pitch gisih2 :: Pitch aisih2 :: Pitch bisih2 :: Pitch c3 :: Pitch d3 :: Pitch e3 :: Pitch f3 :: Pitch g3 :: Pitch a3 :: Pitch b3 :: Pitch ces3 :: Pitch des3 :: Pitch ees3 :: Pitch fes3 :: Pitch ges3 :: Pitch aes3 :: Pitch bes3 :: Pitch cis3 :: Pitch dis3 :: Pitch eis3 :: Pitch fis3 :: Pitch gis3 :: Pitch ais3 :: Pitch bis3 :: Pitch ceses3 :: Pitch deses3 :: Pitch eeses3 :: Pitch feses3 :: Pitch geses3 :: Pitch aeses3 :: Pitch beses3 :: Pitch cisis3 :: Pitch disis3 :: Pitch eisis3 :: Pitch fisis3 :: Pitch gisis3 :: Pitch aisis3 :: Pitch bisis3 :: Pitch ceseh3 :: Pitch deseh3 :: Pitch eeseh3 :: Pitch feseh3 :: Pitch geseh3 :: Pitch aeseh3 :: Pitch beseh3 :: Pitch ceh3 :: Pitch deh3 :: Pitch eeh3 :: Pitch feh3 :: Pitch geh3 :: Pitch aeh3 :: Pitch beh3 :: Pitch cih3 :: Pitch dih3 :: Pitch eih3 :: Pitch fih3 :: Pitch gih3 :: Pitch aih3 :: Pitch bih3 :: Pitch cisih3 :: Pitch disih3 :: Pitch eisih3 :: Pitch fisih3 :: Pitch gisih3 :: Pitch aisih3 :: Pitch bisih3 :: Pitch c4 :: Pitch d4 :: Pitch e4 :: Pitch f4 :: Pitch g4 :: Pitch a4 :: Pitch b4 :: Pitch ces4 :: Pitch des4 :: Pitch ees4 :: Pitch fes4 :: Pitch ges4 :: Pitch aes4 :: Pitch bes4 :: Pitch cis4 :: Pitch dis4 :: Pitch eis4 :: Pitch fis4 :: Pitch gis4 :: Pitch ais4 :: Pitch bis4 :: Pitch ceses4 :: Pitch deses4 :: Pitch eeses4 :: Pitch feses4 :: Pitch geses4 :: Pitch aeses4 :: Pitch beses4 :: Pitch cisis4 :: Pitch disis4 :: Pitch eisis4 :: Pitch fisis4 :: Pitch gisis4 :: Pitch aisis4 :: Pitch bisis4 :: Pitch ceseh4 :: Pitch deseh4 :: Pitch eeseh4 :: Pitch feseh4 :: Pitch geseh4 :: Pitch aeseh4 :: Pitch beseh4 :: Pitch ceh4 :: Pitch deh4 :: Pitch eeh4 :: Pitch feh4 :: Pitch geh4 :: Pitch aeh4 :: Pitch beh4 :: Pitch cih4 :: Pitch dih4 :: Pitch eih4 :: Pitch fih4 :: Pitch gih4 :: Pitch aih4 :: Pitch bih4 :: Pitch cisih4 :: Pitch disih4 :: Pitch eisih4 :: Pitch fisih4 :: Pitch gisih4 :: Pitch aisih4 :: Pitch bisih4 :: Pitch c5 :: Pitch d5 :: Pitch e5 :: Pitch f5 :: Pitch g5 :: Pitch a5 :: Pitch b5 :: Pitch ces5 :: Pitch des5 :: Pitch ees5 :: Pitch fes5 :: Pitch ges5 :: Pitch aes5 :: Pitch bes5 :: Pitch cis5 :: Pitch dis5 :: Pitch eis5 :: Pitch fis5 :: Pitch gis5 :: Pitch ais5 :: Pitch bis5 :: Pitch ceses5 :: Pitch deses5 :: Pitch eeses5 :: Pitch feses5 :: Pitch geses5 :: Pitch aeses5 :: Pitch beses5 :: Pitch cisis5 :: Pitch disis5 :: Pitch eisis5 :: Pitch fisis5 :: Pitch gisis5 :: Pitch aisis5 :: Pitch bisis5 :: Pitch ceseh5 :: Pitch deseh5 :: Pitch eeseh5 :: Pitch feseh5 :: Pitch geseh5 :: Pitch aeseh5 :: Pitch beseh5 :: Pitch ceh5 :: Pitch deh5 :: Pitch eeh5 :: Pitch feh5 :: Pitch geh5 :: Pitch aeh5 :: Pitch beh5 :: Pitch cih5 :: Pitch dih5 :: Pitch eih5 :: Pitch fih5 :: Pitch gih5 :: Pitch aih5 :: Pitch bih5 :: Pitch cisih5 :: Pitch disih5 :: Pitch eisih5 :: Pitch fisih5 :: Pitch gisih5 :: Pitch aisih5 :: Pitch bisih5 :: Pitch c6 :: Pitch d6 :: Pitch e6 :: Pitch f6 :: Pitch g6 :: Pitch a6 :: Pitch b6 :: Pitch ces6 :: Pitch des6 :: Pitch ees6 :: Pitch fes6 :: Pitch ges6 :: Pitch aes6 :: Pitch bes6 :: Pitch cis6 :: Pitch dis6 :: Pitch eis6 :: Pitch fis6 :: Pitch gis6 :: Pitch ais6 :: Pitch bis6 :: Pitch ceseh6 :: Pitch deseh6 :: Pitch eeseh6 :: Pitch feseh6 :: Pitch geseh6 :: Pitch aeseh6 :: Pitch beseh6 :: Pitch ceh6 :: Pitch deh6 :: Pitch eeh6 :: Pitch feh6 :: Pitch geh6 :: Pitch aeh6 :: Pitch beh6 :: Pitch cih6 :: Pitch dih6 :: Pitch eih6 :: Pitch fih6 :: Pitch gih6 :: Pitch aih6 :: Pitch bih6 :: Pitch cisih6 :: Pitch disih6 :: Pitch eisih6 :: Pitch fisih6 :: Pitch gisih6 :: Pitch aisih6 :: Pitch bisih6 :: Pitch c7 :: Pitch d7 :: Pitch e7 :: Pitch f7 :: Pitch g7 :: Pitch a7 :: Pitch b7 :: Pitch ces7 :: Pitch des7 :: Pitch ees7 :: Pitch fes7 :: Pitch ges7 :: Pitch aes7 :: Pitch bes7 :: Pitch cis7 :: Pitch dis7 :: Pitch eis7 :: Pitch fis7 :: Pitch gis7 :: Pitch ais7 :: Pitch bis7 :: Pitch c8 :: Pitch cis8 :: Pitch d8 :: Pitch -- | Common music notation intervals. module Music.Theory.Interval -- | Interval type or degree. data Interval_Type Unison :: Interval_Type Second :: Interval_Type Third :: Interval_Type Fourth :: Interval_Type Fifth :: Interval_Type Sixth :: Interval_Type Seventh :: Interval_Type -- | Interval quality. data Interval_Quality Diminished :: Interval_Quality Minor :: Interval_Quality Perfect :: Interval_Quality Major :: Interval_Quality Augmented :: Interval_Quality -- | Common music notation interval. An Ordering of LT -- indicates an ascending interval, GT a descending interval, and -- EQ a unison. data Interval Interval :: Interval_Type -> Interval_Quality -> Ordering -> Octave -> Interval [interval_type] :: Interval -> Interval_Type [interval_quality] :: Interval -> Interval_Quality [interval_direction] :: Interval -> Ordering [interval_octave] :: Interval -> Octave -- | Interval type between Note values. -- --
--   map (interval_ty C) [E,B] == [Third,Seventh]
--   
interval_ty :: Note -> Note -> Interval_Type -- | Table of interval qualities. For each Interval_Type gives -- directed semitone interval counts for each allowable -- Interval_Quality. For lookup function see interval_q, -- for reverse lookup see interval_q_reverse. interval_q_tbl :: Integral n => [(Interval_Type, [(n, Interval_Quality)])] -- | Lookup Interval_Quality for given Interval_Type and -- semitone count. -- --
--   interval_q Unison 11 == Just Diminished
--   interval_q Third 5 == Just Augmented
--   interval_q Fourth 5 == Just Perfect
--   interval_q Unison 3 == Nothing
--   
interval_q :: Interval_Type -> Int -> Maybe Interval_Quality -- | Lookup semitone difference of Interval_Type with -- Interval_Quality. -- --
--   interval_q_reverse Third Minor == Just 3
--   interval_q_reverse Unison Diminished == Just 11
--   
interval_q_reverse :: Interval_Type -> Interval_Quality -> Maybe Int -- | Semitone difference of Interval. -- --
--   interval_semitones (interval (Pitch C Sharp 4) (Pitch E Sharp 5)) == 16
--   interval_semitones (interval (Pitch C Natural 4) (Pitch D Sharp 3)) == -9
--   
interval_semitones :: Interval -> Int -- | Determine Interval between two Pitches. -- --
--   interval (T.Pitch T.C T.Sharp 4) (T.Pitch T.D T.Flat 4) == Interval Second Diminished EQ 0
--   interval (T.Pitch T.C T.Sharp 4) (T.Pitch T.E T.Sharp 5) == Interval Third Major LT 1
--   
interval :: Pitch -> Pitch -> Interval -- | Apply ord_invert to interval_direction of -- Interval. -- --
--   invert_interval (Interval Third Major LT 1) == Interval Third Major GT 1
--   
invert_interval :: Interval -> Interval -- | The signed difference in semitones between two Interval_Quality -- values when applied to the same Interval_Type. Can this be -- written correctly without knowing the Interval_Type? -- --
--   quality_difference_m Minor Augmented == Just 2
--   quality_difference_m Augmented Diminished == Just (-3)
--   quality_difference_m Major Perfect == Nothing
--   
quality_difference_m :: Interval_Quality -> Interval_Quality -> Maybe Int -- | Erroring variant of quality_difference_m. quality_difference :: Interval_Quality -> Interval_Quality -> Int -- | Transpose a Pitch by an Interval. -- --
--   transpose (Interval Third Diminished LT 0) (Pitch C Sharp 4) == Pitch E Flat 4
--   
pitch_transpose :: Interval -> Pitch -> Pitch -- | Make leftwards (perfect fourth) and and rightwards (perfect fifth) -- circles from Pitch. -- --
--   let c = circle_of_fifths (Pitch F Sharp 4)
--   in map pitch_to_pc (snd c) == [6,1,8,3,10,5,12,7,2,9,4,11]
--   
circle_of_fifths :: Pitch -> ([Pitch], [Pitch]) -- | Parse a positive integer into interval type and octave displacement. -- --
--   mapMaybe parse_interval_type (map show [1 .. 15])
--   
parse_interval_type :: String -> Maybe (Interval_Type, Octave) -- | Parse interval quality notation. -- --
--   mapMaybe parse_interval_quality "dmPMA" == [minBound .. maxBound]
--   
parse_interval_quality :: Char -> Maybe Interval_Quality -- | Degree of interval type and octave displacement. Inverse of -- parse_interval_type. -- --
--   map interval_type_degree [(Third,0),(Second,1),(Unison,2)] == [3,9,15]
--   
interval_type_degree :: (Interval_Type, Octave) -> Int -- | Inverse of 'parse_interval_quality. interval_quality_pp :: Interval_Quality -> Char -- | Parse standard common music interval notation. -- --
--   let i = mapMaybe parse_interval (words "P1 d2 m2 M2 A3 P8 +M9 -M2")
--   in unwords (map interval_pp i) == "P1 d2 m2 M2 A3 P8 M9 -M2"
--   
-- --
--   mapMaybe (fmap interval_octave . parse_interval) (words "d1 d8 d15") == [-1,0,1]
--   
parse_interval :: String -> Maybe Interval -- | error variant. parse_interval_err :: String -> Interval -- | Pretty printer for intervals, inverse of parse_interval. interval_pp :: Interval -> String -- | Standard names for the intervals within the octave, divided into -- perfect, major and minor at the left, and diminished and augmented at -- the right. -- --
--   let {bimap f (p,q) = (f p,f q)
--       ;f = mapMaybe (fmap interval_semitones . parse_interval)}
--   in bimap f std_interval_names
--   
std_interval_names :: ([String], [String]) instance GHC.Show.Show Music.Theory.Interval.Interval_Type instance GHC.Classes.Ord Music.Theory.Interval.Interval_Type instance GHC.Enum.Bounded Music.Theory.Interval.Interval_Type instance GHC.Enum.Enum Music.Theory.Interval.Interval_Type instance GHC.Classes.Eq Music.Theory.Interval.Interval_Type instance GHC.Show.Show Music.Theory.Interval.Interval_Quality instance GHC.Classes.Ord Music.Theory.Interval.Interval_Quality instance GHC.Enum.Bounded Music.Theory.Interval.Interval_Quality instance GHC.Enum.Enum Music.Theory.Interval.Interval_Quality instance GHC.Classes.Eq Music.Theory.Interval.Interval_Quality instance GHC.Show.Show Music.Theory.Interval.Interval instance GHC.Classes.Eq Music.Theory.Interval.Interval -- | Common music keys. module Music.Theory.Key -- | Enumeration of common music notation modes. data Mode Minor_Mode :: Mode Major_Mode :: Mode -- | Pretty printer for Mode. mode_pp :: Mode -> String -- | Lower-cased mode_pp. mode_identifier_pp :: Mode -> String -- | There are two modes, given one return the other. mode_parallel :: Mode -> Mode mode_pc_seq :: Num t => Mode -> [t] -- | A common music notation key is a Note, Alteration, -- Mode triple. type Key = (Note, Alteration, Mode) -- | Mode of Key. key_mode :: Key -> Mode -- | Enumeration of 42 CMN keys. -- --
--   length key_sequence_42 == 7 * 3 * 2
--   
key_sequence_42 :: [Key] -- | Subset of key_sequence not including very eccentric keys -- (where there are more than 7 alterations). -- --
--   length key_sequence_30 == 30
--   
key_sequence_30 :: [Key] -- | Parallel key, ie. mode_parallel of Key. key_parallel :: Key -> Key -- | Transposition of Key. key_transpose :: Key -> Int -> Key -- | Relative key (ie. mode_parallel with the same number of and -- type of alterations. -- --
--   let k = [(T.C,T.Natural,Major_Mode),(T.E,T.Natural,Minor_Mode)]
--   in map (key_lc_uc_pp . key_relative) k == ["a♮","G♮"]
--   
key_relative :: Key -> Key -- | Mediant minor of major key. -- --
--   key_mediant (T.C,T.Natural,Major_Mode) == Just (T.E,T.Natural,Minor_Mode)
--   
key_mediant :: Key -> Maybe Key key_pc_set :: Integral i => Key -> [i] -- | Pretty-printer where Minor_Mode is written in lower case (lc) -- and alteration symbol is shown using indicated function. key_lc_pp :: (Alteration -> String) -> Key -> String -- | key_lc_pp with unicode (uc) alteration. -- --
--   map key_lc_uc_pp [(C,Sharp,Minor_Mode),(E,Flat,Major_Mode)] == ["c♯","E♭"]
--   
key_lc_uc_pp :: Key -> String -- | key_lc_pp with ISO alteration. key_lc_iso_pp :: Key -> String -- | key_lc_pp with tonh alteration. -- --
--   map key_lc_tonh_pp [(T.C,T.Sharp,Minor_Mode),(T.E,T.Flat,Major_Mode)]
--   
key_lc_tonh_pp :: Key -> String key_identifier_pp :: (Show a, Show a1) => (a, a1, Mode) -> [Char] note_char_to_key :: Char -> Maybe Key -- | Parse Key from lc-uc string. -- --
--   let k = mapMaybe key_lc_uc_parse ["c","E","f♯","ab","G#"]
--   map key_lc_uc_pp k == ["c♮","E♮","f♯","a♭","G♯"]
--   
key_lc_uc_parse :: String -> Maybe Key -- | Distance along circle of fifths path of indicated Key. A -- positive number indicates the number of sharps, a negative number the -- number of flats. -- --
--   key_fifths (T.A,T.Natural,Minor_Mode) == Just 0
--   key_fifths (T.A,T.Natural,Major_Mode) == Just 3
--   key_fifths (T.C,T.Natural,Minor_Mode) == Just (-3)
--   key_fifths (T.B,T.Sharp,Minor_Mode) == Just 9
--   key_fifths (T.E,T.Sharp,Major_Mode) == Just 11
--   key_fifths (T.B,T.Sharp,Major_Mode) == Nothing
--   
-- --
--   zip (map key_lc_iso_pp key_sequence_42) (map key_fifths key_sequence_42)
--   
key_fifths :: Key -> Maybe Int -- | Table mapping Key to key_fifths value. key_fifths_tbl :: [(Key, Int)] -- | Lookup key_fifths value in key_fifths_tbl. -- --
--   let a = [0,1,-1,2,-2,3,-3,4,-4,5,-5]
--   let f md = map key_lc_iso_pp . mapMaybe (fifths_to_key md)
--   f Minor_Mode a
--   f Major_Mode a
--   
fifths_to_key :: Mode -> Int -> Maybe Key -- | Given sorted pitch-class set, find simplest implied key in given mode. -- --
--   mapMaybe (implied_key Major_Mode) [[0,2,4],[1,3],[4,10],[3,9],[8,9]]
--   map (implied_key Major_Mode) [[0,1,2],[0,1,3,4]] == [Nothing,Nothing]
--   
implied_key :: Integral i => Mode -> [i] -> Maybe Key -- | key_fifths of implied_key. implied_fifths :: Integral i => Mode -> [i] -> Maybe Int implied_key_err :: Integral i => Mode -> [i] -> Key implied_fifths_err :: Integral i => Mode -> [i] -> Int instance GHC.Show.Show Music.Theory.Key.Mode instance GHC.Classes.Ord Music.Theory.Key.Mode instance GHC.Classes.Eq Music.Theory.Key.Mode module Music.Theory.Pitch.Spelling.Key pcset_spell_implied_key_f :: Integral i => [i] -> Maybe (Spelling i) pcset_spell_implied_key :: Integral i => [i] -> Maybe [(Note, Alteration)] octpc_spell_implied_key :: [OctPc] -> Maybe [Pitch] midi_spell_implied_key :: [Midi] -> Maybe [Pitch] -- | Spelling rules for common music notation. module Music.Theory.Pitch.Spelling spell_octpc_set :: [OctPc] -> [Pitch] spell_midi_set :: Integral i => [i] -> [Pitch] module Music.Theory.Pitch.Chord type Pc = (Note, Alteration) pc_pp :: Pc -> [Char] -- | D = dominant, M = major data Extension D7 :: Extension M7 :: Extension extension_tbl :: Num n => [(Extension, (String, n))] extension_dat :: Num n => Extension -> (String, n) extension_pp :: Extension -> String extension_to_pc :: Num n => Extension -> n data Chord_Type Major :: Chord_Type Minor :: Chord_Type Augmented :: Chord_Type Diminished :: Chord_Type Diminished_7 :: Chord_Type Half_Diminished :: Chord_Type Suspended_2 :: Chord_Type Suspended_4 :: Chord_Type is_suspended :: Chord_Type -> Bool -- | Names and pc-sets for chord types. The name used here is in the first -- position, alternates follow. chord_type_tbl :: Num n => [(Chord_Type, ([String], [n]))] chord_type_dat :: Num n => Chord_Type -> ([String], [n]) chord_type_pp :: Chord_Type -> String chord_type_pcset :: Num n => Chord_Type -> [n] data Chord Chord :: Pc -> Chord_Type -> Maybe Extension -> Maybe Pc -> Chord chord_pcset :: Chord -> (Maybe Int, [Int]) bass_pp :: Pc -> String chord_pp :: Chord -> String m_error :: String -> Maybe a -> a p_pc :: P Pc p_mode_m :: P Mode p_chord_type :: P Chord_Type p_extension :: P Extension p_bass :: P (Maybe Pc) p_chord :: P Chord -- | Parse chord. -- --
--   let ch = words "CmM7 C#o EbM7 Fo7 Gx/D C/E GØ/F Bbsus4/C E7sus2"
--   let c = map parse_chord ch
--   map chord_pp c == ch
--   map chord_pcset c
--   
parse_chord :: String -> Chord instance GHC.Show.Show Music.Theory.Pitch.Chord.Extension instance GHC.Classes.Eq Music.Theory.Pitch.Chord.Extension instance GHC.Show.Show Music.Theory.Pitch.Chord.Chord_Type instance GHC.Classes.Eq Music.Theory.Pitch.Chord.Chord_Type instance GHC.Show.Show Music.Theory.Pitch.Chord.Chord -- | Spelling rules for Interval values. module Music.Theory.Interval.Spelling -- | Simplest spelling for semitone intervals. This is ambiguous for -- 6 which could be either aug.4 or dim.5. -- --
--   i_to_interval 6 == Interval Fourth Augmented LT 0
--   map i_to_interval [0..11]
--   
i_to_interval :: Int -> Interval -- | Perform some interval simplifications. For non-tonal music some -- spellings are poor, ie. (f,g#). -- --
--   interval_simplify (Interval Second Augmented LT 0) == Interval Third Minor LT 0
--   interval_simplify (Interval Seventh Augmented GT 0) == Interval Unison Perfect GT 1
--   
interval_simplify :: Interval -> Interval -- | Constants names for ascending Interval values. module Music.Theory.Interval.Name perfect_fourth :: Interval perfect_fifth :: Interval major_seventh :: Interval -- | Common music notation clefs. module Music.Theory.Clef -- | Clef enumeration type. data Clef_Type Bass :: Clef_Type Tenor :: Clef_Type Alto :: Clef_Type Treble :: Clef_Type Percussion :: Clef_Type -- | Clef with octave offset. data Clef i Clef :: Clef_Type -> i -> Clef i [clef_t] :: Clef i -> Clef_Type [clef_octave] :: Clef i -> i -- | Give clef range as a Pitch pair indicating the notes below and -- above the staff. -- --
--   map clef_range [Treble,Bass] == [Just (d4,g5),Just (f2,b3)]
--   clef_range Percussion == Nothing
--   
clef_range :: Clef_Type -> Maybe (Pitch, Pitch) -- | Suggest a Clef given a Pitch. -- --
--   map clef_suggest [c2,c4] == [Clef Bass (-1),Clef Treble 0]
--   
clef_suggest :: Integral i => Pitch -> Clef i -- | Set clef_octave to 0. clef_zero :: Integral i => Clef i -> Clef i -- | Set clef_octave to be no further than r from 0. clef_restrict :: Integral i => i -> Clef i -> Clef i instance GHC.Show.Show Music.Theory.Clef.Clef_Type instance GHC.Classes.Ord Music.Theory.Clef.Clef_Type instance GHC.Classes.Eq Music.Theory.Clef.Clef_Type instance GHC.Show.Show i => GHC.Show.Show (Music.Theory.Clef.Clef i) instance GHC.Classes.Ord i => GHC.Classes.Ord (Music.Theory.Clef.Clef i) instance GHC.Classes.Eq i => GHC.Classes.Eq (Music.Theory.Clef.Clef i) module Music.Theory.Instrument.Choir -- | Voice types. data Voice Bass :: Voice Tenor :: Voice Alto :: Voice Soprano :: Voice -- | Single character abbreviation for Voice. voice_abbrev :: Voice -> Char -- | Standard Clef for Voice. voice_clef :: Integral i => Voice -> Clef i -- | Table giving ranges for Voices. type Voice_Rng_Tbl = [(Voice, (Pitch, Pitch))] -- | More or less standard choir ranges, inclusive. voice_rng_tbl_std :: Voice_Rng_Tbl -- | More conservative ranges, inclusive. voice_rng_tbl_safe :: Voice_Rng_Tbl -- | Lookup voice range table. voice_rng :: Voice_Rng_Tbl -> Voice -> (Pitch, Pitch) -- | Lookup voice_rng_tbl_std. voice_rng_std :: Voice -> (Pitch, Pitch) -- | Lookup voice_rng_tbl_safe. voice_rng_safe :: Voice -> (Pitch, Pitch) -- | Is p >= l and <= r. in_range_inclusive :: Ord a => a -> (a, a) -> Bool -- | Is p in range for v, (std & safe). -- --
--   map (in_voice_rng T.c4) [Bass .. Soprano]
--   
in_voice_rng :: Pitch -> Voice -> (Bool, Bool) -- | Given tbl list Voices that can sing Pitch. possible_voices :: Voice_Rng_Tbl -> Pitch -> [Voice] -- | std variant. possible_voices_std :: Pitch -> [Voice] -- | safe variant. possible_voices_safe :: Pitch -> [Voice] -- | Enumeration of SATB voices. satb :: [Voice] -- | Names of satb. satb_name :: [String] -- | voice_abbrev of satb as Strings. satb_abbrev :: [String] -- | Voice & part number. type Part = (Voice, Int) -- | k part choir, ordered by voice. ch_satb_seq :: Int -> [Part] -- | ch_satb_seq grouped in parts. -- --
--   map (map part_nm) (ch_parts 8)
--   
ch_parts :: Int -> [[Part]] -- | Abreviated name for part. -- --
--   part_nm (Soprano,1) == "S1"
--   
part_nm :: Part -> String -- | k SATB choirs, grouped by choir. -- --
--   k_ch_groups 2
--   
k_ch_groups :: Int -> [[Part]] -- | concat of k_ch_groups. k_ch_groups' :: Int -> [Part] -- | Two k part SATB choirs in score order. -- --
--   map part_nm (concat (dbl_ch_parts 8))
--   
dbl_ch_parts :: Int -> [[Part]] -- | voice_clef for Parts. mk_clef_seq :: [Part] -> [Clef Int] instance GHC.Show.Show Music.Theory.Instrument.Choir.Voice instance GHC.Enum.Bounded Music.Theory.Instrument.Choir.Voice instance GHC.Enum.Enum Music.Theory.Instrument.Choir.Voice instance GHC.Classes.Ord Music.Theory.Instrument.Choir.Voice instance GHC.Classes.Eq Music.Theory.Instrument.Choir.Voice -- | Clarence Barlow. "Two Essays on Theory". Computer Music -- Journal, 11(1):44-60, 1987. Translated by Henning Lohner. module Music.Theory.Interval.Barlow_1987 -- | Barlow's indigestibility function for prime numbers. -- --
--   map barlow [1,2,3,5,7,11,13] == [0,1,8/3,32/5,72/7,200/11,288/13]
--   
barlow :: (Integral a, Fractional b) => a -> b -- | Compute the disharmonicity of the interval (p,q) using the -- prime valuation function pv. -- --
--   map (disharmonicity barlow) [(9,10),(8,9)] == ([12 + 11/15,8 + 1/3] :: [Rational])
--   
disharmonicity :: (Integral a, Num b) => (a -> b) -> (a, a) -> b -- | The reciprocal of disharmonicity. -- --
--   map (harmonicity barlow) [(9,10),(8,9),(2,1)] == ([15/191,3/25,1] :: [Rational])
--   
harmonicity :: (Integral a, Fractional b) => (a -> b) -> (a, a) -> b harmonicity_m :: (Eq b, Integral a, Fractional b) => (a -> b) -> (a, a) -> Maybe b -- | Variant of harmonicity with Ratio input. -- --
--   harmonicity_r barlow 1 == 1/0
--   
harmonicity_r :: (Integral a, Fractional b) => (a -> b) -> Ratio a -> b -- | Variant of harmonicity_r with output in (0,100), infinity maps -- to 100. harmonicity_r_100 :: (RealFrac b, Integral a) => (a -> b) -> Ratio a -> Int -- | Set of 1. interval size (cents), 2. intervals as product of powers of -- primes, 3. frequency ratio and 4. harmonicity value. type Table_2_Row = (Double, [Int], Rational, Double) -- | Given ratio r generate Table_2_Row mk_table_2_row :: Rational -> Table_2_Row -- | Table 2 (p.45) -- --
--   length (table_2 0.06) == 24
--   length (table_2 0.04) == 66
--   
table_2 :: Double -> [Table_2_Row] -- | Pretty printer for Table_2_Row values. -- --
--   mapM_ (putStrLn . table_2_pp) (table_2 0.06)
--   
-- --
--   >    0.000 |  0  0  0  0  0  0 |  1:1  | Infinity
--   >  111.731 |  4 -1 -1  0  0  0 | 15:16 | 0.076531
--   >  182.404 |  1 -2  1  0  0  0 |  9:10 | 0.078534
--   >  203.910 | -3  2  0  0  0  0 |  8:9  | 0.120000
--   >  231.174 |  3  0  0 -1  0  0 |  7:8  | 0.075269
--   >  266.871 | -1 -1  0  1  0  0 |  6:7  | 0.071672
--   >  294.135 |  5 -3  0  0  0  0 | 27:32 | 0.076923
--   >  315.641 |  1  1 -1  0  0  0 |  5:6  | 0.099338
--   >  386.314 | -2  0  1  0  0  0 |  4:5  | 0.119048
--   >  407.820 | -6  4  0  0  0  0 | 64:81 | 0.060000
--   >  435.084 |  0  2  0 -1  0  0 |  7:9  | 0.064024
--   >  498.045 |  2 -1  0  0  0  0 |  3:4  | 0.214286
--   >  519.551 | -2  3 -1  0  0  0 | 20:27 | 0.060976
--   >  701.955 | -1  1  0  0  0  0 |  2:3  | 0.272727
--   >  764.916 |  1 -2  0  1  0  0 |  9:14 | 0.060172
--   >  813.686 |  3  0 -1  0  0  0 |  5:8  | 0.106383
--   >  884.359 |  0 -1  1  0  0  0 |  3:5  | 0.110294
--   >  905.865 | -4  3  0  0  0  0 | 16:27 | 0.083333
--   >  933.129 |  2  1  0 -1  0  0 |  7:12 | 0.066879
--   >  968.826 | -2  0  0  1  0  0 |  4:7  | 0.081395
--   >  996.090 |  4 -2  0  0  0  0 |  9:16 | 0.107143
--   > 1017.596 |  0  2 -1  0  0  0 |  5:9  | 0.085227
--   > 1088.269 | -3  1  1  0  0  0 |  8:15 | 0.082873
--   > 1200.000 |  1  0  0  0  0  0 |  1:2  | 1.000000
--   
table_2_pp :: Table_2_Row -> String -- | Anamark tuning (TUN) files -- -- https://www.mark-henning.de/files/am/Tuning_File_V2_Doc.pdf module Music.Theory.Tuning.Anamark -- | Format section string tun_sec :: String -> String -- | Format String (text) attribute tun_attr_txt :: (String, String) -> String -- | Format Int attribute tun_attr_int :: (String, Int) -> String -- | Format Double attribute tun_attr_real :: (String, Double) -> String -- | TUN V.200 Scale Begin (header) section. tun_begin :: [String] -- | Format Info section given Name and ID (the only required -- fields). -- --
--   tun_info ("name","id")
--   
tun_info :: (String, String) -> [String] -- | Format Tuning section given sequence of 128 integral cents -- values. -- --
--   tun_tuning [0,100.. 12700]
--   
tun_tuning :: [Int] -> [String] -- | The default base frequency for Exact Tuning (A4=440) tun_f0_default :: Double -- | Format Exact Tuning section given base frequency and sequence -- of 128 real cents values. -- --
--   tun_exact_tuning tun_f0_default [0,100.. 12700]
--   
tun_exact_tuning :: Double -> [Double] -> [String] -- | Format Functional Tuning section given base frequency and -- sequence of 128 real cents values. -- -- This simply sets note zero to f0 and increments each note by -- the difference from the previous note. -- --
--   tun_functional_tuning tun_f0_default [0,100.. 12700]
--   
tun_functional_tuning :: Double -> [Double] -> [String] -- | Format Scale End section header. tun_end :: [String] -- | Synonym for a list of strings. type TUN = [String] -- | Version 1 has just the Tuning and Exact Tuning. tun_from_cents_version_one :: (Double, [Double]) -> TUN -- | Version 2 files have, in addition, Begin, Info, -- Functional Tuning and End sections. tun_from_cents_version_two :: (String, String) -> (Double, [Double]) -> TUN tun_store :: FilePath -> TUN -> IO () -- | Euler-Fokker genus -- http://www.huygens-fokker.org/microtonality/efg.html module Music.Theory.Tuning.Efg -- | Normal form, value with occurences count (ie. exponent in notation -- above). type Efg i = [(i, Int)] -- | Degree of Efg, ie. sum of exponents. -- --
--   efg_degree [(3,3),(7,2)] == 3 + 2
--   
efg_degree :: Efg i -> Int -- | Number of tones of Efg, ie. product of increment of exponents. -- --
--   efg_tones [(3,3),(7,2)] == (3 + 1) * (2 + 1)
--   
efg_tones :: Efg i -> Int -- | Collate a genus given as a multiset into standard form, ie. histogram. -- --
--   efg_collate [3,3,3,7,7] == [(3,3),(7,2)]
--   
efg_collate :: Ord i => [i] -> Efg i -- | Factors of Efg given with co-ordinate of grid location. -- --
--   efg_factors [(3,3)]
--   
-- --
--   let r = [([0,0],[]),([0,1],[7]),([0,2],[7,7])
--           ,([1,0],[3]),([1,1],[3,7]),([1,2],[3,7,7])
--           ,([2,0],[3,3]),([2,1],[3,3,7]),([2,2],[3,3,7,7])
--           ,([3,0],[3,3,3]),([3,1],[3,3,3,7]),([3,2],[3,3,3,7,7])]
--   
-- --
--   efg_factors [(3,3),(7,2)] == r
--   
efg_factors :: Efg i -> [([Int], [i])] -- | Ratios of Efg, taking n as the 1:1 ratio, with indices, folded -- into one octave. -- --
--   import Data.List
--   let r = sort $ map snd $ efg_ratios 7 [(3,3),(7,2)]
--   r == [1/1,9/8,8/7,9/7,21/16,189/128,3/2,27/16,12/7,7/4,27/14,63/32]
--   map (round . ratio_to_cents) r == [0,204,231,435,471,675,702,906,933,969,1137,1173]
--   
-- -- 0: 1/1 C 0.000 cents 1: 9/8 D 203.910 cents 2: 8/7 D+ 231.174 cents 3: -- 9/7 E+ 435.084 cents 4: 21/16 F- 470.781 cents 5: 189/128 G- 674.691 -- cents 6: 3/2 G 701.955 cents 7: 27/16 A 905.865 cents 8: 12/7 A+ -- 933.129 cents 9: 7/4 Bb- 968.826 cents 10: 27/14 B+ 1137.039 cents 11: -- 63/32 C- 1172.736 cents 12: 2/1 C 1200.000 cents -- --
--   let r' = sort $ map snd $ efg_ratios 5 [(5,2),(7,3)]
--   r' == [1/1,343/320,35/32,49/40,5/4,343/256,7/5,49/32,8/5,1715/1024,7/4,245/128]
--   map (round . ratio_to_cents) r' == [0,120,155,351,386,506,583,738,814,893,969,1124]
--   
-- --
--   let r'' = sort $ map snd $ efg_ratios 3 [(3,1),(5,1),(7,1)]
--   r'' == [1/1,35/32,7/6,5/4,4/3,35/24,5/3,7/4]
--   map (round . ratio_to_cents) r'' == [0,155,267,386,498,653,884,969]
--   
-- --
--   let c0 = [0,204,231,435,471,675,702,906,933,969,1137,1173,1200]
--   let c1 = [0,120,155,351,386,506,583,738,814,893,969,1124,1200]
--   let c2 = [0,155,267,386,498,653,884,969,1200]
--   let f (c',y) = map (\x -> (x,y,x,y + 10)) c'
--   map f (zip [c0,c1,c2] [0,20,40])
--   
efg_ratios :: Real r => Rational -> Efg r -> [([Int], Rational)] -- | Generate a line drawing, as a set of (x0,y0,x1,y1) 4-tuples. h=row -- height, m=distance of vertical mark from row edge, k=distance between -- rows -- --
--   let e = [[3,3,3],[3,3,5],[3,5,5],[3,5,7],[3,7,7],[5,5,5],[5,5,7],[3,3,7],[5,7,7],[7,7,7]]
--   let e = [[3,3,3],[5,5,5],[7,7,7],[3,3,5],[3,5,5],[5,5,7],[5,7,7],[3,7,7],[3,3,7],[3,5,7]]
--   let e' = map efg_collate e
--   efg_diagram_set (round,25,4,75) e'
--   
efg_diagram_set :: (Enum n, Real n) => (Cents -> n, n, n, n) -> [Efg n] -> [(n, n, n, n)] -- | Equal temperament tuning tables. module Music.Theory.Tuning.Et -- | octpc_to_pitch and octpc_to_cps_k0. octpc_to_pitch_cps_k0 :: Floating n => (n, n) -> OctPc -> (Pitch, n) -- | octpc_to_pitch_cps_k0 of (69,440) octpc_to_pitch_cps :: Floating n => OctPc -> (Pitch, n) -- | 12-tone equal temperament table equating Pitch and frequency -- over range of human hearing, where A4 has given frequency. -- --
--   tbl_12et_k0 (69,440)
--   
tbl_12et_k0 :: (Double, Double) -> [(Pitch, Double)] -- | tbl_12et_k0 (69,440). -- --
--   length tbl_12et == 192
--   T.minmax (map (round . snd) tbl_12et) == (1,31609)
--   
tbl_12et :: [(Pitch, Double)] -- | 24-tone equal temperament variant of tbl_12et_k0. tbl_24et_k0 :: (Double, Double) -> [(Pitch, Double)] -- | tbl_24et_k0 (69,440). -- --
--   length tbl_24et == 360
--   T.minmax (map (round . snd) tbl_24et) == (1,32535)
--   
tbl_24et :: [(Pitch, Double)] -- | Given an Et table (or like) find bounds of frequency. -- --
--   import qualified Music.Theory.Tuple as T
--   let r = Just (T.t2_map octpc_to_pitch_cps ((3,11),(4,0)))
--   bounds_et_table tbl_12et 256 == r
--   
bounds_et_table :: Ord s => [(t, s)] -> s -> Maybe ((t, s), (t, s)) -- | bounds_et_table of tbl_12et. -- --
--   import qualified Music.Theory.Tuning.Hs as T
--   map bounds_12et_tone (T.harmonic_series_cps_n 17 55)
--   
bounds_12et_tone :: Double -> Maybe ((Pitch, Double), (Pitch, Double)) -- | Tuple indicating nearest Pitch to frequency with -- Et frequency, and deviation in hertz and Cents. -- -- (cps,nearest-pitch,cps-of-nearest-pitch,cps-deviation,cents-deviation) type HS_R p = (Double, p, Double, Double, Cents) -- | n-decimal places. -- --
--   ndp 3 (1/3) == "0.333"
--   
ndp :: Int -> Double -> String -- | Pretty print HS_R. This discards the cps-deviation -- field, ie. it has only four fields. hs_r_pp :: (p -> String) -> Int -> HS_R p -> [String] -- | hs_r_pp of pitch_pp hs_r_pitch_pp :: Int -> HS_R Pitch -> [String] -- | Form HS_R for frequency by consulting table. -- --
--   let f = 256
--   let f' = octpc_to_cps (4,0)
--   let r = (f,Pitch C Natural 4,f',f-f',fratio_to_cents (f/f'))
--   nearest_et_table_tone tbl_12et 256 == r
--   
nearest_et_table_tone :: [(p, Double)] -> Double -> HS_R p -- | nearest_et_table_tone for tbl_12et_k0. nearest_12et_tone_k0 :: (Double, Double) -> Double -> HS_R Pitch -- | nearest_et_table_tone for tbl_24et. -- --
--   let r = "55.0 A1 55.0 0.0"
--   unwords (hs_r_pitch_pp 1 (nearest_24et_tone_k0 (69,440) 55)) == r
--   
nearest_24et_tone_k0 :: (Double, Double) -> Double -> HS_R Pitch -- | Monzo 72-edo HEWM notation. The domain is (-9,9). -- http://www.tonalsoft.com/enc/number/72edo.aspx -- --
--   let r = ["+",">","^","#<","#-","#","#+","#>","#^"]
--   map alteration_72et_monzo [1 .. 9] == r
--   
-- --
--   let r = ["-","<","v","b>","b+","b","b-","b<","bv"]
--   map alteration_72et_monzo [-1,-2 .. -9] == r
--   
alteration_72et_monzo :: Integral n => n -> String -- | Given a midi note number and 1/6 deviation determine -- Pitch' and frequency. -- --
--   let f = pitch_r_pp . fst . pitch_72et_k0 (69,440)
--   let r = "C4 C+4 C>4 C^4 C#<4 C#-4 C#4 C#+4 C#>4 C#^4"
--   unwords (map f (zip (repeat 60) [0..9])) == r
--   
-- --
--   let r = "A4 A+4 A>4 A^4 Bb<4 Bb-4 Bb4 Bb+4 Bb>4 Bv4"
--   unwords (map f (zip (repeat 69) [0..9])) == r
--   
-- --
--   let r = "Bb4 Bb+4 Bb>4 Bv4 B<4 B-4 B4 B+4 B>4 B^4"
--   unwords (map f (zip (repeat 70) [0..9])) == r
--   
pitch_72et_k0 :: (Double, Double) -> (Midi, Int) -> (Pitch_R, Double) -- | 72-tone equal temperament table equating Pitch' and frequency -- over range of human hearing, where A4 = 440hz. -- --
--   length (tbl_72et_k0 (69,440)) == 792
--   T.minmax (map (round . snd) (tbl_72et_k0 (69,440))) == (16,33167)
--   
tbl_72et_k0 :: (Double, Double) -> [(Pitch_R, Double)] -- | nearest_et_table_tone for tbl_72et. -- --
--   let r = "324.0 E<4 323.3 0.7 3.5"
--   unwords (hs_r_pp pitch_r_pp 1 (nearest_72et_tone_k0 (69,440) 324))
--   
-- --
--   let f = take 2 . hs_r_pp pitch_r_pp 1 . nearest_72et_tone_k0 (69,440) . snd
--   mapM_ (print . unwords . f) (tbl_72et_k0 (69,440))
--   
nearest_72et_tone_k0 :: (Double, Double) -> Double -> HS_R Pitch_R -- | Pitch with 12-Et/24-Et tuning deviation given in Cents. type Pitch_Detune = (Pitch, Cents) -- | Extract Pitch_Detune from HS_R. hsr_to_pitch_detune :: HS_R Pitch -> Pitch_Detune -- | Nearest 12-Et Pitch_Detune to indicated frequency (hz). -- --
--   nearest_pitch_detune_12et_k0 (69,440) 452.8929841231365
--   
nearest_pitch_detune_12et_k0 :: (Double, Double) -> Double -> Pitch_Detune -- | Nearest 24-Et Pitch_Detune to indicated frequency (hz). -- --
--   nearest_pitch_detune_24et_k0 (69,440) 452.8929841231365
--   
nearest_pitch_detune_24et_k0 :: (Double, Double) -> Double -> Pitch_Detune -- | Given near function, f0 and ratio derive -- Pitch_Detune. ratio_to_pitch_detune :: (Double -> HS_R Pitch) -> OctPc -> Rational -> Pitch_Detune -- | Frequency (hz) of Pitch_Detune. -- --
--   pitch_detune_to_cps (octpc_to_pitch pc_spell_ks (4,9),50)
--   
pitch_detune_to_cps :: Floating n => Pitch_Detune -> n -- | ratio_to_pitch_detune of nearest_12et_tone ratio_to_pitch_detune_12et_k0 :: (Double, Double) -> OctPc -> Rational -> Pitch_Detune -- | ratio_to_pitch_detune of nearest_24et_tone ratio_to_pitch_detune_24et_k0 :: (Double, Double) -> OctPc -> Rational -> Pitch_Detune pitch_detune_in_octave_nearest :: Pitch -> Pitch_Detune -> Pitch_Detune -- | Markdown pretty-printer for Pitch_Detune. pitch_detune_md :: Pitch_Detune -> String -- | HTML pretty-printer for Pitch_Detune. pitch_detune_html :: Pitch_Detune -> String -- | No-octave variant of pitch_detune_md. pitch_class_detune_md :: Pitch_Detune -> String -- | No-octave variant of pitch_detune_html. pitch_class_detune_html :: Pitch_Detune -> String -- | Gamelan instruments and pitch structures. module Music.Theory.Gamelan -- | fromJust with error message. fromJust_err :: String -> Maybe a -> a -- | approxRational of 0.01. near_rat :: Double -> Rational -- | Enumeration of gamelan instrument families. data Instrument_Family Bonang :: Instrument_Family Gambang :: Instrument_Family Gender :: Instrument_Family Gong :: Instrument_Family Saron :: Instrument_Family -- | Universe instrument_family_set :: [Instrument_Family] -- | Enumeration of Gamelan instruments. data Instrument_Name -- | Bonang Barung (horizontal gong, middle) Bonang_Barung :: Instrument_Name -- | Bonang Panerus (horizontal gong, high) Bonang_Panerus :: Instrument_Name -- | Gambang Kayu (wooden key&resonator) Gambang_Kayu :: Instrument_Name -- | Gender Barung (key&resonator, middle) Gender_Barung :: Instrument_Name -- | Gender Panembung (key&resonator, high) Gender_Panerus :: Instrument_Name -- | Gender Panembung, Slenthem (key&resonator, low) Gender_Panembung :: Instrument_Name -- | Gong Ageng (hanging gong, low) Gong_Ageng :: Instrument_Name -- | Gong Suwukan (hanging gong, middle) Gong_Suwukan :: Instrument_Name -- | Kempul (hanging gong, middle) Kempul :: Instrument_Name -- | Kempyang (horizontal gong, high) Kempyang :: Instrument_Name -- | Kenong (horizontal gong, low) Kenong :: Instrument_Name -- | Ketuk, Kethuk (horizontal gong, middle) Ketuk :: Instrument_Name -- | Saron Barung, Saron (key, middle) Saron_Barung :: Instrument_Name -- | Saron Demung, Demung (key, low) Saron_Demung :: Instrument_Name -- | Saron Panerus, Peking (key, high) Saron_Panerus :: Instrument_Name instrument_family :: Instrument_Name -> Instrument_Family instrument_name_pp :: Instrument_Name -> String -- | Clef appropriate for Instrument_Name. instrument_name_clef :: Integral i => Instrument_Name -> Clef i instrument_name_clef_plain :: Integral i => Instrument_Name -> Clef i -- | Enumeration of Gamelan scales. data Scale Pelog :: Scale Slendro :: Scale -- | Octaves are zero-indexed and may be negative. type Octave = Integer -- | Degrees are one-indexed. type Degree = Integer -- | Frequency in hertz. type Frequency = Double -- | A text annotation. type Annotation = String -- | Octave and Degree. data Pitch Pitch :: Octave -> Degree -> Pitch [pitch_octave] :: Pitch -> Octave [pitch_degree] :: Pitch -> Degree -- | Octaves are written as repeated - or +, degrees are -- printed ordinarily. -- --
--   map pitch_pp_ascii (zipWith Pitch [-2 .. 2] [1 .. 5]) == ["--1","-2","3","+4","++5"]
--   
pitch_pp_ascii :: Pitch -> String pitch_pp_duple :: Pitch -> String -- | Scale and Pitch. data Note Note :: Scale -> Pitch -> Note [note_scale] :: Note -> Scale [note_pitch] :: Note -> Pitch -- | pitch_degree of note_pitch. note_degree :: Note -> Degree -- | It is an error to compare notes from different scales. note_compare :: Note -> Note -> Ordering -- | Ascending sequence of Note for Scale from p1 to -- p2 inclusive. note_range_elem :: Scale -> Pitch -> Pitch -> [Note] -- | Ascending sequence of Note from n1 to n2 -- inclusive. -- --
--   note_gamut_elem (Note Slendro (Pitch 0 5)) (Note Slendro (Pitch 1 2))
--   
note_gamut_elem :: Note -> Note -> [Note] data Tone t Tone :: Instrument_Name -> Maybe Note -> Maybe Frequency -> Maybe t -> Tone t [tone_instrument_name] :: Tone t -> Instrument_Name [tone_note] :: Tone t -> Maybe Note [tone_frequency] :: Tone t -> Maybe Frequency [tone_annotation] :: Tone t -> Maybe t tone_frequency_err :: Tone t -> Frequency -- | Constructor for Tone without frequency or -- annotation. plain_tone :: Instrument_Name -> Scale -> Octave -> Degree -> Tone t -- | Tones are considered equivalent if they have the same -- Instrument_Name and Note. tone_equivalent :: Tone t -> Tone t -> Bool tone_24et_pitch :: Tone t -> Maybe Pitch tone_24et_pitch' :: Tone t -> Pitch tone_24et_pitch_detune :: Tone t -> Maybe Pitch_Detune tone_24et_pitch_detune' :: Tone t -> Pitch_Detune tone_fmidi :: Tone t -> Double -- | Fractional (rational) 24-et midi note number of Tone. tone_24et_fmidi :: Tone t -> Rational tone_12et_pitch :: Tone t -> Maybe Pitch tone_12et_pitch' :: Tone t -> Pitch tone_12et_pitch_detune :: Tone t -> Maybe Pitch_Detune tone_12et_pitch_detune' :: Tone t -> Pitch_Detune -- | Fractional (rational) 24-et midi note number of Tone. tone_12et_fmidi :: Tone t -> Rational tone_family :: Tone t -> Instrument_Family tone_in_family :: Instrument_Family -> Tone t -> Bool select_tones :: Instrument_Family -> [Tone t] -> [Maybe (Tone t)] -- | Specify subset as list of families and scales. type Tone_Subset = ([Instrument_Family], [Scale]) -- | Extract subset of Tone_Set. tone_subset :: Tone_Subset -> Tone_Set t -> Tone_Set t data Instrument Instrument :: Instrument_Name -> Maybe Scale -> Maybe [Pitch] -> Maybe [Frequency] -> Instrument [instrument_name] :: Instrument -> Instrument_Name [instrument_scale] :: Instrument -> Maybe Scale [instrument_pitches] :: Instrument -> Maybe [Pitch] [instrument_frequencies] :: Instrument -> Maybe [Frequency] type Tone_Set t = [Tone t] type Tone_Group t = [Tone_Set t] type Gamelan = [Instrument] tone_scale :: Tone t -> Maybe Scale tone_pitch :: Tone t -> Maybe Pitch tone_degree :: Tone t -> Maybe Degree tone_degree' :: Tone t -> Degree tone_octave :: Tone t -> Maybe Octave tone_class :: Tone t -> (Instrument_Name, Maybe Scale) instrument_class :: Instrument -> (Instrument_Name, Maybe Scale) tone_class_p :: (Instrument_Name, Scale) -> Tone t -> Bool tone_family_class_p :: (Instrument_Family, Scale) -> Tone t -> Bool -- | Given a Tone_Set, find those Tones that are within -- Cents of Frequency. tone_set_near_frequency :: Tone_Set t -> Cents -> Frequency -> Tone_Set t -- | Compare Tones by frequency. Tones without frequency -- compare as if at frequency 0. tone_compare_frequency :: Tone t -> Tone t -> Ordering -- | If all f of a are Just b, then Just -- [b], else Nothing. map_maybe_uniform :: (a -> Maybe b) -> [a] -> Maybe [b] instrument :: Tone_Set t -> Instrument instruments :: Tone_Set t -> [Instrument] instrument_gamut :: Instrument -> Maybe (Pitch, Pitch) -- | Pelog has seven degrees, numbered one to seven. Slendro has five -- degrees, numbered one to six excluding four. -- --
--   map scale_degrees [Pelog,Slendro] == [[1,2,3,4,5,6,7],[1,2,3,5,6]]
--   
scale_degrees :: Scale -> [Degree] -- | Zero based index of scale degree, or Nothing. -- --
--   degree_index Slendro 4 == Nothing
--   degree_index Pelog 4 == Just 3
--   
degree_index :: Scale -> Degree -> Maybe Int tone_set_gamut :: Tone_Set t -> Maybe (Pitch, Pitch) tone_set_instrument :: Tone_Set t -> (Instrument_Name, Maybe Scale) -> Tone_Set t instance GHC.Read.Read Music.Theory.Gamelan.Instrument_Family instance GHC.Show.Show Music.Theory.Gamelan.Instrument_Family instance GHC.Classes.Ord Music.Theory.Gamelan.Instrument_Family instance GHC.Classes.Eq Music.Theory.Gamelan.Instrument_Family instance GHC.Enum.Bounded Music.Theory.Gamelan.Instrument_Family instance GHC.Enum.Enum Music.Theory.Gamelan.Instrument_Family instance GHC.Read.Read Music.Theory.Gamelan.Instrument_Name instance GHC.Show.Show Music.Theory.Gamelan.Instrument_Name instance GHC.Classes.Ord Music.Theory.Gamelan.Instrument_Name instance GHC.Classes.Eq Music.Theory.Gamelan.Instrument_Name instance GHC.Enum.Bounded Music.Theory.Gamelan.Instrument_Name instance GHC.Enum.Enum Music.Theory.Gamelan.Instrument_Name instance GHC.Read.Read Music.Theory.Gamelan.Scale instance GHC.Show.Show Music.Theory.Gamelan.Scale instance GHC.Classes.Ord Music.Theory.Gamelan.Scale instance GHC.Classes.Eq Music.Theory.Gamelan.Scale instance GHC.Enum.Enum Music.Theory.Gamelan.Scale instance GHC.Show.Show Music.Theory.Gamelan.Pitch instance GHC.Classes.Ord Music.Theory.Gamelan.Pitch instance GHC.Classes.Eq Music.Theory.Gamelan.Pitch instance GHC.Show.Show Music.Theory.Gamelan.Note instance GHC.Classes.Eq Music.Theory.Gamelan.Note instance GHC.Show.Show t => GHC.Show.Show (Music.Theory.Gamelan.Tone t) instance GHC.Classes.Eq t => GHC.Classes.Eq (Music.Theory.Gamelan.Tone t) instance GHC.Show.Show Music.Theory.Gamelan.Instrument instance GHC.Classes.Eq Music.Theory.Gamelan.Instrument instance GHC.Classes.Eq t => GHC.Classes.Ord (Music.Theory.Gamelan.Tone t) instance GHC.Classes.Ord Music.Theory.Gamelan.Note -- | Euler plane diagrams as dot language graphs. -- -- http://rohandrape.net/?t=hmt-texts&e=md/euler.md module Music.Theory.Tuning.Graph.Euler -- | fold_ratio_to_octave_err of *. rat_mul :: Rational -> Rational -> Rational -- | fold_ratio_to_octave_err of /. rat_div :: Rational -> Rational -> Rational -- | n = length, m = multiplier, r = initial ratio. -- --
--   tun_seq 5 (3/2) 1 == [1/1,3/2,9/8,27/16,81/64]
--   
tun_seq :: Int -> Rational -> Rational -> [Rational] -- | All possible pairs of elements (x,y) where x is -- from p and y from q. -- --
--   all_pairs "ab" "cde" == [('a','c'),('a','d'),('a','e'),('b','c'),('b','d'),('b','e')]
--   
all_pairs :: [t] -> [u] -> [(t, u)] -- | Give all pairs from (l2,l1) and (l3,l2) that are at interval ratios r1 -- and r2 respectively. euler_align_rat :: T2 Rational -> T3 [Rational] -> T2 [T2 Rational] -- | Pretty printer for pitch class (UNICODE). -- --
--   unwords (map pc_pp [0..11]) == "C♮ C♯ D♮ E♭ E♮ F♮ F♯ G♮ A♭ A♮ B♭ B♮"
--   
pc_pp :: (Integral i, Show i) => i -> String -- | Show ratio as intergral (round) cents value. cents_pp :: Rational -> String -- | (unit-pitch-class,print-cents) type RAT_LABEL_OPT = (Int, Bool) -- | Dot label for ratio, k is the pitch-class of the unit ratio. -- --
--   rat_label (0,False) 1 == "C♮\\n1:1"
--   rat_label (3,True) (7/4) == "C♯=969\\n7:4"
--   
rat_label :: RAT_LABEL_OPT -> Rational -> String -- | Generate value dot node identifier for ratio. -- --
--   rat_id (5/4) == "R_5_4"
--   
rat_id :: Rational -> String -- | Printer for edge label between given ratio nodes. rat_edge_label :: (Rational, Rational) -> String -- | Zip start-middle-end. -- --
--   zip_sme (0,1,2) "abcd" == [(0,'a'),(1,'b'),(1,'c'),(2,'d')]
--   
zip_sme :: (t, t, t) -> [u] -> [(t, u)] -- | Euler diagram given as (h,v) duple, where h are -- the horizontal sequences and v are the vertical edges. type Euler_Plane t = ([[t]], [(t, t)]) -- | Ratios at plane, sorted. euler_plane_r :: Ord t => Euler_Plane t -> [t] -- | Apply f at all nodes of the plane. euler_plane_map :: (t -> u) -> Euler_Plane t -> Euler_Plane u -- | Generate dot graph given printer functions and an -- Euler_Plane. euler_plane_to_dot :: (t -> String, t -> String, (t, t) -> String) -> Euler_Plane t -> [String] -- | Variant with default printers and fixed node type. euler_plane_to_dot_rat :: RAT_LABEL_OPT -> Euler_Plane Rational -> [String] -- | Max Meyer. "The musician's arithmetic: drill problems for an -- introduction to the scientific study of musical composition." The -- University of Missouri, 1929. p.22 module Music.Theory.Tuning.Meyer_1929 -- | Odd numbers to n. -- --
--   odd_to 7 == [1,3,5,7]
--   
odd_to :: (Num t, Enum t) => t -> [t] -- | Generate initial row for n. -- --
--   row 7 == [1,5/4,3/2,7/4]
--   
row :: Integral i => i -> [Ratio i] -- | Generate initial column for n. -- --
--   column 7 == [1,8/5,4/3,8/7]
--   
column :: Integral i => i -> [Ratio i] -- | fold_to_octave . *. in_oct_mul :: Integral i => Ratio i -> Ratio i -> Ratio i -- | Given row and column generate matrix value at -- (i,j). -- --
--   inner (row 7,column 7) (1,2) == 6/5
--   
inner :: Integral i => ([Ratio i], [Ratio i]) -> (i, i) -> Ratio i meyer_table_rck :: Integral i => i -> ([Ratio i], [Ratio i], i) -- | Meyer table in form (r,c,n). -- --
--   meyer_table_indices 7 == [(0,0,1/1),(0,1,5/4),(0,2,3/2),(0,3,7/4)
--                            ,(1,0,8/5),(1,1,1/1),(1,2,6/5),(1,3,7/5)
--                            ,(2,0,4/3),(2,1,5/3),(2,2,1/1),(2,3,7/6)
--                            ,(3,0,8/7),(3,1,10/7),(3,2,12/7),(3,3,1/1)]
--   
meyer_table_indices :: Integral i => i -> [(i, i, Ratio i)] -- | Meyer table as set of rows. -- --
--   meyer_table_rows 7 == [[1/1, 5/4, 3/2,7/4]
--                         ,[8/5, 1/1, 6/5,7/5]
--                         ,[4/3, 5/3, 1/1,7/6]
--                         ,[8/7,10/7,12/7,1/1]]
--   
-- --
--   let r = [[ 1/1,   9/8,   5/4,  11/8,   3/2,  13/8,   7/4,  15/8]
--           ,[16/9,   1/1,  10/9,  11/9,   4/3,  13/9,  14/9,   5/3]
--           ,[ 8/5,   9/5,   1/1,  11/10,  6/5,  13/10,  7/5,   3/2]
--           ,[16/11, 18/11, 20/11,  1/1,  12/11, 13/11, 14/11, 15/11]
--           ,[ 4/3,   3/2,   5/3,  11/6,   1/1,  13/12,  7/6,   5/4]
--           ,[16/13, 18/13, 20/13, 22/13, 24/13,  1/1,  14/13, 15/13]
--           ,[ 8/7,   9/7,   10/7, 11/7,  12/7,  13/7,   1/1,  15/14]
--           ,[16/15,  6/5,    4/3, 22/15,  8/5,  26/15, 28/15,  1/1]]
--   in meyer_table_rows 15 == r
--   
meyer_table_rows :: Integral a => a -> [[Ratio a]] -- | Third element of three-tuple. t3_3 :: (t1, t2, t3) -> t3 -- | Set of unique ratios in n table. -- --
--   elements 7 == [1,8/7,7/6,6/5,5/4,4/3,7/5,10/7,3/2,8/5,5/3,12/7,7/4]
--   
-- --
--   elements 9 == [1,10/9,9/8,8/7,7/6,6/5,5/4,9/7,4/3,7/5,10/7
--                 ,3/2,14/9,8/5,5/3,12/7,7/4,16/9,9/5]
--   
elements :: Integral i => i -> [Ratio i] -- | Number of unique elements at n table. -- --
--   map degree [7,9,11,13,15] == [13,19,29,41,49]
--   
degree :: Integral i => i -> i -- | http://en.wikipedia.org/wiki/Farey_sequence -- --
--   r = [[0                                              ]
--       ,[0                                            ,1]
--       ,[0                    ,1/2                    ,1]
--       ,[0            ,1/3    ,1/2    ,2/3            ,1]
--       ,[0        ,1/4,1/3    ,1/2    ,2/3,3/4        ,1]
--       ,[0    ,1/5,1/4,1/3,2/5,1/2,3/5,2/3,3/4,4/5    ,1]
--       ,[0,1/6,1/5,1/4,1/3,2/5,1/2,3/5,2/3,3/4,4/5,5/6,1]]
--   
-- --
--   map farey_sequence [0..6]
--   
farey_sequence :: Integral a => a -> [Ratio a] -- | Tuning, Harry Partch module Music.Theory.Tuning.Partch orelate :: Integral i => Ratio i -> i -> Ratio i urelate :: Integral i => Ratio i -> i -> Ratio i -- | Incipient Tonality Diamond -- --
--   itd_map [4 .. 6]
--   
itd_map :: [Integer] -> Map (Int, Int) Rational map_to_table :: t -> (Int, Int) -> Map (Int, Int) t -> [[t]] -- | map_to_table of itd_map. -- --
--   itd_tbl [4 .. 13]
--   
itd_tbl :: [Integer] -> [[Rational]] -- | Larry Polansky. "Tuning Systems in American Gamelan, Part I: Interval -- Sizes in Javanese Slendro". Balungan, 1(2):9-11, 1984 module Music.Theory.Tuning.Polansky_1984 k_manisrenga :: Fractional n => [n] k_kanjutmesem :: Fractional n => [n] k_udanriris :: Fractional n => [n] k_pengawesari :: Fractional n => [n] k_rarasrum :: Fractional n => [n] k_hardjanagara :: Fractional n => [n] k_madukentir :: Fractional n => [n] k_surak :: Fractional n => [n] -- | The set of K slendro tunings. -- --
--   map length k_set == replicate (length k_set) 5
--   minimum (concat k_set) == 206
--   maximum (concat k_set) == 268.5
--   
k_set :: Fractional n => [[n]] -- | Given a set of equal length lists calculate the average value of each -- position. -- --
--   calculate_averages [[1,2,3],[3,2,1]] == [2,2,2]
--   
calculate_averages :: Fractional n => [[n]] -> [n] -- | Averages of K set, p. 10. -- --
--   k_averages == [233.8125,245.0625,234.0,240.8125,251.875]
--   
k_averages :: Fractional n => [n] gm_1 :: Fractional n => [n] gm_2 :: Fractional n => [n] gm_3 :: Fractional n => [n] gm_4 :: Fractional n => [n] gm_5 :: Fractional n => [n] gm_6 :: Fractional n => [n] gm_7 :: Fractional n => [n] gm_8 :: Fractional n => [n] -- | The set of GM (Gadja Mada University) slendro tunings. -- --
--   map length gm_set == replicate (length gm_set) 5
--   minimum (concat gm_set) == 218
--   maximum (concat gm_set) == 262
--   
gm_set :: Fractional n => [[n]] -- | Averages of GM set, p. 10. -- --
--   gm_averages == [234.0,240.25,247.625,243.125,254.0625]
--   
gm_averages :: Fractional n => [n] -- | Association list giving interval boundaries for interval class -- categories (pp.10-11). i_categories :: Num n => [((n, n), String)] -- | Categorise an interval. i_category :: (Ord a, Num a) => a -> String -- | Pretty interval category table (pp. 10-11). -- --
--   i_category_table k_set ==
--    ["S    L    S    S    L  "
--    ,"S    L    S    S    L  "
--    ,"L    L    S    S    S  "
--    ,"L    S    S    S    L  "
--    ,"S    S    L    S    L  "
--    ,"S    E-L  S    L    L  "
--    ,"L    E    E    S    S  "
--    ,"S    S    S-E  L    L  "]
--   
-- --
--   i_category_table gm_set ==
--    ["S    L    E-L  E    L  "
--    ,"L    S-E  E    S    L  "
--    ,"S    S-E  S    L    S-E"
--    ,"S    L    L    S    L  "
--    ,"S    S-E  E-L  S    L  "
--    ,"S    S-E  E    E    L  "
--    ,"S-E  S    L    E    L  "
--    ,"S    S    E-L  L    L  "]
--   
i_category_table :: (Ord a, Num a) => [[a]] -> [String] -- | Rational tuning derived from gm_averages, p.11. -- --
--   polansky_1984_r == sort polansky_1984_r
--   polansky_1984_r == [1/1,8/7,21/16,512/343,12/7,96/49]
--   
-- --
--   import Music.Theory.List
--   d_dx polansky_1984_r == [1/7,19/112,989/5488,76/343,12/49]
--   
polansky_1984_r :: [Rational] -- | ratio_to_cents of polansky_1984_r. -- --
--   import Music.Theory.List
--   map round (d_dx polansky_1984_c) == [231,240,223,240,231]
--   
polansky_1984_c :: [Cents] -- | Larry Polansky. "Notes on the Tunings of Three Central Javanese -- Slendro/Pelog Pairs". Experimental Musical Instruments, -- 6(2):12-13,16-17, 1990. module Music.Theory.Tuning.Polansky_1990 -- | Kanjutmesem Slendro (S1,S2,S3,S5,S6,S1') -- --
--   L.d_dx kanjutmesem_s == [252,238,241,236,253]
--   
kanjutmesem_s :: Num n => [n] -- | Kanjutmesem Pelog (P1,P2,P3,P4,P5,P6,P7,P1') -- --
--   L.d_dx kanjutmesem_p == [141,141,272,140,115,172,246]
--   
kanjutmesem_p :: Num n => [n] -- | Darius Slendro (S1,S2,S3,S5,S6,S1') -- --
--   L.d_dx darius_s == [204,231,267,231,267]
--   ax_r darius_s == [9/8,8/7,7/6,8/7,7/6]
--   
darius_s :: Num n => [n] -- | Madeleine Pelog (P1,P2,P3,P4,P5,P6,P7,P1') -- --
--   L.d_dx madeleine_p == [139,128,336,99,94,173,231]
--   ax_r madeleine_p == [13/12,14/13,17/14,18/17,19/18,21/19,8/7]
--   
madeleine_p :: Num n => [n] -- | Lipur Sih Slendro (S1,S2,S3,S5,S6,S1') -- --
--   L.d_dx lipur_sih_s == [273,236,224,258,256]
--   
lipur_sih_s :: Num n => [n] -- | Lipur Sih Pelog (P1,P2,P3,P4,P5,P6,P7,P1') -- --
--   L.d_dx lipur_sih_p == [110,153,253,146,113,179]
--   
lipur_sih_p :: Num n => [n] -- | Idealized ET Slendro, 5-tone equal temperament (p.17) -- --
--   L.d_dx idealized_et_s == [240,240,240,240,240]
--   
idealized_et_s :: Num n => [n] -- | Idealized ET Pelog, subset of 9-tone equal temperament (p.17) -- --
--   L.d_dx idealized_et_p == [400/3,800/3,400/3,400/3,400/3,400/3,800/3]
--   
idealized_et_p :: Integral n => [Ratio n] -- | Reconstruct approximate ratios to within 1e-3 from intervals. ax_r :: Real n => [n] -> [Rational] -- | Scala DB meta-data. module Music.Theory.Tuning.Scala.Meta -- | Just-intonation (ie. all rational) scales, collected by author. scl_ji_au :: [(String, [String])] -- | William A. Sethares. "Adaptive Tunings for Musical Scales". Journal -- of the Acoustical Society of America, 96(1), July 1994. module Music.Theory.Tuning.Sethares_1994 -- | Plomp-Levelt consonance curve. -- -- R. Plomp and W. J. M. Levelt, "Tonal Consonance and Critical -- Bandwidth," Journal of the Acoustical Society of America.38, 548-560 -- (1965). -- -- "Relating Tuning and Timbre" -- http://sethares.engr.wisc.edu/consemi.html MATLAB: -- https://sethares.engr.wisc.edu/comprog.html -- --
--   import Sound.SC3.Plot 
--   plot_p1_ln [map (\f -> pl_dissonance (220,1) (f,1)) [220 .. 440]]
--   
pl_dissonance :: (Floating n, Ord n) => (n, n) -> (n, n) -> n -- | Sum of pl_dissonance for all p in s1 and all q in s2. pl_dissonance_h :: (Floating n, Ord n) => [(n, n)] -> [(n, n)] -> n -- | Return local minima of sequence with index. local_minima :: Ord t => [t] -> [(Int, t)] -- | William A. Sethares "Adaptive Tunings for Musical Scales". -- --
--   plot_p1_ln atms_fig_1
--   
atms_fig_1 :: (Floating n, Enum n, Ord n) => [[n]] atms_fig_2 :: (Ord t, Floating t, Enum t) => t -> [t] atms_fig_3 :: (Ord t, Floating t, Enum t) => t -> [t] -- | "Relating Tuning and Timbre" -- http://sethares.engr.wisc.edu/consemi.html -- --
--   plot_p1_ln [rtt_fig_2 880]
--   map fst (local_minima (rtt_fig_2 880)) == [267,316,386,498,582,702,884,969]
--   
rtt_fig_2 :: (Ord t, Floating t, Enum t) => t -> [t] -- | Tuning type module Music.Theory.Tuning.Type -- | A tuning specified Either as a sequence of exact ratios, or as -- a sequence of possibly inexact Cents, and an octave if not -- 2:1 or 1200. -- -- In both cases, the values are given in relation to the first degree of -- the scale, which for ratios is 1 and for cents 0. data Tuning Tuning :: Either [Rational] [Cents] -> Maybe (Either Rational Cents) -> Tuning [tn_ratios_or_cents] :: Tuning -> Either [Rational] [Cents] [tn_octave] :: Tuning -> Maybe (Either Rational Cents) -- | Default epsilon for recovering ratios from cents. tn_epsilon :: Double -- | Tuning value as rational, reconstructed if required. tn_as_ratio :: Double -> Either Rational Cents -> Rational -- | Tuning value as cents. tn_as_cents :: Either Rational Cents -> Cents -- | Tuning octave, defaulting to 2:1. tn_octave_def :: Tuning -> Either Rational Cents -- | Tuning octave in cents. tn_octave_cents :: Tuning -> Cents -- | Tuning octave as ratio cents. tn_octave_ratio :: Double -> Tuning -> Rational -- | Divisions of octave. -- --
--   tn_divisions (tn_equal_temperament 12) == 12
--   
tn_divisions :: Tuning -> Int -- | Maybe exact ratios of Tuning, NOT including the octave. tn_ratios :: Tuning -> Maybe [Rational] -- | Limit of JI tuning. tn_limit :: Tuning -> Maybe Integer -- | erroring variant. tn_ratios_err :: Tuning -> [Rational] -- | Possibly inexact Cents of tuning, NOT including the octave. tn_cents :: Tuning -> [Cents] -- | map round . cents. tn_cents_i :: Integral i => Tuning -> [i] -- | Variant of tn_cents that includes octave at right. tn_cents_octave :: Tuning -> [Cents] -- | tn_cents / 100 tn_fmidi :: Tuning -> [Double] -- | Possibly inexact Approximate_Ratios of tuning. tn_approximate_ratios :: Tuning -> [Approximate_Ratio] -- | Cyclic form, taking into consideration octave_ratio. tn_approximate_ratios_cyclic :: Tuning -> [Approximate_Ratio] -- | Lookup function that allows both negative & multiple octave -- indices. -- --
--   :l Music.Theory.Tuning.DB.Werckmeister
--   let map_zip f l = zip l (map f l)
--   map_zip (tn_ratios_lookup werckmeister_vi) [-24 .. 24]
--   
tn_ratios_lookup :: Tuning -> Int -> Maybe Rational -- | Lookup function that allows both negative & multiple octave -- indices. -- --
--   map_zip (tn_approximate_ratios_lookup werckmeister_v) [-24 .. 24]
--   
tn_approximate_ratios_lookup :: Tuning -> Int -> Approximate_Ratio -- | Maybe exact ratios reconstructed from possibly inexact -- Cents of Tuning. -- --
--   :l Music.Theory.Tuning.DB.Werckmeister
--   let r = [1,17/16,9/8,13/11,5/4,4/3,7/5,3/2,11/7,5/3,16/9,15/8]
--   tn_reconstructed_ratios 1e-2 werckmeister_iii == Just r
--   
tn_reconstructed_ratios :: Double -> Tuning -> Maybe [Rational] -- | Make n division equal temperament. tn_equal_temperament :: Integral n => n -> Tuning -- | 12-tone equal temperament. -- --
--   tn_cents tn_equal_temperament_12 == [0,100..1100]
--   
tn_equal_temperament_12 :: Tuning -- | 19-tone equal temperament. -- --
--   let c = [0,63,126,189,253,316,379,442,505,568,632,695,758,821,884,947,1011,1074,1137]
--   tn_cents_i tn_equal_temperament_19 == c
--   
tn_equal_temperament_19 :: Tuning -- | 31-tone equal temperament. tn_equal_temperament_31 :: Tuning -- | 53-tone equal temperament. tn_equal_temperament_53 :: Tuning -- | 72-tone equal temperament. -- --
--   let r = [0,17,33,50,67,83,100]
--   take 7 (map round (tn_cents tn_equal_temperament_72)) == r
--   
tn_equal_temperament_72 :: Tuning -- | 96-tone equal temperament. tn_equal_temperament_96 :: Tuning instance GHC.Show.Show Music.Theory.Tuning.Type.Tuning instance GHC.Classes.Eq Music.Theory.Tuning.Type.Tuning -- | Syntonic tuning. module Music.Theory.Tuning.Syntonic -- | Construct an isomorphic layout of r rows and c columns -- with an upper left value of (i,j). -- --
--   r = [[(0,0),(-1,2),(-2,4)],[(-1,1),(-2,3),(-3,5)],[(-2,2),(-3,4),(-4,6)]]
--   mk_isomorphic_layout 3 3 (0,0) == r
--   map (map fst) r == [[0,-1,-2],[-1,-2,-3],[-2,-3,-4]]
--   map (map snd) r == [[0,2,4],[1,3,5],[2,4,6]]
--   map (map fst) r == map (map fst) (transpose r)
--   map (map snd) (transpose r) == [[0,1,2],[2,3,4],[4,5,6]]
--   
mk_isomorphic_layout :: Integral a => a -> a -> (a, a) -> [[(a, a)]] -- | A minimal isomorphic note layout. -- --
--   let [i,j,k] = mk_isomorphic_layout 3 5 (3,-4)
--   [i,take 4 j,(2,-4):take 4 k] == minimal_isomorphic_note_layout
--   
minimal_isomorphic_note_layout :: [[(Int, Int)]] -- | Make a rank two regular temperament from a list of (i,j) -- positions by applying the scalars a and b. rank_two_regular_temperament :: Integral a => a -> a -> [(a, a)] -> [a] -- | Syntonic tuning system based on mk_isomorphic_layout of -- 5 rows and 7 columns starting at (3,-4) and -- a rank_two_regular_temperament with a of 1200 -- and indicated b. mk_syntonic_tuning :: Int -> [Cents] -- | mk_syntonic_tuning of 697. -- --
--   tn_divisions syntonic_697 == 17
--   
-- --
--   let c = [0,79,194,273,309,388,467,503,582,697,776,812,891,970,1006,1085,1164]
--   tn_cents_i syntonic_697 == c
--   
syntonic_697 :: Tuning -- | mk_syntonic_tuning of 702. -- --
--   tn_divisions syntonic_702 == 17
--   
-- --
--   let c = [0,24,114,204,294,318,408,498,522,612,702,792,816,906,996,1020,1110]
--   tn_cents_i syntonic_702 == c
--   
syntonic_702 :: Tuning -- | Parser for the Scala scale file format. -- -- See http://www.huygens-fokker.org/scala/scl_format.html for -- details. -- -- This module succesfully parses all scales in v.91 of the scale -- library. module Music.Theory.Tuning.Scala -- | A .scl pitch is either in Cents or is a -- Ratio. type Pitch = Either Cents Rational -- | An enumeration type for .scl pitch classification. data Pitch_Type Pitch_Cents :: Pitch_Type Pitch_Ratio :: Pitch_Type -- | A nearness value for deriving approximate rationals. type Epsilon = Double -- | Derive Pitch_Type from Pitch. pitch_type :: Pitch -> Pitch_Type -- | Pitch as Cents, conversion by ratio_to_cents if -- necessary. pitch_cents :: Pitch -> Cents -- | Pitch as Rational, conversion by reconstructed_ratio if -- necessary, hence epsilon. pitch_ratio :: Epsilon -> Pitch -> Rational -- | A pair giving the number of Cents and number of Ratio -- pitches. pitch_representations :: [Pitch] -> (Int, Int) -- | If scale is uniform, give type. uniform_pitch_type :: [Pitch] -> Maybe Pitch_Type -- | The predominant type of the pitches for Scale. pitch_type_predominant :: [Pitch] -> Pitch_Type -- | A scale has a name, a description, a degree, and a sequence of -- pitches. The name is the the file-name without the .scl -- suffix. By convention the first comment line gives the file name (with -- suffix). The pitches do NOT include 1:1 or 0c and do include the -- octave. type Scale = (String, String, Int, [Pitch]) -- | The name of a scale. scale_name :: Scale -> String -- | Text description of a scale. scale_description :: Scale -> String -- | The degree of the scale (number of Pitches). scale_degree :: Scale -> Int -- | The Pitches at Scale. scale_pitches :: Scale -> [Pitch] -- | Is Pitch outside of the standard octave (ie. cents 0-1200 and -- ratios 1-2) pitch_non_oct :: Pitch -> Bool -- | Ensure degree and number of pitches align. scale_verify :: Scale -> Bool -- | Raise error if scale doesn't verify, else id. scale_verify_err :: Scale -> Scale -- | The last Pitch element of the scale (ie. the octave). -- For empty scales give Nothing. scale_octave :: Scale -> Maybe Pitch -- | Error variant. scale_octave_err :: Scale -> Pitch -- | Is scale_octave perfect, ie. Ratio of 2 or -- Cents of 1200. perfect_octave :: Scale -> Bool -- | Are all pitches of the same type. is_scale_uniform :: Scale -> Bool -- | Are the pitches in ascending sequence. is_scale_ascending :: Scale -> Bool -- | Make scale pitches uniform, conforming to the most predominant pitch -- type. scale_uniform :: Epsilon -> Scale -> Scale -- | Scale as list of Cents (ie. pitch_cents) with 0 -- prefix. scale_cents :: Scale -> [Cents] -- | map round of scale_cents. scale_cents_i :: Scale -> [Cents_I] -- | Scale as list of Rational (ie. pitch_ratio) with -- 1 prefix. scale_ratios :: Epsilon -> Scale -> [Rational] -- | Require that Scale be uniformly of Ratios. scale_ratios_u :: Scale -> Maybe [Rational] -- | Erroring variant of 'scale_ratios_u. scale_ratios_req :: Scale -> [Rational] -- | Are scales equal (==) at degree and tuning data. -- --
--   db <- scl_load_db
--   let r = [2187/2048,9/8,32/27,81/64,4/3,729/512,3/2,6561/4096,27/16,16/9,243/128,2/1]
--   let Just py = find (scale_eq ("","",length r,map Right r)) db
--   scale_name py == "pyth_12"
--   
-- -- scale_eqv provides an approximate equality function. -- --
--   let c = map T.ratio_to_cents r
--   let Just py' = find (scale_eqv 0.00001 ("","",length c,map Left c)) db
--   scale_name py' == "pyth_12"
--   
scale_eq :: Scale -> Scale -> Bool -- | Are scales equal at degree and intersect to at least k -- places of tuning data. scale_eq_n :: Int -> Scale -> Scale -> Bool -- | Is s1 a proper subset of s2. scale_sub :: Scale -> Scale -> Bool -- | Are scales equal at degree and equivalent to within epsilon at -- pitch_cents. scale_eqv :: Epsilon -> Scale -> Scale -> Bool -- | Comment lines begin with !. is_comment :: String -> Bool -- | Remove to end of line ! comments. -- --
--   remove_eol_comments " 1 ! comment" == " 1 "
--   
remove_eol_comments :: String -> String -- | Remove comments and trailing comments (the description may be empty, -- keep nulls) -- --
--   filter_comments ["!a","b","","c","d!e"] == ["b","","c","d"]
--   
filter_comments :: [String] -> [String] -- | Pitches are either cents (with decimal point, possibly trailing) or -- ratios (with /). -- --
--   map parse_pitch ["70.0","350.","3/2","2","2/1"] == [Left 70,Left 350,Right (3/2),Right 2,Right 2]
--   
parse_pitch :: String -> Pitch -- | Pitch lines may contain commentary. parse_pitch_ln :: String -> Pitch -- | Parse .scl file. parse_scl :: String -> String -> Scale -- | Read the environment variable SCALA_SCL_DIR, which is a -- sequence of directories used to locate scala files on. -- --
--   setEnv "SCALA_SCL_DIR" "/home/rohan/data/scala/90/scl"
--   
scl_get_dir :: IO [FilePath] -- | Lookup the SCALA_SCL_DIR environment variable, which must -- exist, and derive the filepath. It is an error if the name has a file -- extension. -- --
--   mapM scl_derive_filename ["young-lm_piano","et12"]
--   
scl_derive_filename :: FilePath -> IO FilePath -- | If the name is an absolute file path and has a .scl -- extension, then return it, else run scl_derive_filename. -- --
--   scl_resolve_name "young-lm_piano"
--   scl_resolve_name "/home/rohan/data/scala/90/scl/young-lm_piano.scl"
--   scl_resolve_name "/home/rohan/data/scala/90/scl/unknown-tuning.scl"
--   
scl_resolve_name :: String -> IO FilePath -- | Load .scl file, runs resolve_scl. -- --
--   s <- scl_load "xenakis_chrom"
--   pitch_representations (scale_pitches s) == (6,1)
--   scale_ratios 1e-3 s == [1,21/20,29/23,179/134,280/187,11/7,100/53,2]
--   
scl_load :: String -> IO Scale -- | Load all .scl files at dir, associate with file-name. -- --
--   db <- scl_load_dir_fn "/home/rohan/data/scala/91/scl"
--   length db == 5176 -- v.91
--   map (\(fn,s) -> (takeFileName fn,scale_name s)) db
--   
scl_load_dir_fn :: FilePath -> IO [(FilePath, Scale)] -- | snd of scl_load_dir_fn scl_load_dir :: FilePath -> IO [Scale] -- | Load Scala data base at scl_get_dir. -- --
--   db <- scl_load_db
--   mapM_ (putStrLn . unlines . scale_stat) (filter (not . perfect_octave) db)
--   
scl_load_db :: IO [Scale] -- | http://www.huygens-fokker.org/docs/scalesdir.txt scales_dir_txt_tbl :: [Scale] -> [[String]] -- | Format as CSV file. -- --
--   db <- scl_load_db
--   writeFile "/tmp/scl.csv" (scales_dir_txt_csv db)
--   
scales_dir_txt_csv :: [Scale] -> String -- | Simple plain-text display of scale data. -- --
--   db <- scl_load_db
--   writeFile "/tmp/scl.txt" (unlines (intercalate [""] (map scale_stat db)))
--   
scale_stat :: Scale -> [String] -- | Pretty print Pitch in Scala format. pitch_pp :: Pitch -> String -- | Pretty print Scale in Scala format. -- --
--   scl <- scl_load "et19"
--   scl <- scl_load "young-lm_piano"
--   putStr $ unlines $ scale_pp scl
--   
scale_pp :: Scale -> [String] scale_wr :: FilePath -> Scale -> IO () -- | Write scl to dir with the file-name -- scale_name.scl scale_wr_dir :: FilePath -> Scale -> IO () -- | scala distribution directory, given at -- SCALA_DIST_DIR. -- --
--   setEnv "SCALA_DIST_DIR" "/home/rohan/opt/build/scala-22"
--   
dist_get_dir :: IO String -- | Load file from dist_get_dir. load_dist_file :: FilePath -> IO String -- | fmap lines load_dist_file -- --
--   s <- load_dist_file_ln "intnam.par"
--   length s == 565 -- Scala 2.46d
--   
load_dist_file_ln :: FilePath -> IO [String] -- | Is scale just-intonation (ie. are all pitches ratios) scl_is_ji :: Scale -> Bool -- | Calculate limit for JI scale (ie. largest prime factor) scl_ji_limit :: Scale -> Integer -- | Sum of absolute differences to scale given in cents, sorted, with -- rotation. scl_cdiff_abs_sum :: [Cents] -> Scale -> [(Double, [Cents], Int)] -- | Variant selecting only nearest and with post-processing function. -- --
--   scl <- scl_load "holder"
--   scale_cents_i scl
--   c = [0,83,193,308,388,502,584,695,778,890,1004,1085,1200]
--   (_,r,_) = scl_cdiff_abs_sum_1 round c scl
--   r == [0,2,-1,1,0,-1,0,-1,0,0,0,0,0]
--   
scl_cdiff_abs_sum_1 :: (Double -> n) -> [Cents] -> Scale -> (Double, [n], Int) -- | Sort DB into ascending order of sum of absolute of differences to -- scale given in cents. Scales are sorted and all rotations are -- considered. -- --
--   db <- scl_load_db
--   c = [0,83,193,308,388,502,584,695,778,890,1004,1085,1200]
--   r = scl_db_query_cdiff_asc round db c
--   ((_,dx,_),_):_ = r
--   dx == [0,2,-1,1,0,-1,0,-1,0,0,0,0,0]
--   mapM_ (putStrLn . unlines . scale_stat . snd) (take 10 r)
--   
scl_db_query_cdiff_asc :: Ord n => (Double -> n) -> [Scale] -> [Cents] -> [((Double, [n], Int), Scale)] -- | Is x the same scale as scl under cmp. scale_cmp_ji :: ([Rational] -> [Rational] -> Bool) -> [Rational] -> Scale -> Bool -- | Find scale(s) that are scale_cmp_ji to x. Usual -- cmp are (==) and is_subset. scl_find_ji :: ([Rational] -> [Rational] -> Bool) -> [Rational] -> [Scale] -> [Scale] -- | Translate Scale to Tuning. If Scale is uniformly -- rational, Tuning is rational, else it is in Cents. scale_to_tuning :: Scale -> Tuning -- | Convert Tuning to Scale. -- --
--   tuning_to_scale ("et12","12 tone equal temperament") (T.tn_equal_temperament 12)
--   
tuning_to_scale :: (String, String) -> Tuning -> Scale -- | scale_to_tuning of scl_load. -- --
--   fmap T.tn_limit (scl_load_tuning "pyra") -- Just 59
--   
scl_load_tuning :: String -> IO Tuning instance GHC.Show.Show Music.Theory.Tuning.Scala.Pitch_Type instance GHC.Classes.Eq Music.Theory.Tuning.Scala.Pitch_Type -- | Parser for the modename.par file. -- -- The terminology here is: -- -- module Music.Theory.Tuning.Scala.Mode -- | (mode-start-degree,mode-intervals,mode-description) type Mode = (Int, [Int], String) -- | Starting degree of mode in underlying scale. If non-zero the mode will -- not lie within an ordinary octave of the tuning. mode_starting_degree :: Mode -> Int -- | Intervals (in steps) between adjacent elements of the mode. mode_intervals :: Mode -> [Int] -- | Interval set of mode (ie. nub of sort of -- mode_intervals) mode_iset :: Mode -> [Int] -- | Histogram (histogram) of mode_intervals mode_histogram :: Mode -> [(Int, Int)] -- | The text description of the mode, ordinarily a comma separated list of -- names. mode_description :: Mode -> String -- | length (or degree) of mode_intervals (ie. number of -- notes in mode) mode_length :: Mode -> Int -- | sum of mode_intervals (ie. number of notes in tuning -- system) mode_univ :: Mode -> Int -- | dx_d of mode_intervals. This seqence includes the -- octave. mode_degree_seq :: Mode -> [Int] -- | (mode-count,mode-length-maxima,mode-list) type ModeNam = (Int, Int, [Mode]) modenam_modes :: ModeNam -> [Mode] -- | Search for mode by interval list. modenam_search_seq :: ModeNam -> [Int] -> [Mode] -- | Expect one result. -- --
--   mn <- load_modenam
--   let sq = putStrLn . unlines . mode_stat . fromJust . modenam_search_seq1 mn
--   sq [2,2,1,2,2,2,1]
--   sq [2,1,2,2,1,2,2]
--   sq [2,1,2,2,1,3,1]
--   sq (replicate 6 2)
--   sq [1,2,1,2,1,2,1,2]
--   sq [2,1,2,1,2,1,2,1]
--   sq (replicate 12 1)
--   
modenam_search_seq1 :: ModeNam -> [Int] -> Maybe Mode -- | Search for mode by description text. -- --
--   map (modenam_search_description mn) ["Messiaen","Xenakis","Raga"]
--   
modenam_search_description :: ModeNam -> String -> [Mode] -- | Is p an element of the set of rotations of q. mode_rot_eqv :: Mode -> Mode -> Bool -- | Pretty printer. -- --
--   mn <- load_modenam
--   
-- --
--   let r = filter ((/=) 0 . mode_starting_degree) (modenam_modes mn) -- non-zero starting degrees
--   let r = filter ((== [(1,2),(2,5)]) . mode_histogram) (modenam_modes mn) -- 2×1 and 5×2
--   let r = filter ((== 22) . mode_univ) (modenam_search_description mn "Raga") -- raga of 22 shruti univ
--   
-- --
--   [(p,q) | p <- r, q <- r, p < q, mode_rot_eqv p q] -- rotationally equivalent elements of r
--   
-- --
--   length r
--   putStrLn $ unlines $ intercalate ["\n"] $ map mode_stat r
--   
mode_stat :: Mode -> [String] -- | Bracketed integers are a non-implicit starting degree. -- --
--   map non_implicit_degree ["4","[4]"] == [Nothing,Just 4]
--   
non_implicit_degree :: String -> Maybe Int -- | Predicate form is_non_implicit_degree :: String -> Bool is_integer :: String -> Bool parse_modenam_entry :: [String] -> Mode -- | Lines ending with @@ continue to next line. join_long_lines :: [String] -> [String] -- | Parse joined non-comment lines of modenam file. parse_modenam :: [String] -> ModeNam -- | parse_modenam of load_dist_file of modenam.par. -- --
--   mn <- load_modenam
--   let (n,x,m) = mn
--   (n, x, length m) == (3087,15,3087) -- Scala 2.64p
--   
load_modenam :: IO ModeNam -- | Scala "keyboard mapping" files (.kbm) and related data structure. -- -- http://www.huygens-fokker.org/scala/help.htm#mappings module Music.Theory.Tuning.Scala.Kbm -- | Scala keyboard mapping -- -- (sz,(m0,mN),mC,(mF,f),o,m) -- -- type Kbm = (Int, (Int, Int), Int, (Int, Double), Int, [Maybe Int]) -- | Pretty-printer for scala .kbm file. kbm_pp :: Kbm -> String -- | Is mnn in range? kbm_in_rng :: Kbm -> Int -> Bool -- | Is kbm linear?, ie. is size zero? (formal-octave may or may not -- be zero) kbm_is_linear :: Kbm -> Bool -- | Given kbm and midi-note-number lookup (octave,scale-degree). -- --
--   k <- kbm_load_dist "example.kbm" -- 12-tone scale
--   k <- kbm_load_dist "a440.kbm" -- linear
--   k <- kbm_load_dist "white.kbm" -- 7-tone scale on white notes
--   k <- kbm_load_dist "black.kbm" -- 5-tone scale on black notes
--   k <- kbm_load_dist "128.kbm"
--   
-- --
--   map (kbm_lookup k) [48 .. 72]
--   
kbm_lookup :: Kbm -> Int -> Maybe (Int, Int) -- | Return the triple (mF,kbm_lookup k mF,f). The lookup for mF is not-nil -- by definition. -- --
--   kbm_lookup_mF k
--   
kbm_lookup_mF :: Kbm -> (Int, (Int, Int), Double) -- | Parser for scala .kbm file. kbm_parse :: String -> Kbm -- | kbm_parse of readFile kbm_load_file :: FilePath -> IO Kbm -- | kbm_parse of load_dist_file -- --
--   pp nm = kbm_load_dist nm >>= \x -> putStrLn (kbm_pp x)
--   pp "example"
--   pp "bp"
--   pp "7" -- error -- 12/#13
--   pp "8" -- error -- 12/#13
--   pp "white" -- error -- 12/#13
--   pp "black" -- error -- 12/#13
--   pp "128"
--   pp "a440"
--   pp "61"
--   
kbm_load_dist :: String -> IO Kbm -- | If nm is a file name (has a .kbm) extension run -- kbm_load_file else run kbm_load_dist. kbm_load :: String -> IO Kbm -- | Load all .kbm files at directory. kbm_load_dir_fn :: FilePath -> IO [(FilePath, Kbm)] -- | Load all .kbm files at scala dist dir. -- --
--   db <- kbm_load_dist_dir_fn
--   length db == 41
--   x = map (\(fn,(sz,_,_,_,o,m)) -> (System.FilePath.takeFileName fn,sz,length m,o)) db
--   filter (\(_,i,j,_) -> i < j) x -- size < map-length
--   filter (\(_,i,_,k) -> i == 0 && k == 0) x -- size and formal octave both zero
--   
-- --
--   map (\(fn,k) -> (System.FilePath.takeFileName fn,kbm_lookup_mF k)) db
--   
kbm_load_dist_dir_fn :: IO [(FilePath, Kbm)] -- | Pretty-printer for scala .kbm file. -- --
--   m <- kbm_load_dist "7.kbm"
--   kbm_parse (kbm_format m) == m
--   putStrLn $ kbm_pp m
--   
kbm_format :: Kbm -> String -- | writeFile of kbm_format kbm_wr :: FilePath -> Kbm -> IO () -- | Standard 12-tone mapping with A=440hz (ie. example.kbm) -- --
--   fmap (== kbm_d12_a440) (kbm_load_dist "example.kbm")
--   putStrLn $ kbm_pp kbm_d12_a440
--   
kbm_d12_a440 :: Kbm kbm_d12_c256 :: Kbm -- | Given size and note-center calculate relative octave and key number -- (not scale degree) of the zero entry. -- --
--   map (kbm_k0 12) [59,60,61] == [(-4,1),(-5,0),(-5,11)]
--   
kbm_k0 :: Int -> Int -> (Int, Int) -- | Given size and note-center calculate complete octave and key number -- sequence (ie. for entries 0 - 127). -- --
--   map (zip [0..] . kbm_oct_key_seq 12) [59,60,61]
--   
kbm_oct_key_seq :: Kbm -> [(Int, (Int, Int))] -- | Given Kbm and SCL calculate frequency of note-center. kbm_mC_freq :: Kbm -> Scale -> Double -- | Given Kbm and SCL calculate fractional midi note-numbers for each key. kbm_fmidi_tbl :: Kbm -> Scale -> [(Int, Double)] -- | Given Kbm and SCL calculate frequencies for each key. kbm_cps_tbl :: Kbm -> Scale -> [(Int, Double)] -- | Parser for the SCALA intnam.par file. module Music.Theory.Tuning.Scala.Interval -- | Interval and name, ie. (3/2,"perfect fifth") type INTERVAL = (Rational, String) -- | Length prefixed list of INTERVAL. type INTNAM = (Int, [INTERVAL]) -- | 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_ratio :: INTNAM -> Rational -> Maybe INTERVAL -- | 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_fratio :: (Fractional n, Ord n) => n -> INTNAM -> n -> Maybe INTERVAL -- | Lookup name of interval, or error. intnam_search_ratio_name_err :: INTNAM -> Rational -> String -- | Lookup interval name in INTNAM, ci = case-insensitive. -- --
--   db <- load_intnam
--   intnam_search_description_ci db "didymus" == [(81/80,"syntonic comma, Didymus comma")]
--   
intnam_search_description_ci :: INTNAM -> String -> [INTERVAL] -- | Parse line from intnam.par parse_intnam_entry :: String -> INTERVAL -- | Parse non-comment lines from intnam.par parse_intnam :: [String] -> INTNAM -- | 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"
--   
load_intnam :: IO INTNAM -- | Scala functions, http://www.huygens-fokker.org/scala/help.htm module Music.Theory.Tuning.Scala.Functions -- | http://www.huygens-fokker.org/scala/help.htm#EQUALTEMP -- --
--   map round (equaltemp 12 2 13) == [0,100,200,300,400,500,600,700,800,900,1000,1100,1200]
--   map round (equaltemp 13 3 14) == [0,146,293,439,585,732,878,1024,1170,1317,1463,1609,1756,1902]
--   map round (equaltemp 12.5 3 14) == [0,152,304,456,609,761,913,1065,1217,1369,1522,1674,1826,1978]
--   
equaltemp :: Double -> Double -> Int -> [Double] -- | http://www.huygens-fokker.org/scala/help.htm#LINEARTEMP -- --
--   let py = lineartemp 12 2 () (3/2 :: Rational) 3
--   py == [1/1,2187/2048,9/8,32/27,81/64,4/3,729/512,3/2,6561/4096,27/16,16/9,243/128,2/1]
--   
lineartemp :: (Fractional n, Ord n) => Int -> n -> () -> n -> Int -> [n] interval_hist_ratios :: (Fractional t, Ord t) => [t] -> [(t, Int)] intervals_list_ratios_r :: INTNAM -> [Rational] -> IO () -- | http://www.huygens-fokker.org/scala/help.htm#SHOW_INTERVALS -- --
--   mapM_ intervals_list_ratios (words "pyth_12 kepler1")
--   
intervals_list_ratios :: String -> IO () -- | Given interval function (ie. - or /) and scale generate -- interval half-matrix. interval_half_matrix :: (t -> t -> u) -> [t] -> [[u]] interval_half_matrix_tbl :: (t -> String) -> (t -> t -> t) -> [t] -> [[String]] intervals_half_matrix :: (Scale -> [t]) -> (t -> t -> t) -> (t -> String) -> String -> IO () intervals_half_matrix_cents :: Int -> String -> IO () intervals_half_matrix_ratios :: String -> IO () interval_matrix_ratio :: [Rational] -> [[Rational]] interval_matrix_cents :: [Cents] -> [[Cents]] intervals_matrix_wr :: (t -> String) -> [[t]] -> IO () intervals_matrix :: (Scale -> [t]) -> ([t] -> [[t]]) -> (t -> String) -> String -> IO () intervals_matrix_cents :: Int -> String -> IO () intervals_matrix_ratios :: String -> IO () -- | David Rosenboom, "In the Beginning: Etude I (Trombones)", 1979 -- http://davidrosenboom.com/media/beginning-etude-i-trombones -- -- kw: subharmonics, difference tones module Music.Theory.Tuning.Rosenboom_1979 t2_to_ratio :: (Integer, Integer) -> Rational -- | Tuning, ratios for each octave. -- --
--   length (concat dr_tuning_oct) == 19
--   import qualified Music.Theory.Tuning as T
--   map (map (T.ratio_to_cents . t2_to_ratio)) dr_tuning_oct
--   
dr_tuning_oct :: Num n => [[(n, n)]] -- | Tuning, actual ratios. dr_tuning :: [Rational] -- | Actual scale, in CPS. -- --
--   let r = [52,69,76,83,92,104,119,138,156,166,185,208,234,260,277,286,311,332,363]
--   map round dr_scale == r
--   
dr_scale :: [Double] dr_scale_tbl_12et :: [HS_R Pitch] dr_scale_scala :: Scale dr_scale_tbl_24et :: [HS_R Pitch] dr_chords :: [[Pitch]] dr_ratio_seq :: Num n => [[(n, n)]] dr_ratio_seq_hist :: (Ord n, Num n) => [((n, n), Int)] dr_nt :: Integral i => [([i], [i])] dr_nt_pitch :: ([Int], [Int]) -> ([Pitch], [Pitch]) -- | Tuning graph with edges determined by interval set. module Music.Theory.Tuning.Graph.Iset -- | R = Rational type R = Rational -- | Flip a ratio in (1,2) and multiply by 2. -- --
--   import Data.Ratio {- base -}
--   map r_flip [5%4,3%2,7%4] == [8%5,4%3,8%7]
--   map r_flip [3/2,5/4,7/4] == [4/3,8/5,8/7]
--   
r_flip :: R -> R -- | r = ratio, nrm = normalise r_nrm :: R -> R -- | The folded interval from p to q. -- --
--   r_rel (1,3/2) == 4/3
--   
r_rel :: (R, R) -> R -- | The interval set i and it's r_flip. iset_sym :: [R] -> [R] -- | Require r to have a perfect octave as last element, and remove it. rem_oct :: [R] -> [R] r_pcset :: [R] -> [Int] r_pcset_univ :: [R] -> [Int] -- | Does [R] construct indicated pcset. r_is_pcset :: [Int] -> [R] -> Bool -- | Edges are (v1,v2) where v1 < v2 type G = Gr R edj_r :: (R, R) -> R -- | The graph with vertices scl_r and all edges where the interval -- (i,j) is in iset. mk_graph :: [R] -> [R] -> G gen_graph :: Ord v => [Dot_Meta_Attr] -> Graph_Pp v e -> [Edge_Lbl v e] -> [String] g_to_dot :: Int -> [(String, String)] -> (R -> [(String, String)]) -> G -> [String] mk_graph_scl :: [R] -> Scale -> G scl_to_dot :: ([R], Int, [(String, String)], R -> [(String, String)]) -> String -> IO [String] graph_to_fgl :: G -> Gr R R mk_graph_fgl :: [R] -> [R] -> Gr R R -- | Larry Polansky. "Notes on Piano Study #5". _1, The Journal of the Just -- Intonation Newtork_, 1(4), Autumn 1985. module Music.Theory.Tuning.Polansky_1985c -- | The tuning has four octaves, these ratios are per-octave. ps5_jpr_r :: [[Rational]] -- | Four-octave tuning. -- --
--   import Data.List.Split
--   
-- --
--   let r = [[   0,  84, 204, 316, 386, 498, 583, 702, 814, 884, 969,1088]
--           ,[1200,1284,1404,1516,1586,1698,1783,1902,2014,2084,2169,2288]
--           ,[2400,2453,2604,2716,2786,2871,2951,3102,3214,3241,3369,3488]
--           ,[3600,3684,3804,3867,3986,4098,4151,4302,4414,4506,4569,4688]]
--   in chunksOf 12 (cents_i ps5_jpr) == r
--   
-- --
--   let r = [[0,84,204,316,386,498,583,702,814,884,969,1088]
--           ,[0,84,204,316,386,498,583,702,814,884,969,1088]
--           ,[0,53,204,316,386,471,551,702,814,841,969,1088]
--           ,[0,84,204,267,386,498,551,702,814,906,969,1088]]
--   chunksOf 12 (map (`mod` 1200) (cents_i ps5_jpr))
--   
ps5_jpr :: Tuning -- | Larry Polansky. "Psaltery (for Lou Harrison)". Frog Peak Music, 1978. module Music.Theory.Tuning.Polansky_1978 -- | Three interlocking harmonic series on 1:5:3, by Larry Polansky in -- "Psaltery". -- --
--   import qualified Music.Theory.Tuning.Scala as T
--   scl <- T.scl_load "polansky_ps"
--   T.pitch_representations (T.scale_pitches scl) == (0,50)
--   1 : Data.Either.rights (T.scale_pitches scl) == psaltery_r
--   
psaltery_r :: [Rational] -- | fold_ratio_to_octave' of psaltery. -- --
--   length psaltery_r == 51 && length psaltery_o_r == 21
--   
-- --
--   psaltery_o_r == [1,65/64,33/32,17/16,35/32,9/8,75/64,39/32
--                   ,5/4,21/16,85/64,11/8,45/32
--                   ,3/2,25/16,51/32,13/8,27/16,55/32,7/4,15/8]
--   
psaltery_o_r :: [Rational] -- | Tuning derived from psaltery_o with -- octave_ratio of 2. -- --
--   cents_i psaltery_o == [0,27,53,105,155,204,275,342,386,471,491,551,590
--   
-- -- ,702,773,807,841,906,938,969,1088] -- --
--   let r = [0,1200,1902,2400,2786,3102,3369,3600,3804,3986,4151,4302,4441,4569,4688,4800,4905
--   
-- -- -- ,386,1586,2288,2786,3173,3488,3755,3986,4190,4373,4538,4688,4827,4955,5075,5186,5291 -- ,702,1902,2604,3102,3488,3804,4071,4302,4506,4688,4853,5004,5142,5271,5390,5502] -- > in cents_i (T.scale_tuning 0.01 scl) == r psaltery_o :: Tuning -- | Midi + Tuning module Music.Theory.Tuning.Midi -- | (n -> dt). Function from midi note number n to -- Midi_Detune dt. The incoming note number is the key -- pressed, which may be distant from the note sounded. type Midi_Tuning_f = Midi -> Midi_Detune -- | Variant for tunings that are incomplete. type Sparse_Midi_Tuning_f = Midi -> Maybe Midi_Detune -- | Variant for sparse tunings that require state. type Sparse_Midi_Tuning_St_f st = st -> Midi -> (st, Maybe Midi_Detune) -- | Lift Midi_Tuning_f to Sparse_Midi_Tuning_f. lift_tuning_f :: Midi_Tuning_f -> Sparse_Midi_Tuning_f -- | Lift Sparse_Midi_Tuning_f to Sparse_Midi_Tuning_St_f. lift_sparse_tuning_f :: Sparse_Midi_Tuning_f -> Sparse_Midi_Tuning_St_f st -- | (t,c,k) where t=tuning (must have 12 divisions of octave), c=cents -- deviation (ie. constant detune offset), k=midi offset (ie. value to be -- added to incoming midi note number). type D12_Midi_Tuning = (Tuning, Cents, Midi) -- | Midi_Tuning_f for D12_Midi_Tuning. -- --
--   let f = d12_midi_tuning_f (equal_temperament 12,0,0)
--   map f [0..127] == zip [0..127] (repeat 0)
--   
d12_midi_tuning_f :: D12_Midi_Tuning -> Midi_Tuning_f -- | (t,f0,k,g) where t=tuning, f0=fundamental-frequency, -- k=midi-note-number (for f0), g=gamut type Cps_Midi_Tuning = (Tuning, Double, Midi, Int) -- | Midi_Tuning_f for Cps_Midi_Tuning. The function is -- sparse, it is only valid for g values from k. -- --
--   import qualified Music.Theory.Pitch as T
--   let f = cps_midi_tuning_f (equal_temperament 72,T.midi_to_cps 59,59,72 * 4)
--   map f [59 .. 59 + 72]
--   
cps_midi_tuning_f :: Cps_Midi_Tuning -> Sparse_Midi_Tuning_f -- | midi-note-number -> fractional-midi-note-number table, possibly -- sparse. type Mnn_Fmnn_Table = [(Int, Double)] -- | Load Mnn_Fmnn_Table from two-column Csv file. mnn_fmnn_table_load_csv :: FilePath -> IO Mnn_Fmnn_Table -- | Midi-note-number -> Cps table, possibly sparse. type Mnn_Cps_Table = [(Midi, Double)] -- | Generates Mnn_Cps_Table given Midi_Tuning_f with keys -- for all valid Mnn. -- --
--   import Sound.SC3.Plot
--   let f = cps_midi_tuning_f (equal_temperament 12,T.midi_to_cps 0,0,127)
--   plot_p2_ln [map (fmap round) (gen_cps_tuning_tbl f)]
--   
gen_cps_tuning_tbl :: Sparse_Midi_Tuning_f -> Mnn_Cps_Table -- | Given an Mnn_Cps_Table tbl, a list of Cps -- c, and a Mnn m find the Cps in -- c that is nearest to the Cps in t for m. -- In equal distance cases bias left. dtt_lookup :: (Eq k, Num v, Ord v) => [(k, v)] -> [v] -> k -> (Maybe v, Maybe v) -- | Require table be non-sparse. dtt_lookup_err :: (Eq k, Num v, Ord v) => [(k, v)] -> [v] -> k -> (k, v, v) -- | Given two tuning tables generate the dtt table. gen_dtt_lookup_tbl :: Mnn_Cps_Table -> Mnn_Cps_Table -> Mnn_Cps_Table gen_dtt_lookup_f :: Mnn_Cps_Table -> Mnn_Cps_Table -> Midi_Tuning_f -- | Command line interface to hmt/scala. module Music.Theory.Tuning.Scala.Cli type R = Double db_stat :: IO () db_summarise :: Maybe Int -> Maybe Int -> IO () env :: IO () cut :: Maybe Int -> [a] -> [a] search :: (IO [a], a -> String, a -> [String]) -> (Bool, Maybe Int) -> [String] -> IO () search_scale :: (Bool, Maybe Int) -> [String] -> IO () search_mode :: (Bool, Maybe Int) -> [String] -> IO () stat_all :: Maybe Int -> IO () stat_by_name :: Maybe Int -> FilePath -> IO () rng_enum :: Enum t => (t, t) -> [t] cps_tbl :: String -> Mnn_Cps_Table -> (Midi, Midi) -> IO () cps_tbl_d12 :: String -> (String, Cents, Midi) -> (Midi, Midi) -> IO () cps_tbl_cps :: String -> (String, R, Midi, Int) -> (Midi, Midi) -> IO () csv_mnd_retune_d12 :: (String, Cents, Midi) -> FilePath -> FilePath -> IO () fluidsynth_tuning_d12 :: (String, Int, Int) -> (String, Cents, Midi) -> IO () midi_tbl_tuning_d12 :: String -> (String, Cents, Midi) -> IO () ratio_cents_pp :: Rational -> String intnam_lookup :: [Rational] -> IO () intnam_search :: String -> IO () kbm_tbl :: String -> String -> String -> IO () help :: [String] nil_or_read :: Read a => String -> Maybe a scala_cli :: [String] -> IO () -- | Functions to load a tuning definition and transform it into a sparse -- tuning function. module Music.Theory.Tuning.Load -- | Load possibly sparse and possibly one-to-many -- (midi-note-number,cps-frequency) table from Csv file. -- --
--   load_cps_tbl "/home/rohan/dr.csv"
--   
load_cps_tbl :: FilePath -> IO [(Midi, Double)] -- | Load scala scl file as Tuning. load_tuning_scl :: String -> IO Tuning -- | cps = (tuning-name,frequency-zero,midi-note-number-of-f0) d12 = -- (tuning-name,cents-deviation,midi-note-offset) type Load_Tuning_Opt = (String, Double, Midi) -- | Load scala file and apply cps_midi_tuning_f. load_tuning_cps :: Load_Tuning_Opt -> IO Sparse_Midi_Tuning_f -- | Load scala file and apply d12_midi_tuning_f. load_tuning_d12 :: Load_Tuning_Opt -> IO Sparse_Midi_Tuning_f -- | Lookup first matching element in table. load_tuning_tbl :: Load_Tuning_Opt -> IO Sparse_Midi_Tuning_f type Choose_f st t = [t] -> st -> (t, st) -- | Randomly choose from elements in table, equal weighting. default_choose_f :: RandomGen g => Choose_f g t -- | Load tuning table with stateful selection function for one-to-many -- entries. load_tuning_tbl_st :: Choose_f st (Midi, Double) -> Load_Tuning_Opt -> IO (Sparse_Midi_Tuning_St_f st) load_tuning_ty :: String -> Load_Tuning_Opt -> IO Sparse_Midi_Tuning_f load_tuning_st_ty :: String -> Load_Tuning_Opt -> IO (Sparse_Midi_Tuning_St_f StdGen) -- | Harmonic series module Music.Theory.Tuning.Hs -- | Harmonic series to nth partial, with indicated octave. -- --
--   harmonic_series 17 2
--   
harmonic_series :: Integer -> Maybe Rational -> Tuning -- | Harmonic series on n. harmonic_series_cps :: (Num t, Enum t) => t -> [t] -- | n elements of harmonic_series_cps. -- --
--   let r = [55,110,165,220,275,330,385,440,495,550,605,660,715,770,825,880,935]
--   harmonic_series_cps_n 17 55 == r
--   
harmonic_series_cps_n :: (Num a, Enum a) => Int -> a -> [a] -- | Sub-harmonic series on n. subharmonic_series_cps :: (Fractional t, Enum t) => t -> [t] -- | n elements of harmonic_series_cps. -- --
--   let r = [1760,880,587,440,352,293,251,220,196,176,160,147,135,126,117,110,104]
--   map round (subharmonic_series_cps_n 17 1760) == r
--   
subharmonic_series_cps_n :: (Fractional t, Enum t) => Int -> t -> [t] -- | nth partial of f1, ie. one indexed. -- --
--   map (partial 55) [1,5,3] == [55,275,165]
--   
partial :: (Num a, Enum a) => a -> Int -> a -- | Derivative harmonic series, based on kth partial of f1. -- --
--   import Music.Theory.Pitch
--   
-- --
--   let r = [52,103,155,206,258,309,361,412,464,515,567,618,670,721,773]
--   let d = harmonic_series_cps_derived 5 (T.octpc_to_cps (1,4))
--   map round (take 15 d) == r
--   
harmonic_series_cps_derived :: (RealFrac a, Floating a, Enum a) => Int -> a -> [a] -- | Harmonic series to nth harmonic (folded, duplicated removed). -- --
--   harmonic_series_folded_r 17 == [1,17/16,9/8,5/4,11/8,3/2,13/8,7/4,15/8]
--   
-- --
--   let r = [0,105,204,386,551,702,841,969,1088]
--   map (round . ratio_to_cents) (harmonic_series_folded_r 17) == r
--   
harmonic_series_folded_r :: Integer -> [Rational] -- | ratio_to_cents variant of harmonic_series_folded. harmonic_series_folded_c :: Integer -> [Cents] harmonic_series_folded :: Integer -> Tuning -- | 12-tone tuning of first 21 elements of the harmonic -- series. -- --
--   tn_cents_i harmonic_series_folded_21 == [0,105,204,298,386,471,551,702,841,969,1088]
--   tn_divisions harmonic_series_folded_21 == 11
--   
harmonic_series_folded_21 :: Tuning -- | Kyle Gann. "La Monte Young's The Well-Tuned Piano". Perspectives of -- New Music, 31(1):134--162, Winter 1993. module Music.Theory.Tuning.Gann_1993 -- | Ratios for lmy_wtp. lmy = La Monte Young. wtp = Well-Tuned -- Piano. -- --
--   let c = [0,177,204,240,471,444,675,702,738,969,942,1173]
--   in map (round . T.ratio_to_cents) lmy_wtp_r == c
--   
lmy_wtp_r :: [Rational] -- | The pitch-class of the key associated with each ratio of the tuning. -- --
--   mapMaybe lmy_wtp_ratio_to_pc [1,1323/1024,7/4] == [3,8,0]
--   
lmy_wtp_ratio_to_pc :: Rational -> Maybe PitchClass lmy_wtp_ratio_to_pc_err :: Rational -> PitchClass -- | The list of all non-unison ascending intervals possible in -- lmy_wtp_r. -- --
--   length lmy_wtp_univ == 66
--   
lmy_wtp_univ :: [(Rational, (PitchClass, PitchClass))] -- | Collated and sorted lmy_wtp_univ. -- --
--   let r_cents_pp = show . round . T.ratio_to_cents
--   
-- --
--   import qualified Music.Theory.Math as T 
--   
-- --
--   let f (r,i) = concat [T.ratio_pp r," = "
--                        ,r_cents_pp r," = #"
--                        ,show (length i)," = "
--                        ,unwords (map show i)]
--   
-- --
--   putStrLn $ unlines $ map f lmy_wtp_uniq
--   
-- -- 3:2 = 702 = #9 = (3,10) (4,9) (5,10) (6,11) (6,1) (7,0) (7,2) (8,1) -- (9,2) 7:4 = 969 = #7 = (3,0) (5,2) (6,7) (7,10) (8,9) (11,0) (1,2) 7:6 -- = 267 = #6 = (4,8) (5,7) (6,2) (7,11) (9,1) (10,0) 9:7 = 435 = #4 = -- (4,1) (5,0) (6,9) (11,2) 9:8 = 204 = #6 = (3,5) (4,2) (6,8) (7,9) -- (11,1) (0,2) 21:16 = 471 = #6 = (3,7) (5,9) (6,0) (7,1) (8,2) (10,2) -- 27:14 = 1137 = #2 = (4,6) (9,11) 27:16 = 906 = #3 = (4,7) (8,11) (9,0) -- 49:32 = 738 = #3 = (3,11) (5,1) (6,10) 49:36 = 534 = #1 = (5,11) 63:32 -- = 1173 = #5 = (3,2) (4,5) (8,7) (9,10) (1,0) 49:48 = 36 = #2 = (5,6) -- (10,11) 81:56 = 639 = #1 = (4,11) 81:64 = 408 = #1 = (4,0) 147:128 = -- 240 = #3 = (3,6) (5,8) (10,1) 189:128 = 675 = #3 = (3,9) (4,10) (8,0) -- 441:256 = 942 = #2 = (3,1) (8,10) 567:512 = 177 = #1 = (3,4) 1323:1024 -- = 444 = #1 = (3,8) lmy_wtp_uniq :: [(Rational, [(PitchClass, PitchClass)])] -- | Gann, 1993, p.137. -- --
--   cents_i lmy_wtp == [0,177,204,240,471,444,675,702,738,969,942,1173]
--   
-- --
--   import Data.List 
--   import Music.Theory.Tuning.Scala 
--   scl <- scl_load "young-lm_piano"
--   cents_i (scale_to_tuning 0.01 scl) == cents_i lmy_wtp
--   
-- --
--   let f = d12_midi_tuning_f (lmy_wtp,-74.7,-3)
--   import qualified Music.Theory.Pitch as T
--   T.octpc_to_midi (-1,11) == 11
--   map (round . T.midi_detune_to_cps . f) [62,63,69] == [293,298,440]
--   map (fmap round . T.midi_detune_normalise . f) [0 .. 127]
--   
lmy_wtp :: Tuning -- | Ratios for 'lmy_wtp_1964. lmy_wtp_1964_r :: [Rational] -- | La Monte Young's initial 1964 tuning for "The Well-Tuned Piano" (Gann, -- 1993, p.141). -- --
--   cents_i lmy_wtp_1964 == [0,149,204,240,471,647,675,702,738,969,1145,1173]
--   
-- --
--   import Music.Theory.Tuning.Scala
--   let nm = ("young-lm_piano_1964","LaMonte Young's Well-Tuned Piano (1964)")
--   let scl = tuning_to_scale nm lmy_wtp_1964
--   putStr $ unlines $ scale_pp scl
--   
lmy_wtp_1964 :: Tuning -- | Euler diagram for lmy_wtp. -- -- let dir = "homerohanswhmtdatadot/" let f = -- unlines . T.euler_plane_to_dot_rat (3,True) writeFile (dir ++ -- "euler-wtp.dot") (f lmy_wtp_euler) lmy_wtp_euler :: Euler_Plane Rational -- | Andreas Werckmeister (1645-1706). module Music.Theory.Tuning.Db.Werckmeister -- | Approximate ratios for werckmeister_iii. -- --
--   let c = [0,90,192,294,390,498,588,696,792,888,996,1092]
--   in map (round . ratio_to_cents) werckmeister_iii_ar == c
--   
werckmeister_iii_ar :: [Approximate_Ratio] -- | Cents for werckmeister_iii. werckmeister_iii_ar_c :: [Cents] -- | Werckmeister III, Andreas Werckmeister (1645-1706) -- --
--   cents_i werckmeister_iii == [0,90,192,294,390,498,588,696,792,888,996,1092]
--   
-- --
--   import Music.Theory.Tuning.Scala
--   scl <- scl_load "werck3"
--   cents_i (scale_tuning 0.01 scl) == cents_i werckmeister_iii
--   
werckmeister_iii :: Tuning -- | Approximate ratios for werckmeister_iv. -- --
--   let c = [0,82,196,294,392,498,588,694,784,890,1004,1086]
--   in map (round . ratio_to_cents) werckmeister_iv_ar == c
--   
werckmeister_iv_ar :: [Approximate_Ratio] -- | Cents for werckmeister_iv. werckmeister_iv_c :: [Cents] -- | Werckmeister IV, Andreas Werckmeister (1645-1706) -- --
--   cents_i werckmeister_iv == [0,82,196,294,392,498,588,694,784,890,1004,1086]
--   
-- --
--   scl <- scl_load "werck4"
--   cents_i (scale_tuning 0.01 scl) == cents_i werckmeister_iv
--   
werckmeister_iv :: Tuning -- | Approximate ratios for werckmeister_v. -- --
--   let c = [0,96,204,300,396,504,600,702,792,900,1002,1098]
--   in map (round . ratio_to_cents) werckmeister_v_ar == c
--   
werckmeister_v_ar :: [Approximate_Ratio] -- | Cents for werckmeister_v. werckmeister_v_c :: [Cents] -- | Werckmeister V, Andreas Werckmeister (1645-1706) -- --
--   cents_i werckmeister_v == [0,96,204,300,396,504,600,702,792,900,1002,1098]
--   
-- --
--   scl <- scl_load "werck5"
--   cents_i (scale_tuning 0.01 scl) == cents_i werckmeister_v
--   
werckmeister_v :: Tuning -- | Ratios for werckmeister_vi, with supposed correction of 2825 -- to 4944. -- --
--   let c = [0,91,186,298,395,498,595,698,793,893,1000,1097]
--   in map (round . ratio_to_cents) werckmeister_vi_r == c
--   
werckmeister_vi_r :: [Rational] -- | Werckmeister VI, Andreas Werckmeister (1645-1706) -- --
--   cents_i werckmeister_vi == [0,91,186,298,395,498,595,698,793,893,1000,1097]
--   
-- --
--   scl <- scl_load "werck6"
--   cents_i (scale_tuning 0.01 scl) == cents_i werckmeister_vi
--   
werckmeister_vi :: Tuning -- | Terry Riley. module Music.Theory.Tuning.Db.Riley -- | Ratios for riley_albion. -- --
--   let r = [0,112,204,316,386,498,610,702,814,884,996,1088]
--   in map (round . ratio_to_cents) riley_albion_r == r
--   
riley_albion_r :: [Rational] -- | Riley's five-limit tuning as used in _The Harp of New Albion_, see -- http://www.ex-tempore.org/Volx1/hudson/hudson.htm. -- --
--   cents_i riley_albion == [0,112,204,316,386,498,610,702,814,884,996,1088]
--   
-- --
--   import Music.Theory.Tuning.Scala
--   scl <- scl_load "riley_albion"
--   cents_i (scale_tuning 0.01 scl) == cents_i riley_albion
--   
riley_albion :: Tuning -- | http://www.microtonal-synthesis.com/scales.html module Music.Theory.Tuning.Db.Microtonal_Synthesis -- | Ratios for pythagorean. pythagorean_12_r :: [Rational] -- | Pythagorean tuning, -- http://www.microtonal-synthesis.com/scale_pythagorean.html. -- --
--   cents_i pythagorean_12 == [0,114,204,294,408,498,612,702,816,906,996,1110]
--   
-- --
--   scl <- scl_load "pyth_12"
--   cents_i (scale_tuning 0.1 scl) == cents_i pythagorean_12
--   
pythagorean_12 :: Tuning -- | Ratios for five_limit_tuning. -- --
--   let c = [0,112,204,316,386,498,590,702,814,884,996,1088]
--   in map (round . ratio_to_cents) five_limit_tuning_r == c
--   
five_limit_tuning_r :: [Rational] -- | Five-limit tuning (five limit just intonation), Alexander Malcolm's -- Monochord (1721). -- --
--   cents_i five_limit_tuning == [0,112,204,316,386,498,590,702,814,884,996,1088]
--   
-- --
--   scl <- scl_load "malcolm"
--   cents_i (scale_tuning 0.1 scl) == cents_i five_limit_tuning
--   
five_limit_tuning :: Tuning -- | Ratios for septimal_tritone_just_intonation. -- --
--   let c = [0,112,204,316,386,498,583,702,814,884,1018,1088]
--   in map (round . ratio_to_cents) septimal_tritone_just_intonation == c
--   
septimal_tritone_just_intonation_r :: [Rational] -- | Septimal tritone Just Intonation, see -- http://www.microtonal-synthesis.com/scale_just_intonation.html -- --
--   let c = [0,112,204,316,386,498,583,702,814,884,1018,1088]
--   in cents_i septimal_tritone_just_intonation == c
--   
-- --
--   scl <- scl_load "ji_12"
--   cents_i (scale_tuning 0.1 scl) == cents_i septimal_tritone_just_intonation
--   
septimal_tritone_just_intonation :: Tuning -- | Ratios for seven_limit_just_intonation. -- --
--   let c = [0,112,204,316,386,498,583,702,814,884,969,1088]
--   in map (round . ratio_to_cents) seven_limit_just_intonation == c
--   
seven_limit_just_intonation_r :: [Rational] -- | Seven limit Just Intonation. -- --
--   cents_i seven_limit_just_intonation == [0,112,204,316,386,498,583,702,814,884,969,1088]
--   
seven_limit_just_intonation :: Tuning -- | Approximate ratios for kirnberger_iii. -- --
--   let c = [0,90,193,294,386,498,590,697,792,890,996,1088]
--   in map (round.to_cents) kirnberger_iii_ar == c
--   
kirnberger_iii_ar :: [Approximate_Ratio] -- | http://www.microtonal-synthesis.com/scale_kirnberger.html. -- --
--   cents_i kirnberger_iii == [0,90,193,294,386,498,590,697,792,890,996,1088]
--   
-- --
--   scl <- scl_load "kirnberger"
--   cents_i (scale_tuning 0.1 scl) == cents_i kirnberger_iii
--   
kirnberger_iii :: Tuning vallotti_c :: [Cents] -- | Vallotti & Young scale (Vallotti version), see -- http://www.microtonal-synthesis.com/scale_vallotti_young.html. -- --
--   cents_i vallotti == [0,94,196,298,392,502,592,698,796,894,1000,1090]
--   
-- --
--   scl <- scl_load "vallotti"
--   cents_i (scale_tuning 0.1 scl) == cents_i vallotti
--   
vallotti :: Tuning mayumi_tsuda_r :: [Rational] -- | Mayumi Tsuda 13-limit Just Intonation scale, -- http://www.microtonal-synthesis.com/scale_reinhard.html. -- --
--   cents_i mayumi_tsuda == [0,128,139,359,454,563,637,746,841,911,1072,1183]
--   
-- --
--   scl <- scl_load "tsuda13"
--   cents_i (scale_tuning 0.1 scl) == cents_i mayumi_tsuda
--   
mayumi_tsuda :: Tuning -- | Ratios for lou_harrison_16. -- --
--   length lou_harrison_16_r == 16
--   
-- --
--   let c = [0,112,182,231,267,316,386,498,603,702,814,884,933,969,1018,1088]
--   in map (round . ratio_to_cents) lou_harrison_16_r == c
--   
lou_harrison_16_r :: [Rational] -- | Lou Harrison 16 tone Just Intonation scale, see -- http://www.microtonal-synthesis.com/scale_harrison_16.html -- --
--   let r = [0,112,182,231,267,316,386,498,603,702,814,884,933,969,1018,1088]
--   in cents_i lou_harrison_16 == r
--   
-- --
--   import Music.Theory.Tuning.Scala
--   scl <- scl_load "harrison_16"
--   cents_i (scale_tuning 0.1 scl) == cents_i lou_harrison_16
--   
lou_harrison_16 :: Tuning -- | Ratios for partch_43. partch_43_r :: [Rational] -- | Harry Partch 43 tone scale, see -- http://www.microtonal-synthesis.com/scale_partch.html -- --
--   cents_i partch_43 == [0,22,53,84,112,151,165
--                        ,182,204,231,267,294,316
--                        ,347,386,418,435
--                        ,471,498,520,551,583,617,649
--                        ,680,702,729,765,782,814,853,884,906,933
--                        ,969,996,1018,1035,1049,1088,1116,1147,1178]
--   
-- --
--   scl <- scl_load "partch_43"
--   cents_i (scale_tuning 0.1 scl) == cents_i partch_43
--   
partch_43 :: Tuning -- | Ratios for ben_johnston_25. ben_johnston_25_r :: [Rational] -- | Ben Johnston 25 note just enharmonic scale, see -- http://www.microtonal-synthesis.com/scale_johnston_25.html -- --
--   scl <- scl_load "johnston_25"
--   cents_i (scale_tuning 0.1 scl) == cents_i ben_johnston_25
--   
ben_johnston_25 :: Tuning -- | Kyle Gann. module Music.Theory.Tuning.Db.Gann -- | Cents for pietro_aaron_1523. -- --
--   let c = [0,76,193,310,386,503,580,697,773,890,1007,1083]
--   map round pietro_aaron_1523_c == c
--   
-- --
--   map ((+ 60) . (/ 100)) pietro_aaron_1523_c
--   
pietro_aaron_1523_c :: [Cents] -- | Pietro Aaron (1523) meantone temperament, see -- http://www.kylegann.com/histune.html -- --
--   tn_cents_i pietro_aaron_1523 == [0,76,193,310,386,503,580,697,773,890,1007,1083]
--   
-- --
--   import Music.Theory.Tuning.Scala
--   scl <- scl_load "meanquar"
--   tn_cents_i (scale_to_tuning 0.01 scl) == [0,76,193,310,386,503,579,697,773,890,1007,1083]
--   
pietro_aaron_1523 :: Tuning -- | Cents for thomas_young_1799. -- --
--   let c = [0,94,196,298,392,500,592,698,796,894,1000,1092]
--   map round thomas_young_1799_c == c
--   
thomas_young_1799_c :: [Cents] -- | Thomas Young (1799), Well Temperament, -- http://www.kylegann.com/histune.html. -- --
--   tn_cents_i thomas_young_1799 == [0,94,196,298,392,500,592,698,796,894,1000,1092]
--   
-- --
--   scl <- scl_load "young2"
--   tn_cents_i (scale_to_tuning 0.01 scl) == tn_cents_i thomas_young_1799
--   
thomas_young_1799 :: Tuning -- | Ratios for zarlino. -- --
--   length zarlino_1588_r == 16
--   
zarlino_1588_r :: [Rational] -- | Gioseffo Zarlino, 1588, see -- http://www.kylegann.com/tuning.html. -- --
--   tn_divisions zarlino_1588 == 16
--   tn_cents_i zarlino_1588 == [0,71,182,204,294,316,386,498,569,590,702,773,884,996,1018,1088]
--   
-- --
--   scl <- scl_load "zarlino2"
--   tn_cents_i (scale_to_tuning 0.01 scl) == tn_cents_i zarlino_1588
--   
zarlino_1588 :: Tuning -- | Ratios for ben_johnston_mtp_1977. -- --
--   let c = [0,105,204,298,386,471,551,702,841,906,969,1088]
--   map (round . ratio_to_cents) ben_johnston_mtp_1977_r == c
--   
ben_johnston_mtp_1977_r :: [Rational] -- | Ben Johnston's "Suite for Microtonal Piano" (1977), see -- http://www.kylegann.com/tuning.html -- --
--   tn_cents_i ben_johnston_mtp_1977 == [0,105,204,298,386,471,551,702,841,906,969,1088]
--   
ben_johnston_mtp_1977 :: Tuning -- | Ratios for gann_arcana_xvi. gann_arcana_xvi_r :: [Rational] -- | Kyle Gann, _Arcana XVI_, see -- http://www.kylegann.com/Arcana.html. -- --
--   let r = [0,84,112,204,267,316,347,386,471,498,520,583,663,702,734,814,845,884,898,969,1018,1049,1088,1161]
--   tn_cents_i gann_arcana_xvi == r
--   
gann_arcana_xvi :: Tuning -- | Ratios for gann_superparticular. gann_superparticular_r :: [Rational] -- | Kyle Gann, _Superparticular_, see -- http://www.kylegann.com/Super.html. -- --
--   tn_divisions gann_superparticular == 22
--   
-- --
--   let r = [0,165,182,204,231,267,316,386,435,498,551,583,617,702,782,765,814,884,933,969,996,1018]
--   tn_cents_i gann_superparticular == r
--   
-- --
--   scl <- scl_load "gann_super"
--   tn_cents_i (scale_to_tuning 0.01 scl) == tn_cents_i gann_superparticular
--   
gann_superparticular :: Tuning -- | Bill Alves. module Music.Theory.Tuning.Db.Alves -- | Ratios for harrison_ditone (SCALA=pyth_12) -- --
--   import Music.Theory.Tuning 
--   let c = [0,114,204,294,408,498,612,702,816,906,996,1110]
--   map (round . ratio_to_cents) harrison_ditone_r == c
--   
-- --
--   import Music.Theory.Tuning.Scala 
--   scl_find_ji (harrison_ditone_r ++ [2])
--   
harrison_ditone_r :: [Rational] -- | Ditonepythagorean tuning, -- <http:www.billalves.comporgitaro/ditonesettuning.html> -- --
--   tn_divisions harrison_ditone == 12
--   tn_cents_i harrison_ditone == [0,114,204,294,408,498,612,702,816,906,996,1110]
--   
harrison_ditone :: Tuning -- | Bill Alves. "Pleng: Composing for a Justly Tuned Gender Barung". 1/1: -- Journal of the Just Intonation Network, 1:4-11, Spring 1997. -- http://www2.hmc.edu/~alves/pleng.html module Music.Theory.Tuning.Alves_1997 alves_slendro_r :: [Rational] -- | HMC slendro tuning. -- --
--   cents_i alves_slendro == [0,231,498,765,996]
--   
-- --
--   import Music.Theory.Tuning.Scala 
--   scl <- scl_load "alves_slendro"
--   tn_cents_i (scale_to_tuning 0.01 scl) == tn_cents_i alves_slendro
--   
alves_slendro :: Tuning alves_pelog_bem_r :: [Rational] -- | HMC pelog bem tuning. -- --
--   tn_cents_i alves_pelog_bem == [0,231,316,702,814]
--   
-- --
--   scl <- scl_load "alves_pelog"
--   tn_cents_i (scale_to_tuning 0.01 scl) == [0,231,316,471,702,814,969]
--   
alves_pelog_bem :: Tuning alves_pelog_barang_r :: [Rational] -- | HMC pelog barang tuning. -- --
--   tn_cents_i alves_pelog_barang == [0,386,471,857,969]
--   
alves_pelog_barang :: Tuning alves_pelog_23467_r :: [Rational] -- | HMC pelog 2,3,4,6,7 tuning. -- --
--   tn_cents_i alves_pelog_23467 == [0,386,471,702,969]
--   
alves_pelog_23467 :: Tuning -- | Db of locally defined tunings, but for ordinary use see -- Music.Theory.Tuning.Scala. module Music.Theory.Tuning.Db -- | (last-name,first-name,title,year,hmttuning,scalaname) type Named_Tuning = (String, String, String, String, Tuning, String) named_tuning_t :: Named_Tuning -> Tuning tuning_db :: [Named_Tuning] tuning_db_lookup_scl :: String -> Maybe Tuning -- | Erv Wilson, archives http://anaphoria.com/wilson.html module Music.Theory.Tuning.Wilson type V2 n = (n, n) v2_map :: (t -> u) -> V2 t -> V2 u v2_zip :: (a -> b -> c) -> V2 a -> V2 b -> V2 c v2_add :: Num n => V2 n -> V2 n -> V2 n v2_sum :: Num n => [V2 n] -> V2 n v2_scale :: Num n => n -> V2 n -> V2 n -- | Normalise set of points to lie in (-1,-1) - (1,1), scaling -- symetrically about (0,0) -- --
--   pt_set_normalise_sym [(40,0),(0,40),(13,11),(-8,4)] == [(1,0),(0,1),(0.325,0.275),(-0.2,0.1)]
--   pt_set_normalise_sym [(-10,0),(1,10)] == [(-1,0),(0.1,1)]
--   
pt_set_normalise_sym :: (Fractional n, Ord n) => [V2 n] -> [V2 n] -- | k-unit co-ordinates for k-lattice. type Lattice_Design n = (Int, [V2 n]) -- | Erv Wilson standard lattice, unit co-ordinates for 5-dimensions, ie. -- [3,5,7,11,13] -- -- http://anaphoria.com/wilsontreasure.html ew_lc_std :: Num n => Lattice_Design n -- | Kraig Grady standard lattice, unit co-ordinates for 5-dimensions, ie. -- [3,5,7,11,13] -- -- http://anaphoria.com/wilsontreasure.html kg_lc_std :: Num n => Lattice_Design n -- | Erv Wilson tetradic lattice (3-lattice), used especially when working -- with hexanies or 7 limit tunings -- -- http://anaphoria.com/wilsontreasure.html ew_lc_tetradic :: Num n => Lattice_Design n -- | A discrete k-lattice is described by a sequence of -- k-factors. Values are ordinarily though not necessarily primes -- beginning at three. type Lattice_Factors i = (Int, [i]) -- | Positions in a k-lattice are given as a k-list of steps. type Lattice_Position = (Int, [Int]) -- | Delete entry at index. lc_pos_del :: Int -> Lattice_Position -> Lattice_Position -- | Resolve Lattice_Position against Lattice_Design to V2 lc_pos_to_pt :: (Fractional n, Ord n) => Lattice_Design n -> Lattice_Position -> V2 n -- | White-space pretty printer for Lattice_Position. -- --
--   pos_pp_ws (3,[0,-2,1]) == "  0 -2  1"
--   
pos_pp_ws :: Lattice_Position -> String -- | Given Lattice_Factors [X,Y,Z..] and Lattice_Position [x,y,z..], -- calculate the indicated ratio. -- --
--   lat_res (2,[3,5]) (2,[-5,2]) == (5 * 5) / (3 * 3 * 3 * 3 * 3)
--   
lat_res :: Integral i => Lattice_Factors i -> Lattice_Position -> Ratio i -- | Ratio given as (n,d) type Rat = (Integer, Integer) -- | Remove all octaves from n and d. rat_rem_oct :: Rat -> Rat -- | Lift Rat function to Rational. rat_lift_1 :: (Rat -> Rat) -> Rational -> Rational -- | Convert Rat to Rational rat_to_ratio :: Rat -> Rational -- | Mediant, ie. n1+n2/d1+d2 -- --
--   rat_mediant (0,1) (1,2) == (1,3)
--   
rat_mediant :: Rat -> Rat -> Rat -- | Rat written as n/d rat_pp :: Rat -> String -- | Lifted rat_rem_oct. -- --
--   map ew_r_rem_oct [256/243,7/5,1/7] == [1/243,7/5,1/7]
--   
r_rem_oct :: Rational -> Rational -- | Assert that n is in [1,2). r_verify_oct :: Rational -> Rational -- | Find limit of set of ratios, ie. largest factor in either numerator or -- denominator. -- --
--   r_seq_limit [1] == 1
--   
r_seq_limit :: [Rational] -> Integer -- | Find factors of set of ratios, ie. the union of all factor in both -- numerator & denominator. -- --
--   r_seq_factors [1/3,5/7,9/8,13,27,31] == [2,3,5,7,13,31]
--   
r_seq_factors :: [Rational] -> [Integer] -- | Vector of prime-factors up to limit. -- --
--   map (rat_fact_lm 11) [3,5,7,2/11] == [(5,[0,1,0,0,0]),(5,[0,0,1,0,0]),(5,[0,0,0,1,0]),(5,[1,0,0,0,-1])]
--   
rat_fact_lm :: Integer -> Rational -> Lattice_Position tbl_txt :: Bool -> Integer -> [Rational] -> [[String]] tbl_wr :: Bool -> [Rational] -> IO () -- | (maybe (maybe lattice-design, maybe primes),gr-attr,vertex-pp) type Ew_Gr_Opt = (Maybe (Lattice_Design Rational, Maybe [Integer]), [Dot_Meta_Attr], Rational -> String) ew_gr_opt_pos :: Ew_Gr_Opt -> Bool ew_gr_r_pos :: Lattice_Design Rational -> Maybe [Integer] -> Rational -> Dot_Attr -- | lbl_to_udot add position attribute if a Lattice_Design -- is given. ew_gr_udot :: Ew_Gr_Opt -> Lbl Rational () -> [String] -- | writeFile of ew_gr_udot ew_gr_udot_wr :: Ew_Gr_Opt -> FilePath -> Lbl Rational () -> IO () ew_gr_udot_wr_svg :: Ew_Gr_Opt -> FilePath -> Lbl Rational () -> IO () zz_seq_1 :: (Eq n, Num n) => Int -> (n, n) -> (n, n) -> [(n, n)] zz_next :: (Eq n, Num n) => Int -> [(n, n)] -> [(n, n)] zz_recur :: (Eq n, Num n) => [Int] -> [(n, n)] -> [[(n, n)]] zz_seq :: (Eq n, Num n) => [Int] -> [[(n, n)]] gen_coprime :: Integral a => a -> [a] mos_2 :: Num n => n -> n -> (n, n) -- | Divide MOS, keeps retained value on same side -- --
--   mos_step (5,7) == (5,2)
--   mos_step (5,2) == (3,2)
--   mos_step (3,2) == (1,2)
--   
mos_step :: (Ord a, Num a) => (a, a) -> (a, a) mos_unfold :: (Ord b, Num b) => (b, b) -> [(b, b)] mos_verify :: Integral a => a -> a -> Bool mos :: (Ord b, Integral b) => b -> b -> [(b, b)] mos_seq :: (Ord b, Integral b) => b -> b -> [[b]] mos_cell_pp :: (Integral i, Show i) => i -> String mos_row_pp :: (Integral i, Show i) => [i] -> String mos_tbl_pp :: (Integral i, Show i) => [[i]] -> [String] mos_tbl_wr :: (Integral i, Show i) => [[i]] -> IO () mos_recip_seq :: Double -> [(Int, Double)] mos_log :: Double -> [(Int, Double)] mos_log_kseq :: Double -> [Int] data SBT_DIV NIL :: SBT_DIV LHS :: SBT_DIV RHS :: SBT_DIV type Sbt_Node = (SBT_DIV, Rat, Rat, Rat) sbt_step :: Sbt_Node -> [Sbt_Node] sbt_root :: Sbt_Node sbt_half :: Sbt_Node sbt_from :: Sbt_Node -> [[Sbt_Node]] sbt_k_from :: Int -> Sbt_Node -> [[Sbt_Node]] sbt_node_to_edge :: Sbt_Node -> String sbt_node_elem :: Sbt_Node -> [Rat] sbt_dot :: [Sbt_Node] -> [String] (^.) :: Rational -> Int -> Rational r_normalise :: [Rational] -> [Rational] -- | (ratio,multiplier,steps) type M_Gen = (Rational, Rational, Int) m_gen_unfold :: M_Gen -> [Rational] m_gen_to_r :: [M_Gen] -> [Rational] -- | (ratio,M3-steps) type M3_Gen = (Rational, Int) m3_to_m :: M3_Gen -> M_Gen m3_gen_unfold :: M3_Gen -> [Rational] m3_gen_to_r :: [M3_Gen] -> [Rational] r_to_scale :: String -> String -> [Rational] -> Scale ew_scl_find_r :: [Rational] -> [Scale] -> [String] ew_1357_3_gen :: [M3_Gen] -- | P.3 7-limit {Scala=nil} -- --
--   db <- Scala.scl_load_db
--   ew_scl_find_r (1 : ew_1357_3_r) db
--   
ew_1357_3_r :: [Rational] ew_1357_3_scl :: Scale -- | P.7 11-limit {Scala=nil} -- --
--   ew_scl_find_r ew_el12_7_r db
--   
ew_el12_7_r :: [Rational] ew_el12_7_scl :: Scale -- | P.9 7-limit {Scala=wilson_class} -- --
--   ew_scl_find_r ew_el12_9_r db
--   
ew_el12_9_r :: [Rational] -- | P.12 11-limit {Scala=nil} -- --
--   ew_scl_find_r ew_el12_12_r db
--   
ew_el12_12_r :: [Rational] ew_el12_12_scl :: Scale -- | P.2 11-limit {Scala=wilson_l4} -- --
--   ew_scl_find_r ew_el22_2_r db
--   
ew_el22_2_r :: [Rational] -- | P.3 11-limit {Scala=wilson_l5} -- --
--   ew_scl_find_r ew_el22_3_r db
--   
ew_el22_3_r :: [Rational] -- | P.4 11-limit {Scala=wilson_l3} -- --
--   ew_scl_find_r ew_el22_4_r db
--   
ew_el22_4_r :: [Rational] -- | P.5 11-limit {Scala=wilson_l1} -- --
--   ew_scl_find_r ew_el22_5_r db
--   
ew_el22_5_r :: [Rational] -- | P.6 11-limit {Scala=wilson_l2} -- --
--   ew_scl_find_r ew_el22_6_r db
--   
ew_el22_6_r :: [Rational] ew_diamond_mk :: [Integer] -> [Rational] ew_diamond_12_gen :: [M3_Gen] -- | P.7 & P.12 11-limit {Scala=partch_29} -- -- 1,3,5,7,9,11 diamond -- --
--   ew_scl_find_r ew_diamond_12_r db -- partch_29
--   
ew_diamond_12_r :: [Rational] -- | P.10 & P.13 13-limit {Scala=novaro15} -- -- 1,3,5,7,9,11,13,15 diamond -- --
--   ew_scl_find_r ew_diamond_13_r db -- novaro15
--   
ew_diamond_13_r :: [Rational] hel_r_asc :: (Integer, Integer) -> [Rational] type HEL = ([Rational], [Rational]) -- | P.6 hel_1_i :: HEL -- | P.6 hel_2_i :: HEL -- | P.10 hel_3_i :: HEL hel_r :: HEL -> [[Rational]] -- | P.12 {Scala=nil} -- -- 22-tone 23-limit Evangalina tuning (2001) -- --
--   ew_scl_find_r ew_hel_12_r db
--   
ew_hel_12_r :: [Rational] ew_hel_12_scl :: Scale she_div :: Eq a => [a] -> [[[a]]] she_div_r :: [Rational] -> [Rational] she_mul_r :: [Rational] -> [Rational] -- | she = Stellate Hexany Expansions, P.10 -- {Scala=stelhex1,stelhex2,stelhex5,stelhex6} -- --
--   she [1,3,5,7] == [1,21/20,15/14,35/32,9/8,5/4,21/16,35/24,3/2,49/32,25/16,105/64,7/4,15/8]
--   mapM (flip ew_scl_find_r db . she) [[1,3,5,7],[1,3,5,9],[1,3,7,9],[1,3,5,11]]
--   ew_scl_find_r (she [1,(5*7)/(3*3),1/(3 * 5),1/3]) db -- NIL
--   
she :: [Rational] -> [Rational] every_nth :: [t] -> Int -> [t] meru :: Num n => [[n]] meru_k :: Num n => Int -> [[n]] meru_1 :: Num n => Int -> [n] meru_1_direct :: Num n => [n] -- | Meru 2 = META-PELOG -- --
--   map (sum . meru_2) [1 .. 14] == [1,1,1,2,3,4,6,9,13,19,28,41,60,88]
--   
meru_2 :: Num n => Int -> [n] meru_2_direct :: Num n => [n] -- | meru_3 = META-SLENDRO meru_3 :: Num n => Int -> [[n]] meru_3_seq :: Num n => Int -> [[n]] meru_3_direct :: Num n => [n] meru_4 :: Num n => Int -> [n] meru_4_direct :: Num n => [n] meru_5 :: Num n => Int -> [[n]] meru_5_seq :: Num n => Int -> [[n]] meru_5_direct :: Num n => [n] meru_6 :: Num n => Int -> [n] meru_6_direct :: Num n => [n] meru_7_direct :: Num n => [n] -- | P.13, tanabe {Scala=chin_7} -- --
--   ew_scl_find_r ew_mos_13_tanabe_r db
--   
ew_mos_13_tanabe_r :: [Rational] ew_novarotreediamond_1 :: ([[Rational]], [[Rational]]) -- | P.1 {Scala=nil} -- -- 23-tone 7-limit (2004) -- --
--   ew_scl_find_r ew_novarotreediamond_1_r db
--   
ew_novarotreediamond_1_r :: [Rational] ew_novarotreediamond_1_scl :: Scale -- | P.2 {Scala=nil} -- -- 9-tone Pelog cycle (1988) -- --
--   ew_scl_find_r ew_Pelogflute_2_r db
--   
ew_Pelogflute_2_r :: Fractional n => [n] ew_Pelogflute_2_scl :: Scale -- | P.9, Fig. 3 xen1_fig3 :: (Sbt_Node, Int) -- | P.9, Fig. 4 xen1_fig4 :: (Sbt_Node, Int) -- | P.3 Turkisk Baglama Scale {11-limit, Scala=nil} ew_xen3b_3_gen :: [(Rational, Int)] ew_xen3b_3_r :: [Rational] ew_xen3b_3_scl :: Scale xen3b_9_i :: [[Rational]] -- | P.9 {SCALA 5=nil 7=ptolemy_idiat 12=nil 19=wilson2 31=wilson_31} -- --
--   mapM ew_scl_find_r xen3b_9_r db
--   
xen3b_9_r :: [[Rational]] xen3b_13_i :: [[Rational]] -- | P.13 {SCALA 5=slendro5_2 7=ptolemy_diat2 12=nil 17=nil 22=wilson7_4} xen3b_13_r :: [[Rational]] -- | PP.1-2 {SCALA: 22=wilson7_4} -- -- 17,31,41 lattices from XEN3B (1975) ew_xen3b_apx_gen :: [(Int, [M3_Gen])] ew_xen3b_apx_r :: [(Int, [Rational])] ew_xen456_7_gen :: [M3_Gen] ew_xen456_7_r :: [Rational] ew_xen456_9_gen :: [M3_Gen] -- | P.9 {Scala=nil ; Scala:Rot=wilson11} -- -- 19-tone scale for the Clavichord-19 (1976) -- --
--   ew_scl_find_r ew_xen456_9_r db
--   
-- --
--   import qualified Music.Theory.List as List 
--   Scala.scl_find_ji List.is_subset ew_xen456_9_r db -- NIL
--   
ew_xen456_9_r :: [Rational] ew_xen456_9_scl :: Scale -- | -- http://wilsonarchives.blogspot.com/2010/10/scale-for-rod-poole.html -- -- 13-limit 22-tone scale {Scala=nil} -- --
--   ew_scl_find_r ew_poole_r db
--   
ew_poole_r :: [Rational] ew_poole_scl :: Scale -- | -- http://wilsonarchives.blogspot.com/2014/05/an-11-limit-centaur-implied-in-wilson.html -- -- 11-limit 17-tone scale {Scala=wilcent17} -- --
--   ew_scl_find_r ew_centaur17_r db
--   
ew_centaur17_r :: [Rational] -- | -- http://wilsonarchives.blogspot.com/2018/03/an-unusual-22-tone-7-limit-tuning.html -- -- 7-limit 22-tone scale {Scala=nil} -- --
--   ew_scl_find_r ew_two_22_7_r db
--   
ew_two_22_7_r :: [Rational] ew_two_22_7_scl :: Scale -- | Scales not present in the standard scala file set. -- --
--   mapM_ (Scala.scale_wr_dir "/home/rohan/sw/hmt/data/scl/") ew_scl_db
--   map Scala.scale_name ew_scl_db
--   
ew_scl_db :: [Scale] instance GHC.Show.Show Music.Theory.Tuning.Wilson.SBT_DIV -- | http://www.ivan-wyschnegradsky.fr/en/chromatic-drawings/ module Music.Theory.Wyschnegradsky -- | In a modulo m system, normalise step increments to be either -1 -- or 1. Non steps raise an error. -- --
--   map (normalise_step 6) [-5,-1,1,5] == [1,-1,1,-1]
--   
normalise_step :: (Eq n, Num n) => n -> n -> n -- | Wyschnegradsky writes the direction sign at the end of the number. -- --
--   map parse_num_sign ["2+","4-"] == [2,-4]
--   
parse_num_sign :: (Num n, Read n) => String -> n -- | Expand a chromatic (step-wise) sequence, sign indicates direction. -- --
--   map vec_expand [2,-4] == [[1,1],[-1,-1,-1,-1]]
--   
vec_expand :: Num n => Int -> [n] -- | Parse the vector notation used in some drawings, a comma separated -- list of chromatic sequences. -- --
--   parse_vec Nothing 0 "4-,4+,4-,4+,4-,4+,4-,4+,4-"
--   parse_vec Nothing 0 "2+,2-,2+,2-,2+,2-,2+,2-,2+,18+"
--   
parse_vec :: Num n => Maybe Int -> n -> String -> [n] -- | Modulo addition. add_m :: Integral a => a -> a -> a -> a -- | Parse hex colour string, as standard in HTML5. -- --
--   parse_hex_clr "#e14630" == (225,70,48)
--   
parse_hex_clr :: (Read n, Num n) => String -> (n, n, n) -- | Type specialised. parse_hex_clr_int :: String -> (Int, Int, Int) -- | Normalise colour by dividing each component by m. -- --
--   clr_normalise 255 (parse_hex_clr "#ff0066") == (1,0,0.4)
--   
clr_normalise :: (Real r, Fractional f) => f -> (r, r, r) -> (f, f, f) -- | Sequences are either in Radial or Circumferential order. data Seq a Radial :: [a] -> Seq a Circumferential :: [a] -> Seq a -- | Group sequence into normal (ie. Circumferential) order given -- drawing dimensions. seq_group :: Int -> Int -> Seq a -> [[a]] -- | Printer for pitch-class segments. iw_pc_pp :: Integral n => String -> [[n]] -> IO () -- | Index to colour name abbreviation. -- --
--   map u3_ix_ch [0..5] == "ROYGBV"
--   
u3_ix_ch :: Integral i => i -> Char -- | Inverse of u3_ix_ch. -- --
--   map u3_ch_ix "ROYGBV" == [0..5]
--   
u3_ch_ix :: Char -> Int -- | Drawing definition, as written by Wyschnegradsky. -- --
--   mapM_ (\(c,r) -> putStrLn (unlines ["C: " ++ c,"R: " ++ r])) u3_vec_text_iw
--   
u3_vec_text_iw :: [(String, String)] -- | Re-written for local parser and to correct ambiguities and errors (to -- align with actual drawing). -- --
--   let f = parse_vec Nothing 0 in map (\(p,q) -> (f p,f q)) u3_vec_text_rw
--   
-- --
--   let f (c,r) = putStrLn (unlines ["C: " ++ c,"R: " ++ r])
--   mapM_ f (List.interleave u3_vec_text_iw u3_vec_text_rw)
--   
u3_vec_text_rw :: [(String, String)] -- | Parse of u3_vec_text_rw. -- --
--   let {(c,r) = u3_vec_ix ; c' = map length c}
--   in (length c,c',sum c',length r,map length r)
--   
u3_vec_ix :: Num n => ([[n]], [[n]]) -- | Radial indices (ie. each ray as an index sequence). -- --
--   putStrLn $ unlines $ map (map u3_ix_ch) u3_ix_radial
--   
u3_ix_radial :: Integral n => [[n]] -- | Colour names in index sequence. u3_clr_nm :: [String] -- | Colour values (hex strings) in index sequence. u3_clr_hex :: [String] -- | RGB form of u3_clr_hex. u3_clr_rgb :: Fractional n => [(n, n, n)] -- | Notated radial color sequence, transcribed from drawing. -- --
--   map (\(n,c) -> let v = u3_ch_seq_to_vec c in (n,sum v,v)) u3_radial_ch
--   
u3_radial_ch :: [(Int, [Char])] -- | Notated circumferenctial color sequence, transcribed from drawing. -- --
--   map (\(n,c) -> (n,u3_ch_seq_to_vec c)) u3_circ_ch
--   
u3_circ_ch :: [(Int, [Char])] -- | Translate notated sequence to "re-written" vector notation. u3_ch_seq_to_vec :: [Char] -> [Int] -- | Circumference pitch classes, C = 0. -- --
--   let c' = map length dc9_circ in (sum c',c') == (72,[5,6,7,2,3,4,4,3,2,7,7,4,4,3,2,2,3,4])
--   
-- --
--   iw_pc_pp " | " dc9_circ
--   
dc9_circ :: Num n => [[n]] -- | Rayon pitch classes, C = 0. -- --
--   length dc9_rad == 18
--   putStrLn $ unwords $ map f dc9_rad
--   
dc9_rad :: Num n => [n] -- | Radial indices. -- --
--   map length dc9_ix == replicate 72 18
--   
dc9_ix :: Integral n => [[n]] -- | Approximate colours, hex strings. dc9_clr_hex :: [String] -- | RGB form of colours. dc9_clr_rgb :: Fractional n => [(n, n, n)] u11_circ :: Num n => [[n]] u11_gen_seq :: Integral i => i -> Int -> [i] -> [i] u11_seq_rule :: Integral i => Maybe Int -> [i] ull_rad_text :: [Char] u11_rad :: Integral n => [[n]] u11_clr_hex :: [String] u11_clr_rgb :: Fractional n => [(n, n, n)] -- | Symetric Group S4 as related to the composition "Nomos Alpha" by -- Iannis Xenakis. In particular in relation to the discussion in -- "Towards a Philosophy of Music", Formalized Music pp. 219 -- -- 221 module Music.Theory.Xenakis.S4 -- | Labels for elements of the symmetric group P4. data Label A :: Label B :: Label C :: Label D :: Label D2 :: Label E :: Label E2 :: Label G :: Label G2 :: Label I :: Label L :: Label L2 :: Label Q1 :: Label Q2 :: Label Q3 :: Label Q4 :: Label Q5 :: Label Q6 :: Label Q7 :: Label Q8 :: Label Q9 :: Label Q10 :: Label Q11 :: Label Q12 :: Label -- | Initial half of Seq (ie. #4). The complete Seq is formed -- by appending the complement of the Half_Seq. type Half_Seq = [Int] -- | Complete sequence (ie. #8). type Seq = [Int] -- | Complement of a Half_Seq. -- --
--   map complement [[4,1,3,2],[6,7,8,5]] == [[8,5,7,6],[2,3,4,1]]
--   
complement :: Half_Seq -> Half_Seq -- | Form Seq from Half_Seq. -- --
--   full_seq [3,2,4,1] == [3,2,4,1,7,6,8,5]
--   label_of (full_seq [3,2,4,1]) == G2
--   label_of (full_seq [1,4,2,3]) == L
--   
full_seq :: Half_Seq -> Seq -- | Lower Half_Seq, ie. complement or id. -- --
--   map lower [[4,1,3,2],[6,7,8,5]] == [[4,1,3,2],[2,3,4,1]]
--   
lower :: Half_Seq -> Half_Seq -- | Application of Label p on q. -- --
--   l_on Q1 I == Q1
--   l_on D Q12 == Q4
--   [l_on L L,l_on E D,l_on D E] == [L2,C,B]
--   
l_on :: Label -> Label -> Label -- | Generalisation of Fibonnaci process, f is the binary operator -- giving the next element, p and q are the initial -- elements. -- -- See discussion in: Carlos Agon, Moreno Andreatta, Gérard Assayag, and -- Stéphan Schaub. _Formal Aspects of Iannis Xenakis' "Symbolic Music": A -- Computer-Aided Exploration of Compositional Processes_. Journal of New -- Music Research, 33(2):145-159, 2004. -- -- Note that the article has an error, printing Q4 for Q11 in the -- sequence below. -- --
--   import qualified Music.Theory.List as T
--   
-- --
--   let r = [D,Q12,Q4, E,Q8,Q2, E2,Q7,Q4, D2,Q3,Q11, L2,Q7,Q2, L,Q8,Q11]
--   (take 18 (fib_proc l_on D Q12) == r,T.duplicates r == [Q2,Q4,Q7,Q8,Q11])
--   
-- -- Beginning E then G2 no Q nodes are visited. -- --
--   let r = [E,G2,L2,C,G,D,E,B,D2,L,G,C,L2,E2,D2,B]
--   (take 16 (fib_proc l_on E G2) == r,T.duplicates r == [B,C,D2,E,G,L2])
--   
-- --
--   let [a,b] = take 2 (T.segments 18 18 (fib_proc l_on D Q12)) in a == b
--   
-- -- The prime numbers that are not factors of 18 are {1,5,7,11,13,17}. -- They form a closed group under modulo 18 multiplication. -- --
--   let n = [5,7,11,13,17]
--   let r0 = [(5,7,17),(5,11,1),(5,13,11),(5,17,13)]
--   let r1 = [(7,11,5),(7,13,1),(7,17,11)]
--   let r2 = [(11,13,17),(11,17,7)]
--   let r3 = [(13,17,5)]
--   [(p,q,(p * q) `mod` 18) | p <- n, q <- n, p < q] == concat [r0,r1,r2,r3]
--   
-- -- The article also omits the 5 after 5,1 in the sequence below. -- --
--   let r = [11,13,17,5,13,11,17,7,11,5,1,5,5,7,17,11,7,5,17,13,5,11,1,11]
--   take 24 (fib_proc (\p q -> (p * q) `mod` 18) 11 13) == r
--   
fib_proc :: (a -> a -> a) -> a -> a -> [a] -- | Seq of Label, inverse of label_of. -- --
--   seq_of Q1 == [8,7,5,6,4,3,1,2]
--   
seq_of :: Label -> Seq -- | Half_Seq of Label, ie. half_seq . -- seq_of. -- --
--   half_seq_of Q1 == [8,7,5,6]
--   
half_seq_of :: Label -> Seq -- | Half_Seq of Seq, ie. take 4. -- --
--   complement (half_seq (seq_of Q7)) == [3,4,2,1]
--   
half_seq :: Seq -> Half_Seq -- | Label of Seq, inverse of seq_of. -- --
--   label_of [8,7,5,6,4,3,1,2] == Q1
--   label_of (seq_of Q4) == Q4
--   
label_of :: Seq -> Label -- | True if two Half_Seqs are complementary, ie. form a -- Seq. -- --
--   complementary [4,2,1,3] [8,6,5,7] == True
--   
complementary :: Half_Seq -> Half_Seq -> Bool -- | Relation between to Half_Seq values as a -- (complementary,permutation) pair. type Rel = (Bool, Permutation) -- | Determine Rel of Half_Seqs. -- --
--   relate [1,4,2,3] [1,3,4,2] == (False,[0,3,1,2])
--   relate [1,4,2,3] [8,5,6,7] == (True,[1,0,2,3])
--   
relate :: Half_Seq -> Half_Seq -> Rel -- | Rel from Label p to q. -- --
--   relate_l L L2 == (False,[0,3,1,2])
--   
relate_l :: Label -> Label -> Rel -- | relate adjacent Half_Seq, see also relations_l. relations :: [Half_Seq] -> [Rel] -- | relate adjacent Labels. -- --
--   relations_l [L2,L,A] == [(False,[0,2,3,1]),(False,[2,0,1,3])]
--   
relations_l :: [Label] -> [Rel] -- | Apply Rel to Half_Seq. -- --
--   apply_relation (False,[0,3,1,2]) [1,4,2,3] == [1,3,4,2]
--   
apply_relation :: Rel -> Half_Seq -> Half_Seq -- | Apply sequence of Rel to initial Half_Seq. apply_relations :: [Rel] -> Half_Seq -> [Half_Seq] -- | Variant of apply_relations. -- --
--   apply_relations_l (relations_l [L2,L,A,Q1]) L2 == [L2,L,A,Q1]
--   
apply_relations_l :: [Rel] -> Label -> [Label] -- | Enumeration of set of faces of a cube. data Face F_Back :: Face F_Front :: Face F_Right :: Face F_Left :: Face F_Bottom :: Face F_Top :: Face -- | Table indicating set of faces of cubes as drawn in Fig. VIII-6 -- (p.220). -- --
--   lookup [1,4,6,7] faces == Just F_Left
--   T.reverse_lookup F_Right faces == Just [2,3,5,8]
--   
faces :: [([Int], Face)] -- | Label sequence of Fig. VIII-6. Hexahedral (Octahedral) Group (p. 220) -- --
--   let r = [I,A,B,C,D,D2,E,E2,G,G2,L,L2,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10,Q11,Q12]
--   in viii_6_lseq == r
--   
viii_6_lseq :: [Label] -- | Label sequence of Fig. VIII-7 (p.221) -- --
--   let r = [I,A,B,C,D,D2,E,E2,G,G2,L,L2,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10,Q11,Q12]
--   in viii_7_lseq == r
--   
viii_7_lseq :: [Label] -- | Fig. VIII-7 (p.221) -- --
--   map (take 4) (take 4 viii_7) == [[I,A,B,C]
--                                   ,[A,I,C,B]
--                                   ,[B,C,I,A]
--                                   ,[C,B,A,I]]
--   
-- --
--   import Music.Theory.Array.MD
--   
-- --
--   let t = md_matrix_opt show (\x -> "_" ++ x ++ "_") (head viii_7,head viii_7) viii_7
--   putStrLn $ unlines $ md_table' t
--   
viii_7 :: [[Label]] -- | Label sequence of Fig. VIII-6/b (p.221) -- --
--   length viii_6b_l == length viii_6_l
--   take 8 viii_6b_l == [I,A,B,C,D2,D,E2,E]
--   
viii_6b_lseq :: [Label] -- | Fig. VIII-6/b Half_Seq. -- --
--   viii_6b_p' == map half_seq_of viii_6b_l
--   nub (map (length . nub) viii_6b_p') == [4]
--   
viii_6b_p' :: [Half_Seq] -- | Variant of viii_6b with Half_Seq. viii_6b' :: [(Label, Half_Seq)] -- | Fig. VIII-6/b. -- --
--   map (viii_6b !!) [0,8,16] == [(I,[1,2,3,4,5,6,7,8])
--                                ,(G2,[3,2,4,1,7,6,8,5])
--                                ,(Q8,[6,8,5,7,2,4,1,3])]
--   
viii_6b :: [(Label, Seq)] -- | The sequence of Rel to give viii_6_l from L2. -- --
--   apply_relations_l viii_6_relations L2 == viii_6_l
--   length (nub viii_6_relations) == 14
--   
viii_6_relations :: [Rel] -- | The sequence of Rel to give viii_6b_l from I. -- --
--   apply_relations_l viii_6b_relations I == viii_6b_l
--   length (nub viii_6b_relations) == 10
--   
viii_6b_relations :: [Rel] instance GHC.Show.Show Music.Theory.Xenakis.S4.Label instance GHC.Enum.Bounded Music.Theory.Xenakis.S4.Label instance GHC.Enum.Enum Music.Theory.Xenakis.S4.Label instance GHC.Classes.Ord Music.Theory.Xenakis.S4.Label instance GHC.Classes.Eq Music.Theory.Xenakis.S4.Label instance GHC.Show.Show Music.Theory.Xenakis.S4.Face instance GHC.Classes.Ord Music.Theory.Xenakis.S4.Face instance GHC.Enum.Bounded Music.Theory.Xenakis.S4.Face instance GHC.Enum.Enum Music.Theory.Xenakis.S4.Face instance GHC.Classes.Eq Music.Theory.Xenakis.S4.Face -- | "Sieves" by Iannis Xenakis and John Rahn Perspectives of New -- Music Vol. 28, No. 1 (Winter, 1990), pp. 58-78 module Music.Theory.Xenakis.Sieve -- | A Sieve. data Sieve -- | Empty Sieve Empty :: Sieve -- | Primitive Sieve of modulo and index L :: (Integer, Integer) -> Sieve -- | Union of two Sieves Union :: Sieve -> Sieve -> Sieve -- | Intersection of two Sieves Intersection :: Sieve -> Sieve -> Sieve -- | Complement of a Sieve Complement :: Sieve -> Sieve -- | The Union of a list of Sieves, ie. foldl1 -- Union. union :: [Sieve] -> Sieve -- | The Intersection of a list of Sieves, ie. foldl1 -- Intersection. intersection :: [Sieve] -> Sieve -- | Unicode synonym for Union. (∪) :: Sieve -> Sieve -> Sieve infixl 3 ∪ -- | Unicode synonym for Intersection. (∩) :: Sieve -> Sieve -> Sieve infixl 4 ∩ -- | Synonym for Complement. c :: Sieve -> Sieve -- | Pretty-print sieve. Fully parenthesised. sieve_pp :: Sieve -> String -- | Variant of L, ie. curry L. -- --
--   l 15 19 == L (15,19)
--   
l :: Integer -> Integer -> Sieve -- | unicode synonym for l. (⋄) :: Integer -> Integer -> Sieve infixl 5 ⋄ -- | In a normal Sieve m is > i. -- --
--   normalise (L (15,19)) == L (15,4)
--   normalise (L (11,13)) == L (11,2)
--   
normalise :: Sieve -> Sieve -- | Predicate to test if a Sieve is normal. -- --
--   is_normal (L (15,4)) == True
--   is_normal (L (11,13)) == False
--   
is_normal :: Sieve -> Bool -- | Predicate to determine if an I is an element of the -- Sieve. -- --
--   map (element (L (3,1))) [1..4] == [True,False,False,True]
--   map (element (L (15,4))) [4,19 .. 49] == [True,True,True,True]
--   
element :: Sieve -> Integer -> Bool -- | I not in set. -- --
--   take 9 (i_complement [1,3..]) == [0,2..16]
--   
i_complement :: [Integer] -> [Integer] -- | Construct the sequence defined by a Sieve. Note that building a -- sieve that contains an intersection clause that has no elements gives -- _|_. -- --
--   let d = [0,2,4,5,7,9,11]
--   let r = d ++ map (+ 12) d
--   take 14 (build (union (map (l 12) d))) == r
--   
build :: Sieve -> [Integer] -- | Variant of build that gives the first n places of the -- reduce of Sieve. -- --
--   buildn 6 (union (map (l 8) [0,3,6])) == [0,3,6,8,11,14]
--   buildn 12 (L (3,2)) == [2,5,8,11,14,17,20,23,26,29,32,35]
--   buildn 9 (L (8,0)) == [0,8,16,24,32,40,48,56,64]
--   buildn 3 (L (3,2) ∩ L (8,0)) == [8,32,56]
--   buildn 12 (L (3,1) ∪ L (4,0)) == [0,1,4,7,8,10,12,13,16,19,20,22]
--   buildn 14 (5⋄4 ∪ 3⋄2 ∪ 7⋄3) == [2,3,4,5,8,9,10,11,14,17,19,20,23,24]
--   buildn 6 (3⋄0 ∪ 4⋄0) == [0,3,4,6,8,9]
--   buildn 8 (5⋄2 ∩ 2⋄0 ∪ 7⋄3) == [2,3,10,12,17,22,24,31]
--   buildn 12 (5⋄1 ∪ 7⋄2) == [1,2,6,9,11,16,21,23,26,30,31,36]
--   buildn 19 (L (3,2) ∪ L (7, 1)) == [1, 2, 5, 8, 11, 14, 15, 17, 20, 22, 23, 26, 29, 32, 35, 36, 38, 41, 43]
--   buildn 19 (3⋄0 ∪ 7⋄0) == [0, 3, 6, 7, 9, 12, 14, 15, 18, 21, 24, 27, 28, 30, 33, 35, 36, 39, 42]
--   
-- --
--   buildn 10 (3⋄2 ∩ 4⋄7 ∪ 6⋄9 ∩ 15⋄18) == [3,11,23,33,35,47,59,63,71,83]
--   
-- --
--   let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
--   let s' = 24⋄23 ∪ 30⋄3 ∪ 104⋄70
--   buildn 16 s == buildn 16 s'
--   
-- --
--   buildn 10 (24⋄23 ∪ 30⋄3 ∪ 104⋄70) == [3,23,33,47,63,70,71,93,95,119]
--   
-- --
--   let r = [2,3,4,5,8,9,10,11,14,17,19,20,23,24,26,29,31]
--   buildn 17 (5⋄4 ∪ 3⋄2 ∪ 7⋄3) == r
--   
-- --
--   let r = [0,1,3,6,9,10,11,12,15,16,17,18,21,24,26,27,30]
--   buildn 17 (5⋄1 ∪ 3⋄0 ∪ 7⋄3) == r
--   
-- --
--   let r = [0,2,3,4,6,7,9,11,12,15,17,18,21,22,24,25,27,30,32]
--   buildn 19 (5⋄2 ∪ 3⋄0 ∪ 7⋄4) == r
--   
-- -- Agon et. al. p.155 -- --
--   let a = c (13⋄3 ∪ 13⋄5 ∪ 13⋄7 ∪ 13⋄9)
--   let b = 11⋄2
--   let c' = c (11⋄4 ∪ 11⋄8)
--   let d = 13⋄9
--   let e = 13⋄0 ∪ 13⋄1 ∪ 13⋄6
--   let f = (a ∩ b) ∪ (c' ∩ d) ∪ e
--   buildn 13 f == [0,1,2,6,9,13,14,19,22,24,26,27,32]
--   
-- --
--   differentiate [0,1,2,6,9,13,14,19,22,24,26,27,32] == [1,1,4,3,4,1,5,3,2,2,1,5]
--   
-- --
--   import Music.Theory.Pitch 
--   
-- --
--   let n = [0,1,2,6,9,13,14,19,22,24,26,27,32]
--   let r = "C C𝄲 C♯ D♯ E𝄲 F𝄰 G A𝄲 B C C♯ C𝄰 E"
--   unwords (map (pitch_class_pp . pc24et_to_pitch . (`mod` 24)) n) == r
--   
-- -- Jonchaies -- --
--   let s = map (17⋄) [0,1,4,5,7,11,12,16]
--   let r = [1,3,1,2,4,1,4,1,1,3,1,2,4,1,4,1,1,3,1,2,4,1,4,1]
--   differentiate (buildn 25 (union s)) == r
--   let a2 = octpc_to_midi (2,9)
--   let m = scanl (+) a2 r
--   import Music.Theory.Pitch.Spelling.Table 
--   let p = "A2 A#2 C#3 D3 E3 G#3 A3 C#4 D4 D#4 F#4 G4 A4 C#5 D5 F#5 G5 G#5 B5 C6 D6 F#6 G6 B6 C7"
--   unwords (map (pitch_pp_iso . midi_to_pitch pc_spell_sharp) m) == p
--   
-- -- Nekuïa -- --
--   let s = [24⋄0,14⋄2,22⋄3,31⋄4,28⋄7,29⋄9,19⋄10,25⋄13,24⋄14,26⋄17,23⋄21,24⋄10,30⋄9,35⋄17,29⋄24,32⋄25,30⋄29,26⋄21,30⋄17,31⋄16]
--   let r = [2,1,1,3,2,1,3,1,2,1,4,3,1,4,1,4,1,3,1,4,1,3,1,4,1,4,1,1,3,1,3,1,2,3,1,4,1,4,4,1]
--   differentiate (buildn 41 (union s)) == r
--   let a0 = octpc_to_midi (0,9)
--   let m = scanl (+) a0 r
--   import Music.Theory.Pitch.Spelling.Table 
--   let p = "A0 B0 C1 C#1 E1 F#1 G1 A#1 B1 C#2 D2 F#2 A2 A#2 D3 D#3 G3 G#3 B3 C4 E4 F4 G#4 A4 C#5 D5 F#5 G5 G#5 B5 C6 D#6 E6 F#6 A6 A#6 D7 D#7 G7 B7 C8"
--   unwords (map (pitch_pp_iso . midi_to_pitch pc_spell_sharp) m) == p
--   
-- --
--   let s = [8⋄0∩3⋄0,2⋄0∩7⋄2,2⋄1∩11⋄3,31⋄4,4⋄3∩7⋄0,29⋄9,19⋄10,25⋄13,8⋄6∩3⋄2,2⋄1∩13⋄4,23⋄21,8⋄2∩3⋄1,2⋄1∩3⋄0∩5⋄4,5⋄2∩7⋄3,29⋄24,32⋄25,2⋄1∩3⋄2∩5⋄4,2⋄1∩13⋄8,2⋄1∩3⋄2∩5⋄2,31⋄16]
--   differentiate (buildn 41 (union s)) == r
--   
-- -- Major scale: -- --
--   let s = (c(3⋄2) ∩ 4⋄0) ∪ (c(3⋄1) ∩ 4⋄1) ∪ (3⋄2 ∩ 4⋄2) ∪ (c(3⋄0) ∩ 4⋄3)
--   buildn 7 s == [0,2,4,5,7,9,11]
--   
-- -- Nomos Alpha: -- -- let s = (c (13⋄3 ∪ 13⋄5 ∪ 13⋄7 ∪ 13⋄9) ∩ 11⋄2) ∪ (c (11⋄4 ∪ 11⋄8) ∩ -- 13⋄9) ∪ (13⋄0 ∪ 13⋄1 ∪ 13⋄6) let r = -- [0,1,2,6,9,13,14,19,22,24,26,27,32,35,39,40,45,52,53,58,61,65,66,71,78,79,84,87,90,91,92,97] -- buildn 32 s == r buildn :: Int -> Sieve -> [Integer] -- | Standard differentiation function. -- --
--   differentiate [1,3,6,10] == [2,3,4]
--   differentiate [0,2,4,5,7,9,11,12] == [2,2,1,2,2,2,1]
--   
differentiate :: Num a => [a] -> [a] -- | Euclid's algorithm for computing the greatest common divisor. -- --
--   euclid 1989 867 == 51
--   
euclid :: Integral a => a -> a -> a -- | Bachet De Méziriac's algorithm. -- --
--   de_meziriac 15 4 == 3 && euclid 15 4 == 1
--   
de_meziriac :: Integral a => a -> a -> a -- | Attempt to reduce the Intersection of two L nodes to a -- singular L node. -- --
--   reduce_intersection (3,2) (4,7) == Just (12,11)
--   reduce_intersection (12,11) (6,11) == Just (12,11)
--   reduce_intersection (12,11) (8,7) == Just (24,23)
--   
reduce_intersection :: Integral t => (t, t) -> (t, t) -> Maybe (t, t) -- | Reduce the number of nodes at a Sieve. -- --
--   reduce (L (3,2) ∪ Empty) == L (3,2)
--   reduce (L (3,2) ∩ Empty) == L (3,2)
--   reduce (L (3,2) ∩ L (4,7)) == L (12,11)
--   reduce (L (6,9) ∩ L (15,18)) == L (30,3)
--   
-- --
--   let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
--   reduce s == (24⋄23 ∪ 30⋄3 ∪ 104⋄70)
--   
-- --
--   putStrLn $ sieve_pp (reduce s)
--   
-- --
--   let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
--   reduce s == (24⋄23 ∪ 30⋄3 ∪ 104⋄70)
--   
reduce :: Sieve -> Sieve psappha_flint_c :: [Sieve] -- | Psappha (Flint) -- --
--   let r = [0,1,3,4,6,8,10,11,12,13,14,16,17,19,20,22,23,25,27,28,29,31,33,35,36,37,38]
--   buildn 27 psappha_flint == r
--   
psappha_flint :: Sieve a_r_squibbs_c :: [Sieve] -- | À R. (Hommage à Maurice Ravel) (Squibbs, 1996) -- -- let r = -- [0,2,3,4,7,9,10,13,14,16,17,21,23,25,29,30,32,34,35,38,39,43,44,47,48,52,53,57,58,59,62,63,66,67,69,72,73,77,78,82,86,87] -- buildn 42 a_r_squibbs == r a_r_squibbs :: Sieve instance GHC.Show.Show Music.Theory.Xenakis.Sieve.Sieve instance GHC.Classes.Eq Music.Theory.Xenakis.Sieve.Sieve -- | Z-n functions module Music.Theory.Z -- | Z type. -- --
--   map z_modulus [z7,z12] == [7,12]
--   
newtype Z i Z :: i -> Z i [z_modulus] :: Z i -> i -- | mod of Z. -- --
--   map (z_mod z12) [-1,0,1,11,12,13] == [11,0,1,11,0,1]
--   
z_mod :: Integral i => Z i -> i -> i -- | Common moduli in music theory. z5 :: Num i => Z i -- | Common moduli in music theory. z7 :: Num i => Z i -- | Common moduli in music theory. z12 :: Num i => Z i -- | Common moduli in music theory. z16 :: Num i => Z i -- | Is n in (0,m-1). is_z_n :: (Num a, Ord a) => a -> a -> Bool lift_unary_Z :: Integral i => Z i -> (t -> i) -> t -> i lift_binary_Z :: Integral i => Z i -> (s -> t -> i) -> s -> t -> i -- | Add two Z. -- --
--   map (z_add z12 4) [1,5,6,11] == [5,9,10,3]
--   
z_add :: Integral i => Z i -> i -> i -> i -- | The underlying type i is presumed to be signed... -- --
--   z_sub z12 0 8 == 4
--   
-- --
--   import Data.Word {- base -}
--   z_sub z12 (0::Word8) 8 == 8
--   ((0 - 8) :: Word8) == 248
--   248 `mod` 12 == 8
--   
z_sub :: Integral i => Z i -> i -> i -> i -- | Allowing unsigned i is rather inefficient... -- --
--   z_sub_unsigned z12 (0::Word8) 8 == 4
--   
z_sub_unsigned :: (Integral i, Ord i) => Z i -> i -> i -> i z_mul :: Integral i => Z i -> i -> i -> i z_negate :: Integral i => Z i -> i -> i z_fromInteger :: Integral i => Z i -> Integer -> i z_signum :: t -> u -> v z_abs :: t -> u -> v to_Z :: Integral i => Z i -> i -> i from_Z :: (Integral i, Num n) => i -> n -- | Universe of Z. -- --
--   z_univ z12 == [0..11]
--   
z_univ :: Integral i => Z i -> [i] -- | Z of z_univ not in given set. -- --
--   z_complement z5 [0,2,3] == [1,4]
--   z_complement z12 [0,2,4,5,7,9,11] == [1,3,6,8,10]
--   
z_complement :: Integral i => Z i -> [i] -> [i] z_quot :: Integral i => Z i -> i -> i -> i z_rem :: Integral i => Z i -> i -> i -> i div_err :: Integral i => String -> i -> i -> i z_div :: Integral i => Z i -> i -> i -> i z_quotRem :: Integral i => Z i -> i -> i -> (i, i) z_divMod :: Integral i => Z i -> i -> i -> (i, i) z_toInteger :: Integral i => Z i -> i -> i -- | Type generalised intToDigit. -- --
--   map integral_to_digit [0 .. 15] == "0123456789abcdef"
--   
integral_to_digit :: Integral t => t -> Char -- | is_z_n 16. is_z16 :: Integral t => t -> Bool -- | Alias for integral_to_digit. z16_to_char :: Integral t => t -> Char -- | z16_to_char in braces, {1,2,3}. z16_set_pp :: Integral t => [t] -> String -- | z16_to_char in arrows, 1,2,3. z16_seq_pp :: Integral t => [t] -> String -- | z16_to_char in brackets, [1,2,3]. z16_vec_pp :: Integral t => [t] -> String -- | John Clough. "Aspects of Diatonic Sets". _Journal of Music Theory_, -- 23(1):45--61, 1979. module Music.Theory.Z.Clough_1979 -- | Shift sequence so the initial value is zero. -- --
--   transpose_to_zero [1,2,5] == [0,1,4]
--   
transpose_to_zero :: Num n => [n] -> [n] -- | Diatonic pitch class (Z7) set to chord. -- --
--   map dpcset_to_chord [[0,1],[0,2,4],[2,3,4,5,6]] == [[1,6],[2,2,3],[1,1,1,1,3]]
--   
dpcset_to_chord :: Integral n => [n] -> [n] -- | Inverse of dpcset_to_chord. -- --
--   map chord_to_dpcset [[1,6],[2,2,3]] == [[0,1],[0,2,4]]
--   
chord_to_dpcset :: Integral n => [n] -> [n] -- | Complement, ie. in relation to z7_univ. -- --
--   map dpcset_complement [[0,1],[0,2,4]] == [[2,3,4,5,6],[1,3,5,6]]
--   
dpcset_complement :: Integral n => [n] -> [n] -- | Interval class predicate (ie. is_z4). -- --
--   map is_ic [-1 .. 4] == [False,True,True,True,True,False]
--   
is_ic :: Integral n => n -> Bool -- | Interval to interval class. -- --
--   map i_to_ic [0..7] == [0,1,2,3,3,2,1,0]
--   
i_to_ic :: Integral n => n -> n -- | Is chord, ie. is sum 7. -- --
--   is_chord [2,2,3]
--   
is_chord :: Integral n => [n] -> Bool -- | Interval vector, given list of intervals. -- --
--   iv [2,2,3] == [0,2,1]
--   
iv :: Integral n => [n] -> [n] -- | Comparison function for inv. inf_cmp :: Ord a => [a] -> [a] -> Ordering -- | Interval normal form. -- --
--   map inf [[2,2,3],[1,2,4],[2,1,4]] == [[2,2,3],[1,2,4],[2,1,4]]
--   
inf :: Integral n => [n] -> [n] -- | Inverse of chord (retrograde). -- --
--   let p = [1,2,4] in (inf p,invert p,inf (invert p)) == ([1,2,4],[4,2,1],[2,1,4])
--   
invert :: [n] -> [n] -- | Complement of chord. -- --
--   let r = [[1,1,1,1,3],[1,1,1,2,2],[1,1,2,1,2],[1,1,1,4],[2,1,1,3],[1,2,1,3],[1,2,2,2]]
--   in map complement [[1,6],[2,5],[3,4],[1,1,5],[1,2,4],[1,3,3],[2,2,3]] == r
--   
complement :: Integral n => [n] -> [n] -- | Z7 pitch sequence to Z7 interval sequence, ie. mod7 of -- d_dx. -- --
--   map iseq (permutations [0,1,2]) == [[1,1],[6,2],[6,6],[1,5],[5,1],[2,6]]
--   map iseq (permutations [0,1,3]) == [[1,2],[6,3],[5,6],[2,4],[4,1],[3,5]]
--   map iseq (permutations [0,2,3]) == [[2,1],[5,3],[6,5],[1,4],[4,2],[3,6]]
--   map iseq (permutations [0,1,4]) == [[1,3],[6,4],[4,6],[3,3],[3,1],[4,4]]
--   map iseq (permutations [0,2,4]) == [[2,2],[5,4],[5,5],[2,3],[3,2],[4,5]]
--   
iseq :: Integral n => [n] -> [n] -- | Is n in (0,m - 1). is_z_n :: Integral n => n -> n -> Bool -- | Z m universe, ie [0 .. m-1]. z_n_univ :: Integral n => n -> [n] -- | is_z_n of 4. is_z4 :: Integral n => n -> Bool -- | z_n_univ of 7. -- --
--   z7_univ == [0 .. 6]
--   
z7_univ :: Integral n => [n] -- | is_z_n of 7. is_z7 :: Integral n => n -> Bool -- | mod 7. mod7 :: Integral n => n -> n -- | Z12 set class database. module Music.Theory.Z.Literature -- | Set class database with descriptors for historically and theoretically -- significant set classes, indexed by Forte name. -- --
--   lookup "6-Z17" sc_db == Just "All-Trichord Hexachord"
--   lookup "7-35" sc_db == Just "diatonic collection (d)"
--   
sc_db :: [(String, String)] -- | Robert Morris and D. Starr. "The Structure of All-Interval Series". -- Journal of Music Theory, 18:364-389, 1974. module Music.Theory.Z.Morris_1974 -- | msum . map return. -- --
--   L.observeAll (fromList [1..7]) == [1..7]
--   
fromList :: MonadPlus m => [a] -> m a -- | Interval from i to j in modulo-n. -- --
--   let f = int_n 12 in (f 0 11,f 11 0) == (11,1)
--   
int_n :: Integral a => a -> a -> a -> a -- | MonadLogic all-interval series. -- --
--   map (length . L.observeAll . all_interval_m) [4,6,8,10] == [2,4,24,288]
--   [0,1,3,2,9,5,10,4,7,11,8,6] `elem` L.observeAll (all_interval_m 12)
--   length (L.observeAll (all_interval_m 12)) == 3856
--   
all_interval_m :: (MonadPlus m, MonadLogic m) => Int -> m [Int] -- | observeAll of all_interval_m. -- --
--   let r = [[0,1,5,2,4,3],[0,2,1,4,5,3],[0,4,5,2,1,3],[0,5,1,4,2,3]]
--   all_interval 6 == r
--   
-- --
--   d_dx_n n l = zipWith (int_n n) l (tail l)
--   map (d_dx_n 6) r == [[1,4,3,2,5],[2,5,3,1,4],[4,1,3,5,2],[5,2,3,4,1]]
--   
all_interval :: Int -> [[Int]] -- | Robert Morris. /Composition with Pitch-Classes: A Theory of -- Compositional Design/. Yale University Press, New Haven, 1987. module Music.Theory.Z.Morris_1987 -- | INT operator. -- --
--   map (int z12) [[0,1,3,6,10],[3,7,0]] == [[1,2,3,4],[4,5]]
--   
int :: Integral i => Z i -> [i] -> [i] -- | Parsers for pitch class sets and sequences, and for SROs. module Music.Theory.Z.Morris_1987.Parse -- | Parse a pitch class object string. Each Char is either a -- number, a space which is ignored, or a letter name for the numbers 10 -- (t or a or A) or 11 (e or -- B or b). -- --
--   pco "13te" == [1,3,10,11]
--   pco "13te" == pco "13ab"
--   
pco :: Num n => String -> [n] -- | Serial (ordered) pitch-class operations on Z. module Music.Theory.Z.Sro -- | Serial operator,of the form rRTMI. data Sro t Sro :: Int -> Bool -> t -> t -> Bool -> Sro t [sro_r] :: Sro t -> Int [sro_R] :: Sro t -> Bool [sro_T] :: Sro t -> t [sro_M] :: Sro t -> t [sro_I] :: Sro t -> Bool -- | Printer in rnRTnMI form. sro_pp :: (Show t, Eq t, Num t) => Sro t -> String -- | Parser for Sro. p_sro :: Integral t => t -> P (Sro t) -- | Parse a Morris format serial operator descriptor. -- --
--   sro_parse 5 "r2RT3MI" == Sro 2 True 3 5 True
--   
sro_parse :: Integral i => i -> String -> Sro i -- | The total set of serial operations. -- --
--   let u = z_sro_univ 3 5 z12
--   zip (map sro_pp u) (map (\o -> z_sro_apply z12 o [0,1,3]) u)
--   
z_sro_univ :: Integral i => Int -> i -> Z i -> [Sro i] -- | The set of transposition Sros. z_sro_Tn :: Integral i => Z i -> [Sro i] -- | The set of transposition and inversion Sros. z_sro_TnI :: Integral i => Z i -> [Sro i] -- | The set of retrograde and transposition and inversion Sros. z_sro_RTnI :: Integral i => Z i -> [Sro i] -- | The set of transposition, M and inversion Sros. z_sro_TnMI :: Integral i => i -> Z i -> [Sro i] -- | The set of retrograde,transposition,M5 and inversion -- Sros. z_sro_RTnMI :: Integral i => i -> Z i -> [Sro i] -- | Apply Sro. -- --
--   z_sro_apply z12 (Sro 1 True 1 5 False) [0,1,2,3] == [11,6,1,4]
--   z_sro_apply z12 (Sro 1 False 4 5 True) [0,1,2,3] == [11,6,1,4]
--   
z_sro_apply :: Integral i => Z i -> Sro i -> [i] -> [i] -- | Find Sros that map x to y given m and -- z. -- --
--   map sro_pp (z_sro_rel 5 z12 [0,1,2,3] [11,6,1,4]) == ["r1T4MI","r1RT1M"]
--   
z_sro_rel :: (Ord t, Integral t) => t -> Z t -> [t] -> [t] -> [Sro t] -- | Transpose p by n. -- --
--   z_sro_tn z5 4 [0,1,4] == [4,0,3]
--   z_sro_tn z12 4 [1,5,6] == [5,9,10]
--   
z_sro_tn :: (Integral i, Functor f) => Z i -> i -> f i -> f i -- | Invert p about n. -- --
--   z_sro_invert z5 0 [0,1,4] == [0,4,1]
--   z_sro_invert z12 6 [4,5,6] == [8,7,6]
--   map (z_sro_invert z12 0) [[0,1,3],[1,4,8]] == [[0,11,9],[11,8,4]]
--   
-- --
--   import Data.Word {- base -}
--   z_sro_invert z12 (0::Word8) [1,4,8] == [3,0,8]
--   
z_sro_invert :: (Integral i, Functor f) => Z i -> i -> f i -> f i -- | Composition of invert about 0 and tn. -- --
--   z_sro_tni z5 1 [0,1,3] == [1,0,3]
--   z_sro_tni z12 4 [1,5,6] == [3,11,10]
--   (z_sro_invert z12 0 . z_sro_tn z12 4) [1,5,6] == [7,3,2]
--   
z_sro_tni :: (Integral i, Functor f) => Z i -> i -> f i -> f i -- | Modulo multiplication. -- --
--   z_sro_mn z12 11 [0,1,4,9] == z_sro_tni z12 0 [0,1,4,9]
--   
z_sro_mn :: (Integral i, Functor f) => Z i -> i -> f i -> f i -- | M5, ie. mn 5. -- --
--   z_sro_m5 z12 [0,1,3] == [0,5,3]
--   
z_sro_m5 :: (Integral i, Functor f) => Z i -> f i -> f i -- | T-related sequences of p. -- --
--   length (z_sro_t_related z12 [0,3,6,9]) == 12
--   z_sro_t_related z5 [0,2] == [[0,2],[1,3],[2,4],[3,0],[4,1]]
--   
z_sro_t_related :: (Integral i, Functor f) => Z i -> f i -> [f i] -- | T/I-related sequences of p. -- --
--   length (z_sro_ti_related z12 [0,1,3]) == 24
--   length (z_sro_ti_related z12 [0,3,6,9]) == 24
--   z_sro_ti_related z12 [0] == map return [0..11]
--   
z_sro_ti_related :: (Eq (f i), Integral i, Functor f) => Z i -> f i -> [f i] -- | R/T/I-related sequences of p. -- --
--   length (z_sro_rti_related z12 [0,1,3]) == 48
--   length (z_sro_rti_related z12 [0,3,6,9]) == 24
--   
z_sro_rti_related :: Integral i => Z i -> [i] -> [[i]] -- | T/M/I-related sequences of p, duplicates removed. z_sro_tmi_related :: Integral i => Z i -> [i] -> [[i]] -- | R/T/M/I-related sequences of p, duplicates removed. z_sro_rtmi_related :: Integral i => Z i -> [i] -> [[i]] -- | r/R/T/M/I-related sequences of p, duplicates removed. z_sro_rrtmi_related :: Integral i => Z i -> [i] -> [[i]] -- | Variant of tn, transpose p so first element is -- n. -- --
--   z_sro_tn_to z12 5 [0,1,3] == [5,6,8]
--   map (z_sro_tn_to z12 0) [[0,1,3],[1,3,0],[3,0,1]] == [[0,1,3],[0,2,11],[0,9,10]]
--   
z_sro_tn_to :: Integral i => Z i -> i -> [i] -> [i] -- | Variant of invert, inverse about nth element. -- --
--   map (z_sro_invert_ix z12 0) [[0,1,3],[3,4,6]] == [[0,11,9],[3,2,0]]
--   map (z_sro_invert_ix z12 1) [[0,1,3],[3,4,6]] == [[2,1,11],[5,4,2]]
--   
z_sro_invert_ix :: Integral i => Z i -> Int -> [i] -> [i] -- | The standard t-matrix of p. -- --
--   z_tmatrix z12 [0,1,3] == [[0,1,3],[11,0,2],[9,10,0]]
--   
z_tmatrix :: Integral i => Z i -> [i] -> [[i]] instance GHC.Show.Show t => GHC.Show.Show (Music.Theory.Z.Sro.Sro t) instance GHC.Classes.Eq t => GHC.Classes.Eq (Music.Theory.Z.Sro.Sro t) -- | Ronald C. Read. "Every one a winner or how to avoid isomorphism search -- when cataloguing combinatorial configurations." /Annals of Discrete -- Mathematics/ 2:107–20, 1978. module Music.Theory.Z.Read_1978 -- | Coding. type Code = Word64 -- | Number of bits at Code. code_len :: Num n => n -- | Bit array. type Bit_Array = [Bool] -- | Logical complement. bit_array_complement :: Bit_Array -> Bit_Array -- | Pretty printer for Bit_Array. bit_array_pp :: Bit_Array -> String -- | Parse PP of Bit_Array. -- --
--   bit_array_parse "01001" == [False,True,False,False,True]
--   
bit_array_parse :: String -> Bit_Array -- | Generate Code from Bit_Array, the coding is most to -- least significant. -- --
--   map (bit_array_to_code . bit_array_parse) (words "000 001 010 011 100 101 110 111") == [0..7]
--   bit_array_to_code (bit_array_parse "1100100011100") == 6428
--   
bit_array_to_code :: Bit_Array -> Code -- | Inverse of bit_array_to_code. -- --
--   code_to_bit_array 13 6428 == bit_array_parse "1100100011100"
--   
code_to_bit_array :: Int -> Code -> Bit_Array -- | Bit_Array to set. -- --
--   bit_array_to_set (bit_array_parse "1100100011100") == [0,1,4,8,9,10]
--   set_to_code 13 [0,1,4,8,9,10] == 6428
--   
bit_array_to_set :: Integral i => Bit_Array -> [i] -- | Inverse of bit_array_to_set, z is the degree of the -- array. set_to_bit_array :: Integral i => i -> [i] -> Bit_Array -- | bit_array_to_code of set_to_bit_array. -- --
--   set_to_code 12 [0,2,3,5] == 2880
--   map (set_to_code 12) (Sro.z_sro_ti_related (flip mod 12) [0,2,3,5])
--   
set_to_code :: Integral i => i -> [i] -> Code -- | The prime form is the maximum encoding. -- --
--   bit_array_is_prime (set_to_bit_array 12 [0,2,3,5]) == False
--   
bit_array_is_prime :: Bit_Array -> Bool -- | The augmentation rule adds 1 in each empty slot at end of -- array. -- --
--   map bit_array_pp (bit_array_augment (bit_array_parse "01000")) == ["01100","01010","01001"]
--   
bit_array_augment :: Bit_Array -> [Bit_Array] -- | Enumerate first half of the set-classes under given prime -- function. The second half can be derived as the complement of the -- first. -- --
--   import Music.Theory.Z.Forte_1973
--   length scs == 224
--   map (length . scs_n) [0..12] == [1,1,6,12,29,38,50,38,29,12,6,1,1]
--   
-- --
--   let z12 = map (fmap (map bit_array_to_set)) (enumerate_half bit_array_is_prime 12)
--   map (length . snd) z12 == [1,1,6,12,29,38,50]
--   
-- -- This can become slow, edit z to find out. It doesn't matter -- about n. This can be edited so that small n would run -- quickly even for large z. -- --
--   fmap (map bit_array_to_set) (lookup 5 (enumerate_half bit_array_is_prime 16))
--   
enumerate_half :: (Bit_Array -> Bool) -> Int -> [(Int, [Bit_Array])] -- | If the size of the set is > code_len then -- error, else id. set_coding_validate :: [t] -> [t] -- | Encoder for encode_prime. -- --
--   map set_encode [[0,1,3,7,8],[0,1,3,6,8,9]] == [395,843]
--   
-- --
--   map (set_to_code 12) [[0,1,3,7,8],[0,1,3,6,8,9]] == [3352,3372]
--   
set_encode :: Integral i => [i] -> Code -- | Decoder for encode_prime. -- --
--   map (set_decode 12) [395,843] == [[0,1,3,7,8],[0,1,3,6,8,9]]
--   
set_decode :: Integral i => Int -> Code -> [i] -- | Binary encoding prime form algorithm, equalivalent to Rahn. -- --
--   set_encode_prime Z.z12 [0,1,3,6,8,9] == [0,2,3,6,7,9]
--   Music.Theory.Z.Rahn_1980.rahn_prime Z.z12 [0,1,3,6,8,9] == [0,2,3,6,7,9]
--   
set_encode_prime :: Integral i => Z i -> [i] -> [i] -- | Allen Forte. The Structure of Atonal Music. Yale University -- Press, New Haven, 1973. module Music.Theory.Z.Forte_1973 -- | T-related rotations of p, ie. all rotations tranposed to be at -- zero. -- --
--   z_t_rotations z12 [1,2,4] == [[0,1,3],[0,2,11],[0,9,10]]
--   
z_t_rotations :: Integral i => Z i -> [i] -> [[i]] -- | T/I-related rotations of p. -- --
--   ti_rotations z12 [0,1,3] == [[0,1,3],[0,2,11],[0,9,10],[0,9,11],[0,2,3],[0,1,10]]
--   
z_ti_rotations :: Integral i => Z i -> [i] -> [[i]] -- | Prime form rule requiring comparator, considering -- t_rotations. z_t_cmp_prime :: Integral i => Z i -> ([i] -> [i] -> Ordering) -> [i] -> [i] -- | Prime form rule requiring comparator, considering -- ti_rotations. z_ti_cmp_prime :: Integral i => Z i -> ([i] -> [i] -> Ordering) -> [i] -> [i] -- | Forte comparison function (rightmost first then leftmost outwards). -- --
--   forte_cmp [0,1,3,6,8,9] [0,2,3,6,7,9] == LT
--   
forte_cmp :: Ord t => [t] -> [t] -> Ordering -- | Forte prime form, ie. z_ti_cmp_prime of forte_cmp. -- --
--   z_forte_prime z12 [0,1,3,6,8,9] == [0,1,3,6,8,9]
--   z_forte_prime z5 [0,1,4] == [0,1,2]
--   z_forte_prime z5 [0,1,1] -- ERROR
--   
-- --
--   S.set (map (z_forte_prime z5) (S.powerset [0..4]))
--   S.set (map (z_forte_prime z7) (S.powerset [0..6]))
--   
z_forte_prime :: Integral i => Z i -> [i] -> [i] -- | Transpositional equivalence prime form, ie. z_t_cmp_prime of -- forte_cmp. -- --
--   (z_forte_prime z12 [0,2,3],z_t_prime z12 [0,2,3]) == ([0,1,3],[0,2,3])
--   
z_t_prime :: Integral i => Z i -> [i] -> [i] -- | Interval class of interval i. -- --
--   map (z_ic z12) [0..12] == [0,1,2,3,4,5,6,5,4,3,2,1,0]
--   map (z_ic z7) [0..7] == [0,1,2,3,3,2,1,0]
--   map (z_ic z5) [0..5] == [0,1,2,2,1,0]
--   map (z_ic z12) [5,6,7] == [5,6,5]
--   map (z_ic z12) [-13,-1,0,1,13] == [1,1,0,1,1]
--   
z_ic :: Integral i => Z i -> i -> i -- | Forte notation for interval class vector. -- --
--   z_icv z12 [0,1,2,4,7,8] == [3,2,2,3,3,2]
--   
z_icv :: (Integral i, Num n) => Z i -> [i] -> [n] -- | Basic interval pattern, see Allen Forte "The Basic Interval Patterns" -- JMT 17/2 (1973):234-272 -- --
--   >>> bip 0t95728e3416
--   11223344556
--   
-- --
--   z_bip z12 [0,10,9,5,7,2,8,11,3,4,1,6] == [1,1,2,2,3,3,4,4,5,5,6]
--   
z_bip :: Integral i => Z i -> [i] -> [i] -- | Generate SC universe, though not in order of the Forte table. -- --
--   length (z_sc_univ z7) == 18
--   sort (z_sc_univ z12) == sort (map snd sc_table)
--   zipWith (\p q -> (p == q,p,q)) (z_sc_univ z12) (map snd sc_table)
--   
z_sc_univ :: Integral i => Z i -> [[i]] -- | Synonym for String. type SC_Name = String -- | Table of (SC-NAME,PCSET). type SC_Table n = [(SC_Name, [n])] -- | The Z12 set-class table (Forte prime forms). -- --
--   length sc_table == 224
--   
sc_table :: Num n => SC_Table n -- | Unicode (non-breaking hyphen) variant. sc_table_unicode :: Num n => SC_Table n -- | Lookup name of prime form of set class. It is an error for the input -- not to be a forte prime form. -- --
--   forte_prime_name [0,1,4,6] == ("4-Z15",[0,1,4,6])
--   
forte_prime_name :: (Num n, Eq n) => [n] -> (SC_Name, [n]) -- | Lookup entry for set in table. sc_tbl_lookup :: Integral i => SC_Table i -> [i] -> Maybe (SC_Name, [i]) -- | Erroring variant sc_tbl_lookup_err :: Integral i => SC_Table i -> [i] -> (SC_Name, [i]) -- | fst of sc_tbl_lookup_err sc_name_tbl :: Integral i => SC_Table i -> [i] -> SC_Name -- | Lookup a set-class name. The input set is subject to -- forte_prime of z12 before lookup. -- --
--   sc_name [0,2,3,6,7] == "5-Z18"
--   sc_name [0,1,4,6,7,8] == "6-Z17"
--   
sc_name :: Integral i => [i] -> SC_Name -- | Long name (ie. with enumeration of prime form). -- --
--   sc_name_long [0,1,4,6,7,8] == "6-Z17[012478]"
--   
sc_name_long :: Integral i => [i] -> SC_Name -- | Unicode (non-breaking hyphen) variant. sc_name_unicode :: Integral i => [i] -> SC_Name -- | Lookup a set-class given a set-class name. -- --
--   sc "6-Z17" == [0,1,2,4,7,8]
--   
sc :: Num n => SC_Name -> [n] -- | The set-class table (Forte prime forms), ie. snd of -- sc_table. scs :: Num n => [[n]] -- | Cardinality n subset of scs. -- --
--   map (length . scs_n) [1..11] == [1,6,12,29,38,50,38,29,12,6,1]
--   
scs_n :: (Integral i, Num n) => i -> [[n]] -- | Vector indicating degree of intersection with inversion at each -- transposition. -- --
--   tics z12 [0,2,4,5,7,9] == [3,2,5,0,5,2,3,4,1,6,1,4]
--   map (tics z12) scs
--   
tics :: Integral i => Z i -> [i] -> [Int] -- | Locate Z relation of set class. -- --
--   fmap sc_name (z_relation_of (sc "7-Z12")) == Just "7-Z36"
--   
z_relation_of :: Integral i => [i] -> Maybe [i] -- | John Rahn. Basic Atonal Theory. Longman, New York, 1980. module Music.Theory.Z.Rahn_1980 -- | Rahn prime form (comparison is rightmost inwards). -- --
--   rahn_cmp [0,1,3,6,8,9] [0,2,3,6,7,9] == GT
--   
rahn_cmp :: Ord a => [a] -> [a] -> Ordering -- | Rahn prime form, ie. ti_cmp_prime of rahn_cmp. -- --
--   z_rahn_prime z12 [0,1,3,6,8,9] == [0,2,3,6,7,9]
--   
z_rahn_prime :: Integral i => Z i -> [i] -> [i] -- | The six sets where the Forte and Rahn prime forms differ. Given here -- in Forte prime form. -- --
--   all (\p -> Forte_1973.forte_prime z12 p /= rahn_prime z12 p) rahn_forte_diff == True
--   
rahn_forte_diff :: Num n => [[n]] -- | Robert Morris. "A Similarity Index for Pitch-Class Sets". Perspectives -- of New Music, 18(2):445-460, 1980. module Music.Theory.Metric.Morris_1980 -- | SIM -- --
--   icv 12 [0,1,3,6] == [1,1,2,0,1,1] && icv 12 [0,2,4,7] == [0,2,1,1,2,0]
--   sim [0,1,3,6] [0,2,4,7] == 6
--   sim [0,1,2,4,5,8] [0,1,3,7] == 9
--   
sim :: Integral a => [Int8] -> [Int8] -> a -- | ASIM -- --
--   asim [0,1,3,6] [0,2,4,7] == 6/12
--   asim [0,1,2,4,5,8] [0,1,3,7] == 9/21
--   asim [0,1,2,3,4] [0,1,4,5,7] == 2/5
--   asim [0,1,2,3,4] [0,2,4,6,8] == 3/5
--   asim [0,1,4,5,7] [0,2,4,6,8] == 3/5
--   
asim :: Integral n => [Int8] -> [Int8] -> Ratio n -- | Michael Buchler. "Relative Saturation of Subsets and Interval Cycles -- as a Means for Determining Set-Class Similarity". PhD thesis, -- University of Rochester, 1998 module Music.Theory.Metric.Buchler_1998 -- | Predicate for list with cardinality n. of_c :: Integral n => n -> [a] -> Bool -- | Set classes of cardinality n. -- --
--   sc_table_n 2 == [[0,1],[0,2],[0,3],[0,4],[0,5],[0,6]]
--   
sc_table_n :: Integral n => n -> [[Int8]] -- | Minima and maxima of ICV of SCs of cardinality n. -- --
--   icv_minmax 5 == ([0,0,0,1,0,0],[4,4,4,4,4,2])
--   
icv_minmax :: (Integral n, Integral b) => n -> ([b], [b]) data R MIN :: R MAX :: R type D n = (R, n) -- | Pretty printer for R. -- --
--   map r_pp [MIN,MAX] == ["+","-"]
--   
r_pp :: R -> String -- | SATV element measure with given funtion. satv_f :: Integral n => ((n, n, n) -> D n) -> [Int8] -> [D n] -- | Pretty printer for SATV element. -- --
--   satv_e_pp (satv_a [0,1,2,6,7,8]) == "<-1,+2,+0,+0,-1,-0>"
--   
satv_e_pp :: Show i => [D i] -> String type SATV i = ([D i], [D i]) -- | Pretty printer for SATV. satv_pp :: Show i => SATV i -> String -- | SATVa measure. -- --
--   satv_e_pp (satv_a [0,1,2,6,7,8]) == "<-1,+2,+0,+0,-1,-0>"
--   satv_e_pp (satv_a [0,1,2,3,4]) == "<-0,-1,-2,+0,+0,+0>"
--   
satv_a :: Integral i => [Int8] -> [D i] -- | SATVb measure. -- --
--   satv_e_pp (satv_b [0,1,2,6,7,8]) == "<+4,-4,-5,-4,+4,+3>"
--   satv_e_pp (satv_b [0,1,2,3,4]) == "<+4,+3,+2,-3,-4,-2>"
--   
satv_b :: Integral i => [Int8] -> [D i] -- | SATV measure. -- --
--   satv_pp (satv [0,3,6,9]) == "(<+0,+0,-0,+0,+0,-0>,<-3,-3,+4,-3,-3,+2>)"
--   satv_pp (satv [0,1,3,4,8]) == "(<-2,+1,-2,-1,-2,+0>,<+2,-3,+2,+2,+2,-2>)"
--   satv_pp (satv [0,1,2,6,7,8]) == "(<-1,+2,+0,+0,-1,-0>,<+4,-4,-5,-4,+4,+3>)"
--   satv_pp (satv [0,4]) == "(<+0,+0,+0,-0,+0,+0>,<-1,-1,-1,+1,-1,-1>)"
--   satv_pp (satv [0,1,3,4,6,9]) == "(<+2,+2,-0,+0,+2,-1>,<-3,-4,+5,-4,-3,+2>)"
--   satv_pp (satv [0,1,3,6,7,9]) == "(<+2,+2,-1,+0,+2,-0>,<-3,-4,+4,-4,-3,+3>)"
--   satv_pp (satv [0,1,2,3,6]) == "(<-1,-2,-2,+0,+1,-1>,<+3,+2,+2,-3,-3,+1>)"
--   satv_pp (satv [0,1,2,3,4,6]) == "(<-1,-2,-2,+0,+1,+1>,<+4,+4,+3,-4,-4,-2>)"
--   satv_pp (satv [0,1,3,6,8]) == "(<+1,-2,-2,+0,-1,-1>,<-3,+2,+2,-3,+3,+1>)"
--   satv_pp (satv [0,2,3,5,7,9]) == "(<+1,-2,-2,+0,-1,+1>,<-4,+4,+3,-4,+4,-2>)"
--   
satv :: Integral i => [Int8] -> SATV i -- | SATV reorganised by R. -- --
--   satv_minmax (satv [0,1,2,6,7,8]) == ([4,2,0,0,4,3],[1,4,5,4,1,0])
--   
satv_minmax :: SATV i -> ([i], [i]) -- | Absolute difference. abs_dif :: Num a => a -> a -> a -- | Sum of numerical components of a and b parts of -- SATV. -- --
--   satv_n_sum (satv [0,1,2,6,7,8]) == [5,6,5,4,5,3]
--   satv_n_sum (satv [0,3,6,9]) == [3,3,4,3,3,2]
--   
satv_n_sum :: Num c => SATV c -> [c] two_part_difference_vector :: Integral i => [D i] -> SATV i -> [i] two_part_difference_vector_set :: Integral i => SATV i -> SATV i -> ([i], [i]) -- | SATSIM metric. -- --
--   satsim [0,1,2,6,7,8] [0,3,6,9] == 25/46
--   satsim [0,4] [0,1,3,4,6,9] == 25/34
--   satsim [0,4] [0,1,3,6,7,9] == 25/34
--   satsim [0,1,2,3,6] [0,1,2,3,4,6] == 1/49
--   satsim [0,1,3,6,8] [0,2,3,5,7,9] == 1/49
--   satsim [0,1,2,3,4] [0,1,4,5,7] == 8/21
--   satsim [0,1,2,3,4] [0,2,4,6,8] == 4/7
--   satsim [0,1,4,5,7] [0,2,4,6,8] == 4/7
--   
satsim :: Integral a => [Int8] -> [Int8] -> Ratio a -- | Table of satsim measures for all SC pairs. -- --
--   length satsim_table == 24310
--   
satsim_table :: Integral i => [(([Int8], [Int8]), Ratio i)] -- | Histogram of values at satsim_table. -- --
--   satsim_table_histogram == T.histogram (map snd satsim_table)
--   
satsim_table_histogram :: Integral i => [(Ratio i, i)] instance GHC.Show.Show Music.Theory.Metric.Buchler_1998.R instance GHC.Classes.Eq Music.Theory.Metric.Buchler_1998.R -- | Marcus Castrén. RECREL: A Similarity Measure for Set-Classes. -- PhD thesis, Sibelius Academy, Helsinki, 1994. module Music.Theory.Z.Castren_1994 type Z12 = Int8 -- | Is p symmetrical under inversion. -- --
--   map inv_sym (Forte.scs_n 2) == [True,True,True,True,True,True]
--   map (fromEnum.inv_sym) (Forte.scs_n 3) == [1,0,0,0,0,1,0,0,1,1,0,1]
--   
inv_sym :: [Z12] -> Bool -- | If p is not inv_sym then (p,invert 0 p) else -- Nothing. -- --
--   sc_t_ti [0,2,4] == Nothing
--   sc_t_ti [0,1,3] == Just ([0,1,3],[0,2,3])
--   
sc_t_ti :: [Z12] -> Maybe ([Z12], [Z12]) -- | Transpositional equivalence variant of Forte's sc_table. The -- inversionally related classes are distinguished by labels A -- and B; the class providing the best normal order -- (Forte 1973) is always the A class. If neither A nor -- B appears in the name of a set-class, it is inversionally -- symmetrical. -- --
--   (length Forte.sc_table,length t_sc_table) == (224,352)
--   lookup "5-Z18B" t_sc_table == Just [0,2,3,6,7]
--   
t_sc_table :: [(SC_Name, [Z12])] -- | Lookup a set-class name. The input set is subject to t_prime -- before lookup. -- --
--   t_sc_name [0,2,3,6,7] == "5-Z18B"
--   t_sc_name [0,1,4,6,7,8] == "6-Z17B"
--   
t_sc_name :: [Z12] -> SC_Name -- | Lookup a set-class given a set-class name. -- --
--   t_sc "6-Z17A" == [0,1,2,4,7,8]
--   
t_sc :: SC_Name -> [Z12] -- | List of set classes. t_scs :: [[Z12]] -- | Cardinality n subset of t_scs. -- --
--   map (length . t_scs_n) [2..10] == [6,19,43,66,80,66,43,19,6]
--   
t_scs_n :: Integral i => i -> [[Z12]] -- | T-related q that are subsets of p. -- --
--   t_subsets [0,1,2,3,4] [0,1]  == [[0,1],[1,2],[2,3],[3,4]]
--   t_subsets [0,1,2,3,4] [0,1,4] == [[0,1,4]]
--   t_subsets [0,2,3,6,7] [0,1,4] == [[2,3,6]]
--   
t_subsets :: [Z12] -> [Z12] -> [[Z12]] -- | T/I-related q that are subsets of p. -- --
--   ti_subsets [0,1,2,3,4] [0,1]  == [[0,1],[1,2],[2,3],[3,4]]
--   ti_subsets [0,1,2,3,4] [0,1,4] == [[0,1,4],[0,3,4]]
--   ti_subsets [0,2,3,6,7] [0,1,4] == [[2,3,6],[3,6,7]]
--   
ti_subsets :: [Z12] -> [Z12] -> [[Z12]] -- | Trivial run length encoder. -- --
--   rle "abbcccdde" == [(1,'a'),(2,'b'),(3,'c'),(2,'d'),(1,'e')]
--   
rle :: (Eq a, Integral i) => [a] -> [(i, a)] -- | Inverse of rle. -- --
--   rle_decode [(5,'a'),(4,'b')] == "aaaaabbbb"
--   
rle_decode :: Integral i => [(i, a)] -> [a] -- | Length of rle encoded sequence. -- --
--   rle_length [(5,'a'),(4,'b')] == 9
--   
rle_length :: Integral i => [(i, a)] -> i -- | T-equivalence n-class vector (subset-class vector, nCV). -- --
--   t_n_class_vector 2 [0..4] == [4,3,2,1,0,0]
--   rle (t_n_class_vector 3 [0..4]) == [(1,3),(2,2),(2,1),(4,0),(1,1),(9,0)]
--   rle (t_n_class_vector 4 [0..4]) == [(1,2),(3,1),(39,0)]
--   
t_n_class_vector :: (Num a, Integral i) => i -> [Z12] -> [a] -- | T/I-equivalence n-class vector (subset-class vector, nCV). -- --
--   ti_n_class_vector 2 [0..4] == [4,3,2,1,0,0]
--   ti_n_class_vector 3 [0,1,2,3,4] == [3,4,2,0,0,1,0,0,0,0,0,0]
--   rle (ti_n_class_vector 4 [0,1,2,3,4]) == [(2,2),(1,1),(26,0)]
--   
ti_n_class_vector :: (Num b, Integral i) => i -> [Z12] -> [b] -- | icv scaled by sum of icv. -- --
--   dyad_class_percentage_vector [0,1,2,3,4] == [40,30,20,10,0,0]
--   dyad_class_percentage_vector [0,1,4,5,7] == [20,10,20,20,20,10]
--   
dyad_class_percentage_vector :: Integral i => [Z12] -> [i] -- | rel metric. -- --
--   rel [0,1,2,3,4] [0,1,4,5,7] == 40
--   rel [0,1,2,3,4] [0,2,4,6,8] == 60
--   rel [0,1,4,5,7] [0,2,4,6,8] == 60
--   
rel :: Integral i => [Z12] -> [Z12] -> Ratio i -- | David Lewin. "A Response to a Response: On PC Set Relatedness". -- Perspectives of New Music, 18(1-2):498-502, 1980. module Music.Theory.Z.Lewin_1980 type Z12 = Int8 -- | REL function with given ncv function (see t_rel and -- ti_rel). rel :: Floating n => (Int -> [a] -> [n]) -> [a] -> [a] -> n -- | T-equivalence REL function. -- -- Kuusi 2001, 7.5.2 -- --
--   let (~=) p q = abs (p - q) < 0.001
--   t_rel [0,1,2,3,4] [0,2,3,6,7] ~= 0.429
--   t_rel [0,1,2,3,4] [0,2,4,6,8] ~= 0.253
--   t_rel [0,2,3,6,7] [0,2,4,6,8] ~= 0.324
--   
t_rel :: Floating n => [Z12] -> [Z12] -> n -- | T/I-equivalence REL function. -- -- Buchler 1998, Fig. 3.38 -- --
--   let (~=) p q = abs (p - q) < 0.001
--   let a = [0,2,3,5,7]::[Z12]
--   let b = [0,2,3,4,5,8]::[Z12]
--   let g = [0,1,2,3,5,6,8,10]::[Z12]
--   let j = [0,2,3,4,5,6,8]::[Z12]
--   ti_rel a b ~= 0.593
--   ti_rel a g ~= 0.648
--   ti_rel a j ~= 0.509
--   ti_rel b g ~= 0.712
--   ti_rel b j ~= 0.892
--   ti_rel g j ~= 0.707
--   
ti_rel :: Floating n => [Z12] -> [Z12] -> n -- | Generalised twelve-tone operations on un-ordered pitch-class sets with -- arbitrary Z. module Music.Theory.Z.Tto -- | Twelve-tone operator, of the form TMI. data Tto t Tto :: t -> t -> Bool -> Tto t [tto_T] :: Tto t -> t [tto_M] :: Tto t -> t [tto_I] :: Tto t -> Bool -- | T0 tto_identity :: Num t => Tto t -- | Pretty printer. It is an error here is M is not 1 or 5. tto_pp :: (Show t, Num t, Eq t) => Tto t -> String -- | Parser for Tto, requires value for M (ordinarily 5 for 12-tone Tto). p_tto :: Integral t => t -> P (Tto t) -- | Parser, transposition must be decimal. -- --
--   map (tto_pp . tto_parse 5) (words "T5 T3I T11M T9MI") == ["T5","T3I","T11M","T9MI"]
--   
tto_parse :: Integral i => i -> String -> Tto i -- | Set M at Tto. tto_M_set :: Integral t => t -> Tto t -> Tto t -- | The set of all Tto, given Z. -- --
--   length (z_tto_univ 5 z12) == 48
--   map tto_pp (z_tto_univ 5 z12)
--   
z_tto_univ :: Integral t => t -> Z t -> [Tto t] -- | Apply Tto to pitch-class. -- --
--   map (z_tto_f z12 (tto_parse 5 "T1M")) [0,1,2,3] == [1,6,11,4]
--   
z_tto_f :: Integral t => Z t -> Tto t -> t -> t -- | nub of sort of z_tto_f. (nub because M may be 0). -- --
--   z_tto_apply z12 (tto_parse 5 "T1M") [0,1,2,3] == [1,4,6,11]
--   
z_tto_apply :: Integral t => Z t -> Tto t -> [t] -> [t] -- | Find Ttos that map pc-set x to pc-set y given -- m and z. -- --
--   map tto_pp (z_tto_rel 5 z12 [0,1,2,3] [1,4,6,11]) == ["T1M","T4MI"]
--   
z_tto_rel :: (Ord t, Integral t) => t -> Z t -> [t] -> [t] -> [Tto t] -- | nub of sort of z_mod of z. -- --
--   z_pcset z12 [1,13] == [1]
--   map (z_pcset z12) [[0,6],[6,12],[12,18]] == replicate 3 [0,6]
--   
z_pcset :: (Integral t, Ord t) => Z t -> [t] -> [t] -- | Transpose by n. -- --
--   z_tto_tn z12 4 [1,5,6] == [5,9,10]
--   z_tto_tn z12 4 [0,4,8] == [0,4,8]
--   
z_tto_tn :: Integral i => Z i -> i -> [i] -> [i] -- | Invert about n. -- --
--   z_tto_invert z12 6 [4,5,6] == [6,7,8]
--   z_tto_invert z12 0 [0,1,3] == [0,9,11]
--   
z_tto_invert :: Integral i => Z i -> i -> [i] -> [i] -- | Composition of z_tto_invert about 0 and -- z_tto_tn. -- --
--   z_tto_tni z12 4 [1,5,6] == [3,10,11]
--   (z_tto_invert z12 0 . z_tto_tn z12 4) [1,5,6] == [2,3,7]
--   
z_tto_tni :: Integral i => Z i -> i -> [i] -> [i] -- | Modulo-z multiplication -- --
--   z_tto_mn z12 11 [0,1,4,9] == z_tto_invert z12 0 [0,1,4,9]
--   
z_tto_mn :: Integral i => Z i -> i -> [i] -> [i] -- | M5, ie. mn 5. -- --
--   z_tto_m5 z12 [0,1,3] == [0,3,5]
--   
z_tto_m5 :: Integral i => Z i -> [i] -> [i] -- | T-related sets of p. z_tto_t_related_seq :: Integral i => Z i -> [i] -> [[i]] -- | Unique elements of z_tto_t_related_seq. -- --
--   length (z_tto_t_related z12 [0,1,3]) == 12
--   z_tto_t_related z12 [0,3,6,9] == [[0,3,6,9],[1,4,7,10],[2,5,8,11]]
--   
z_tto_t_related :: Integral i => Z i -> [i] -> [[i]] -- | T/I-related set of p. z_tto_ti_related_seq :: Integral i => Z i -> [i] -> [[i]] -- | Unique elements of z_tto_ti_related_seq. -- --
--   length (z_tto_ti_related z12 [0,1,3]) == 24
--   z_tto_ti_related z12 [0,3,6,9] == [[0,3,6,9],[1,4,7,10],[2,5,8,11]]
--   
z_tto_ti_related :: Integral i => Z i -> [i] -> [[i]] instance GHC.Show.Show t => GHC.Show.Show (Music.Theory.Z.Tto.Tto t) instance GHC.Classes.Eq t => GHC.Classes.Eq (Music.Theory.Z.Tto.Tto t) -- | Haskell implementations of pct operations. See -- http://rd.slavepianos.org/?t=pct module Music.Theory.Z.Drape_1999 -- | Cardinality filter -- --
--   cf [0,3] (cg [1..4]) == [[1,2,3],[1,2,4],[1,3,4],[2,3,4],[]]
--   
cf :: Integral n => [n] -> [[a]] -> [[a]] -- | Combinatorial sets formed by considering each set as possible values -- for slot. -- --
--   cgg [[0,1],[5,7],[3]] == [[0,5,3],[0,7,3],[1,5,3],[1,7,3]]
--   let n = "01" in cgg [n,n,n] == ["000","001","010","011","100","101","110","111"]
--   
cgg :: [[a]] -> [[a]] -- | Combinations generator, ie. synonym for powerset. -- --
--   sort (cg [0,1,3]) == [[],[0],[0,1],[0,1,3],[0,3],[1],[1,3],[3]]
--   
cg :: [a] -> [[a]] -- | Powerset filtered by cardinality. -- --
--   >>> pct cg -r3 0159
--   015
--   019
--   059
--   159
--   
-- --
--   cg_r 3 [0,1,5,9] == [[0,1,5],[0,1,9],[0,5,9],[1,5,9]]
--   
cg_r :: Integral n => n -> [a] -> [[a]] -- | Chain pcsegs. -- --
--   >>> echo 024579 | pct chn T0 3 | sort -u
--   579468 (RT8M)
--   579A02 (T5)
--   
-- --
--   chn_t0 z12 3 [0,2,4,5,7,9] == [[5,7,9,10,0,2],[5,7,9,4,6,8]]
--   
-- --
--   >>> echo 02457t | pct chn T0 2
--   7A0135 (RT5I)
--   7A81B9 (RT9MI)
--   
-- --
--   chn_t0 z12 2 [0,2,4,5,7,10] == [[7,10,0,1,3,5],[7,10,8,1,11,9]]
--   
chn_t0 :: Integral i => Z i -> Int -> [i] -> [[i]] -- | Cyclic interval segment. -- --
--   >>> echo 014295e38t76 | pct cisg
--   13A7864529B6
--   
-- --
--   ciseg z12 [0,1,4,2,9,5,11,3,8,10,7,6] == [1,3,10,7,8,6,4,5,2,9,11,6]
--   
ciseg :: Integral i => Z i -> [i] -> [i] -- | Synonynm for z_complement. -- --
--   >>> pct cmpl 02468t
--   13579B
--   
-- --
--   cmpl z12 [0,2,4,6,8,10] == [1,3,5,7,9,11]
--   
cmpl :: Integral i => Z i -> [i] -> [i] -- | Form cycle. -- --
--   >>> echo 056 | pct cyc
--   0560
--   
-- --
--   cyc [0,5,6] == [0,5,6,0]
--   
cyc :: [a] -> [a] -- | Diatonic set name. d for diatonic set, m for melodic -- minor set, o for octotonic set. d_nm :: Integral a => [a] -> Maybe Char -- | Diatonic implications. dim :: Integral i => [i] -> [(i, [i])] -- | Variant of dim that is closer to the pct form. -- --
--   >>> pct dim 016
--   T1d
--   T1m
--   T0o
--   
-- --
--   dim_nm [0,1,6] == [(1,'d'),(1,'m'),(0,'o')]
--   
dim_nm :: Integral i => [i] -> [(i, Char)] -- | Diatonic interval set to interval set. -- --
--   >>> pct dis 24
--   1256
--   
-- --
--   dis [2,4] == [1,2,5,6]
--   
dis :: Integral t => [Int] -> [t] -- | Degree of intersection. -- --
--   >>> echo 024579e | pct doi 6 | sort -u
--   024579A
--   024679B
--   
-- --
--   let p = [0,2,4,5,7,9,11]
--   doi z12 6 p p == [[0,2,4,5,7,9,10],[0,2,4,6,7,9,11]]
--   
-- --
--   >>> echo 01234 | pct doi 2 7-35 | sort -u
--   13568AB
--   
-- --
--   doi z12 2 (sc "7-35") [0,1,2,3,4] == [[1,3,5,6,8,10,11]]
--   
doi :: Integral i => Z i -> Int -> [i] -> [i] -> [[i]] -- | Embedded segment search. -- --
--   >>> echo 23A | pct ess 0164325
--   2B013A9
--   923507A
--   
-- --
--   ess z12 [0,1,6,4,3,2,5] [2,3,10] == [[9,2,3,5,0,7,10],[2,11,0,1,3,10,9]]
--   
ess :: Integral i => Z i -> [i] -> [i] -> [[i]] -- | Forte name (ie sc_name). fn :: Integral i => [i] -> String -- | Z-12 cycles. frg_cyc :: Integral i => T6 [[i]] -- | Fragmentation of cycles. frg :: Integral i => [i] -> T6 [String] -- | Header sequence for frg_pp. frg_hdr :: [String] -- | Fragmentation of cycles. -- --
--   >>> pct frg 024579
--   Fragmentation of 1-cycle(s):  [0-2-45-7-9--]
--   Fragmentation of 2-cycle(s):  [024---] [--579-]
--   Fragmentation of 3-cycle(s):  [0--9] [-47-] [25--]
--   Fragmentation of 4-cycle(s):  [04-] [-59] [2--] [-7-]
--   Fragmentation of 5-cycle(s):  [05------4927]
--   Fragmentation of 6-cycle(s):  [0-] [-7] [2-] [-9] [4-] [5-]
--   IC cycle vector: <1> <22> <111> <1100> <5> <000000>
--   
-- --
--   putStrLn $ frg_pp [0,2,4,5,7,9]
--   
frg_pp :: Integral i => [i] -> String -- | Can the set-class q (under prime form algorithm pf) be drawn from the -- pcset p. has_sc_pf :: Integral a => ([a] -> [a]) -> [a] -> [a] -> Bool -- | has_sc_pf of forte_prime -- --
--   let d = [0,2,4,5,7,9,11]
--   has_sc z12 d (z_complement z12 d) == True
--   
-- --
--   has_sc z12 [] [] == True
--   
has_sc :: Integral i => Z i -> [i] -> [i] -> Bool -- | Interval-class cycle vector. ic_cycle_vector :: Integral i => [i] -> T6 [Int] -- | Pretty printer for ic_cycle_vector. -- --
--   let r = "IC cycle vector: <1> <22> <111> <1100> <5> <000000>"
--   ic_cycle_vector_pp (ic_cycle_vector [0,2,4,5,7,9]) == r
--   
ic_cycle_vector_pp :: T6 [Int] -> String -- | Interval cycle filter. -- --
--   >>> echo 22341 | pct icf
--   22341
--   
-- --
--   icf [[2,2,3,4,1]] == [[2,2,3,4,1]]
--   
icf :: (Num a, Eq a) => [[a]] -> [[a]] -- | Interval class set to interval sets. -- --
--   >>> pct ici -c 123
--   123
--   129
--   1A3
--   1A9
--   
-- --
--   ici_c [1,2,3] == [[1,2,3],[1,2,9],[1,10,3],[1,10,9]]
--   
ici :: Num t => [Int] -> [[t]] -- | Interval class set to interval sets, concise variant. -- --
--   ici_c [1,2,3] == [[1,2,3],[1,2,9],[1,10,3],[1,10,9]]
--   
ici_c :: [Int] -> [[Int]] -- | Interval segment (INT). iseg :: Integral i => Z i -> [i] -> [i] -- | Imbrications. -- --
--   let r = [[[0,2,4],[2,4,5],[4,5,7],[5,7,9]]
--           ,[[0,2,4,5],[2,4,5,7],[4,5,7,9]]]
--   in imb [3,4] [0,2,4,5,7,9] == r
--   
imb :: Integral n => [n] -> [a] -> [[[a]]] -- | issb gives the set-classes that can append to p to -- give q. -- --
--   >>> pct issb 3-7 6-32
--   3-7
--   3-2
--   3-11
--   
-- --
--   issb (sc "3-7") (sc "6-32") == ["3-2","3-7","3-11"]
--   
issb :: Integral i => [i] -> [i] -> [String] -- | Matrix search. -- --
--   >>> pct mxs 024579 642 | sort -u
--   6421B9
--   B97642
--   
-- --
--   set (mxs z12 [0,2,4,5,7,9] [6,4,2]) == [[6,4,2,1,11,9],[11,9,7,6,4,2]]
--   
mxs :: Integral i => Z i -> [i] -> [i] -> [[i]] -- | Normalize (synonym for set) -- --
--   >>> pct nrm 0123456543210
--   0123456
--   
-- --
--   nrm [0,1,2,3,4,5,6,5,4,3,2,1,0] == [0,1,2,3,4,5,6]
--   
nrm :: Ord a => [a] -> [a] -- | Normalize, retain duplicate elements. nrm_r :: Ord a => [a] -> [a] -- | Pitch-class invariances (called pi at pct). -- --
--   >>> pct pi 0236 12
--   pcseg 0236
--   pcseg 6320
--   pcseg 532B
--   pcseg B235
--   
-- --
--   pci z12 [1,2] [0,2,3,6] == [[0,2,3,6],[5,3,2,11],[6,3,2,0],[11,2,3,5]]
--   
pci :: Integral i => Z i -> [Int] -> [i] -> [[i]] -- | Relate sets (TnMI), ie z_tto_rel -- --
--   >>> $ pct rs 0123 641B
--   
--   >>> T1M
--   
-- --
--   map tto_pp (rs 5 z12 [0,1,2,3] [6,4,1,11]) == ["T1M","T4MI"]
--   
rs :: Integral t => t -> Z t -> [t] -> [t] -> [Tto t] -- | Relate segments. -- --
--   >>> $ pct rsg 156 3BA
--   
--   >>> T4I
--   
--   >>> $ pct rsg 0123 05A3
--   
--   >>> T0M
--   
--   >>> $ pct rsg 0123 4B61
--   
--   >>> RT1M
--   
--   >>> $ pct rsg 0123 B614
--   
--   >>> r3RT1M
--   
-- --
--   let sros = map (sro_parse 5) . words
--   rsg 5 z12 [1,5,6] [3,11,10] == sros "T4I r1RT4MI"
--   rsg 5 z12 [0,1,2,3] [0,5,10,3] == sros "T0M RT3MI"
--   rsg 5 z12 [0,1,2,3] [4,11,6,1] == sros "T4MI RT1M"
--   rsg 5 z12 [0,1,2,3] [11,6,1,4] == sros "r1T4MI r1RT1M"
--   
rsg :: Integral i => i -> Z i -> [i] -> [i] -> [Sro i] -- | Subsets. -- --
--   cf [4] (sb z12 [sc "6-32",sc "6-8"]) == [[0,2,3,5],[0,1,3,5],[0,2,3,7],[0,2,4,7],[0,2,5,7]]
--   
sb :: Integral i => Z i -> [[i]] -> [[i]] -- | scc = set class completion -- --
--   >>> pct scc 6-32 168
--   35A
--   49B
--   3AB
--   34B
--   
-- --
--   scc z12 (sc "6-32") [1,6,8] == [[3,5,10],[4,9,11],[3,10,11],[3,4,11]]
--   
scc :: Integral i => Z i -> [i] -> [i] -> [[i]] -- | Header fields for si. si_hdr :: [String] -- | (Pcset,Tto,Forte-Prime) type Si i = ([i], Tto i, [i]) -- | Calculator for si. -- --
--   si_calc [0,5,3,11]
--   
si_calc :: Integral i => [i] -> (Si i, [i], [Int], Si i, Si i) -- | Pretty printer for RHS for si. -- --
--   si_rhs_pp [0,5,3,11]
--   
si_rhs_pp :: (Integral i, Show i) => [i] -> [String] -- | Set information. -- -- $ pct si 053b pitch-class-set: {035B} set-class: TB 4-Z15[0146] -- interval-class-vector: [4111111] tics: [102222102022] complement: -- {1246789A} (TAI 8-Z15) multiplication-by-five-transform: {0317} (T0 -- 4-Z29) $ -- --
--   putStr $ unlines $ si [0,5,3,11]
--   
si :: (Integral i, Show i) => [i] -> [String] -- | Super set-class. -- --
--   >>> pct spsc 4-11 4-12
--   5-26[02458]
--   
-- --
--   spsc z12 [sc "4-11",sc "4-12"] == [[0,2,4,5,8]]
--   
-- --
--   >>> pct spsc 3-11 3-8
--   4-27[0258]
--   4-Z29[0137]
--   
-- --
--   spsc z12 [sc "3-11",sc "3-8"] == [[0,2,5,8],[0,1,3,7]]
--   
-- --
--   >>> pct spsc `pct fl 3`
--   6-Z17[012478]
--   
-- --
--   spsc z12 (cf [3] scs) == [[0,1,2,4,7,8]]
--   
spsc :: Integral i => Z i -> [[i]] -> [[i]] -- | sra = stravinsky rotational array -- --
--   >>> echo 019BA7 | pct sra
--   019BA7
--   08A96B
--   021A34
--   0B812A
--   0923B1
--   056243
--   
-- --
--   let r = [[0,1,9,11,10,7],[0,8,10,9,6,11],[0,2,1,10,3,4],[0,11,8,1,2,10],[0,9,2,3,11,1],[0,5,6,2,4,3]]
--   sra z12 [0,1,9,11,10,7] == r
--   
sra :: Integral i => Z i -> [i] -> [[i]] -- | Serial operation. -- --
--   >>> echo 156 | pct sro T4
--   59A
--   
-- --
--   sro (Z.sro_parse "T4") [1,5,6] == [5,9,10]
--   
-- --
--   >>> echo 024579 | pct sro RT4I
--   79B024
--   
-- --
--   sro (Z.Sro 0 True 4 False True) [0,2,4,5,7,9] == [7,9,11,0,2,4]
--   
-- --
--   >>> echo 156 | pct sro T4I
--   3BA
--   
-- --
--   sro (Z.sro_parse "T4I") [1,5,6] == [3,11,10]
--   sro (Z.Sro 0 False 4 False True) [1,5,6] == [3,11,10]
--   
-- --
--   >>> echo 156 | pct sro T4  | pct sro T0I
--   732
--   
-- --
--   (sro (Z.sro_parse "T0I") . sro (Z.sro_parse "T4")) [1,5,6] == [7,3,2]
--   
-- --
--   >>> echo 024579 | pct sro RT4I
--   79B024
--   
-- --
--   sro (Z.sro_parse "RT4I") [0,2,4,5,7,9] == [7,9,11,0,2,4]
--   
sro :: Integral i => Z i -> Sro i -> [i] -> [i] -- | tmatrix -- --
--   >>> pct tmatrix 1258
--   
-- -- 1258 0147 9A14 67A1 -- --
--   tmatrix z12 [1,2,5,8] == [[1,2,5,8],[0,1,4,7],[9,10,1,4],[6,7,10,1]]
--   
tmatrix :: Integral i => Z i -> [i] -> [[i]] -- | trs = transformations search. Search all RTnMI of p for -- q. -- --
--   >>> echo 642 | pct trs 024579 | sort -u
--   531642
--   6421B9
--   642753
--   B97642
--   
-- --
--   let r = [[5,3,1,6,4,2],[6,4,2,1,11,9],[6,4,2,7,5,3],[11,9,7,6,4,2]]
--   sort (trs z12 [0,2,4,5,7,9] [6,4,2]) == r
--   
trs :: Integral i => Z i -> [i] -> [i] -> [[i]] -- | Like trs, but of z_sro_rti_related. -- --
--   trs_m z12 [0,2,4,5,7,9] [6,4,2] == [[6,4,2,1,11,9],[11,9,7,6,4,2]]
--   
trs_m :: Integral i => Z i -> [i] -> [i] -> [[i]] module Music.Theory.Z.Drape_1999.Cli type Z12 = Int8 help :: [String] z16_seq_parse :: String -> [Int] pco_parse :: String -> [Z12] pco_pp :: [Z12] -> String cset_parse :: String -> [Int] type CMD = String -> String mk_cmd :: ([Z12] -> [Z12]) -> CMD mk_cmd_many :: ([Z12] -> [[Z12]]) -> CMD ess_cmd :: String -> CMD z12_sc_name :: [Z12] -> SC_Name fl_c_cmd :: CMD frg_cmd :: CMD pi_cmd :: String -> CMD scc_cmd :: String -> CMD si_cmd :: CMD z12_sc_name_long :: [Z12] -> SC_Name spsc_cmd :: [String] -> String sra_cmd :: CMD sro_cmd :: String -> CMD tmatrix_cmd :: CMD trs_cmd :: ([Z12] -> [Z12] -> [[Z12]]) -> String -> CMD interact_ln :: CMD -> IO () pct_cli :: [String] -> IO () -- | James Boros. "Some Properties of the All-Trichord Hexachord". _In -- Theory Only_, 11(6):19--41, 1990. module Music.Theory.Z.Boros_1990 singular :: String -> [t] -> t set_eq :: Ord t => [t] -> [t] -> Bool elem_by :: (t -> t -> Bool) -> t -> [t] -> Bool tto_tni_univ :: Integral i => [Tto i] all_tn :: Integral i => [i] -> [[i]] all_tni :: Integral i => [i] -> [[i]] uniq_tni :: Integral i => [i] -> [[i]] type Pc = Int type Pcset = [Pc] type Sc = Pcset pcset_trs :: Int -> Pcset -> Pcset -- | Forte prime forms of the twelve trichordal set classes. -- --
--   length trichords == 12
--   
trichords :: [Pcset] -- | Is a pcset self-inversional, ie. is the inversion of p a -- transposition of p. -- --
--   map (\p -> (p,self_inv p)) trichords
--   
self_inv :: Pcset -> Bool -- | Pretty printer, comma separated. -- --
--   pcset_pp [0,3,7,10] == "0,3,7,10"
--   
pcset_pp :: Pcset -> String -- | Pretty printer, hexadecimal, no separator. -- --
--   pcset_pp_hex [0,3,7,10] == "037A"
--   
pcset_pp_hex :: Pcset -> String -- | Forte prime form of the all-trichord hexachord. -- --
--   T.sc_name ath == "6-Z17"
--   T.sc "6-Z17" == ath
--   
ath :: Pcset -- | Is p an instance of ath. is_ath :: Pcset -> Bool -- | Table 1, p.20 -- --
--   length ath_univ == 24
--   
ath_univ :: [Pcset] -- | Calculate Tto of pcset, which must be an instance of -- ath. -- --
--   ath_tni [1,2,3,7,8,11] == T.Tto 3 1 True
--   
ath_tni :: Pcset -> Tto Pc -- | Give label for instance of ath, prime forms are written H and -- inversions h. -- --
--   ath_pp [1,2,3,7,8,11] == "h3"
--   
ath_pp :: Pcset -> String -- | The twenty three-element subsets of ath. -- --
--   length ath_trichords == 20
--   
ath_trichords :: [Pcset] -- | \\ of ath and p, ie. the pitch classes that are -- in ath and not in p. -- --
--   ath_complement [0,1,2] == [4,7,8]
--   
ath_complement :: Pcset -> Pcset -- | p is a pcset, q a sc, calculate pcsets in q that -- with p form ath. -- --
--   ath_completions [0,1,2] (T.sc "3-3") == [[6,7,10],[4,7,8]]
--   ath_completions [6,7,10] (T.sc "3-5") == [[1,2,8]]
--   
ath_completions :: Pcset -> Sc -> [Pcset] realise_ath_seq :: [Pcset] -> [[Pcset]] ath_gr_extend :: [Edge Pcset] -> Pcset -> [Edge Pcset] gr_trs :: Int -> [Edge Pcset] -> [Edge Pcset] table_3 :: [((Pcset, Sc, SC_Name), (Pcset, Sc, SC_Name))] pp_tbl :: Text_Table -> [String] table_3_md :: [String] table_4 :: [((Pcset, Pcset, SC_Name), (Pcset, Pcset, SC_Name))] table_4_md :: [String] table_5 :: [(Pcset, Int)] table_5_md :: [String] table_6 :: [(Pcset, Int, Int)] table_6_md :: [String] fig_1 :: [Edge Pcset] fig_1_gr :: Gr Pcset () fig_2 :: [[Pcset]] fig_3 :: [[Edge Pcset]] fig_3_gr :: [Gr Pcset ()] fig_4 :: [[Edge Pcset]] fig_5 :: [[Edge Pcset]] uedge_set :: Ord v => [Edge v] -> [Edge v] -- | Self-inversional pcsets are drawn in a double circle, other pcsets in -- a circle. set_shape :: Pcset -> Dot_Attr type Gr = Gr Pcset () gr_pp' :: (Pcset -> String) -> Graph_Pp Pcset () gr_pp :: Graph_Pp Pcset () d_fig_1 :: [String] d_fig_3_g :: Gr d_fig_3 :: [String] d_fig_3' :: [[String]] d_fig_4_g :: Gr d_fig_4 :: [String] d_fig_5_g :: Gr d_fig_5 :: [String] d_fig_5_e :: [Edge_Lbl Pcset Pcset] d_fig_5_g' :: Gr Pcset Pcset d_fig_5' :: [String] -- | Tom Johnson. Other Harmony: Beyond Tonal and Atonal. Editions -- 75, 2014. module Music.Theory.Graph.Johnson_2014 type Z12 = Int8 dif :: Num a => (a, a) -> a absdif :: Num a => (a, a) -> a -- | interval (0,11) to interval class (0,6) i_to_ic :: (Num a, Ord a) => a -> a p2_and :: (t -> u -> Bool) -> (t -> u -> Bool) -> t -> u -> Bool -- | degree of intersection doi :: Eq t => [t] -> [t] -> Int doi_of :: Eq t => Int -> [t] -> [t] -> Bool -- | The sum of the pointwise absolute difference. loc_dif :: Num t => [t] -> [t] -> t loc_dif_of :: (Eq t, Num t) => t -> [t] -> [t] -> Bool loc_dif_in :: (Eq t, Num t) => [t] -> [t] -> [t] -> Bool -- | The number of places that are, pointwise, not equal. -- --
--   loc_dif_n "test" "pest" == 1
--   
loc_dif_n :: (Eq t, Num i) => [t] -> [t] -> i loc_dif_n_of :: Eq t => Int -> [t] -> [t] -> Bool min_vl :: (Num a, Ord a) => [a] -> [a] -> a min_vl_of :: (Num a, Ord a) => a -> [a] -> [a] -> Bool min_vl_in :: (Num a, Ord a) => [a] -> [a] -> [a] -> Bool combinations2 :: Ord t => [t] -> [(t, t)] set_pp :: Show t => [t] -> String tto_rel_to :: Integral t => Z t -> [t] -> [t] -> [Tto t] set_pp_tto_rel :: (Integral t, Show t) => Z t -> [t] -> [t] -> String m_get :: Ord k => Map k v -> k -> v -- | degree of intersection m_doi_of :: Map Int [Z12] -> Int -> Int -> Int -> Bool -- | Add k as prefix to both left and right hand sides of edge. e_add_id :: k -> [(t, u)] -> [((k, t), (k, u))] gen_edges :: (t -> t -> Bool) -> [t] -> [(t, t)] gen_u_edges :: Ord a => (a -> a -> Bool) -> [a] -> [(a, a)] oh_def_opt :: [Dot_Meta_Attr] gen_graph :: Ord v => [Dot_Meta_Attr] -> Graph_Pp v e -> [Edge_Lbl v e] -> [String] gen_graph_ul :: Ord v => [Dot_Meta_Attr] -> (v -> String) -> [Edge v] -> [String] gen_graph_ul_ty :: Ord v => String -> (v -> String) -> [Edge v] -> [String] gen_flt_graph_pp :: Ord t => [Dot_Meta_Attr] -> ([t] -> String) -> ([t] -> [t] -> Bool) -> [[t]] -> [String] gen_flt_graph :: (Ord t, Show t) => [Dot_Meta_Attr] -> ([t] -> [t] -> Bool) -> [[t]] -> [String] circ_5 :: Integral a => Int -> a -> [a] all_pairs :: [t] -> [u] -> [(t, u)] adj :: [t] -> [(t, t)] adj_cyc :: [t] -> [(t, t)] p12_c5_eset :: [(Int, Int)] e_add_label :: (Edge v -> l) -> [Edge v] -> [Edge_Lbl v l] p12_c5_gr :: [String] p12_euler_plane :: Euler_Plane Rational p12_euler_plane_gr :: [String] p14_eset :: ([(Int, Int)], [(Int, Int)], [(Int, Int)]) p14_mk_e :: [(Int, Int)] -> [(Key, Key)] p14_edges_u :: [(Key, Key)] p14_edges :: [(Key, Key)] p14_mk_gr :: [Dot_Meta_Attr] -> [Edge Key] -> [String] p14_gr_u :: [String] p14_gr :: [String] p14_gen_tonnetz_n :: Int -> [Int] -> [Int] -> [Int] p14_gen_tonnetz_e :: Int -> [Int] -> [Int] -> [((Int, Int), Int)] p14_nrt_gr :: [String] p31_f_4_22 :: [Z12] p31_e_set :: [([Z12], [Z12])] p31_gr :: [String] p114_f_3_7 :: [Z12] p114_mk_o :: Show t => t -> [Dot_Meta_Attr] p114_mk_gr :: Double -> ([Z12] -> [Z12] -> Bool) -> [String] p114_f37_sc_pp :: [Z12] -> String p114_g0 :: [String] p114_g1 :: [String] p114_gr_set :: [(String, [String])] p125_gr :: [String] p131_gr :: [String] p148_mk_gr :: ([Int] -> [Int] -> Bool) -> [String] p148_gr_set :: [(String, [String])] p162_ch :: [[Int]] p162_e :: [Edge [Int]] p162_gr :: [String] p172_nd_map :: Map Int [Z12] p172_nd_e_set :: [(Int, Int)] p172_nd_e_set_alt :: [Edge Int] p172_gr :: Gr () () p172_set_pp :: Int -> String p172_all_cyc :: ([[Int]], [[Int]]) p172_cyc0 :: [[Int]] p172_g1 :: [String] p172_g2 :: [String] p172_g3 :: [String] -- | Tto Tn. tto_tn :: Integral t => t -> Tto t -- | Tto TnI. tto_tni :: Integral t => t -> Tto t gen_tto_alt_seq :: Integral t => (t -> Tto t, t -> Tto t) -> Int -> t -> t -> t -> [Tto t] -- | k is length of the T & I sequences, n is the T & -- I sequence interval, m is the interval between the T & I -- sequence. -- --
--   r = ["T0 T5I T3 T8I T6 T11I T9 T2I","T1 T6I T4 T9I T7 T0I T10 T3I"]
--   map (unwords . map T.tto_pp . gen_tni_seq 4 3 5) [0,1] == r
--   
gen_tni_seq :: Integral t => Int -> t -> t -> t -> [Tto t] p172_c4 :: [[Tto Int]] tto_seq_edges :: (Show t, Num t, Eq t) => [[Tto t]] -> [(String, String)] p172_g4 :: [String] p172_gr_set :: [(String, [String])] partition_ic :: (Num t, Ord t, Show t) => t -> [t] -> ([t], [t]) p177_gr_set :: [(String, [String])] type SC = [Int] type PCSET = [Int] ait :: [SC] -- | List of pcsets s where prime(p+s)=r and -- prime(q+s)=r. #p and #q must be equal, and less -- than #r. -- --
--   mk_bridge (T.sc "4-Z15") [0,6] [1,7] == [[2,5],[8,11]]
--   mk_bridge (T.sc "4-Z29") [0,6] [1,7] == [[2,11],[5,8]]
--   
mk_bridge :: SC -> PCSET -> PCSET -> [PCSET] -- | concatMap of mk_bridge. -- --
--   mk_bridge_set ait [0,6] [1,7] == [[2,5],[8,11],[2,11],[5,8]]
--   
mk_bridge_set :: [SC] -> PCSET -> PCSET -> [PCSET] mk_bridge_set_seq :: [SC] -> [PCSET] -> [[PCSET]] p178_i6_seq :: [PCSET] p178_ch :: [(PCSET, [PCSET], PCSET)] type ID = Char -- | Add ID to vertices, the 2,11 the is between -- 0,6 and 1,7 is not the same 2,11 -- that is between 3,9 and 4,10. p178_e :: [((ID, PCSET), (ID, PCSET))] p178_gr_1 :: [String] p178_gr_2 :: [String] p196_gr :: [String] type SET = [Int] type E = (SET, SET) bd_9_3_2_12 :: [SET] p201_mk_e :: [Int] -> [E] p201_e :: [[E]] p201_o :: [Dot_Meta_Attr] p201_gr_set :: [[String]] p201_gr_join :: [String] bd_9_3_2_34 :: [SET] p205_mk_e :: [Int] -> [E] p205_gr :: [String] wr_graphs :: FilePath -> IO ()