\version "2.19.25" % TODO: rename malte-length and malte-abs-time? % TODO: rename replace-all-in-all? % adds property 'malte-length to all music add-length = #(define-music-function (music) (ly:music?) (music-map (lambda (m) (ly:music-set-property! m 'malte-length (ly:music-length m)) m) music)) % adds property 'malte-abs-time (time since beginning) to all music add-abs-time = #(define-music-function (music) (ly:music?) (let loop ((cur-time (ly:make-moment 0)) (music music)) (ly:music-set-property! music 'malte-abs-time cur-time) (cond ((music-is-of-type? music 'music-wrapper-music) (loop cur-time (ly:music-property music 'element)) music) ((music-is-of-type? music 'simultaneous-music) (map (lambda (element) (loop cur-time element)) (ly:music-property music 'elements)) music) ((music-is-of-type? music 'sequential-music) (map (lambda (element) (loop cur-time element) (set! cur-time (ly:moment-add cur-time (ly:music-property element 'malte-length)))) (ly:music-property music 'elements)) music) (else music)))) % extracts music between begin-moment (inclusive) and end-moment (exclusive), % correctly extracting only parts of quotes (but not yet other wrappers like tuplets) extract-music-between = #(define-music-function (begin-moment end-moment original-music) (ly:moment? ly:moment? ly:music?) (let ((music (ly:music-deep-copy original-music))) ; TODO: deep-copy necessary? (let loop ((music music)) (cond ((eq? (ly:music-property music 'name) 'QuoteMusic) (let* ((quote-begin (ly:music-property music 'malte-abs-time)) (quote-end (ly:moment-add quote-begin (ly:music-property music 'malte-length))) (shortened? #f)) (if (ly:moment> % instead of % \useAndAlignTo \global \bassoon % because bassoon is now already aligned (and \bassoon instead of % \alignTo \bassoon). replaceQuotes = #(define-void-function () () (let ((replaced-quotes-list (replace-all-in-all quotes-alist))) (for-each (lambda (element-qal element-rql) (ly:parser-define! (string->symbol (car element-qal)) element-rql)) quotes-alist replaced-quotes-list)))