What is music?
Fundamentally it is sound, but we want a more structured representation.
What is music?
Fundamentally it is sound, but we want a more structured representation.
A Haskell library for ... of music
Composition | a | ➝ | Music | ||
Manipulation | Music | ➝ | Music | ||
Analysis | Music | ➝ | b |
No closed definition of music(s)
Music making software necessarily impose restrictions on the music.
Usually those of Western classical/popular music.
Diatonic/chromatic scale, 3/4 and 4/4 time signatures, etc.
Difficult to work with other kinds of music.
No closed definition of music(s)
Music making software necessarily impose restrictions on the music.
Usually those of Western classical/popular music.
Diatonic/chromatic scale, 3/4 and 4/4 time signatures, etc.
Difficult to work with other kinds of music.
But there are many common elements in music!
Musical theory
Musical theory
Musical aspects
Musical cultures treat (and rank) aspects differently!
Time is special
Time is special
In other words, aspects may depend on time, but not the other way around.
Time is special
In other words, aspects may depend on time, but not the other way around.
We provide multiple versions of all aspects except time.
Why not simply use the largest type?
Restricting the space in which we are working empowers the type system
A more high-level concept can be performance-dependent, for example pitch vs. frequency
For each aspect: Start out with a free affine space and add structure
Compare graphics (2D or 3D)!
An affine transformation is simply (ProductDuration ⨯ SumTime)
Generalizes time transformations delay
and stretch
class Transformable a where
transform :: Span -> a -> a
class Transformable a where
transform :: Span -> a -> a
class HasPosition a where
_position :: a -> Duration -> Time
_onset, _offset :: a -> Time
class HasDuration a where
_duration :: a -> Duration
type Note a | = | (Duration, a) |
type Delayed a | = | (Time, a) |
type Placed a | = | (Span, a) |
type Voice a | = | [Note a] |
type Score a | = | [Voice a] |
type Track a | = | [Placed a] |
type Behavior a | = | Time -> a |
Defined in music-pitch
Main hierarchies are Music.Pitch.Absolute
Music.Pitch.Common
Former defines Frequency
Latter defines Pitch
and Interval
Defined as (Diatonic ⨯ Chromatic)
Pitches and intervals form an affine/vector space pair
Based on lens
vocabulary:
HasPitches
provides a traversal pitches
Scores, voices, chords etc
HasPitch
provides a lens pitch
Actual pitch types, notes etc
Whenever pitch
exists it is the same as pitches
Similar for all other aspects.
Allows polymorphic updating of aspects.
Pitches
Dynamic values
In the style of OverloadedStrings
.
A system to annotate all time types with arbitrary values.
Uses Typeable
wrappers, same as Diagrams' styles.
Backends can ignore meta-data they don't understand.
Used for most things that does not affect how the music sounds:
Develop high-level theory while staying general
Difficult error messages
Consolidate with other libraries