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 |
- 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
Query
Construction
notes :: Lens (Score a) (Score b) [Note a] [Note b] Source
View a Score
as a list of Note
values.
view
notes
::Score
a -> [Note
a]set
notes
:: [Note
a] ->Score
a ->Score
aover
notes
:: ([Note
a] -> [Note
b]) ->Score
a ->Score
b
preview
(notes
.each
) ::Score
a ->Maybe
(Note
a)preview
(notes
.element
1) ::Score
a ->Maybe
(Note
a)preview
(notes
.elements
odd) ::Score
a ->Maybe
(Note
a)
set
(notes
.each
) ::Note
a ->Score
a ->Score
aset
(notes
.element
1) ::Note
a ->Score
a ->Score
aset
(notes
.elements
odd) ::Note
a ->Score
a ->Score
a
over
(notes
.each
) :: (Note
a ->Note
b) ->Score
a ->Score
bover
(notes
.element
1) :: (Note
a ->Note
a) ->Score
a ->Score
aover
(notes
.elements
odd) :: (Note
a ->Note
a) ->Score
a ->Score
a
toListOf
(notes
.each
) ::Score
a -> [Note
a]toListOf
(notes
.elements
odd) ::Score
a -> [Note
a]toListOf
(notes
.each
.filtered
(\x ->_duration
x < 2)) ::Score
a -> [Note
a]
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