blob: aa19defe7a27708b76acb676e03636fccff57514 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE NondecreasingIndentation #-}
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
|