import AlsaSeq import Control.Concurrent (threadDelay) import qualified Sound.ALSA.Exception as AlsaExc import qualified Data.Set as Set main = (do withAlsaInit $ \h public private q publicAddr privateAddr -> do cmdlineAlsaConnect h public let forwardNOW = forwardNoteEvent h q publicAddr go keysDown = do keysDown' <- parseAlsaEvents h keysDown forwardNOW if (keysDown == keysDown') then threadDelay 15000 -- 15ms. Seems like a lot, but it sounds OK. Cuts CPU down to 2%. else do printChordLn keysDown' go keysDown' putStrLn "Rock on!" go Set.empty) `AlsaExc.catch` \e -> putStrLn $ "alsa_exception: " ++ AlsaExc.show e