From 01df45553934d9d61f7810d49beec9419d2f1e4e Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 3 Dec 2015 00:56:40 -0500 Subject: filter out channel 9 This is a very old change, I'm committing now to start working on this again. I don't actually understand how the code could have worked without this patch. The variable "actions" is created here, but used in code that's already committed. Oh well. --- axis.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/axis.hs b/axis.hs index 95f3930..90770f0 100644 --- a/axis.hs +++ b/axis.hs @@ -20,6 +20,7 @@ import GHC.Word import Data.Bits import qualified Sound.ALSA.Sequencer.Event as Event import qualified Graphics.UI.SDL.Utilities as SDL.Util +import qualified Data.Map as Map netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String netwireIsCool = @@ -162,7 +163,7 @@ allKeysOff colsRepeat reallyErase videoSurface font axis_key_locations axis_key_ -- would choose based on the "structure" of the actual music. -- Question: how to deal with simultaneous keypresses? --- First order of business: get rid of all calls to smartDrawKeys but one +-- Next order of business: --drawKey :: (Integral a1, Integral a2, Integral a) => Int -> SDL.Surface -> SDL.TTF.Font -> [(a1, a2)] -> a -> SDL.Color -> t -> Maybe String -> [Int] -> IO () drawKey idx videoSurface font axis_key_locations axis_key_size fillColor text channels = do @@ -268,6 +269,16 @@ main = -- textBand videoSurface videoClipRect (SDL.Rect 0 0 0 70) font x' -- return () + let + chanfilter = Set.filter (\ (c, _) -> c /= (Event.Channel 9)) + beforeKeys = chanfilter midiKeysDown + nowKeys = chanfilter midiKeysDown' + + changedPitches = Set.map (\ (_, p) -> p) $ Set.union (Set.difference nowKeys beforeKeys) (Set.difference beforeKeys nowKeys) + playingNowChans n = Set.map (\ (c, _) -> c) $ Set.filter (\ (_, p) -> p == n) nowKeys + actions = Set.toList $ Set.map (\p -> (p, Set.toList $ playingNowChans p)) changedPitches + chanPitches = Map.fromListWith (++) $ map (\ (c, p) -> (c, [p])) $ Set.toList nowKeys + Control.Monad.when (midiKeysDown' /= midiKeysDown) $ do -- let chord = showChord midiKeysDown' -- let chord = show $ pitchList midiKeysDown' -- cgit v1.2.3