{- Rohan Drape: Haskell-Cafe, 2006-11-08 -} import Sound.OpenSoundControl(OSC(Bundle)) import Sound.OpenSoundControl.Time(utc) import Rhs.Schedule(at, pauseThread) import Sound.OpenSoundControl.Transport.Monad(send) import Sound.SC3 import qualified Sound.SC3.Server.Play as Play import Control.Concurrent (forkIO) import Control.Monad.Trans (liftIO) ping f a = out 0 (sinOsc AR f 0 * e) where c = EnvNum (-4.0) e = envGen KR 1 a 0 1 RemoveSynth (envPerc 0.1 0.6 1 [c,c]) latency = 0.05 bundle t m = Bundle (t + latency) m scPutStrLn = liftIO . putStrLn pinger = do now <- utc at (fromIntegral (ceiling now)) f where f t = withSC3 $ do send (bundle t [s_new "ping" 42 AddToTail 1]) -- send (n_run (-1) True) send (bundle (t+0.1) [n_run 42 False, n_free 42]) -- send (bundle (t+0.1) []) -- send (n_free 101) -- send (bundle (t+0.1) [s_new "pong" 5 AddToTail 1]) scPutStrLn "Sending ping" return 1.0 main = withSC3 $ do scPutStrLn "Sending Ping Instrument" Play.sync (Play.d_recv' "ping" (ping 880 0.1)) -- sync (d_recv' "pong" (ping 660 0.1)) scPutStrLn "Resetting scsynth" reset scPutStrLn "Starting schedule thread" liftIO $ forkIO pinger scPutStrLn "Delaying main thread" liftIO $ pauseThread 30 scPutStrLn "End of delay, exiting"