arpeggiated :: SF (ControllerValue, Event Note) (Event Note)
arpeggiated = proc (c,n) -> do
non <- uncurry gate ^<< identity &&& arr (event False isOn) -< n
- non' <- fmap perfectFifth ^<< delayEvent t -< non
- non'' <- fmap majorThird ^<< delayEvent t -< non'
- (nof',nof'') <- makeOff *** makeOff -< (non',non'')
+ non' <- fmap majorThird ^<< delayEvent t -< non
+ non'' <- fmap perfectFifth ^<< delayEvent t -< non'
+ (nof',
+ nof'') <- makeOff *** makeOff -< (non',non'')
-- It's assumed that the NoteOff event corresponding to n will be
-- emitted.
returnA -< mergeEvents [n, non, non', nof', non'', nof'']
where onoffGap = 0.9*t
- t = 10
+ t = 100000
makeOff = delayEvent onoffGap <<^ fmap switchOnOff
--- /dev/null
+import FRP.Yampa
+
+import MIDI
+import Note
+import Arpeggiated
+
+import System.IO
+import Data.Maybe
+
+ifReadyDo :: Handle -> IO a -> IO (Maybe a)
+ifReadyDo hnd x = hReady hnd >>= f
+ where f True = x >>= return . Just
+ f _ = return Nothing
+
+main :: IO ()
+main = reactimate initInput sensing output arpeggiated
+
+initInput = return (110, NoEvent)
+
+sensing _ = do c <- stdin `ifReadyDo` getChar
+ let c' = if isJust c
+ then Event (NoteOn (toPitch 60) (toVelocity 100))
+ else NoEvent
+ return (1, Just (110,c'))
+
+output _ x = print x >> return False