summaryrefslogtreecommitdiff
path: root/midi-dump.hs
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-13 13:34:35 -0500
committerAndrew Cady <d@jerkface.net>2015-12-13 13:34:35 -0500
commitd2f4cd39447783d6b983e81b5fb65cfdd3ff2ea2 (patch)
treeff74a77f094df7972bc79acc76fb74ae2eee7a89 /midi-dump.hs
parent880648742a618714a9fb32657babe1380b71f24f (diff)
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.
Diffstat (limited to 'midi-dump.hs')
-rw-r--r--midi-dump.hs8
1 files 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)
58data Triad = 58data Triad =
59 Triad 59 Triad
60 { _triadType :: TriadType 60 { _triadType :: TriadType
61 , triadPitch :: Event.Pitch 61 , _triadPitch :: Event.Pitch
62 , _triadVelocity :: Event.Velocity 62 , _triadVelocity :: Event.Velocity
63 } 63 }
64 deriving (Show, Eq, Ord) 64 deriving (Show, Eq, Ord)
@@ -442,12 +442,12 @@ processMidi = do
442 when (Map.null newKeys) $ 442 when (Map.null newKeys) $
443 modify $ \s -> s { _triadRecording = Recording pitch ttype, _triadMap = Map.delete (pc, ttype) (_triadMap s) } 443 modify $ \s -> s { _triadRecording = Recording pitch ttype, _triadMap = Map.delete (pc, ttype) (_triadMap s) }
444 Recording pitch ttype -> do 444 Recording pitch ttype -> do
445 triadMap <- gets _triadMap
445 let f :: Map (Event.Channel, Event.Pitch) Event.Velocity -> Set ScaleDegree 446 let f :: Map (Event.Channel, Event.Pitch) Event.Velocity -> Set ScaleDegree
446 f = Set.fromList . map (subtract (fromIntegral $ Event.unPitch pitch) . fromIntegral . Event.unPitch . snd) . Map.keys 447 f = Set.fromList . map (subtract (fromIntegral $ Event.unPitch pitch) . fromIntegral . Event.unPitch . snd) . Map.keys
447 pc = toPitchClass pitch 448 pc = toPitchClass pitch
448 let detected = triadPitch . snd <$> detectTriads newKeys 449 done = Map.null newKeys && not (Map.null triadMap)
449 detected :: [Event.Pitch] 450 if done then do
450 if pitch `elem` detected then do
451 modify $ \s -> s { _triadRecording = TriadNotRecording } 451 modify $ \s -> s { _triadRecording = TriadNotRecording }
452 liftIO $ putStrLn "Recorded triad" 452 liftIO $ putStrLn "Recorded triad"
453 else 453 else