tidal 0.4.7 → 0.4.8
raw patch · 5 files changed
+75/−17 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Sound.Tidal.Strategies: chop :: Int -> OscPattern -> OscPattern
+ Sound.Tidal.Stream: ticksPerCycle :: Num a => a
Files
- Sound/Tidal/Strategies.hs +15/−0
- Sound/Tidal/Stream.hs +11/−11
- Sound/Tidal/Time.hs +1/−1
- doc/tidal.md +47/−4
- tidal.cabal +1/−1
Sound/Tidal/Strategies.hs view
@@ -4,12 +4,15 @@ import Data.Ratio import Control.Applicative+import qualified Data.Map as Map import Sound.Tidal.Dirt import Sound.Tidal.Pattern import Sound.Tidal.Stream import Sound.Tidal.Time import Sound.Tidal.Utils+import qualified Sound.OSC.FD as OSC.FD+import Sound.OSC.Datum stutter n t p = stack $ map (\i -> (t * (fromIntegral i)) ~> p) [0 .. (n-1)] @@ -115,3 +118,15 @@ scale :: (Functor f, Num b) => b -> b -> f b -> f b scale from to p = ((+ from) . (* (to-from))) <$> p+++chop :: Int -> OscPattern -> OscPattern+chop n p = Pattern $ \a -> concatMap f $ arcCycles a+ where f a = concatMap chopEvent (arc p a)+ chopEvent (a,a',v) = map (newEvent v) $ filter ((isIn a') . fst) (chopArc a n)+ chopArc :: Arc -> Int -> [Arc]+ chopArc (s, e) n = map (\i -> ((s + d*(fromIntegral i)), s + d*(fromIntegral $ i+1))) [0 .. n-1]+ where d = e - s+ newEvent :: OscMap -> Arc -> Event OscMap+ newEvent v a = (a,a,Map.insert (param dirt "begin") (Just $ OSC.FD.float 0) v)+
Sound/Tidal/Stream.hs view
@@ -41,6 +41,8 @@ latency = 0.04 +ticksPerCycle = 8+ defaultDatum :: Param -> Maybe Datum defaultDatum (S _ (Just x)) = Just $ string x defaultDatum (I _ (Just x)) = Just $ int32 x@@ -70,11 +72,11 @@ isSubset xs ys = all (\x -> elem x ys) xs toMessage :: UDP -> OscShape -> Tempo -> Int -> (Double, OscMap) -> Maybe (IO ())-toMessage s shape change cycle (o, m) =+toMessage s shape change tick (o, m) = do m' <- applyShape' shape m- let cycleD = (fromIntegral cycle) :: Double+ let cycleD = ((fromIntegral tick) / (fromIntegral ticksPerCycle)) :: Double logicalNow = (logicalTime change cycleD)- logicalPeriod = (logicalTime change (cycleD + 1)) - logicalNow+ logicalPeriod = 1 / fromIntegral ticksPerCycle logicalOnset = logicalNow + (logicalPeriod * o) + latency sec = floor logicalOnset usec = floor $ 1000000 * (logicalOnset - (fromIntegral sec))@@ -97,11 +99,9 @@ start :: String -> Int -> OscShape -> IO (MVar (OscPattern)) start address port shape = do patternM <- newMVar silence- --putStrLn $ "connecting " ++ (show address) ++ ":" ++ (show port) s <- openUDP address port- --putStrLn $ "connected " let ot = (onTick s shape patternM) :: Tempo -> Int -> IO ()- forkIO $ clocked $ ot+ forkIO $ clockedTick ticksPerCycle ot return patternM stream :: String -> Int -> OscShape -> IO (OscPattern -> IO ())@@ -118,13 +118,13 @@ return f' onTick :: UDP -> OscShape -> MVar (OscPattern) -> Tempo -> Int -> IO ()-onTick s shape patternM change cycles+onTick s shape patternM change ticks = do p <- readMVar patternM- let cycles' = (fromIntegral cycles) :: Integer- a = cycles' % 1- b = (cycles' + 1) % 1+ let ticks' = (fromIntegral ticks) :: Integer+ a = ticks' % ticksPerCycle+ b = (ticks' + 1) % ticksPerCycle messages = mapMaybe - (toMessage s shape change cycles) + (toMessage s shape change ticks) (seqToRelOnsets (a, b) p) E.catch (sequence_ messages) (\msg -> putStrLn $ "oops " ++ show (msg :: E.SomeException)) return ()
Sound/Tidal/Time.hs view
@@ -15,7 +15,7 @@ -- | An Event is a value that occurs during the period given by the -- first @Arc@. The second one indicates the event's "domain of -- influence". These will often be the same, but many temporal--- transformations, such as rotation and scaling time, may resuqlt in+-- transformations, such as rotation and scaling time, may result in -- arcs being split or truncated. In such cases, the first arc is -- preserved, but the second arc reflects the portion of the event -- which is relevant.
doc/tidal.md view
@@ -25,10 +25,7 @@ Feel free to ask questions and share problems and success stories on the mailing list. -Tidal is currently only usable within the emacs editor, as installed-via the above instructions. Emacs is a long-lived and rather complex-beast. If you're new to emacs, you can bring up a tutorial by pressing-`ctrl-h`, and then `t`.+The above instructions, and the rest of this document, assumes you're using the emacs editor. Emacs is a long-lived and rather complex beast. If you're new to emacs, you can bring up a tutorial by pressing `ctrl-h`, and then `t`. If you're looking for a VIM plugin, check <a href="http://lurk.org/groups/tidal/messages/topic/5F3bHtJPs6NRmm0b2VyQ8Z/">this forum thread</a>. # Sequences @@ -130,6 +127,14 @@ d1 $ sound "{bd [ht sn, lt mt ht] lt, sn cp}" ~~~~ +By default, the number of steps in the first part (in this case, 3) is taken as the number of events per cycle used for the other parts. To specify a different number of steps per cycle, you can use `%`, like this:++~~~~ {.haskell}+d1 $ sound "{bd [ht sn, lt mt ht] lt, sn cp}%5"+~~~~++In the above example, five events will be played from each part, in rotation, every cycle.+ You can make parts of patterns repeat by using `*`, for example the following expressions produce the same pattern: @@ -471,6 +476,31 @@ d1 $ interlace (sound "bd sn kurt") (every 3 rev $ sound "bd sn:2") ~~~~ +## iter++~~~~ {.haskell}+iter :: Int -> Pattern a -> Pattern a+~~~~++Divides a pattern into a given number of subdivisions, plays the subdivisions+in order, but increments the starting subdivision each cycle. The pattern+wraps to the first subdivision after the last subdivision is played.++Example:++~~~~ {.haskell}+d1 $ iter 4 $ sound "bd hh sn cp"+~~~~++This will produce the following over four cycles:++~~~~ {.haskell}+bd hh sn cp+hh sn cp bd+sn cp bd hh+cp bd hh sn+~~~~+ ## rev ~~~~ {.haskell}@@ -682,6 +712,19 @@ ~~~~ {.haskell} d1 $ stut 4 0.5 (-0.2) $ sound "bd sn"+~~~~++## trunc++~~~~ {.haskell}+trunc :: Time -> Pattern a -> Pattern a+~~~~++Truncates a pattern so that only a fraction of the pattern is played. +The following example plays only the first three quarters of the pattern:++~~~~ {.haskell}+d1 $ trunc 0.75 $ sound "bd sn*2 cp hh*4 arpy bd*2 cp bd*2" ~~~~ ## wedge
tidal.cabal view
@@ -1,5 +1,5 @@ name: tidal-version: 0.4.7+version: 0.4.8 synopsis: Pattern language for improvised music -- description: homepage: http://yaxu.org/tidal/