diff options
author | Andrew Cady <d@jerkface.net> | 2014-01-17 14:13:44 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2014-01-17 14:13:44 -0500 |
commit | e804a2b7c210560fd6c62d689fd21367792e1080 (patch) | |
tree | ebd0e425fd1b34e06b7bd941ca2eb49626b6f89f | |
parent | 2a5b879b672b099ce4bb82c3536f5bd8089b9a3b (diff) |
get ready to recognize midi channels
-rw-r--r-- | AlsaSeq.hs | 4 | ||||
-rw-r--r-- | axis.hs | 15 |
2 files changed, 14 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | {-# LANGUAGE NondecreasingIndentation #-} | 1 | {-# LANGUAGE NondecreasingIndentation #-} |
2 | module AlsaSeq (withAlsaInit, parseAlsaEvents, forwardNoteEvent, cmdlineAlsaConnect, printChordLn, showChord, pitchList, showPitch) where | 2 | module AlsaSeq (withAlsaInit, parseAlsaEvents, forwardNoteEvent, cmdlineAlsaConnect, printChordLn, showChord, pitchList, showPitch, unPitch) where |
3 | import qualified Sound.ALSA.Exception as AlsaExc | 3 | import qualified Sound.ALSA.Exception as AlsaExc |
4 | import qualified Sound.ALSA.Sequencer.Address as Addr | 4 | import qualified Sound.ALSA.Sequencer.Address as Addr |
5 | import qualified Sound.ALSA.Sequencer as SndSeq | 5 | import qualified Sound.ALSA.Sequencer as SndSeq |
@@ -26,6 +26,8 @@ import Haskore.Basic.Pitch | |||
26 | import Foreign.C.Error (Errno(Errno)) | 26 | import Foreign.C.Error (Errno(Errno)) |
27 | import Control.Exception.Base (try) | 27 | import Control.Exception.Base (try) |
28 | 28 | ||
29 | unPitch = Event.unPitch | ||
30 | |||
29 | printChordLn set = printWords $ pitchWords set | 31 | printChordLn set = printWords $ pitchWords set |
30 | 32 | ||
31 | joinWords [] = "" | 33 | joinWords [] = "" |
@@ -68,6 +68,14 @@ drawKeys pitches videoSurface font axis_key_locations axis_key_size = do | |||
68 | reallyEraseKeys = eraseKeys_ True | 68 | reallyEraseKeys = eraseKeys_ True |
69 | eraseKeys = eraseKeys_ False | 69 | eraseKeys = eraseKeys_ False |
70 | 70 | ||
71 | smartDrawKeys really drawSet eraseSet videoSurface font axis_key_locations axis_key_size = do | ||
72 | |||
73 | let drawList = map (\ (_, n) -> unPitch n) $ Set.toList drawSet | ||
74 | let eraseList = map (\ (_, n) -> unPitch n) $ Set.toList eraseSet | ||
75 | |||
76 | drawKeys drawList videoSurface font axis_key_locations axis_key_size | ||
77 | eraseKeys_ really eraseList videoSurface font axis_key_locations axis_key_size | ||
78 | |||
71 | eraseKeys_ really pitches videoSurface font axis_key_locations axis_key_size = do | 79 | eraseKeys_ really pitches videoSurface font axis_key_locations axis_key_size = do |
72 | 80 | ||
73 | forM_ pitches $ \pitch -> do | 81 | forM_ pitches $ \pitch -> do |
@@ -133,11 +141,10 @@ main = | |||
133 | -- let chord = show $ map (\i->elemIndices i pitchIndex) $ pitchList midiKeysDown' | 141 | -- let chord = show $ map (\i->elemIndices i pitchIndex) $ pitchList midiKeysDown' |
134 | -- textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord | 142 | -- textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord |
135 | let ignoreThese = Set.intersection midiKeysDown' midiKeysDown | 143 | let ignoreThese = Set.intersection midiKeysDown' midiKeysDown |
136 | let drawThese = pitchList $ Set.difference midiKeysDown' ignoreThese | 144 | let drawThese = Set.difference midiKeysDown' ignoreThese |
137 | let eraseThese = pitchList $ Set.difference midiKeysDown ignoreThese | 145 | let eraseThese = Set.difference midiKeysDown ignoreThese |
138 | 146 | ||
139 | drawKeys drawThese videoSurface font axis_key_locations axis_key_size | 147 | smartDrawKeys False drawThese eraseThese videoSurface font axis_key_locations axis_key_size |
140 | eraseKeys eraseThese videoSurface font axis_key_locations axis_key_size | ||
141 | return () | 148 | return () |
142 | 149 | ||
143 | Control.Monad.when (keysDown' /= keysDown && keyDown SDL.SDLK_BACKSPACE keysDown') allKeysOFF | 150 | Control.Monad.when (keysDown' /= keysDown && keyDown SDL.SDLK_BACKSPACE keysDown') allKeysOFF |