\version "2.19.40" #(set-global-staff-size 18) #(define mark-alphabets `((alphabet . ,(list->vector (string->list "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) (omit-i . ,(list->vector (string->list "ABCDEFGHJKLMNOPQRSTUVWXYZ"))) (omit-j . ,(list->vector (string->list "ABCDEFGHIKLMNOPQRSTUVWXYZ"))))) #(define (mark-generic-string number alphabet uppercase? repeat?) (let* ((the-alphabet (assq-ref mark-alphabets alphabet)) (the-alphabet-length (vector-length the-alphabet)) (the-string (if repeat? (let ((the-length (1+ (quotient (1- number) the-alphabet-length))) (the-index (remainder (1- number) the-alphabet-length))) (make-string the-length (vector-ref the-alphabet the-index))) (let loop ((num (1- number))) (if (< num the-alphabet-length) (string (vector-ref the-alphabet num)) (string-append (loop (1- (quotient num the-alphabet-length))) (loop (remainder num the-alphabet-length)))))))) (if uppercase? the-string (string-capitalize the-string)))) #(define-markup-command (mark-generic layout props number alphabet uppercase? repeat?) (integer? symbol? boolean? boolean?) #:category other (ly:text-interface::interpret-markup layout props (mark-generic-string number alphabet uppercase? repeat?))) #(define (format-mark-generic alphabet framed bold? uppercase? repeat?) (lambda (number context) (let* ((the-string (case alphabet ((barnumbers) (number->string (ly:context-property context 'currentBarNumber))) ((arabic) (number->string number)) ((roman) (if uppercase? (format #f "address@hidden" number) (string-downcase (format #f "address@hidden" number)))) (else (make-mark-generic-markup number alphabet uppercase? repeat?)))) (the-framed-string (case framed ((box) (make-box-markup the-string)) ((circle) (make-circle-markup the-string)) ((oval) (make-oval-markup the-string)) ((#f) the-string)))) (if bold? (make-bold-markup the-framed-string) the-framed-string)))) \paper { indent = 0 ragged-last = ##f ragged-last-bottom = ##f score-system-spacing.basic-distance = 5 } \header { title = "format-mark-generic" subtitle = "a versatile markFormatter function" composer = "Malte Meyn" } foo = { R1 \mark 1 R \mark 8 R \mark 9 R \mark 10 R \mark 26 R \mark 27 R \mark 28 R \mark 52 R \mark 53 R } \markup "Use barnumbers, …" \new Score \with { markFormatter = #(format-mark-generic 'barnumbers #f #t '() '()) } \foo \markup "… arabic numbers, …" \new Score \with { markFormatter = #(format-mark-generic 'arabic #f #t '() '()) } \foo \markup "… roman numbers, …" \new Score \with { markFormatter = #(format-mark-generic 'roman #f #t #t '()) } \foo \markup "… or the latin alphabet (optionally omitting either I or J), …" \new Score \with { markFormatter = #(format-mark-generic 'alphabet #f #t #t #f) } \foo \new Score \with { markFormatter = #(format-mark-generic 'omit-i #f #t #t #f) } \foo \new Score \with { markFormatter = #(format-mark-generic 'omit-j #f #t #t #f) } \foo \markup "… combine letters after Z (as shown above) or use repeated letters, …" \new Score \with { markFormatter = #(format-mark-generic 'alphabet #f #t #t #t) } \foo \markup "… use lowercase/mixed case variants, …" \new Score \with { markFormatter = #(format-mark-generic 'roman #f #t #f '()) } \foo \new Score \with { markFormatter = #(format-mark-generic 'alphabet #f #t #f #t) } \foo %\pageBreak \markup "… put the mark into a box, circle, or oval, …" \new Score \with { markFormatter = #(format-mark-generic 'alphabet 'box #t #f #t) } \foo \new Score \with { markFormatter = #(format-mark-generic 'alphabet 'circle #t #f #t) } \foo \new Score \with { markFormatter = #(format-mark-generic 'alphabet 'oval #t #f #t) } \foo \markup "… use a medium font, …" \new Score \with { markFormatter = #(format-mark-generic 'alphabet #f #f #f #t) } \foo \markup \justify-string #"… and combine any of these options! Any of LilyPond’s original format-mark-??? functions can be imitated and much more is possible through one single function. Usage: \\set Score.markFormatter = #(format-mark-generic alphabet framed bold? uppercase? repeat?) • alphabet can be one of 'alphabet 'omit-i 'omit-j 'barnumbers 'arabic 'roman • framed can be one of 'box 'circle 'oval #f (the latter for no frame) • bold? is #t for bold and #f for medium font • uppercase? is #t for uppercase and #f for lowercase (roman numbers) or mixed case (letters) • repeat? is #t for repeated and #f for combined letters"