Portability | non-portable (TF,GNTD) |
---|---|
Stability | experimental |
Maintainer | hans@hanshoglund.se |
Safe Haskell | None |
Provides the Voice
type.
- data Voice a
- voice' :: Iso' [(Duration, a)] (Voice a)
- voice :: Iso [(Duration, a)] [(Duration, b)] (Voice a) (Voice b)
- zipVoice :: Voice a -> Voice b -> Voice (a, b)
- zipVoiceWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice c
- dzipVoiceWith :: (Duration -> Duration -> a -> b -> (Duration, c)) -> Voice a -> Voice b -> Voice c
- mergeEqual :: Eq a => Voice a -> Voice a
Voice type
A voice is a list of events with explicit duration. Events can not overlap.
Voice is a Monoid
under sequential composition. mempty
is the empty part and mappend
appends parts.
Voice is a Monad
. return
creates a part containing a single value of duration
one, and >>=
transforms the values of a part, allowing the addition and
removal of values under relative duration. Perhaps more intuitively, join
scales
each inner part to the duration of the outer part, then removes the
intermediate structure.
let p = Voice [(1, Just 0), (2, Just 1)] :: Voice Int p >>= \x -> Voice [ (1, Just $ toEnum $ x+65), (3, Just $ toEnum $ x+97) ] :: Voice Char ===> Voice {getVoice = [ (1 % 1,Just 'A'), (3 % 1,Just 'a'), (2 % 1,Just 'B'), (6 % 1,Just 'b') ]}
Voice is a VectorSpace
using sequential composition as addition, and time scaling
as scalar multiplication.
Monad Voice | |
Functor Voice | |
Typeable1 Voice | |
Applicative Voice | |
Foldable Voice | |
Traversable Voice | |
Eq a => Eq (Voice a) | |
Num a => Num (Voice a) | |
Ord a => Ord (Voice a) | |
Show a => Show (Voice a) | |
Monoid (Voice a) | |
Semigroup (Voice a) | |
Wrapped (Voice a) | |
IsDynamics a => IsDynamics (Voice a) | |
IsPitch a => IsPitch (Voice a) | |
IsInterval a => IsInterval (Voice a) | |
Stretchable (Voice a) | |
HasDuration (Voice a) | |
(HasSetPitch a b, Transformable (Pitch a), Transformable (Pitch b)) => HasSetPitch (Voice a) (Voice b) |
voice :: Iso [(Duration, a)] [(Duration, b)] (Voice a) (Voice b)Source
Create a voice from a list of events.
zipVoice :: Voice a -> Voice b -> Voice (a, b)Source
Join the given voices by multiplying durations and pairing values.
zipVoiceWith :: (a -> b -> c) -> Voice a -> Voice b -> Voice cSource
Join the given voices by multiplying durations and combining values using the given function.
dzipVoiceWith :: (Duration -> Duration -> a -> b -> (Duration, c)) -> Voice a -> Voice b -> Voice cSource
Join the given voices by combining durations and values using the given function.
mergeEqual :: Eq a => Voice a -> Voice aSource
Merge consecutive equal note.