Copyright | (c) Hans Hoglund 2012-2014 |
---|---|
License | BSD-style |
Maintainer | hans@hanshoglund.se |
Stability | experimental |
Portability | non-portable (TF,GNTD) |
Safe Haskell | None |
Language | Haskell2010 |
- module Music.Time.Types
- class Transformable a where
- itransform :: Transformable a => Span -> a -> a
- transformed :: (Transformable a, Transformable b) => Span -> Iso a b a b
- itransformed :: (Transformable a, Transformable b) => Span -> Iso a b a b
- whilst :: (Transformable a, Transformable b) => (a -> b) -> Span -> a -> b
- whilstL :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Span, s) (Span, t) a b
- whilstL2 :: (Transformable t, Transformable a, Functor f) => (t -> f a) -> (Span, t) -> f (Span, a)
- whilstLT :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Time, s) (Time, t) a b
- whilstLD :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Duration, s) (Duration, t) a b
- whilstStretch :: (Transformable a, Transformable b) => (a -> b) -> Duration -> a -> b
- whilstDelay :: (Transformable a, Transformable b) => (a -> b) -> Time -> a -> b
- spanned :: (Transformable b, Transformable a, Profunctor p, Functor f) => Span -> p a (f b) -> p a (f b)
- onSpan :: (Transformable s, Transformable t, Functor f) => LensLike f s t a b -> Span -> LensLike f s t a b
- conjugateS :: Span -> Span -> Span
- delaying :: Duration -> Span
- undelaying :: Duration -> Span
- stretching :: Duration -> Span
- compressing :: Duration -> Span
- delay :: Transformable a => Duration -> a -> a
- undelay :: Transformable a => Duration -> a -> a
- stretch :: Transformable a => Duration -> a -> a
- compress :: Transformable a => Duration -> a -> a
- delayTime :: Transformable a => Time -> a -> a
Documentation
module Music.Time.Types
The Transformable class
class Transformable a where Source
Class of values that can be transformed (i.e. scaled and moved) in time.
Law
transform mempty = id transform (s <> t) = transform s . transform t transform (s <> negateV s) = id
Law
onset (delay n a) = n ^+. onset a offset (delay n a) = n ^+. offset a duration (stretch n a) = n * duration a duration (compress n a) = duration a / n
delay n b ! t = b ! (t .-^ n) undelay n b ! t = b ! (t .+^ n)
Lemma
duration a = duration (delay n a)
itransform :: Transformable a => Span -> a -> a Source
Apply the inverse of the given transformation.
itransform
s =transform
(negateV
s)
transformed :: (Transformable a, Transformable b) => Span -> Iso a b a b Source
View the given value in the context of the given transformation.
itransformed :: (Transformable a, Transformable b) => Span -> Iso a b a b Source
Transforms a lens of to a Transformable
type to act inside a transformation.
Apply under a transformation
whilst :: (Transformable a, Transformable b) => (a -> b) -> Span -> a -> b Source
whilstL :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Span, s) (Span, t) a b Source
whilstL2 :: (Transformable t, Transformable a, Functor f) => (t -> f a) -> (Span, t) -> f (Span, a) Source
whilstLT :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Time, s) (Time, t) a b Source
whilstLD :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Duration, s) (Duration, t) a b Source
whilstStretch :: (Transformable a, Transformable b) => (a -> b) -> Duration -> a -> b Source
Apply a function under transformation.
whilstDelay :: (Transformable a, Transformable b) => (a -> b) -> Time -> a -> b Source
Apply a function under transformation.
spanned :: (Transformable b, Transformable a, Profunctor p, Functor f) => Span -> p a (f b) -> p a (f b) Source
Deprecated: Use itransformed
onSpan :: (Transformable s, Transformable t, Functor f) => LensLike f s t a b -> Span -> LensLike f s t a b Source
Transforms a lens of to a Transformable
type to act inside a transformation.
Designed to be used infix, as in
l onSpan
(2 <-> 3)
conjugateS :: Span -> Span -> Span Source
The conjugate of two spans.
Specific transformations
Transformations
undelaying :: Duration -> Span Source
A transformation that moves a value backward in time.
stretching :: Duration -> Span Source
A transformation that stretches (augments) a value by the given factor.
compressing :: Duration -> Span Source
A transformation that compresses (diminishes) a value by the given factor.
Transforming values
delay :: Transformable a => Duration -> a -> a Source
Moves a value forward in time.
undelay :: Transformable a => Duration -> a -> a Source
stretch :: Transformable a => Duration -> a -> a Source
Stretches (augments) a value by the given factor.
compress :: Transformable a => Duration -> a -> a Source
delayTime :: Transformable a => Time -> a -> a Source
Delay relative to origin
.
Provided for situations when we really want to use startAt
, but the
type does not have an instance for HasPosition
and we can assume that
the value is starting at time zero.