Safe Haskell | None |
---|---|
Language | Haskell98 |
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
- rest :: Dur -> Score a
- str :: Dur -> Score a -> Score a
- del :: 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
- mel :: [Score a] -> Score a
- har :: [Score a] -> Score a
- harT :: [Score a] -> Score a
- loop :: Int -> Score a -> Score a
- sustain :: Dur -> Score a -> Score a
- sustainT :: Dur -> Score a -> Score a
- melTemp :: [a] -> Score a
- harTemp :: [a] -> Score a
- melMap :: (a -> Score b) -> [a] -> Score b
- harMap :: (a -> Score b) -> [a] -> Score b
- harTMap :: (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
- line :: [Score a] -> Score a
- chord :: [Score a] -> Score a
- delay :: Double -> Score a -> Score a
- stretch :: Double -> Score a -> 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.
(=:/) :: Score a -> Score a -> Score a Source
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 a Source
Analog of replicate
function for scores. Replicated
scores are played sequentially.
sustain :: Dur -> Score a -> Score a Source
After this transformation events last longer by some constant amount of time.
sustainT :: Dur -> Score a -> Score a Source
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 b Source
General mapping. Mapps not only values but events.
tmapRel :: (Event Dur a -> b) -> Score a -> Score b Source
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 a Source
Sets diapason to specified value.
setDiapRel :: VolumeLike a => (Double, Double) -> Score a -> Score a Source
Relative update of diapason value in decibels, (0, 1) turns diapason interval into itself.
louder :: VolumeLike a => Int -> Score a -> Score a Source
Input becomes louder by given number of levels.
quieter :: VolumeLike a => Int -> Score a -> Score a Source
Input becomes quieter by given number of levels.
loud :: VolumeLike a => Score a -> Score a Source
Input becomes one level louder.
quiet :: VolumeLike a => Score a -> Score a Source
Input becomes one level quieter.
withAccent :: VolumeLike a => (Dur -> Accent) -> Score a -> Score a Source
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 a Source
envelopeSeg
lifts function linfun
to dynamics level
withAccentRel :: VolumeLike a => [Accent] -> Score a -> Score a Source
envelopeRel
lifts function linfunRel
to dynamics level
Pitch control
step :: PitchLike a => Int -> Score a -> Score a Source
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 a Source
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 (str 2)
w
means whole (str 1)
h
means half (str $ 1/2)
q
means quater (str $ 1/4)
e
means eighth (str $ 1/8)
s
means sixteenth (str $ 1/16)
t
means thirty second (str $ 1/32)
d[x]
means dotted [x] (str 1.5 $ x)
Pauses
Naming conventions are the same as for 'time string'.