Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Bel(R) is a simplified form of the Bel notation described in:
- Bernard Bel. "Time and musical structures". Interface (Journal of New Music Research) Volume 19, Issue 2-3, 1990. (http://hal.archives-ouvertes.fr/hal-00134160)
- Bernard Bel. "Two algorithms for the instantiation of structures of musical objects". Centre National de la Recherche Scientifique, 1992. GRTC 458 (http://www.lpl.univ-aix.fr/~belbernard/music/2algorithms.pdf)
For details see http://rohandrape.net/?t=hmt-texts.
Synopsis
- data Par_Mode
- par_mode_brackets :: Par_Mode -> (String, String)
- par_mode_kind :: (String, String) -> Par_Mode
- bel_brackets_match :: (Char, Char) -> Bool
- type Tempo = Rational
- data Term a
- term_value :: Term t -> Maybe t
- data Bel a
- par_of :: Par_Mode -> [Bel a] -> Bel a
- bel_pp :: (a -> String) -> Bel a -> String
- bel_char_pp :: Bel Char -> String
- par_analyse :: Tempo -> Par_Mode -> Bel a -> Bel a -> (Rational, Rational, Rational)
- par_dur :: Tempo -> Par_Mode -> Bel a -> Bel a -> Rational
- bel_tdur :: Tempo -> Bel a -> (Tempo, Rational)
- bel_dur :: Tempo -> Bel a -> Rational
- type Time = Rational
- type Voice = [Char]
- type L_St = (Time, Tempo, Voice)
- type L_Term a = (L_St, Term a)
- lterm_time :: L_Term a -> Time
- lterm_duration :: L_Term a -> Time
- lterm_end_time :: L_Term a -> Time
- lterm_voice :: L_Term t -> Voice
- lterm_term :: L_Term t -> Term t
- lterm_value :: L_Term t -> Maybe t
- type L_Bel a = [L_Term a]
- bel_linearise :: L_St -> Bel a -> (L_Bel a, L_St)
- lbel_merge :: L_Bel a -> L_Bel a -> L_Bel a
- lbel_tempi :: L_Bel a -> [Tempo]
- lbel_tempo_mul :: Rational -> L_Bel a -> L_Bel a
- lbel_normalise_multiplier :: L_Bel t -> Rational
- lbel_normalise :: L_Bel a -> L_Bel a
- voice_normalise :: Voice -> Voice
- voice_eq :: Voice -> Voice -> Bool
- lbel_voices :: L_Bel a -> [Voice]
- lbel_duration :: L_Bel a -> Time
- lbel_lookup :: (Time, Voice) -> L_Bel a -> Maybe (L_Term a)
- lbel_grid :: L_Bel a -> [[Maybe (Term a)]]
- bel_grid :: Bel a -> [[Maybe (Term a)]]
- bel_ascii :: Bool -> Bel Char -> String
- bel_ascii_pr :: Bel Char -> IO ()
- (~>) :: Bel a -> Bel a -> Bel a
- lseq :: [Bel a] -> Bel a
- node :: a -> Bel a
- nseq :: [a] -> Bel a
- cseq :: String -> Bel Char
- par :: Bel a -> Bel a -> Bel a
- rest :: Bel a
- nrests :: Integral n => n -> Bel a
- bel_parse_pp_ident :: String -> Bool
- bel_ascii_pp :: String -> IO ()
- p_rest :: P (Term a)
- p_nrests :: P (Bel a)
- p_continue :: P (Term a)
- p_char_value :: P (Term Char)
- p_char_term :: P (Term Char)
- p_char_node :: P (Bel Char)
- p_non_negative_integer :: P Integer
- p_non_negative_rational :: P Rational
- p_non_negative_double :: P Double
- p_non_negative_number :: P Rational
- p_mul :: P (Bel a)
- p_iso :: P (Bel a) -> P (Bel a)
- p_char_iso :: P (Bel Char)
- p_par :: P (Bel a) -> P (Bel a)
- p_char_par :: P (Bel Char)
- p_char_bel :: P (Bel Char)
- bel_char_parse :: String -> Bel Char
Bel
Types of Par
nodes.
Instances
par_mode_brackets :: Par_Mode -> (String, String) Source #
The different Par
modes are indicated by bracket types.
Terms are the leaf nodes of the temporal structure.
term_value :: Term t -> Maybe t Source #
Value of Term, else Nothing
Recursive temporal structure.
Node (Term a) | Leaf node |
Iso (Bel a) | Isolate |
Seq (Bel a) (Bel a) | Sequence |
Par Par_Mode (Bel a) (Bel a) | Parallel |
Mul Tempo | Tempo multiplier |
Instances
par_of :: Par_Mode -> [Bel a] -> Bel a Source #
Given a Par mode, generate either: 1. an Iso, 2. a Par, 3. a series of nested Par.
bel_pp :: (a -> String) -> Bel a -> String Source #
Pretty printer for Bel
, given pretty printer for the term type.
Note this does not write nested Par nodes in their simplified form.
par_analyse :: Tempo -> Par_Mode -> Bel a -> Bel a -> (Rational, Rational, Rational) Source #
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)
Linearisation
Voices are named as a sequence of left and right directions within nested Par
structures.
l is left and r is right.
lterm_term :: L_Term t -> Term t Source #
Term of L_Term
lterm_value :: L_Term t -> Maybe t Source #
Value of Term of L_Term
lbel_normalise_multiplier :: L_Bel t -> Rational Source #
The multiplier that will normalise an L_Bel value. After normalisation all start times and durations are integral.
lbel_normalise :: L_Bel a -> L_Bel a Source #
Calculate and apply L_Bel normalisation multiplier.
voice_normalise :: Voice -> Voice Source #
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"
Combinators
bel_parse_pp_ident :: String -> Bool Source #
Verify that bel_char_pp
of bel_char_parse
is id
.
bel_ascii_pp :: String -> IO () Source #
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}}"
Parsing
p_non_negative_integer :: P Integer Source #
Parse non-negative Integer
.
P.parse p_non_negative_integer "" "3"
p_non_negative_rational :: P Rational Source #
Parse non-negative Rational
.
P.parse (p_non_negative_rational `P.sepBy` (P.char ',')) "" "3%5,2/3"
p_non_negative_double :: P Double Source #
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_number :: P Rational Source #
Parse non-negative number as Rational
.
P.parse (p_non_negative_number `P.sepBy` (P.char ',')) "" "7%2,3.5,3"
p_char_iso :: P (Bel Char) Source #
p_iso
of p_char_bel
.
P.parse p_char_iso "" "{abcde}"
p_char_par :: P (Bel Char) Source #
p_par
of p_char_bel
.
p = P.parse p_char_par "" p "{ab,{c,de}}" == p "{ab,c,de}" p "{ab,~(c,de)}"