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

Change definition of HasPosition and derived position/era/onset etc. #314

Closed hanshoglund closed 9 years ago

hanshoglund commented 9 years ago

HasPosition can be thought to provide for each positioned value:

Because the function is linear, the two definitions are equivalent.

New definition:

class HasPosition a where
  _era      :: a -> Span
  _position :: a -> (LocalDuration -> Time)
  _era x    = (_position 0, _position 1)
  _position x l = alerp a b l where (a,b) = _era x

position :: (HasPosition a, Transformable a) => Duration -> Lens' a Time
era :: (HasPosition a, Transformable a) => Lens' a Span
onset = position 0
_onset = _position 0
offset = position 1
_offset = _position 1
-- etc