packages feed

temporal-media 0.3.1 → 0.3.3

raw patch · 2 files changed

+39/−23 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Temporal.Media: chordMap :: Real t => (a -> Track t b) -> [a] -> Track t b
+ Temporal.Media: chordTMap :: Real t => (a -> Track t b) -> [a] -> Track t b
+ Temporal.Media: chordTemp :: Real t => [a] -> Track t a
+ Temporal.Media: event :: Real t => t -> a -> Track t a
+ Temporal.Media: instance Traversable (TList t)
+ Temporal.Media: instance Traversable (Track t)
+ Temporal.Media: lineMap :: Real t => (a -> Track t b) -> [a] -> Track t b
+ Temporal.Media: lineTemp :: Real t => [a] -> Track t a

Files

src/Temporal/Media.hs view
@@ -1,7 +1,6 @@ {-# Language -        BangPatterns #-}--+        BangPatterns, +        DeriveFunctor, DeriveFoldable, DeriveTraversable #-}  -- | A library for creating lists of constant time events related in time. module Temporal.Media(@@ -20,8 +19,11 @@     -- * Types     Event(..), Track, dur, within, eventEnd,     -- * Composition-    temp, stretch, delay, reflect, (+|), (*|), (=:=), (+:+), (=:/),-    line, chord, chordT, loop, rest, sustain, sustainT,    +    temp, event, stretch, delay, reflect, (+|), (*|), (=:=), (+:+), (=:/),+    line, chord, chordT, loop, rest, sustain, sustainT,+    -- ** Common patterns+    lineTemp, chordTemp, +    lineMap, chordMap, chordTMap,          -- * Filtering     slice, takeT, dropT, filterEvents,     @@ -43,6 +45,7 @@  import Data.Monoid import Data.Foldable(Foldable(foldMap))+import Data.Traversable  import Control.Applicative @@ -66,10 +69,7 @@ -- (as a result of 'mapEvents' function). Total duration is used in sequent  -- composition of tracks.  data Track t a = Track t (TList t a)-    deriving (Show, Eq)--instance Functor (Track t) where-    fmap f (Track d es) = Track d $ fmap f es+    deriving (Show, Eq, Functor, Foldable, Traversable)  instance Real t => Monoid (Track t a) where     mempty = Track 0 mempty@@ -80,6 +80,14 @@ dur :: Track t a -> t dur (Track d _) = d +-- | Creates a single event.+--+-- > event dur a +--+-- Event lasts for some time and contains a value @a@.+event :: Real t => t -> a -> Track t a+event dur content = stretch dur $ temp content+ -- | Stretches track in time domain. stretch :: Real t => t -> Track t a -> Track t a stretch k (Track d es) = Track (k*d) $ stretchTList k es@@ -127,6 +135,26 @@ loop :: (Real t) => Int -> Track t a -> Track t a loop n = line . replicate n +-- | A line of one events. Each of them lasts for one second.+lineTemp :: (Real t) => [a] -> Track t a+lineTemp = lineMap temp++-- | Transforms a sequence and then applies a line.+lineMap :: (Real t) => (a -> Track t b) -> [a] -> Track t b+lineMap f xs = line $ fmap f xs++-- | A chord of one events. Each of them lasts for one second.+chordTemp :: (Real t) => [a] -> Track t a+chordTemp = chordMap temp++-- | Transforms a sequence and then applies a chord.+chordMap :: (Real t) => (a -> Track t b) -> [a] -> Track t b+chordMap f xs = chord $ fmap f xs++-- | Transforms a sequence and then applies a chordT.+chordTMap :: (Real t) => (a -> Track t b) -> [a] -> Track t b+chordTMap f xs = chordT $ fmap f xs+ -- | Reversing the tracks reflect :: (Real t) => Track t a -> Track t a reflect a = mapEvents @@ -138,10 +166,6 @@ rest :: (Real t) => t -> Track t a rest = flip delay nil --instance Foldable (Track t) where-    foldMap f (Track _ x) = foldMap f x        - -- | 'slice' cuts piece of value within given time interval. -- for @('slice' t0 t1 m)@, if @t1 < t0@ result is reversed. -- If @t0@ is negative or @t1@ goes beyond @'dur' m@ blocks of@@ -261,7 +285,7 @@                 | Single a                 | Append  (TList t a) (TList t a)                 | TFun (Tfm t) (TList t a)-            deriving (Show, Eq)+            deriving (Show, Eq, Functor, Foldable, Traversable)   foldT :: b -> (a -> b) -> (b -> b -> b) -> (Tfm t -> b -> b) @@ -280,11 +304,6 @@     mappend a       Empty   = a     mappend a       b       = Append a b --instance Functor (TList t) where-    fmap f = foldT Empty (Single . f) Append TFun-- durTList = maximum . fmap totalEventDur . renderTList      where totalEventDur = (+) <$> eventStart <*> eventDur @@ -297,9 +316,6 @@         TFun t a    -> TFun (delayTfm k t) a         Empty       -> Empty         a           -> TFun (Tfm 1 k) a --instance Foldable (TList t) where-    foldMap f = foldT mempty f mappend (flip const)   renderTList :: Num t => TList t a -> [Event t a]
temporal-media.cabal view
@@ -1,5 +1,5 @@ Name:          temporal-media-Version:       0.3.1+Version:       0.3.3 License-file:  LICENSE Cabal-Version: >= 1.6 License:       BSD3