A function to repeatedly print a given pattern with different notes

This snippet describes a function \changePitch, to repeatedly print a given rhythm with different notes. Its syntax is
\changePitch \pattern \newnotes
This will replace notes in \pattern by notes in \newnotes. If the note-count in \newnotes is greater, the pattern is copied repeatedly. Rests or skips are allowed, and the function also works for chords. More detailed documentation (in pdf format), and also the most recent "changePitch.ly" can be found here.