-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drums.lhs
77 lines (75 loc) · 2 KB
/
Drums.lhs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
\begin{verbatim}
> module Drums (module Basics, module Trill, module Drums) where
> import Basics
> import Trill
>
> data DrumSound =
> AcousticBassDrum -- Midi Key 35
> | BassDrum1 -- Midi Key 36
> | SideStick -- ...
> | AcousticSnare
> | HandClap
> | ElectricSnare
> | LowFloorTom
> | ClosedHiHat
> | HighFloorTom
> | PedalHiHat
> | LowTom
> | OpenHiHat
> | LowMidTom
> | HiMidTom
> | CrashCymbal1
> | HighTom
> | RideCymbal1
> | ChineseCymbal
> | RideBell
> | Tambourine
> | SplashCymbal
> | Cowbell
> | CrashCymbal2
> | Vibraslap
> | RideCymbal2
> | HiBongo
> | LowBongo
> | MuteHiConga
> | OpenHiConga
> | LowConga
> | HighTimbale
> | LowTimbale
> | HighAgogo
> | LowAgogo
> | Cabasa
> | Maracas
> | ShortWhistle
> | LongWhistle
> | ShortGuiro
> | LongGuiro
> | Claves
> | HiWoodBlock
> | LowWoodBlock
> | MuteCuica
> | OpenCuica -- ...
> | MuteTriangle -- Midi Key 80
> | OpenTriangle -- Midi Key 81
> deriving (Show,Eq,Ord,Ix,Enum)
>
> drum :: DrumSound -> Dur -> [NoteAttribute] -> Music
> drum ds dur na = Note (pitch (fromEnum ds + 35)) dur na
>
> data DrumElement = N Dur [NoteAttribute] -- note
> | R Dur -- rest
> | Roll Dur Dur [NoteAttribute] -- roll w/duration
> | Rolln Int Dur [NoteAttribute] -- roll w/number of strokes
>
> drumLine :: DrumSound -> [DrumElement] -> Music
> drumLine dsnd l = Instr "Drums" (dlAux dsnd l) where
> dlAux dsnd [] = Rest 0
> dlAux dsnd (N dur na :xs) = drum dsnd dur na
> :+: dlAux dsnd xs
> dlAux dsnd (R dur :xs) = Rest dur
> :+: dlAux dsnd xs
> dlAux dsnd (Roll sDur dur na :xs) = roll sDur (drum dsnd dur na)
> :+: dlAux dsnd xs
> dlAux dsnd (Rolln nTimes dur na :xs) = rolln nTimes (drum dsnd dur na)
> :+: dlAux dsnd xs
\end{verbatim}