Thursday, November 20, 2008

Bala

Copperbox revision 346.

I've added a new module to Bala for 'focused' shape and contents traversals.

It allows quite sophisticated operations like this:


retrograde :: Motif -> Motif
retrograde = rejoin pitchFocus . second reverse . separate pitchFocus


Here retrograde reverses just the pitch content of a motif, and not the rhythmic content. If you had a motif like this one (where qn is a quarter note and hn as a half note):


C qn, rest qn, D hn, E hn


The result would be


E qn, rest qn, D hn, C hn


The functions separate and rejoin work like decompose and reassemble from the paper 'The Essence of the Iterator Pattern' [Gibbons & Oliveira], but they have a special focusing mechanism that in this case extracts pitches as the content rather than the 'outer' datatype. In this case the outer datatype is a sum type that holds notes, chords and rests, etc. not all of which actually have a pitch attribute.

Blog Archive

About Me

My photo
Disambiguating biog as there are a few Stephen Tetley's in the world. I'm neither a cage fighter or yachtsman. I studied Fine Art in the nineties (foundation Bradford 1992, degree Cheltenham 1992 - 95) then Computing part-time at Leeds Met graduating in 2003. I'm the Stephen Tetley on Haskell Cafe and Stackoverflow.