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 [Stretched a] (Voice a)
- stretcheds :: Lens (Voice a) (Voice b) [Stretched a] [Stretched b]
- eventsV :: Lens (Voice a) (Voice b) [(Duration, a)] [(Duration, b)]
- singleStretched :: Prism' (Voice a) (Stretched a)
- 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)
- valuesV :: Lens (Voice a) (Voice b) [a] [b]
- durationsV :: Lens' (Voice a) [Duration]
- withValues :: ([a] -> [b]) -> Voice a -> Voice b
- withDurations :: ([Duration] -> [Duration]) -> Voice a -> Voice a
- rotateValues :: Int -> Voice a -> Voice a
- rotateDurations :: Int -> Voice a -> Voice a
- reverseValues :: Voice a -> Voice a
- reverseDurations :: Voice a -> Voice a
- unzipVoice :: Voice (a, b) -> (Voice a, Voice b)
- zipVoice :: Voice a -> Voice b -> Voice (a, b)
- zipVoice3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c))
- zipVoice4 :: 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)))
- zipVoiceWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice c
- zipVoiceWith' :: (Duration -> Duration -> Duration) -> (a -> b -> c) -> Voice a -> Voice b -> Voice c
- zipVoiceWithNoScale :: (a -> b -> c) -> Voice a -> Voice b -> Voice c
- withContext :: Voice a -> Voice (Ctxt a)
- voiceLens :: (s -> a) -> (b -> s -> t) -> Lens (Voice s) (Voice t) (Voice a) (Voice b)
- voiceAsList :: Iso (Voice a) (Voice b) [a] [b]
- listAsVoice :: Iso [a] [b] (Voice a) (Voice b)
- unsafeStretcheds :: Iso (Voice a) (Voice b) [Stretched a] [Stretched b]
- unsafeEventsV :: Iso (Voice a) (Voice b) [(Duration, a)] [(Duration, b)]
Voice type
A Voice
is a sequential composition of values. Events may not overlap.
Construction
Extracting values
stretcheds :: Lens (Voice a) (Voice b) [Stretched a] [Stretched b] Source
View a Voice
as a list of Stretched
values.
view
stretcheds
::Voice
a -> [Stretched
a]set
stretcheds
:: [Stretched
a] ->Voice
a ->Voice
aover
stretcheds
:: ([Stretched
a] -> [Stretched
b]) ->Voice
a ->Voice
b
preview
(stretcheds
.each
) ::Voice
a ->Maybe
(Stretched
a)preview
(stretcheds
.element
1) ::Voice
a ->Maybe
(Stretched
a)preview
(stretcheds
.elements
odd) ::Voice
a ->Maybe
(Stretched
a)
set
(stretcheds
.each
) ::Stretched
a ->Voice
a ->Voice
aset
(stretcheds
.element
1) ::Stretched
a ->Voice
a ->Voice
aset
(stretcheds
.elements
odd) ::Stretched
a ->Voice
a ->Voice
a
over
(stretcheds
.each
) :: (Stretched
a ->Stretched
b) ->Voice
a ->Voice
bover
(stretcheds
.element
1) :: (Stretched
a ->Stretched
a) ->Voice
a ->Voice
aover
(stretcheds
.elements
odd) :: (Stretched
a ->Stretched
a) ->Voice
a ->Voice
a
toListOf
(stretcheds
.each
) ::Voice
a -> [Stretched
a]toListOf
(stretcheds
.elements
odd) ::Voice
a -> [Stretched
a]toListOf
(stretcheds
.each
.filtered
(\x ->_duration
x < 2)) ::Voice
a -> [Stretched
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
stretcheds
) empty
singleStretched :: Prism' (Voice a) (Stretched a) Source
Deprecated: Use 'unsafeStretcheds . single'
Fusion
fuseBy :: (a -> a -> Bool) -> Voice a -> Voice a Source
Merge consecutive equal notes using the given function.
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.
Traversal
Separating rhythms and values
durationsV :: Lens' (Voice a) [Duration] Source
withValues :: ([a] -> [b]) -> Voice a -> Voice b Source
Transform the values, leaving durations intact.
withDurations :: ([Duration] -> [Duration]) -> Voice a -> Voice a Source
Transform the durations, leaving values intact.
rotateValues :: Int -> Voice a -> Voice a Source
Rotate values by the given number of steps, leaving durations intact.
rotateDurations :: Int -> Voice a -> Voice a Source
Rotate durations by the given number of steps, leaving values intact.
reverseValues :: Voice a -> Voice a Source
Reverse values, leaving durations intact.
reverseDurations :: Voice a -> Voice a Source
Reverse durations, leaving values intact.
Zips
unzipVoice :: Voice (a, b) -> (Voice a, Voice b) Source
Unzip the given voice. This is specialization of unzipR
.
zipVoice :: Voice a -> Voice b -> Voice (a, b) Source
Join the given voices by multiplying durations and pairing values.
zipVoice3 :: Voice a -> Voice b -> Voice c -> Voice (a, (b, c)) Source
Join the given voices by multiplying durations and pairing values.
zipVoice4 :: 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.
zipVoiceWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice c Source
Join the given voices by multiplying durations and combining values using the given function.
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.
zipVoiceWithNoScale :: (a -> b -> c) -> Voice a -> Voice b -> Voice c Source
Join the given voices without combining durations.
Context
withContext :: Voice a -> Voice (Ctxt a) Source
voiceAsList :: Iso (Voice a) (Voice b) [a] [b] Source
listAsVoice :: Iso [a] [b] (Voice a) (Voice b) Source