From d2f4cd39447783d6b983e81b5fb65cfdd3ff2ea2 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 13 Dec 2015 13:34:35 -0500 Subject: Alternative input method for triad reprogramming Press M-t, press triad, release. All notes played before next release will be programmed into the triad. Thus it isn't necessary to hold down the entire chord, but you must be holding down at least some note or else the reprogramming is done. --- midi-dump.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/midi-dump.hs b/midi-dump.hs index cca4e5c..0082987 100644 --- a/midi-dump.hs +++ b/midi-dump.hs @@ -58,7 +58,7 @@ data TriadType = Major | Minor deriving (Show, Eq, Ord) data Triad = Triad { _triadType :: TriadType - , triadPitch :: Event.Pitch + , _triadPitch :: Event.Pitch , _triadVelocity :: Event.Velocity } deriving (Show, Eq, Ord) @@ -442,12 +442,12 @@ processMidi = do when (Map.null newKeys) $ modify $ \s -> s { _triadRecording = Recording pitch ttype, _triadMap = Map.delete (pc, ttype) (_triadMap s) } Recording pitch ttype -> do + triadMap <- gets _triadMap let f :: Map (Event.Channel, Event.Pitch) Event.Velocity -> Set ScaleDegree f = Set.fromList . map (subtract (fromIntegral $ Event.unPitch pitch) . fromIntegral . Event.unPitch . snd) . Map.keys pc = toPitchClass pitch - let detected = triadPitch . snd <$> detectTriads newKeys - detected :: [Event.Pitch] - if pitch `elem` detected then do + done = Map.null newKeys && not (Map.null triadMap) + if done then do modify $ \s -> s { _triadRecording = TriadNotRecording } liftIO $ putStrLn "Recorded triad" else -- cgit v1.2.3