music-score-1.9.0: Musical score and part representation.

Copyright(c) Hans Hoglund 2012-2014
LicenseBSD-style
Maintainerhans@hanshoglund.se
Stabilityexperimental
Portabilitynon-portable (TF,GNTD)
Safe HaskellNone
LanguageHaskell2010

Music.Time.Voice

Contents

Description

 

Synopsis

Voice type

data Voice a Source

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.

Instances

Alternative Voice 
Monad Voice 
Functor Voice 
MonadPlus Voice 
Applicative Voice 
Foldable Voice 
Traversable Voice 
(HasPart' a, HasMidiProgram (Part a)) => HasBackendScore Midi (Voice a) 
HasBackendScore SuperCollider (Voice (Maybe a)) 
Enum a => Enum (Voice a) 
Eq a => Eq (Voice a) 
Num a => Num (Voice a) 
Ord a => Ord (Voice a) 
(Show a, Transformable a) => Show (Voice a) 
IsString a => IsString (Voice a) 
Monoid (Voice a) 
Wrapped (Voice a) 
Semigroup (Voice a) 
IsPitch a => IsPitch (Voice a) 
IsInterval a => IsInterval (Voice a) 
IsDynamics a => IsDynamics (Voice a) 
ToJSON a => ToJSON (Voice a) 
FromJSON a => FromJSON (Voice a) 
Transformable (Voice a) 
HasDuration (Voice a) 
(Transformable a, Splittable a) => Splittable (Voice a) 
Reversible a => Reversible (Voice a) 
HasSlide a => HasSlide (Voice a) 
HasText a => HasText (Voice a) 
HasColor a => HasColor (Voice a) 
Rewrapped (Voice a) (Voice b) 
HasParts a b => HasParts (Voice a) (Voice b) 
HasPitches a b => HasPitches (Voice a) (Voice b) 
HasDynamics a b => HasDynamics (Voice a) (Voice b) 
HasArticulations a b => HasArticulations (Voice a) (Voice b) 
HasPhrases (PVoice a) (PVoice b) a b 
HasPhrases (MVoice a) (MVoice b) a b

Traverses all phrases in a voice.

Snoc (Voice a) (Voice b) (Note a) (Note b) 
Cons (Voice a) (Voice b) (Note a) (Note b) 
Typeable (* -> *) Voice 
type SetPart g (Voice a) = Voice (SetPart g a) 
type SetPitch b (Voice a) = Voice (SetPitch b a) 
type SetDynamic b (Voice a) = Voice (SetDynamic b a) 
type SetArticulation b (Voice a) = Voice (SetArticulation b a) 
type BackendScoreEvent Midi (Voice a) = a 
type BackendScoreEvent SuperCollider (Voice (Maybe a)) = a 
type Unwrapped (Voice a) = [Note a] 
type Part (Voice a) = Part a 
type Pitch (Voice a) = Pitch a 
type Dynamic (Voice a) = Dynamic a 
type Articulation (Voice a) = Articulation a 

Construction

voice :: Getter [Note a] (Voice a) Source

Create a Voice from a list of Notes.

notes :: Lens (Voice a) (Voice b) [Note a] [Note b] Source

View a Voice as a list of Note values.

pairs :: Lens (Voice a) (Voice b) [(Duration, a)] [(Duration, b)] Source

View a score as a list of duration-value pairs. Analogous to triples.

Traversal

Separating rhythms and values

valuesV :: Lens (Voice a) (Voice b) [a] [b] Source

A lens to the values in a voice.

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

fuse :: Eq a => Voice a -> Voice a Source

Merge consecutive equal notes.

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.

Unsafe versions

unsafeNotes :: Iso (Voice a) (Voice b) [Note a] [Note b] Source

A voice is a list of notes up to meta-data. To preserve meta-data, use the more restricted voice and notes.

unsafePairs :: Iso (Voice a) (Voice b) [(Duration, a)] [(Duration, b)] Source

A score is a list of (duration-value pairs) up to meta-data. To preserve meta-data, use the more restricted pairs.