\version "2.19.15" #(define (get-pitch elt) (ly:music-property elt 'pitch)) #(define (extract-pitches lst result) (cond ((null? lst) result) ((ly:pitch? (get-pitch (car lst))) (set! result (append result (list (get-pitch (car lst))))) (extract-pitches (cdr lst) result)) ((ly:music-property (car lst) 'elements) (append (extract-pitches (ly:music-property (car lst) 'elements) result) (extract-pitches (cdr lst) '()))) (else (extract-pitches (cdr lst) result)))) extractPitches = #(define-scheme-function (parser location lst) (ly:music?) (extract-pitches (extract-named-music lst '(EventChord NoteEvent)) '()) ) #(define (t lst) (let loop ((t lst) (result "")) (if (null? t) result (loop (cdr t) (string-append result "\"" (if (symbol? (car t)) ;; this mess is just for testing (symbol->string (car t)) (number->string (ly:pitch-notename (car t)))) "\"" " "))))) noteNameToLyric = #(define-void-function (parser location lst) (list?) (let* ((str (t lst)) (str (string-append "{ " str "}"))) (display str) (newline) (ly:parser-include-string parser (string-append "\\new Lyrics \\lyricmode " str)))) music = \relative c' { c4 d e f g a b c } %% This works << \new Staff \music \noteNameToLyric #'(c d e f g a b c) >> %% Tis doesn't << \new Staff \music \noteNameToLyric \extractPitches \music >>