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 Voice a
- voice :: Getter [Note a] (Voice a)
- notes :: Lens (Voice a) (Voice b) [Note a] [Note b]
- pairs :: Lens (Voice a) (Voice b) [(Duration, a)] [(Duration, b)]
- durationsVoice :: Iso' [Duration] (Voice ())
- valuesV :: Lens (Voice a) (Voice b) [a] [b]
- durationsV :: Lens' (Voice a) [Duration]
- unzipVoice :: Voice (a, b) -> (Voice a, Voice b)
- zipVoiceScale :: Voice a -> Voice b -> Voice (a, b)
- zipVoiceScale3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c))
- zipVoiceScale4 :: Voice a -> Voice b -> Voice c -> Voice d -> Voice (a, (b, (c, d)))
- zipVoiceNoScale :: Voice a -> Voice b -> Voice (a, b)
- zipVoiceNoScale3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c))
- zipVoiceNoScale4 :: Voice a -> Voice b -> Voice c -> Voice d -> Voice (a, (b, (c, d)))
- zipVoiceScaleWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice c
- zipVoiceWithNoScale :: (a -> b -> c) -> Voice a -> Voice b -> Voice c
- zipVoiceWith' :: (Duration -> Duration -> Duration) -> (a -> b -> c) -> Voice a -> Voice b -> Voice c
- fuse :: Eq a => Voice a -> Voice a
- fuseBy :: (a -> a -> Bool) -> Voice a -> Voice a
- fuseRests :: Voice (Maybe a) -> Voice (Maybe a)
- coverRests :: Voice (Maybe a) -> Maybe (Voice a)
- sameDurations :: Voice a -> Voice b -> Bool
- mergeIfSameDuration :: Voice a -> Voice b -> Maybe (Voice (a, b))
- mergeIfSameDurationWith :: (a -> b -> c) -> Voice a -> Voice b -> Maybe (Voice c)
- homoToPolyphonic :: Voice [a] -> [Voice a]
- onsetsRelative :: Time -> Voice a -> [Time]
- offsetsRelative :: Time -> Voice a -> [Time]
- midpointsRelative :: Time -> Voice a -> [Time]
- erasRelative :: Time -> Voice a -> [Span]
- withContext :: Voice a -> Voice (Ctxt a)
- unsafeNotes :: Iso (Voice a) (Voice b) [Note a] [Note b]
- unsafePairs :: Iso (Voice a) (Voice b) [(Duration, a)] [(Duration, b)]
Voice type
A Voice
is a sequential composition of non-overlapping note values.
Both Voice
and Note
have duration but no position. The difference
is that Note
sustains a single value throughout its duration, while
a voice may contain multiple values. It is called voice because it is
generalizes the notation of a voice in choral or multi-part instrumental music.
It may be useful to think about Voice
and Note
as vectors in time space
(i.e. Duration
), that also happens to carry around other values, such as pitches.
Construction
pairs :: Lens (Voice a) (Voice b) [(Duration, a)] [(Duration, b)] Source
View a score as a list of duration-value pairs. Analogous to triples
.
durationsVoice :: Iso' [Duration] (Voice ()) Source
Traversal
Separating rhythms and values
durationsV :: Lens' (Voice a) [Duration] Source
A lens to the durations in a voice.
Zips
unzipVoice :: Voice (a, b) -> (Voice a, Voice b) Source
Unzip the given voice.
zipVoiceScale :: Voice a -> Voice b -> Voice (a, b) Source
Join the given voices by multiplying durations and pairing values.
zipVoiceScale3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c)) Source
Join the given voices by multiplying durations and pairing values.
zipVoiceScale4 :: Voice a -> Voice b -> Voice c -> Voice d -> Voice (a, (b, (c, d))) Source
Join the given voices by multiplying durations and pairing values.
zipVoiceNoScale :: Voice a -> Voice b -> Voice (a, b) Source
Join the given voices by pairing values and selecting the first duration.
zipVoiceNoScale3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c)) Source
Join the given voices by pairing values and selecting the first duration.
zipVoiceNoScale4 :: Voice a -> Voice b -> Voice c -> Voice d -> Voice (a, (b, (c, d))) Source
Join the given voices by pairing values and selecting the first duration.
zipVoiceScaleWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice c Source
Join the given voices by multiplying durations and combining values using the given function.
zipVoiceWithNoScale :: (a -> b -> c) -> Voice a -> Voice b -> Voice c Source
Join the given voices without combining durations.
zipVoiceWith' :: (Duration -> Duration -> Duration) -> (a -> b -> c) -> Voice a -> Voice b -> Voice c Source
Join the given voices by combining durations and values using the given function.
Fusion
fuseBy :: (a -> a -> Bool) -> Voice a -> Voice a Source
Merge consecutive notes deemed equal by the given predicate.
Fuse rests
fuseRests :: Voice (Maybe a) -> Voice (Maybe a) Source
Fuse all rests in the given voice. The resulting voice will have no consecutive rests.
coverRests :: Voice (Maybe a) -> Maybe (Voice a) Source
Remove all rests in the given voice by prolonging the previous note. Returns Nothing
if and only if the given voice contains rests only.
Homophonic/Polyphonic texture
sameDurations :: Voice a -> Voice b -> Bool Source
Whether two notes have exactly the same duration pattern. Two empty voices are considered to have the same duration pattern. Voices with an non-equal number of notes differ by default.
mergeIfSameDuration :: Voice a -> Voice b -> Maybe (Voice (a, b)) Source
Pair the values of two voices if and only if they have the same duration
pattern (as per sameDurations
).
mergeIfSameDurationWith :: (a -> b -> c) -> Voice a -> Voice b -> Maybe (Voice c) Source
Combine the values of two voices using the given function if and only if they
have the same duration pattern (as per sameDurations
).
homoToPolyphonic :: Voice [a] -> [Voice a] Source
Split a homophonic texture into a polyphonic one. The returned voice list will not have as many elements as the chord with the fewest number of notes.
Points in a voice
onsetsRelative :: Time -> Voice a -> [Time] Source
Returns the onsets of all notes in a voice given the onset of the first note.
offsetsRelative :: Time -> Voice a -> [Time] Source
Returns the offsets of all notes in a voice given the onset of the first note.
midpointsRelative :: Time -> Voice a -> [Time] Source
Returns the midpoints of all notes in a voice given the onset of the first note.
erasRelative :: Time -> Voice a -> [Span] Source
Returns the eras of all notes in a voice given the onset of the first note.
Context
withContext :: Voice a -> Voice (Ctxt a) Source
Decorate all notes in a voice with their context, i.e. previous and following value if present.