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

Music.Theory.Braille

Description

Synopsis

Documentation

type BRAILLE = (Int, Char, [Int], Char, String) Source #

Braille coding data. Elements are: (ASCII HEX,ASCII CHAR,DOT LIST,UNICODE CHAR,MEANING). The dot numbers are in column order.

braille_dots :: BRAILLE -> [Int] Source #

Dot list of BRAILLE.

braille_table :: [BRAILLE] Source #

ASCII Braille table.

all id (map (\(x,c,_,_,_) -> x == fromEnum c) braille_table) == True

braille_lookup_unicode :: Char -> Maybe BRAILLE Source #

Lookup BRAILLE value for unicode character.

braille_lookup_unicode '⠝' == Just (0x4E,'N',[1,3,4,5],'⠝',"n")

braille_lookup_ascii :: Char -> Maybe BRAILLE Source #

Lookup BRAILLE value for ascii character (case invariant).

braille_lookup_ascii 'N' == Just (0x4E,'N',[1,3,4,5],'⠝',"n")

braille_64 :: [(String, String, String)] Source #

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

transcribe_unicode :: String -> String Source #

Transcribe ASCII to unicode braille.

transcribe_unicode "BRAILLE ASCII CHAR GRID" == "⠃⠗⠁⠊⠇⠇⠑⠀⠁⠎⠉⠊⠊⠀⠉⠓⠁⠗⠀⠛⠗⠊⠙"
transcribe_unicode "BRAILLE HTML TABLE GRID" == "⠃⠗⠁⠊⠇⠇⠑⠀⠓⠞⠍⠇⠀⠞⠁⠃⠇⠑⠀⠛⠗⠊⠙"

transcribe_char_grid :: (Char, Char) -> String -> String Source #

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"

dots_grid :: (c, c) -> [Int] -> [[c]] Source #

Generate 6-dot grid given (white,black) values.

dots_grid (0,1) [1,2,3,5] == [[1,0],[1,1],[1,0]]

string_html_table :: String -> String Source #

lines as rows and Char as cells in HTML table.

decode :: Char -> Maybe String Source #

Decoding.

let t0 = ["⠠⠁⠇⠇⠀⠓⠥⠍⠁⠝⠀⠆⠬⠎⠀⠜⠑⠀⠃⠕⠗⠝⠀⠋⠗⠑⠑⠀⠯⠀⠑⠟⠥⠁⠇⠀⠔⠀⠙⠊⠛⠝⠰⠽⠀⠯⠀⠐⠗⠎⠲"
         ,"⠠⠮⠽⠀⠜⠑⠀⠢⠙⠪⠫⠀⠾⠀⠗⠂⠎⠕⠝⠀⠯⠀⠒⠎⠉⠊⠰⠑⠀⠯⠀⠩⠙⠀⠁⠉⠞⠀⠞⠪⠜⠙⠎⠀⠐⠕⠀⠁⠝⠕⠤"
         ,"⠮⠗⠀⠔⠀⠁⠀⠸⠎⠀⠷⠀⠃⠗⠕⠮⠗⠓⠕⠕⠙⠲"]
concatMap (fromMaybe "#" . decode) (concat t0)

braille_rng :: Integral i => (i, i) Source #

Start and end unicode indices.

braille_seq :: [Char] Source #

All characters, in sequence.

length braille_seq == 256
putStrLn braille_seq

braille_char :: Int -> Char Source #

The nth character, zero indexed.

braille_ix :: Int -> (Char, Char) Source #

Two element index, 255 * 255 = 65025 places.

map braille_ix [100,300]

unicode_html :: Char -> String Source #

HTML character encoding (as hex integer).

unwords $ map unicode_html braille_seq

Unicode

white_circle :: Char Source #

White (empty) circle.

black_circle :: Char Source #

Black (filled) circle.

shaded_circle :: Char Source #

Shaded (hatched) circle.

Contractions

one_letter_contractions :: [(Char, String)] Source #

Table of one letter contractions.