Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:yaxu/smooth

  • Loading branch information...
commit 8c942dc2b11bedddf4df3ee92c1820fa8091d630 2 parents b7cca70 + bd0b2a8
alex authored
View
7 AdeSync.hs
@@ -1,18 +1,21 @@
import Sound.OpenSoundControl
import Network.Netclock.Client
+import Control.Concurrent (threadDelay, forkIO)
tpb = 4
address = "127.0.0.1"
-adeip = "192.168.1.3"
+adeip = "10.0.0.3"
adeport = 1777
-main = clocked "adesync" address address tpb ot
+main = do putStrLn "start"
+ clocked "adesync" address address tpb ot
ot :: BpsChange -> Int -> IO ()
ot change tick = do putStrLn "tick"
ade <- openUDP adeip adeport
let m = Message "/PureEvents/Beat" [Int tick]
+ threadDelay $ 1000000 `div` 18
send ade m
close ade
return ()
View
5 Dirt.hs
@@ -51,11 +51,12 @@ accellerate = makeF dirt "accellerate"
sample :: String -> Int -> String
sample name n = name ++ "/" ++ (show n)
-striate :: OscSequence -> Int -> OscSequence
-striate p n = cat $ map (\x -> off (fromIntegral x) p) [0 .. n-1]
+striate :: Int -> OscSequence -> OscSequence
+striate n p = cat $ map (\x -> off (fromIntegral x) p) [0 .. n-1]
where off i p = p ~~ begin (atom (fromIntegral i / fromIntegral n) :: Sequence Double) ~~ end (atom (fromIntegral (i+1) / fromIntegral n) :: Sequence Double)
striateO :: OscSequence -> Int -> Double -> OscSequence
striateO p n o = cat $ map (\x -> off (fromIntegral x) p) [0 .. n-1]
where off i p = p ~~ begin ((atom $ (fromIntegral i / fromIntegral n) + o) :: Sequence Double) ~~ end ((atom $ (fromIntegral (i+1) / fromIntegral n) + o) :: Sequence Double)
+metronome = slow 2 $ sound "[odx, [hh]*8]"
View
3  Pattern.hs
@@ -131,6 +131,9 @@ cat :: (Pattern p) => [p b] -> p b
cat ps = combine $ map (squash l) (zip [0..] ps)
where l = length ps
+slowcat :: (Pattern p) => [p b] -> p b
+slowcat ps = slow (fromIntegral $ length ps) $ cat ps
+
listToPat :: Pattern p => [a] -> p a
listToPat = cat . map atom
View
26 Strategies.hs
@@ -0,0 +1,26 @@
+{-# OPTIONS_GHC -XNoMonomorphismRestriction #-}
+
+module Strategies where
+
+import Pattern
+import Dirt
+import Data.Ratio
+import Control.Applicative
+
+echo n p = combine [p, n ~> p]
+double f p = combine [p, f p]
+
+-- every 4 (smash 4 [1, 2, 3]) $ sound "[odx sn/2 [~ odx] sn/3, [~ hh]*4]"
+
+smash n xs p = cat $ map (\n -> slow n p') xs
+ where p' = striate n p
+
+brak = every 2 (((1%4) <~) . (\x -> cat [x, silence]))
+
+-- samples "jvbass [~ latibro] [jvbass [latibro jvbass]]" ((1%2) <~ slow 6 "[1 6 8 7 3]")
+samples p p' = sample <$> p <*> p'
+
+
+
+
+
View
8 Stream.hs
@@ -67,7 +67,7 @@ isSubset xs ys = all (\x -> elem x ys) xs
tpb = 1
-toMessage :: OscShape -> BpsChange -> Int -> (Double, OscMap) -> Maybe OSC
+toMessage :: OscShape -> BpsChange -> Int -> (Double, OscMap) -> Maybe Bundle
toMessage s change ticks (o, m) =
do m' <- applyShape' s m
let beat = fromIntegral ticks / fromIntegral tpb
@@ -80,7 +80,7 @@ toMessage s change ticks (o, m) =
usec = floor $ 1000000 * (logicalOnset - (fromIntegral sec))
oscdata = catMaybes $ mapMaybe (\x -> Map.lookup x m') (params s)
oscdata' = ((Int sec):(Int usec):oscdata)
- osc | timestamp s = Message (path s) oscdata'
+ osc | timestamp s = Bundle (immediately) [Message (path s) oscdata']
| otherwise = Bundle (UTCr logicalOnset) [Message (path s) oscdata]
return osc
@@ -125,7 +125,7 @@ onTick s shape patternM change ticks
(seqToRelOnsets (a, Just b) p)
--putStrLn $ (show a) ++ ", " ++ (show b)
--putStrLn $ "tick " ++ show ticks ++ " = " ++ show messages
- catch (mapM_ (send s) messages) (\msg -> putStrLn $ "oops " ++ show msg)
+ catch (mapM_ (sendOSC s) messages) (\msg -> putStrLn $ "oops " ++ show msg)
return ()
make :: ParseablePattern p => (a -> Datum) -> OscShape -> String -> p a -> (p OscMap)
@@ -151,9 +151,11 @@ merge' x y = Map.union <$> x <~> y
infixr 1 ~~
(~~) = merge
+infixr 1 |+|
(|+|) :: OscSequence -> OscSequence -> OscSequence
(|+|) = (~~)
+infixr 1 |+~
(|+~) :: OscSequence -> OscSignal -> OscSequence
(|+~) = (~~)
Please sign in to comment.
Something went wrong with that request. Please try again.