% Harm's ottavation code, lifted from % https://lists.gnu.org/archive/html/lilypond-user/2017-02/msg00406.html \version "2.19.52" %% Define new context-property 'ottavaText' #(define (define-translator-property symbol type? description) (if (not (and (symbol? symbol) (procedure? type?) (string? description))) (ly:error "error in call of define-translator-property")) (if (not (equal? (object-property symbol 'translation-doc) #f)) (ly:error (_ "symbol ~S redefined") symbol)) (set-object-property! symbol 'translation-type? type?) (set-object-property! symbol 'translation-doc description) symbol) #(for-each (lambda (x) (apply define-translator-property x)) `((ottavaText ,list? "An alist of pairs with ottavation-number and markup."))) %% Redefine 'make-ottava-set' #(define (make-ottava-set music) "Set context properties for an ottava bracket." (let ((octavation (ly:music-property music 'ottava-number)) (labels '((2 . "15ma") (1 . "8va") (0 . #f) (-1 . "8vb") (-2 . "15mb")))) (list (context-spec-music (make-apply-context (lambda (context) (let* ((offset (* -7 octavation)) (ctx-label-list (ly:context-property context 'ottavaText)) (string (assoc-get octavation (if (null? ctx-label-list) labels ctx-label-list)))) (set! (ly:context-property context 'middleCOffset) offset) (set! (ly:context-property context 'ottavation) string) (ly:set-middle-C! context)))) 'Staff)))) %% Redefine 'ottava' ottava = #(define-music-function (octave) (integer?) (_i "Set the octavation.") (make-music 'OttavaMusic 'elements-callback make-ottava-set 'ottava-number octave)) %%%%%%%%%%%%%%%%%%%%%