\version "2.19.23" off = #(define-music-function (spec event) (pair? ly:music?) "Shift grobs using X- and Y-offset, with outside-staff-priority unset by default. Provides dedicated input modes for Dynamics in order to handle the tricky interaction with DynamicLineSpanner and both settings of outside-staff-priority. " ;; default values (define x-off 0) (define y-off 0) (define inside-staff? #t) (define dynamic? #f) (define dyn-line-off 0) (define (spec-type? spec symbol-list) (and (list? spec) (member (car spec) symbol-list))) ;; Apply tweak only if cond? is true (define (cond-tweak cond? prop val arg) (if cond? (tweak prop val arg) arg)) ;; differentiate between spec-types (cond ((number-pair? spec) (set! x-off (car spec)) (set! y-off (cdr spec))) ;; Offset DynamicText and Hairpin. ((spec-type? spec '(dynamic dyn d)) (set! dynamic? #t) (set! x-off (second spec)) (set! y-off (third spec))) ;; Offset DynamicLineSpanner; Y-offset only ((spec-type? spec '(dynamic-line dyn-line dl)) ;; Allow requiring outside-staff placement ;; by giving #f as an additional element. (if (= 3 (length spec)) (set! inside-staff? (third spec))) (set! dyn-line-off (second spec))) (else (ly:warning "Cannot read specification for offset - using default values."))) (cond-tweak inside-staff? 'outside-staff-priority #f (offset 'X-offset x-off (offset 'Y-offset y-off (cond-tweak (and dynamic? inside-staff?) '(DynamicLineSpanner outside-staff-priority) #f (offset '(DynamicLineSpanner Y-offset) dyn-line-off event)))))) \relative { \hideNotes \dynamicUp b'2-\off #'(dl 0) -\off #'(d 0 0) \< 2\f\> 2 2\!\< 2\f }