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

Portabilitynon-portable (TF,GNTD)
Stabilityexperimental
Maintainerhans@hanshoglund.se
Safe HaskellNone

Music.Score.Combinators

Contents

Description

Combinators for manipulating scores and related structures.

Synopsis

Basic

note :: Monad m => a -> m aSource

Create a score containing a note at time zero and duration one. This is an alias for return.

rest :: MonadPlus m => m (Maybe a)Source

Create a score containing a rest at time zero and duration one. This is an alias for return Nothing.

noteRest :: MonadPlus m => Maybe a -> m aSource

Create a note or a rest at time zero and duration one. This is an alias for mfromMaybe.

removeRests :: MonadPlus m => m (Maybe a) -> m aSource

Remove all rests from a score. This is an alias for mcatMaybes.

Mapping over events

mapEvents :: (Time -> Duration -> a -> b) -> Score a -> Score bSource

Map over the events in a score.

Filtering events

Editing

filterEvents :: (Time -> Duration -> a -> Bool) -> Score a -> Score aSource

Filter the events in a score.

mapFilterEvents :: (Time -> Duration -> a -> Maybe b) -> Score a -> Score bSource

Efficient combination of mapEvents and filterEvents.

Editing

before :: Time -> Score a -> Score aSource

Retain only the notes whose offset does not fall after the given time.

after :: Time -> Score a -> Score aSource

Retain only the notes whose onset does not fall before the given time.

split :: Time -> Score a -> (Score a, Score a)Source

Split a score into events whose onsets

slice :: Time -> Time -> Score a -> Score aSource

Returns notes whose onset and offset fall between the given times.

splice :: Time -> Duration -> Score a -> (Score a, Score a, Score a)Source

Split a score into three parts

Meta-events

metaAt :: (HasPart' a, IsAttribute b) => Time -> Score a -> bSource

withMeta :: (IsAttribute a, HasPart' b) => (a -> Score b -> Score b) -> Score b -> Score bSource

withGlobalMeta :: IsAttribute a => (a -> Score b -> Score b) -> Score b -> Score bSource

withMetaAtStart :: (IsAttribute a, HasPart' b) => (a -> Score b -> Score b) -> Score b -> Score bSource

Map over phrases

mapFirst :: HasPart' a => (a -> b) -> (a -> b) -> Score a -> Score bSource

Map over the first, and remaining notes in each part.

If a part has only one notes, the first function is applied. If a part has no notes, it is returned unchanged.

mapLast :: HasPart' a => (a -> b) -> (a -> b) -> Score a -> Score bSource

Map over the last, and preceding notes in each part.

If a part has only one notes, the first function is applied. If a part has no notes, it is returned unchanged.

mapPhrase :: HasPart' a => (a -> b) -> (a -> b) -> (a -> b) -> Score a -> Score bSource

Map over the first, middle and last note in each part.

If a part has fewer than three notes the first takes precedence over the last, and last takes precedence over the middle.

mapPhraseSingle :: (a -> b) -> (a -> b) -> (a -> b) -> Score a -> Score bSource

Equivalent to mapPhrase for single-part scores.

Fails if the score contains overlapping events.

 (a -> b) -> (a -> b) -> (a -> b) -> Score a -> Score b

Parts

Extracting parts

filterPart :: HasPart' a => (Part a -> Bool) -> Score a -> Score aSource

Deprecated:

Filter a score to include only those events whose parts match a given predicate.

extractParts :: HasPart' a => Score a -> [Score a]Source

Deprecated:

Extract parts from the a score.

The parts are returned in the order defined the associated Ord instance part type.

extractParts' :: HasPart' a => Score a -> [(Part a, Score a)]Source

Deprecated:

Extract parts from the a score and include the part name.

The parts are returned in the order defined the associated Ord instance part type.

Map over parts

mapParts :: HasPart' a => (Score a -> Score b) -> Score a -> Score bSource

Deprecated:

Map over all parts in the given score.

 (Score a -> Score a) -> Score a -> Score a

mapAllParts :: HasPart' a => ([Score a] -> [Score b]) -> Score a -> Score bSource

Deprecated:

Map over all parts in the given score.

 ([Score a] -> [Score a]) -> Score a -> Score a

Part composition

(</>) :: (HasPart' a, Enum (Part a)) => Score a -> Score a -> Score aSource

Similar to <>, but increases parts in the second part to prevent collision.

rcat :: (HasPart' a, Enum (Part a)) => [Score a] -> Score aSource

Concatenate parts.

Zippers

Single-part versions

applySingle :: Voice (Score a -> Score b) -> Score a -> Score bSource

Deprecated:

Apply a time-varying function to all events in score.