Safe Haskell | None |
---|
Composition and control.
- type Dur = Double
- type Score a = Track Double a
- data Event t a = Event {
- eventStart :: t
- eventDur :: t
- eventContent :: a
- eventEnd :: Num t => Event t a -> t
- within :: Real t => t -> t -> Event t a -> Bool
- temp :: a -> Score a
- event :: Dur -> a -> Score a
- rest :: Dur -> Score a
- stretch :: Dur -> Score a -> Score a
- delay :: Dur -> Score a -> Score a
- reflect :: Score a -> Score a
- (+|) :: Dur -> Score a -> Score a
- (*|) :: Dur -> Score a -> Score a
- (=:=) :: Score a -> Score a -> Score a
- (+:+) :: Score a -> Score a -> Score a
- (=:/) :: Score a -> Score a -> Score a
- line :: [Score a] -> Score a
- chord :: [Score a] -> Score a
- chordT :: [Score a] -> Score a
- loop :: Int -> Score a -> Score a
- sustain :: Dur -> Score a -> Score a
- sustainT :: Dur -> Score a -> Score a
- lineTemp :: [a] -> Score a
- chordTemp :: [a] -> Score a
- lineMap :: (a -> Score b) -> [a] -> Score b
- chordMap :: (a -> Score b) -> [a] -> Score b
- chordTMap :: (a -> Score b) -> [a] -> Score b
- slice :: Dur -> Dur -> Score a -> Score a
- takeS :: Dur -> Score a -> Score a
- dropS :: Dur -> Score a -> Score a
- filterEvents :: (Event Dur a -> Bool) -> Score a -> Score a
- mapEvents :: (Event Dur a -> Event Dur b) -> Score a -> Score b
- tmap :: (Event Dur a -> b) -> Score a -> Score b
- tmapRel :: (Event Dur a -> b) -> Score a -> Score b
- dur :: Score a -> Dur
- render :: Score a -> [Event Dur a]
- alignByZero :: Real t => [Event t a] -> [Event t a]
- sortEvents :: Ord t => [Event t a] -> [Event t a]
- linfun :: (Ord t, Fractional t) => [t] -> t -> t
- linfunRel :: (Ord t, Fractional t) => t -> [t] -> t -> t
- nil :: Monoid a => a
- module Data.Monoid
- setDiap :: VolumeLike a => (Double, Double) -> Score a -> Score a
- setDiapRel :: VolumeLike a => (Double, Double) -> Score a -> Score a
- setLevel :: VolumeLike a => Level -> Score a -> Score a
- setAccent :: VolumeLike a => Accent -> Score a -> Score a
- accent :: VolumeLike a => Accent -> Score a -> Score a
- (!) :: VolumeLike a => Score a -> Accent -> Score a
- louder :: VolumeLike a => Int -> Score a -> Score a
- quieter :: VolumeLike a => Int -> Score a -> Score a
- loud :: VolumeLike a => Score a -> Score a
- quiet :: VolumeLike a => Score a -> Score a
- withAccent :: VolumeLike a => (Dur -> Accent) -> Score a -> Score a
- withAccentSeg :: VolumeLike a => [Double] -> Score a -> Score a
- withAccentRel :: VolumeLike a => [Accent] -> Score a -> Score a
- setScale :: PitchLike a => Scale -> Score a -> Score a
- setBend :: PitchLike a => Bend -> Score a -> Score a
- setStep :: PitchLike a => Step -> Score a -> Score a
- step :: PitchLike a => Int -> Score a -> Score a
- bend :: PitchLike a => Bend -> Score a -> Score a
- lower :: PitchLike a => Int -> Score a -> Score a
- higher :: PitchLike a => Int -> Score a -> Score a
- low :: PitchLike a => Score a -> Score a
- high :: PitchLike a => Score a -> Score a
- l' :: PitchLike a => Score a -> Score a
- ll' :: PitchLike a => Score a -> Score a
- hh' :: PitchLike a => Score a -> Score a
- h' :: PitchLike a => Score a -> Score a
- r :: Dur -> Score a
- dot :: Score a -> Score a
- ddot :: Score a -> Score a
- trn :: Score a -> Score a
- bpm :: Dur -> Score a -> Score a
- bn :: Score a -> Score a
- wn :: Score a -> Score a
- hn :: Score a -> Score a
- qn :: Score a -> Score a
- en :: Score a -> Score a
- sn :: Score a -> Score a
- tn :: Score a -> Score a
- dbn :: Score a -> Score a
- dwn :: Score a -> Score a
- dhn :: Score a -> Score a
- dqn :: Score a -> Score a
- den :: Score a -> Score a
- dsn :: Score a -> Score a
- dtn :: Score a -> Score a
- bnr :: Score a
- wnr :: Score a
- hnr :: Score a
- qnr :: Score a
- enr :: Score a
- snr :: Score a
- tnr :: Score a
- dbnr :: Score a
- dwnr :: Score a
- dhnr :: Score a
- dqnr :: Score a
- denr :: Score a
- dsnr :: Score a
- dtnr :: Score a
Types
data Event t a
Constant time events. Value a
starts at some time
and lasts for some time.
Event | |
|
within :: Real t => t -> t -> Event t a -> Bool
Tests if given Event
happens between two time stamps.
Composition
temp
constructs just an event.
Value of type a
lasts for one time unit and starts at zero.
event :: Dur -> a -> Score aSource
Creates a single event.
event dur a
Event lasts for some time and contains a value a
.
(=:/) :: Score a -> Score a -> Score aSource
Turncating parallel composition. Total duration equals to minimum of the two scores. All events that goes beyond the lmimt are dropped.
loop :: Int -> Score a -> Score aSource
Analog of replicate
function for scores. Replicated
scores are played sequentially.
sustain :: Dur -> Score a -> Score aSource
After this transformation events last longer by some constant amount of time.
sustainT :: Dur -> Score a -> Score aSource
Prolongated events can not exceed total score duration. All event are sustained but those that are close to end of the score are clipped. It resembles sustain on piano, when score ends you release the pedal.
Common patterns
Filtering
Mappings
mapEvents :: (Event Dur a -> Event Dur b) -> Score a -> Score bSource
General mapping. Mapps not only values but events.
tmapRel :: (Event Dur a -> b) -> Score a -> Score bSource
Relative tmap. Time values are normalized by argument's duration.
Rendering
alignByZero :: Real t => [Event t a] -> [Event t a]
Shifts all events so that minimal start time equals to zero if first event has negative start time.
sortEvents :: Ord t => [Event t a] -> [Event t a]
Sorts all events by start time.
Miscellaneous
linfun :: (Ord t, Fractional t) => [t] -> t -> t
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
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]
Monoid synonyms
module Data.Monoid
Volume control
setDiap :: VolumeLike a => (Double, Double) -> Score a -> Score aSource
Sets diapason to specified value.
setDiapRel :: VolumeLike a => (Double, Double) -> Score a -> Score aSource
Relative update of diapason value in decibels, (0, 1) turns diapason interval into itself.
louder :: VolumeLike a => Int -> Score a -> Score aSource
Input becomes louder by given number of levels.
quieter :: VolumeLike a => Int -> Score a -> Score aSource
Input becomes quieter by given number of levels.
loud :: VolumeLike a => Score a -> Score aSource
Input becomes one level louder.
quiet :: VolumeLike a => Score a -> Score aSource
Input becomes one level quieter.
withAccent :: VolumeLike a => (Dur -> Accent) -> Score a -> Score aSource
Accent that depends on time of note, time is relative,
so Score
starts at 't = 0' and ends at 't = 1'.
withAccentSeg :: VolumeLike a => [Double] -> Score a -> Score aSource
envelopeSeg
lifts function linfun
to dynamics level
withAccentRel :: VolumeLike a => [Accent] -> Score a -> Score aSource
envelopeRel
lifts function linfunRel
to dynamics level
Pitch control
step :: PitchLike a => Int -> Score a -> Score aSource
Transposition. Increases (octave, step) coordinate by given number of steps.
Shortcuts
Denotes lower 1-2
and higher 1-2
.
Time stretching
bpm :: Dur -> Score a -> Score aSource
Sets tempo in beats per minute, if 1 Dur is equal to 1 second before transformation.
Shortcuts
Naming conventions :
First part x
can be [b | w | h | q | e | s | t | d[x] ]
b
means brewis (stretch 2)
w
means whole (stretch 1)
h
means half (stretch $ 1/2)
q
means quater (stretch $ 1/4)
e
means eighth (stretch $ 1/8)
s
means sixteenth (stretch $ 1/16)
t
means thirty second (stretch $ 1/32)
d[x]
means dotted [x] (stretch 1.5 $ x)
Pauses
Naming conventions are the same as for 'time stretching'.