]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - Reactogon/Note.hs
First version of the output port seems operational.
[tmp/julm/arpeggigon.git] / Reactogon / Note.hs
1 module Note where
2
3 import MIDI
4
5 isOn :: Note -> Bool
6 isOn (NoteOn _ _) = True
7 isOn _ = False
8
9 isOff :: Note -> Bool
10 isOff = not . isOn
11
12 changePitch :: (Pitch -> Pitch) -> Note -> Note
13 changePitch f (NoteOn p v) = NoteOn (f p) v
14 changePitch f (NoteOff p v) = NoteOff (f p) v
15
16 changeVelocity :: (Velocity -> Velocity) -> Note -> Note
17 changeVelocity f (NoteOn p v) = NoteOn p (f v)
18 changeVelocity f (NoteOff p v) = NoteOff p (f v)
19
20 switchOnOff :: Note -> Note
21 switchOnOff (NoteOn p v) = NoteOff p v
22 switchOnOff (NoteOff p v) = NoteOn p v
23
24 perfectFifth :: Note -> Note
25 perfectFifth = changePitch (toPitch . (+7) . fromPitch)
26
27 majorThird :: Note -> Note
28 majorThird = changePitch (toPitch . (+4) . fromPitch)
29
30 minorThird :: Note -> Note
31 minorThird = changePitch (toPitch . (+3) . fromPitch)