hmt-0.15: Haskell Music Theory

Safe Haskell | Safe
Language | Haskell98

Music.Theory.Dynamic_Mark

Contents

- ASCII

Description

Common music notation dynamic marks.

Synopsis

- data Dynamic_Mark_T
  - = Niente
  - | PPPPP
  - | PPPP
  - | PPP
  - | PP
  - | P
  - | MP
  - | MF
  - | F
  - | FF
  - | FFF
  - | FFFF
  - | FFFFF
  - | FP
  - | SF
  - | SFP
  - | SFPP
  - | SFZ
  - | SFFZ
- dynamic_mark_midi :: (Num n, Enum n) => Dynamic_Mark_T -> Maybe n
- dynamic_mark_midi_err :: Integral n => Dynamic_Mark_T -> n
- midi_dynamic_mark :: (Ord n, Eq n, Num n, Enum n) => n -> Maybe Dynamic_Mark_T
- dynamic_mark_db :: Fractional n => n -> Dynamic_Mark_T -> Maybe n
- ampmidid :: Floating a => a -> a -> a
- amp_db :: Floating a => a -> a
- db_amp :: Floating a => a -> a
- data Hairpin_T
  - = Crescendo
  - | Diminuendo
  - | End_Hairpin
- implied_hairpin :: Dynamic_Mark_T -> Dynamic_Mark_T -> Maybe Hairpin_T
- type Dynamic_Node = (Maybe Dynamic_Mark_T, Maybe Hairpin_T)
- empty_dynamic_node :: Dynamic_Node
- dynamic_sequence :: [Dynamic_Mark_T] -> [Dynamic_Node]
- delete_redundant_marks :: [Maybe Dynamic_Mark_T] -> [Maybe Dynamic_Mark_T]
- dynamic_sequence_sets :: [Maybe Dynamic_Mark_T] -> [Maybe Dynamic_Node]
- apply_dynamic_node :: (a -> Dynamic_Mark_T -> a) -> (a -> Hairpin_T -> a) -> Dynamic_Node -> a -> a
- dynamic_mark_ascii :: Dynamic_Mark_T -> String
- hairpin_ascii :: Hairpin_T -> String
- dynamic_node_ascii :: Dynamic_Node -> String
- dynamic_sequence_ascii :: [Dynamic_Node] -> String

# Documentation

data Dynamic_Mark_T Source #

Enumeration of dynamic mark symbols.

Constructors

Niente |
PPPPP |
PPPP |
PPP |
PP |
P |
MP |
MF |
F |
FF |
FFF |
FFFF |
FFFFF |
FP |
SF |
SFP |
SFPP |
SFZ |
SFFZ |

Instances

Bounded Dynamic_Mark_T Source # |
Methods minBound :: Dynamic_Mark_T # maxBound :: Dynamic_Mark_T #
Enum Dynamic_Mark_T Source # |

Methods

succ :: Dynamic_Mark_T -> Dynamic_Mark_T #

pred :: Dynamic_Mark_T -> Dynamic_Mark_T #

toEnum :: Int -> Dynamic_Mark_T #

fromEnum :: Dynamic_Mark_T -> Int #

enumFrom :: Dynamic_Mark_T -> [Dynamic_Mark_T] #

enumFromThen :: Dynamic_Mark_T -> Dynamic_Mark_T -> [Dynamic_Mark_T] #

enumFromTo :: Dynamic_Mark_T -> Dynamic_Mark_T -> [Dynamic_Mark_T] #

enumFromThenTo :: Dynamic_Mark_T -> Dynamic_Mark_T -> Dynamic_Mark_T -> [Dynamic_Mark_T] #

Eq Dynamic_Mark_T Source # |
Methods (==) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool # (/=) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool #
Ord Dynamic_Mark_T Source # |
Methods compare :: Dynamic_Mark_T -> Dynamic_Mark_T -> Ordering # (<) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool # (<=) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool # (>) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool # (>=) :: Dynamic_Mark_T -> Dynamic_Mark_T -> Bool # max :: Dynamic_Mark_T -> Dynamic_Mark_T -> Dynamic_Mark_T # min :: Dynamic_Mark_T -> Dynamic_Mark_T -> Dynamic_Mark_T #
Show Dynamic_Mark_T Source # |
Methods showsPrec :: Int -> Dynamic_Mark_T -> ShowS # show :: Dynamic_Mark_T -> String # showList :: [Dynamic_Mark_T] -> ShowS #

dynamic_mark_midi :: (Num n, Enum n) => Dynamic_Mark_T -> Maybe n Source #

Lookup MIDI velocity for `Dynamic_Mark_T`. The range is linear in `0-127`.

    let r = [0,6,17,28,39,50,61,72,83,94,105,116,127]
    in mapMaybe dynamic_mark_midi [Niente .. FFFFF] == r

    map dynamic_mark_midi [FP,SF,SFP,SFPP,SFZ,SFFZ] == replicate 6 Nothing

dynamic_mark_midi_err :: Integral n => Dynamic_Mark_T -> n Source #

Error variant.

midi_dynamic_mark :: (Ord n, Eq n, Num n, Enum n) => n -> Maybe Dynamic_Mark_T Source #

Map midi velocity (0-127) to dynamic mark.

    histogram (mapMaybe midi_dynamic_mark [0 .. 127])

dynamic_mark_db :: Fractional n => n -> Dynamic_Mark_T -> Maybe n Source #

Translate fixed `Dynamic_Mark_T`s 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]

ampmidid :: Floating a => a -> a -> a Source #

http://www.csounds.com/manual/html/ampmidid.html

    import Sound.SC3.Plot
    plotTable [map (ampmidid 20) [0 .. 127],map (ampmidid 60) [0 .. 127]]

amp_db :: Floating a => a -> a Source #

JMcC (SC3) equation.

    plotTable1 (map amp_db [0,0.005 .. 1])

db_amp :: Floating a => a -> a Source #

JMcC (SC3) equation.

    plotTable1 (map db_amp [-60,-59 .. 0])

data Hairpin_T Source #

Enumeration of hairpin indicators.

Constructors

Crescendo |
Diminuendo |
End_Hairpin |

Instances

Bounded Hairpin_T Source # |
Methods minBound :: Hairpin_T # maxBound :: Hairpin_T #
Enum Hairpin_T Source # |
Methods succ :: Hairpin_T -> Hairpin_T # pred :: Hairpin_T -> Hairpin_T # toEnum :: Int -> Hairpin_T # fromEnum :: Hairpin_T -> Int # enumFrom :: Hairpin_T -> [Hairpin_T] # enumFromThen :: Hairpin_T -> Hairpin_T -> [Hairpin_T] # enumFromTo :: Hairpin_T -> Hairpin_T -> [Hairpin_T] # enumFromThenTo :: Hairpin_T -> Hairpin_T -> Hairpin_T -> [Hairpin_T] #
Eq Hairpin_T Source # |
Methods (==) :: Hairpin_T -> Hairpin_T -> Bool # (/=) :: Hairpin_T -> Hairpin_T -> Bool #
Ord Hairpin_T Source # |
Methods compare :: Hairpin_T -> Hairpin_T -> Ordering # (<) :: Hairpin_T -> Hairpin_T -> Bool # (<=) :: Hairpin_T -> Hairpin_T -> Bool # (>) :: Hairpin_T -> Hairpin_T -> Bool # (>=) :: Hairpin_T -> Hairpin_T -> Bool # max :: Hairpin_T -> Hairpin_T -> Hairpin_T # min :: Hairpin_T -> Hairpin_T -> Hairpin_T #
Show Hairpin_T Source # |
Methods showsPrec :: Int -> Hairpin_T -> ShowS # show :: Hairpin_T -> String # showList :: [Hairpin_T] -> ShowS #

implied_hairpin :: Dynamic_Mark_T -> Dynamic_Mark_T -> Maybe Hairpin_T Source #

The `Hairpin_T` implied by a ordered pair of `Dynamic_Mark_T`s.

    map (implied_hairpin MF) [MP,F] == [Just Diminuendo,Just Crescendo]

type Dynamic_Node = (Maybe Dynamic_Mark_T, Maybe Hairpin_T) Source #

A node in a dynamic sequence.

empty_dynamic_node :: Dynamic_Node Source #

The empty `Dynamic_Node`.

dynamic_sequence :: [Dynamic_Mark_T] -> [Dynamic_Node] Source #

Calculate a `Dynamic_Node` sequence from a sequence of `Dynamic_Mark_T`s.

    dynamic_sequence [PP,MP,MP,PP] == [(Just PP,Just Crescendo)
                                      ,(Just MP,Just End_Hairpin)
                                      ,(Nothing,Just Diminuendo)
                                      ,(Just PP,Just End_Hairpin)]

delete_redundant_marks :: [Maybe Dynamic_Mark_T] -> [Maybe Dynamic_Mark_T] Source #

Delete redundant (unaltered) dynamic marks.

    let s = [Just P,Nothing,Just P,Just P,Just F]
    in delete_redundant_marks s == [Just P,Nothing,Nothing,Nothing,Just F]

dynamic_sequence_sets :: [Maybe Dynamic_Mark_T] -> [Maybe Dynamic_Node] Source #

Variant of `dynamic_sequence` for sequences of `Dynamic_Mark_T` 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)]
    in dynamic_sequence_sets [Just P,Just F,Nothing,Just P] == r

    let s = [Just P,Nothing,Just P]
    in dynamic_sequence_sets s = [Just (Just P,Nothing),Nothing,Nothing]

apply_dynamic_node :: (a -> Dynamic_Mark_T -> a) -> (a -> Hairpin_T -> a) -> Dynamic_Node -> a -> a Source #

Apply `Hairpin_T` and `Dynamic_Mark_T` functions in that order as required by `Dynamic_Node`.

    let f _ x = show x
    in apply_dynamic_node f f (Nothing,Just Crescendo) undefined

# ASCII

dynamic_mark_ascii :: Dynamic_Mark_T -> String Source #

ASCII pretty printer for `Dynamic_Mark_T`.

hairpin_ascii :: Hairpin_T -> String Source #

ASCII pretty printer for `Hairpin_T`.

dynamic_node_ascii :: Dynamic_Node -> String Source #

ASCII pretty printer for `Dynamic_Node`.

dynamic_sequence_ascii :: [Dynamic_Node] -> String Source #

ASCII pretty printer for `Dynamic_Node` sequence.