packages feed

temporal-media 0.1.0 → 0.1.1

raw patch · 2 files changed

+23/−30 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Temporal.Media: linseg :: (Num t, Ord t, Fractional t) => [t] -> t -> t
+ Temporal.Media: linseg :: (Ord t, Fractional t) => [t] -> t -> t
- Temporal.Media.Double: linseg :: (Num t, Ord t, Fractional t) => [t] -> t -> t
+ Temporal.Media.Double: linseg :: (Ord t, Fractional t) => [t] -> t -> t

Files

src/Temporal/Media.hs view
@@ -236,13 +236,15 @@ instance Sliceable t a => Sliceable t (Media c a) where 	slice t0 t1 m  	    | t1 < t0   = sliceErrorMessage+	    | t1 <= 0   = none $ (t1 - t0)+	    | t0 >= tm  = none $ (t1 - t0) 	    | t0 < 0    = none (abs t0) :+: slice 0 t1 m 	    | t1 > tm   = slice t0 tm m :+: none (t1 - tm) 	    | otherwise = case m of-		    		Prim a      -> Prim $ slice t0 t1 a-		    		a :+: b     -> sliceSeq t0 t1 a b -				a :=: b     -> ((:=:) `on` slice t0 t1) a b-				Control c a -> Control c $ slice t0 t1 a+                        Prim a      -> Prim $ slice t0 t1 a+                        a :+: b     -> sliceSeq t0 t1 a b +                        a :=: b     -> ((:=:) `on` slice t0 t1) a b+                        Control c a -> Control c $ slice t0 t1 a 		where tm = dur m  sliceSeq :: Sliceable t a => t -> t -> Media c a -> Media c a -> Media c a@@ -629,29 +631,20 @@ linseg1 (a, dur, b) x = a + (b - a) * x / dur  -- | linear interpolation-linseg :: (Num t, Ord t, Fractional t) => [t] -> t -> t-linseg ps x-    | x < 0     = head ps-    | otherwise = if null ds -                  then last ps-                  else flip f x $ head ds-    where ds  = offset x ps-          f ((k, _), p) x = linseg1 p $ x - k-   -offset :: (Num t, Ord t) => t -> [t] -> [((t, t), (t, t, t))]-offset x ps = dropWhile ((x > ) . snd . fst) $ zip (stamps ps') ps'-    where ps' = parts ps--stamps :: (Num t) => [(t, t, t)] -> [(t, t)]-stamps xs = P.reverse $ foldl f [(0, p)] xs-    where f ((a, b):res) x = (b, b + snd3 x):(a, b):res-          snd3 (_, a, _) = a-          p = snd3 $ head xs--parts :: [t] -> [(t, t, t)]-parts xs = +--+-- linseg [a, da, b, db, c, ... ]+--+-- @a, b, c ...@ - values+--+-- @da, db, ...@ - duration of segments+linseg :: (Ord t, Fractional t) => [t] -> t -> t+linseg xs t =      case xs of-        (a:dur:b:[])      -> [(a, dur, b)] -        (a:dur:b:(x:xs')) -> (a, dur, b) : parts (b : x : xs')-        _                 -> error "linseg : length must be odd and greater than 2"-+        (a:dur:b:[])      -> seg a dur b t+        (a:dur:b:(x:xs')) -> if t < dur +                             then seg a dur b t+                             else linseg (b:x:xs') (t - dur)+    where seg a dur b t +                | t < 0     = a+                | t >= dur  = b+                | otherwise = a + (b - a)*(t/dur)
temporal-media.cabal view
@@ -1,5 +1,5 @@ Name:          temporal-media-Version:       0.1.0+Version:       0.1.1 License-file:  LICENSE Cabal-Version: >= 1.2 License:       BSD3