I wanted to get the output:
{ c'8 c'' d' d'' e' e'' } %etc.
by
typing:
{ \changePitch \test { c' d' e' } }
Ok, i understand now.
Well, i think the \brokenOctaves has to be a little
more complex.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.12"
\include
"changePitch.ly"
brokenOctaves = #(define-music-function (parser location music)
(ly:music?)
(let loop ((x music))
(let ((e (ly:music-property x
'element))
(es (ly:music-property
x 'elements)))
(cond
((eq? 'EventChord (ly:music-property x
'name))
(if (and (pair?
es)
(eq? 'NoteEvent (ly:music-property (car es)
'name)))
(set! x
(make-sequential-music
(list
x
#{\transpose c c' $x #})))))
(else
(if (ly:music? e)
(ly:music-set-property! x 'element (loop
e)))
(if (pair?
es)(ly:music-set-property! x 'elements (map loop es))))))
x))
test = { c8. c16}
\new Staff { \changePitch \test
\brokenOctaves { c' d' e' } }