summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2014-01-17 14:13:44 -0500
committerAndrew Cady <d@jerkface.net>2014-01-17 14:13:44 -0500
commite804a2b7c210560fd6c62d689fd21367792e1080 (patch)
treeebd0e425fd1b34e06b7bd941ca2eb49626b6f89f
parent2a5b879b672b099ce4bb82c3536f5bd8089b9a3b (diff)
get ready to recognize midi channels
-rw-r--r--AlsaSeq.hs4
-rw-r--r--axis.hs15
2 files changed, 14 insertions, 5 deletions
diff --git a/AlsaSeq.hs b/AlsaSeq.hs
index d6e3816..a3905c8 100644
--- a/AlsaSeq.hs
+++ b/AlsaSeq.hs
@@ -1,5 +1,5 @@
1{-# LANGUAGE NondecreasingIndentation #-} 1{-# LANGUAGE NondecreasingIndentation #-}
2module AlsaSeq (withAlsaInit, parseAlsaEvents, forwardNoteEvent, cmdlineAlsaConnect, printChordLn, showChord, pitchList, showPitch) where 2module AlsaSeq (withAlsaInit, parseAlsaEvents, forwardNoteEvent, cmdlineAlsaConnect, printChordLn, showChord, pitchList, showPitch, unPitch) where
3import qualified Sound.ALSA.Exception as AlsaExc 3import qualified Sound.ALSA.Exception as AlsaExc
4import qualified Sound.ALSA.Sequencer.Address as Addr 4import qualified Sound.ALSA.Sequencer.Address as Addr
5import qualified Sound.ALSA.Sequencer as SndSeq 5import qualified Sound.ALSA.Sequencer as SndSeq
@@ -26,6 +26,8 @@ import Haskore.Basic.Pitch
26import Foreign.C.Error (Errno(Errno)) 26import Foreign.C.Error (Errno(Errno))
27import Control.Exception.Base (try) 27import Control.Exception.Base (try)
28 28
29unPitch = Event.unPitch
30
29printChordLn set = printWords $ pitchWords set 31printChordLn set = printWords $ pitchWords set
30 32
31joinWords [] = "" 33joinWords [] = ""
diff --git a/axis.hs b/axis.hs
index f7ec772..c14c0a7 100644
--- a/axis.hs
+++ b/axis.hs
@@ -68,6 +68,14 @@ drawKeys pitches videoSurface font axis_key_locations axis_key_size = do
68reallyEraseKeys = eraseKeys_ True 68reallyEraseKeys = eraseKeys_ True
69eraseKeys = eraseKeys_ False 69eraseKeys = eraseKeys_ False
70 70
71smartDrawKeys 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
71eraseKeys_ really pitches videoSurface font axis_key_locations axis_key_size = do 79eraseKeys_ 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