Safe Haskell  Safe 

Language  Haskell98 
A library for creating lists of constant time events related in time.
 data Event t a = Event {
 eventStart :: t
 eventDur :: t
 eventContent :: a
 data Track t a
 within :: Real t => t > t > Event t a > Bool
 eventEnd :: Num t => Event t a > t
 module Temporal.Class
 temp :: Num t => a > Track t a
 fromEvent :: Num t => Event t a > Track t a
 singleEvent :: Num t => t > t > a > Track t a
 reflect :: (Num t, IfB t, OrdB t) => Track t a > Track t a
 (=:/) :: (Real t, IfB t, OrdB t) => Track t a > Track t a > Track t a
 harT :: (Real t, IfB t, OrdB t) => [Track t a] > Track t a
 sustain :: Num t => t > Track t a > Track t a
 sustainT :: (Ord t, Num t) => t > Track t a > Track t a
 melTemp :: (Num t, IfB t, OrdB t) => [a] > Track t a
 harTemp :: (Num t, IfB t, OrdB t) => [a] > Track t a
 harTMap :: (Real t, IfB t, OrdB t) => (a > Track t b) > [a] > Track t b
 slice :: Real t => t > t > Track t a > Track t a
 takeT :: Real t => t > Track t a > Track t a
 dropT :: Real t => t > Track t a > Track t a
 filterEvents :: Real t => (Event t a > Bool) > Track t a > Track t a
 mapEvents :: Num t => (Event t a > Event t b) > Track t a > Track t b
 traverseEvents :: (Num t1, Applicative f) => (t1 > f t2) > (Event t1 a > f (Event t2 b)) > Track t1 a > f (Track t2 b)
 tmap :: Real t => (Event t a > b) > Track t a > Track t b
 tmapRel :: RealFrac t => (Event t a > b) > Track t a > Track t b
 render :: Num t => Track t a > [Event t a]
 alignByZero :: Real t => [Event t a] > [Event t a]
 sortEvents :: Ord t => [Event t a] > [Event t a]
 nil :: Monoid a => a
 module Data.Monoid
 linfun :: (Ord t, Fractional t) => [t] > t > t
 linfunRel :: (Ord t, Fractional t) => t > [t] > t > t
Introduction
Temporal.Media is a library for creating lists of constant time events related in time. Constant time event is value that starts at some fixed time and lasts for some fixed time. Library provides functions to build lists of such events with timerelations like sequent, parallel or delayed.
Core type of library is Track
. It provides interface
to compose list of events.
Types
Constant time events. Value a
starts at some time
and lasts for some time.
Event  

Track
is a set of Event
s. There is total duration
of the track, but Events can go beyond the scope of total duration
(as a result of mapEvents
function). Total duration is used in sequent
composition of tracks.
Functor (Track t) Source #  
Foldable (Track t) Source #  
Traversable (Track t) Source #  
(Eq a, Eq t) => Eq (Track t a) Source #  
(Show a, Show t) => Show (Track t a) Source #  
(Num t, IfB t, OrdB t) => Monoid (Track t a) Source #  
(Num t, IfB t, OrdB t) => Rest (Track t a) Source #  Empty track that lasts for some time. 
Num t => Stretch (Track t a) Source #  Stretches track in time domain. 
Num t => Delay (Track t a) Source #  Delays all events by given duration. 
(Num t, IfB t, OrdB t) => Compose (Track t a) Source #  
(Num t, IfB t, OrdB t) => Harmony (Track t a) Source #  
(Num t, IfB t, OrdB t) => Melody (Track t a) Source #  
Duration (Track t a) Source #  
type DurOf (Track t a) Source #  
within :: Real t => t > t > Event t a > Bool Source #
Tests if given Event
happens between two time stamps.
Composition
module Temporal.Class
temp :: Num t => a > Track t a Source #
temp
constructs just an event.
Value of type a lasts for one time unit and starts at zero.
fromEvent :: Num t => Event t a > Track t a Source #
Constructs a track that contains a single event.
singleEvent :: Num t => t > t > a > Track t a Source #
Constructs a track that contains a single event.
singleEvent start duration content
(=:/) :: (Real t, IfB t, OrdB t) => Track t a > Track t a > Track t a Source #
Turncating parallel composition. Total duration equals to minimum of the two tracks. All events that goes beyond the limit are dropped.
harT :: (Real t, IfB t, OrdB t) => [Track t a] > Track t a Source #
Turncating parallel composition on list of tracks.
sustain :: Num t => t > Track t a > Track t a Source #
After this transformation events last longer by some constant amount of time.
sustainT :: (Ord t, Num t) => t > Track t a > Track t a Source #
Prolongated events can not exceed total track duration. All event are sustained but those that are close to end of the track are sliced. It resembles sustain on piano, when track ends you release the pedal.
Common patterns
melTemp :: (Num t, IfB t, OrdB t) => [a] > Track t a Source #
Analog of replicate
function for tracks. Replicated
tracks are played sequentially.
A melody of events. Each of them lasts for one second.
harTemp :: (Num t, IfB t, OrdB t) => [a] > Track t a Source #
A chord of events. Each of them lasts for one second.
harTMap :: (Real t, IfB t, OrdB t) => (a > Track t b) > [a] > Track t b Source #
Transforms a sequence and then applies a harT.
Filtering
Mappings
mapEvents :: Num t => (Event t a > Event t b) > Track t a > Track t b Source #
General mapping. Maps not only values but events.
traverseEvents :: (Num t1, Applicative f) => (t1 > f t2) > (Event t1 a > f (Event t2 b)) > Track t1 a > f (Track t2 b) Source #
tmapRel :: RealFrac t => (Event t a > b) > Track t a > Track t b Source #
Relative tmap. Time values are normalized by argument's duration.
Rendering
alignByZero :: Real t => [Event t a] > [Event t a] Source #
Shifts all events so that minimal start time equals to zero if first event has negative start time.
Monoid synonyms
module Data.Monoid
Miscellaneous
linfun :: (Ord t, Fractional t) => [t] > t > t Source #
Linear interpolation. Can be useful with mapEvents
for
envelope changes.
linfun [a, da, b, db, c, ... ]
a, b, c ...
 values
da, db, ...
 duration of segments
linfunRel :: (Ord t, Fractional t) => t > [t] > t > t Source #
With linfunRel
you can make linear interpolation
function that has equal distance between points.
First argument gives total length of the interpolation function
and second argument gives list of values. So call
linfunRel dur [a1, a2, a3, ..., aN]
is equivalent to:
linfun [a1, dur/N, a2, dur/N, a3, ..., dur/N, aN]