summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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