Permalink
Browse files

fiddles

  • Loading branch information...
1 parent db76aaf commit bd0b2a837ac685c0815f203a3d4c422e28d8d0b1 alex committed Dec 11, 2012
Showing with 43 additions and 7 deletions.
  1. +5 −2 AdeSync.hs
  2. +3 −2 Dirt.hs
  3. +3 −0 Pattern.hs
  4. +26 −0 Strategies.hs
  5. +6 −3 Stream.hs
View
@@ -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
@@ -50,11 +50,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
@@ -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
@@ -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
@@ -3,6 +3,7 @@
module Stream where
import Data.Maybe
+import Sound.OSC.FD
import Sound.OpenSoundControl
import Control.Applicative
import Network.Netclock.Client
@@ -66,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
@@ -79,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
@@ -117,7 +118,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)
@@ -143,9 +144,11 @@ merge' x y = Map.union <$> x <~> y
infixr 1 ~~
(~~) = merge
+infixr 1 |+|
(|+|) :: OscSequence -> OscSequence -> OscSequence
(|+|) = (~~)
+infixr 1 |+~
(|+~) :: OscSequence -> OscSignal -> OscSequence
(|+~) = (~~)

0 comments on commit bd0b2a8

Please sign in to comment.