music-suite / music-score

This repo has been merged into: https://github.com/music-suite/music-suite
http://music-suite.github.io
BSD 3-Clause "New" or "Revised" License
52 stars 10 forks source link

Handle duplicated meta-info upon filter and recompose? #103

Closed hanshoglund closed 10 years ago

hanshoglund commented 11 years ago

For example

x <> y where (x,y) = mpartition pred a
hanshoglund commented 11 years ago

I believe this is mainly a matter of choosing the right Monoids for meta-info. Maybe-based ones are OK, list-based ones are not. This makes sense, as meta-info is really not supposed to handle occurences, but (potentially) variable properties.

For list-like types (i.e. annotations), it might be sufficient to use nub. Consider

import Control.Arrow
import Data.AffineSpace.Relative
import Music.Prelude.Basic

mapIf p f = uncurry mplus . first f . mpartition p
accentConsonances p = mapIf (isConsonance . (.-. asPitch p) . head . getPitches) accentAll

main = open $ showAnnotations $ accentConsonances c $ annotate "H" $ scat [c..c']
hanshoglund commented 10 years ago

Fixed, wrote a sketchy paragraph in the User Guide explaining how list-based Monoids can not be used.