module CsoundExpr.Base.Score (
Time, Dur, Score,
rest, note, toList,
dur,
Arrangeable(..),
line, chord, loop, trill, rondo, reprise,
delay,
stretch, tstretch,
cut, takeS, dropS, reverseS,
pedal, pedalBy,
sustain, sustainBy,
tmap, dmap, tdmap,
tmapRel, dmapRel, tdmapRel, tstretchRel,
linseg
)
where
import CsoundExpr.Translator.Types(Time, Dur)
import qualified Temporal.Media as M
import Temporal.Media(Arrangeable(..), linseg)
import Control.Arrow(second)
type Score a = M.MediaUnit Dur () a
dur :: M.Temporal Dur a => a -> Dur
dur = M.dur
rest :: M.Temporal Dur a => Dur -> a
rest = M.none
stretch :: M.Stretchable Dur a => Dur -> a -> a
stretch = M.stretch
tstretch :: M.TemporalStretchable Dur a => (Time -> Dur) -> a -> a
tstretch = M.tstretch
tstretchRel :: M.TemporalStretchable Dur a => (Time -> Dur) -> a -> a
tstretchRel = M.tstretchRel
sustain :: Dur -> Score a -> Score a
sustain = M.sustain
sustainBy :: (Time -> Dur -> a -> (b, Dur)) -> Score a -> Score b
sustainBy = M.sustainBy
pedal :: Dur -> Score a -> Score a
pedal dt' = pedalBy (\t dt a -> (a, dt + dt'))
pedalBy :: (Time -> Dur -> a -> (b, Dur)) -> Score a -> Score b
pedalBy f x = M.sustainBy f' x
where d = dur x
f' t dt a = second (min (d t)) $ f t dt a
note :: Dur -> a -> Score a
note = M.temp
delay :: (M.Temporal Dur a, Arrangeable a) => Dur -> a -> a
delay = M.delay
line :: Arrangeable a => [a] -> a
line = M.sequent
chord :: Arrangeable a => [a] -> a
chord = M.parallel
loop :: Arrangeable a => Int -> a -> a
loop = M.loop
trill :: Arrangeable a => Int -> a -> a -> a
trill n a b = loop n $ line [a, b]
rondo :: Arrangeable a => a -> a -> a -> a
rondo a b c = line [a, b, a, c, a]
reprise :: Arrangeable a => a -> a -> a -> a
reprise a b c = line [a, b, a, c]
cut :: Dur -> Dur -> Score a -> Score a
cut = M.cut
takeS :: Dur -> Score a -> Score a
takeS = M.take
dropS :: Dur -> Score a -> Score a
dropS = M.drop
reverseS :: Score a -> Score a
reverseS = M.reverse
tmap :: (Time -> a -> b) -> Score a -> Score b
tmap = M.tmap
dmap :: (Dur -> a -> b) -> Score a -> Score b
dmap = M.dmap
tdmap :: (Time -> Dur -> a -> b) -> Score a -> Score b
tdmap = M.tdmap
tmapRel :: (Time -> a -> b) -> Score a -> Score b
tmapRel = M.tmapRel
dmapRel :: (Dur -> a -> b) -> Score a -> Score b
dmapRel = M.dmapRel
tdmapRel :: (Time -> Dur -> a -> b) -> Score a -> Score b
tdmapRel = M.tdmapRel
toList :: Score a -> M.EventList Dur a
toList = M.fromMediaUnit (const id)