supercollider-ht 0.1 → 0.1.0.1
raw patch · 2 files changed
+60/−21 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- src/Sound/SC3/Example/Timing.hs +54/−18
- supercollider-ht.cabal +6/−3
src/Sound/SC3/Example/Timing.hs view
@@ -2,43 +2,79 @@ Rohan Drape: Haskell-Cafe, 2006-11-08 -} +import qualified Sound.OpenSoundControl.Transport.Monad.IO as TIO import Sound.OpenSoundControl(OSC(Bundle))-import Sound.OpenSoundControl.Time(utc)-import Rhs.Schedule(at, pauseThread)-import Sound.OpenSoundControl.Transport.Monad(send)+import Sound.OpenSoundControl.Time+ (Time(UTCr), utcr, pauseThread, pauseThreadUntil, )+import Sound.OpenSoundControl.Transport.Monad(send, )+import Sound.OpenSoundControl.Transport.UDP (UDP) import Sound.SC3-import qualified Sound.SC3.Server.Play as Play+ (UGen, out, s_new, n_run, n_free,+ Rate(AR,KR), sinOsc, envGen, envPerc',+ EnvCurve(EnvNum), DoneAction(RemoveSynth),+ AddAction(AddToTail), )+import qualified Sound.SC3.Server.PlayEasy as Play import Control.Concurrent (forkIO) import Control.Monad.Trans (liftIO) ++-- * from old Rhs.Schedule module+{-+http://slavepianos.org/rd/sw/sw-76+Build-Depends: Rhs >=0.1 && <0.2+-}+type UTC = Double+type Interval = Double+type Action = UTC -> IO (Maybe Interval)++-- | Apply action at indicated time and reschedule after interval.+at :: Double -> Action -> IO ()+at t f = pauseThreadUntil t >> f t >>= resched t f++-- | Rescheduler+resched :: Interval -> Action -> (Maybe Interval) -> IO ()+resched _ _ Nothing = return ()+resched t f (Just i) = at (t+i) f+++-- * custom code++ping :: UGen -> UGen -> UGen 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])+ e = envGen KR 1 a 0 1 RemoveSynth (envPerc' 0.1 0.6 1 [c,c]) +latency :: Double latency = 0.05 -bundle t m = Bundle (t + latency) m+bundle :: Double -> [OSC] -> OSC+bundle t m = Bundle (UTCr $ t + latency) m +scPutStrLn :: String -> TIO.T UDP () 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])+pinger :: IO ()+pinger =+ let f t = Play.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) [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])+-- send (n_free [101])+-- send (bundle (t+0.1) [s_new "pong" 5 AddToTail 1 []]) scPutStrLn "Sending ping"- return 1.0+ return (Just 1.0)+ in do now <- utcr+ at (fromInteger (ceiling now)) f -main = withSC3 $+main :: IO ()+main =+ Play.withSC3 $ do scPutStrLn "Sending Ping Instrument"- Play.sync (Play.d_recv' "ping" (ping 880 0.1))--- sync (d_recv' "pong" (ping 660 0.1))+ Play.sync (Play.d_recv_synthdef "ping" (ping 880 0.1))+-- sync (d_recv_synthdef "pong" (ping 660 0.1)) scPutStrLn "Resetting scsynth"- reset+ Play.reset scPutStrLn "Starting schedule thread" liftIO $ forkIO pinger scPutStrLn "Delaying main thread"
supercollider-ht.cabal view
@@ -1,5 +1,5 @@ Name: supercollider-ht-Version: 0.1+Version: 0.1.0.1 License: GPL License-File: LICENSE Copyright: Henning Thielemann, 2008-2009@@ -27,7 +27,7 @@ Source-Repository this type: darcs location: http://code.haskell.org/~thielema/supercollider/- tag: 0.1+ tag: 0.1.0.1 Flag splitBase@@ -42,7 +42,10 @@ Build-Depends: opensoundcontrol-ht >=0.1 && <0.2 Build-Depends: transformers >=0.0 && <0.2, bytestring >=0.9 && <0.10 If flag(splitBase)- Build-Depends: base >= 2, random >= 1.0 && <2, process >= 1.0 && <1.1+ Build-Depends:+ random >= 1.0 && <2,+ process >= 1.0 && <1.1,+ base >= 2 && <5 Else Build-Depends: base >= 1.0 && < 2