| Copyright | (c) Hans Hoglund 2012-2014 |
|---|---|
| License | BSD-style |
| Maintainer | hans@hanshoglund.se |
| Stability | experimental |
| Portability | non-portable (TF,GNTD) |
| Safe Haskell | None |
| Language | Haskell2010 |
Music.Time.Score
Description
- data Score a
- score :: Getter [Note a] (Score a)
- notes :: Lens (Score a) (Score b) [Note a] [Note b]
- eras :: Traversal' (Score a) Span
- events :: Lens (Score a) (Score b) [(Time, Duration, a)] [(Time, Duration, b)]
- singleNote :: Prism' (Score a) (Note a)
- mapWithSpan :: (Span -> a -> b) -> Score a -> Score b
- filterWithSpan :: (Span -> a -> Bool) -> Score a -> Score a
- mapFilterWithSpan :: (Span -> a -> Maybe b) -> Score a -> Score b
- mapEvents :: (Time -> Duration -> a -> b) -> Score a -> Score b
- filterEvents :: (Time -> Duration -> a -> Bool) -> Score a -> Score a
- mapFilterEvents :: (Time -> Duration -> a -> Maybe b) -> Score a -> Score b
- simult :: Transformable a => Lens (Score a) (Score b) (Score [a]) (Score [b])
- simultaneous :: (Transformable a, Semigroup a) => Score a -> Score a
- normalizeScore :: Score a -> Score a
- printEras :: Score a -> IO ()
- unsafeNotes :: Iso (Score a) (Score b) [Note a] [Note b]
- unsafeEvents :: Iso (Score a) (Score b) [(Time, Duration, a)] [(Time, Duration, b)]
Score type
A Score is a sequential or parallel composition of values, and allows overlapping events
You typically create a Score using score, notes, voices, and phrases, or the Alternative interface.
Score is an instance of Transformable, so you can use delay and stretch.
Score is an instance of HasPosition, so you can use duration, onset, offset, era.
To inspect or deconstruct a score, see notes, voices, and phrases, as
well as singleNote, singleVoice, and singlePhrase
Instances
Query
Construction
notes :: Lens (Score a) (Score b) [Note a] [Note b] Source
View a Score as a list of Note values.
viewnotes::Scorea -> [Notea]setnotes:: [Notea] ->Scorea ->Scoreaovernotes:: ([Notea] -> [Noteb]) ->Scorea ->Scoreb
preview(notes.each) ::Scorea ->Maybe(Notea)preview(notes.element1) ::Scorea ->Maybe(Notea)preview(notes.elementsodd) ::Scorea ->Maybe(Notea)
set(notes.each) ::Notea ->Scorea ->Scoreaset(notes.element1) ::Notea ->Scorea ->Scoreaset(notes.elementsodd) ::Notea ->Scorea ->Scorea
over(notes.each) :: (Notea ->Noteb) ->Scorea ->Scorebover(notes.element1) :: (Notea ->Notea) ->Scorea ->Scoreaover(notes.elementsodd) :: (Notea ->Notea) ->Scorea ->Scorea
toListOf(notes.each) ::Scorea -> [Notea]toListOf(notes.elementsodd) ::Scorea -> [Notea]toListOf(notes.each.filtered(\x ->_durationx < 2)) ::Scorea -> [Notea]
This is not an Iso, as the note list representation does not contain meta-data.
To construct a score from a note list, use score or .flip (set notes) empty
eras :: Traversal' (Score a) Span Source
Print all eras of the given score.
>>>toListOf eras $ scat [c,d,e :: Score Integer][0 <-> 1,1 <-> 2,2 <-> 3]
singleNote :: Prism' (Score a) (Note a) Source
Deprecated: Use 'unsafeNotes . single'
View a score as a single note.
Traversal
mapWithSpan :: (Span -> a -> b) -> Score a -> Score b Source
Map over the values in a score.
mapFilterWithSpan :: (Span -> a -> Maybe b) -> Score a -> Score b Source
Combination of mapEvents and filterEvents.
mapEvents :: (Time -> Duration -> a -> b) -> Score a -> Score b Source
Map over the values in a score.
filterEvents :: (Time -> Duration -> a -> Bool) -> Score a -> Score a Source
Filter the values in a score.
mapFilterEvents :: (Time -> Duration -> a -> Maybe b) -> Score a -> Score b Source
Efficient combination of mapEvents and filterEvents.
Simultaneous
simultaneous :: (Transformable a, Semigroup a) => Score a -> Score a Source
Normalize
normalizeScore :: Score a -> Score a Source
Mainly useful for backends.
printEras :: Score a -> IO () Source
Extract all eras of the given score.
>>>printEras $ scat [c,d,e :: Score Integer]0 <-> 1 1 <-> 2 2 <-> 3