Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains some data structures for describing note sequences and time signatures, and a QuasiQuoter for note sequences.
Synopsis
- data Accidental
- data Natural_note_name
- data Note = Note Int Note_name
- data Note_name
- data Note_name' = Note_name' Natural_note_name Accidental
- type Rat = Ratio Int
- data Simultaneous = Simultaneous [Note] Rat
- data Time = Time [Int] Int
- data Time_and_position = Time_and_position Time Rat
- construct_note_name :: Note_name' -> Note_name
- deconstruct_note_name :: Note_name -> Note_name'
- ly :: QuasiQuoter
- measure_length :: Time -> Rat
- sequential_length :: [Simultaneous] -> Rat
- simultaneous_length :: Simultaneous -> Rat
- subdivision :: Time -> Time
Documentation
data Accidental Source #
Accidentals.
Instances
Eq Accidental Source # | |
Defined in Composition.Notes (==) :: Accidental -> Accidental -> Bool # (/=) :: Accidental -> Accidental -> Bool # | |
Show Accidental Source # | |
Defined in Composition.Notes showsPrec :: Int -> Accidental -> ShowS # show :: Accidental -> String # showList :: [Accidental] -> ShowS # |
data Natural_note_name Source #
Natural note names for algorithmic convenience.
Instances
Enum Natural_note_name Source # | |
Defined in Composition.Notes succ :: Natural_note_name -> Natural_note_name # pred :: Natural_note_name -> Natural_note_name # toEnum :: Int -> Natural_note_name # fromEnum :: Natural_note_name -> Int # enumFrom :: Natural_note_name -> [Natural_note_name] # enumFromThen :: Natural_note_name -> Natural_note_name -> [Natural_note_name] # enumFromTo :: Natural_note_name -> Natural_note_name -> [Natural_note_name] # enumFromThenTo :: Natural_note_name -> Natural_note_name -> Natural_note_name -> [Natural_note_name] # | |
Eq Natural_note_name Source # | |
Defined in Composition.Notes (==) :: Natural_note_name -> Natural_note_name -> Bool # (/=) :: Natural_note_name -> Natural_note_name -> Bool # | |
Show Natural_note_name Source # | |
Defined in Composition.Notes showsPrec :: Int -> Natural_note_name -> ShowS # show :: Natural_note_name -> String # showList :: [Natural_note_name] -> ShowS # |
Note. The first argument is the octave.
Note names. Double accidentals are not supported.
C_flat | |
C | |
C_sharp | |
D_flat | |
D | |
D_sharp | |
E_flat | |
E | |
F_flat | |
E_sharp | |
F | |
F_sharp | |
G_flat | |
G | |
G_sharp | |
A_flat | |
A | |
A_sharp | |
B_flat | |
B | |
B_sharp |
Instances
Enum Note_name Source # | |
Defined in Composition.Notes succ :: Note_name -> Note_name # pred :: Note_name -> Note_name # fromEnum :: Note_name -> Int # enumFrom :: Note_name -> [Note_name] # enumFromThen :: Note_name -> Note_name -> [Note_name] # enumFromTo :: Note_name -> Note_name -> [Note_name] # enumFromThenTo :: Note_name -> Note_name -> Note_name -> [Note_name] # | |
Eq Note_name Source # | |
Ord Note_name Source # | |
Defined in Composition.Notes | |
Show Note_name Source # | |
Lift Note_name Source # | |
data Note_name' Source #
An alternative representation of note names that is more convenient for algorithms.
Instances
Eq Note_name' Source # | |
Defined in Composition.Notes (==) :: Note_name' -> Note_name' -> Bool # (/=) :: Note_name' -> Note_name' -> Bool # | |
Show Note_name' Source # | |
Defined in Composition.Notes showsPrec :: Int -> Note_name' -> ShowS # show :: Note_name' -> String # showList :: [Note_name'] -> ShowS # |
Rationals with limited numerators and denominators for representing note lengths.
data Simultaneous Source #
A collection of notes of same length that sound simultaneously. Non-positive length will result in runtime errors when attempting to generate Lilypond and MIDI files.
Instances
Show Simultaneous Source # | |
Defined in Composition.Notes showsPrec :: Int -> Simultaneous -> ShowS # show :: Simultaneous -> String # showList :: [Simultaneous] -> ShowS # | |
Lift Simultaneous Source # | |
Defined in Composition.Notes lift :: Simultaneous -> Q Exp # |
Time signature. The first argument describes the subdivisions of the bar. For example, 2 beats per bar is encoded as [2], 3 as [3], 4 as [2, 2], 6 as [2, 3], 9 as [3, 3]. The second argument is the inverse of the length of the beat. Note that non-positive numbers in either numerator or denominator will result in errors, and Lilypond does not accept denominators that are not a power of two.
data Time_and_position Source #
Time signature and the starting position of the first bar. For example, if the piece starts with a full bar, the initial position is 0. If the piece is in 34 and starts with a 14-note bar, the initial position is 1/2.
Instances
Show Time_and_position Source # | |
Defined in Composition.Notes showsPrec :: Int -> Time_and_position -> ShowS # show :: Time_and_position -> String # showList :: [Time_and_position] -> ShowS # |
construct_note_name :: Note_name' -> Note_name Source #
Construct the note name from a natural note name and an accidental.
deconstruct_note_name :: Note_name -> Note_name' Source #
Deconstruct a note name into the natural note name and the accidental.
ly :: QuasiQuoter Source #
A QuasiQuoter for compile-time parsing of note sequences. The syntax is loosely based on Lilypond. Some example of use:
- An empty note sequence:
[ly||]
. - A single note:
[ly|<C0>1|]
. - Two consecutive notes:
[ly|<C0>1 <C0>1|]
. - A rest, a single note and two simultaneous notes:
[ly|<>1 <C0>1 <C0 D0>1|]
. - All natural notes from C to B:
[ly|<C0 D0 E0 F0 G0 A0 B0>1|]
. - Accidentals:
[ly|<Cb0 C0 C#0>1|]
. - Different octaves:
[ly|<C-1 C0 C1>1|]
. - Rests of length 1/3, 1/2, 2/3, 1, 3/2, 2 and 3:
[ly|<>3 <>2 <>3~3 <>1 <>1. <>1~1 <>1~1~1|]
.
measure_length :: Time -> Rat Source #
The length of one measure.
sequential_length :: [Simultaneous] -> Rat Source #
The length of a note sequence.
simultaneous_length :: Simultaneous -> Rat Source #
The length of a collection of notes.
subdivision :: Time -> Time Source #
Discards the topmost division of the bar. For example, 1/1 is transformed into 1/2, 2/2 into 1/2, 3/4 into 1/4, 4/4 into 2/4, 6/8 into 3/8, 9/16 into 3/16.