]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - Reactogon/MIDI.hs
Reactogon output unabled correctly.
[tmp/julm/arpeggigon.git] / Reactogon / MIDI.hs
1 module MIDI ( SampleRate
2 , Pitch
3 , toPitch
4 , fromPitch
5 , fromVelocity
6 , toVelocity
7 , Velocity
8 , Voice ( fromVoice
9 , toVoice
10 )
11 , Note(..)
12 , ControllerIdx
13 , ControllerValue
14 , Control
15 ) where
16
17 import Sound.MIDI.Message.Channel.Voice ( fromPitch
18 , toPitch
19 , fromVelocity
20 , toVelocity
21 )
22 import qualified Sound.MIDI.Message.Channel.Voice as Voice
23
24 type SampleRate = Int
25
26 type Pitch = Voice.Pitch
27 type Velocity = Voice.Velocity
28
29 class Voice a where
30 fromVoice :: Voice.T -> Maybe a
31 toVoice :: a -> Voice.T
32
33 data Note = NoteOn Pitch Velocity
34 | NoteOff Pitch Velocity
35 deriving(Show)
36
37 instance Voice Note where
38 fromVoice (Voice.NoteOn p v) = Just $ NoteOn p v
39 fromVoice (Voice.NoteOff p v) = Just $ NoteOff p v
40 fromVoice _ = Nothing
41 toVoice (NoteOn p v) = Voice.NoteOn p v
42 toVoice (NoteOff p v) = Voice.NoteOff p v
43
44 type ControllerIdx = Voice.Controller
45 type ControllerValue = Int
46
47 data Control = Control ControllerIdx ControllerValue
48
49 instance Voice Control where
50 fromVoice (Voice.Control i v) = Just $ Control i v
51 fromVoice _ = Nothing
52 toVoice (Control i v) = Voice.Control i v