\version "2.19.64" #(use-modules (ice-9 regex)) %% to make things work here, 'parse-simple-duration' is not public #(define parse-simple-duration (@@ (lily) parse-simple-duration)) %% changed rest-markup #(define-markup-command (rest layout props duration) (string?) #:category music #:properties ((style '()) (word-space 0.6)) ;; No need to check `duration' for validity, `parse-simple-duration' will ;; throw an error in this case anyway (let* (;; Get a (log dots) list. (parsed (parse-simple-duration duration))) (rest-by-number-markup layout props (car parsed) (cadr parsed)))) %% new mm-rest-markup #(define-markup-command (mm-rest layout props duration) (string?) #:category music #:properties ((style '()) (multi-measure-rest-number #t) (word-space 0.6)) ;; Get the number of mmr-glyphs. ;; Store them in a list. ;; example: (mmr-numbers 25) -> '(3 0 0 1) (define (mmr-numbers nmbr) (define (helper i init ls) (if (not (integer? init)) (reverse ls) (helper (remainder i init) (/ init 2) (cons (floor (/ i init)) ls)))) ;; helper is called with the longest mmr-glyph-duration, i.e. 'init = 8' (helper nmbr 8 '())) ;; Get the correct mmr-glyphs. ;; Store them in a list. ;; example: ;; (get-mmr-glyphs '(1 0 1 0) '("rests.M3" "rests.M2" "rests.M1" "rests.0")) ;; -> ("rests.M3" "rests.M1") (define (get-mmr-glyphs lst1 lst2) (append-map! make-list lst1 lst2)) ;; If duration is not valid, print a warning and return empty-stencil (if (not (and (integer? (string->number duration)) (exact? (string->number duration)))) (begin (ly:warning (_ "not a valid duration string: ~a - ignoring") duration) empty-stencil) (let* ((dur (string->number duration)) ;; Get a list of the correct number of each mmr-glyph. (count-mmr-glyphs-list (mmr-numbers dur)) ;; Create a list of mmr-stencils, ;; translating the glyph for a whole rest. (mmr-stils-list (map (lambda (x) (let ((single-mmr-stil (interpret-markup layout props (make-override-markup (cons 'multi-measure-rest #t) (make-rest-by-number-markup (* -1 x) 0))))) (if (= x 0) (ly:stencil-translate-axis single-mmr-stil ;; Ugh, hard-coded, why 1? 1 Y) single-mmr-stil))) (get-mmr-glyphs count-mmr-glyphs-list (iota 4 3 -1)))) ;; Adjust the space between the mmr-glyphs, ;; if not default-glyphs are used. (word-space (if (member style '(neomensural mensural petrucci)) (/ (* word-space 2) 3) word-space)) ;; Create the final mmr-stencil ;; via `stack-stencil-line´ from /scm/markup.scm (mmr-stil (stack-stencil-line word-space mmr-stils-list))) ;; Print the number above a multi-measure-rest ;; Depends on duration, style and multi-measure-rest-number set #t (if (and multi-measure-rest-number (> dur 1) (not (member style '(neomensural mensural petrucci)))) (let* ((mmr-stil-x-center (interval-center (ly:stencil-extent mmr-stil X))) (duration-markup (markup #:fontsize -2 #:override '(font-encoding . fetaText) duration)) (mmr-number-stil (interpret-markup layout props duration-markup)) (mmr-number-stil-x-center (interval-center (ly:stencil-extent mmr-number-stil X)))) (set! mmr-stil (ly:stencil-combine-at-edge mmr-stil Y UP (ly:stencil-translate-axis mmr-number-stil (- mmr-stil-x-center mmr-number-stil-x-center) X) ;; Ugh, hardcoded 0.8)))) mmr-stil))) %% from regtest ‘markup-rest.ly’ %% unchanged showSimpleRest = #(define-scheme-function (dots) (string?) (make-override-markup (cons 'baseline-skip 7) (make-column-markup (map (lambda (style) (make-line-markup (list (make-pad-to-box-markup '(0 . 20) '(0 . 0) (symbol->string style)) (make-override-markup (cons 'line-width 60) (make-override-markup (cons 'style style) (make-fill-line-markup (map (lambda (duration) (make-rest-markup (if (string? duration) duration (string-append (number->string (expt 2 duration)) dots)))) (append '("maxima" "longa" "breve") (iota 8))))))))) '(default mensural neomensural classical baroque altdefault petrucci blackpetrucci semipetrucci kievan))))) %% changed see "!!!!!!" showMultiMeasureRests = #(define-scheme-function ()() (make-override-markup (cons 'baseline-skip 7) (make-column-markup (map (lambda (style) (make-line-markup (list (make-pad-to-box-markup '(0 . 20) '(0 . 0) (symbol->string style)) (make-override-markup (cons 'line-width 80) (make-override-markup (cons 'style style) (make-fill-line-markup (map (lambda (duration) (make-line-markup (list ;; "!!!!!!" ;;- (make-override-markup ;;- (cons 'multi-measure-rest #t) ;;- (make-rest-markup ;;- (number->string duration)))))) (make-mm-rest-markup (number->string duration))))) (cdr (iota 13))))))))) '(default mensural neomensural classical baroque altdefault petrucci blackpetrucci semipetrucci kievan))))) \markup \box \fill-line { \center-column { \bold "Simple Rests" "from ‘markup-rest.ly’" } } \showSimpleRest #"." \markup \box \fill-line { \center-column { \bold "MultiMeasureRests" "from ‘markup-rest.ly’" } } \showMultiMeasureRests