\version "2.19.46" % angle brackets cause SVG error so reformat: % # becomes [Mom 1] #(define (reformat-moment mom) (let* ((mom (format #f "~a" mom)) (mom (string-drop mom 2)) (mom (string-drop-right mom 1))) (string-concatenate (list "[" mom "]")))) % Start Clef Helpers #(define clef-map '(("clefs.C" . ((0 . "alto") (2 . "tenor"))) ("clefs.C_change" . ((0 . "alto") (2 . "tenor"))) ("clefs.F" . ((2 . "bass"))) ("clefs.F_change" . ((2 . "bass"))) ("clefs.G" . ((-2 . "treble"))) ("clefs.G_change" . ((-2 . "treble"))))) #(define (get-clef-string glyph pos) (let* ((clef-map-glyph (assoc-get glyph clef-map)) (name (and clef-map-glyph (assoc-get pos clef-map-glyph)))) (if (and clef-map-glyph name) (format #f "~a" name) (format #f "~a at ~a" glyph pos)))) % End Clef Helpers % Help with alist #(define (concat_alist lis) (if (eq? (length lis) 0) "ZeroList" (if (eq? (length lis) 1) (string-append (string-append (number->string(car(list-ref lis 0))) "," ) (string-append (number->string(cdr(list-ref lis 0))) ",," ) ) (string-append (string-append (string-append (number->string(car(list-ref lis 0))) "," ) (string-append (number->string(cdr(list-ref lis 0))) ",,") ) (concat_alist (list-tail lis 1))) ) ) ) % grob name + absolute moment + (system) coordinates should be enough for a unique id... #(define (get-unique-id grob) (let* ((sys (ly:grob-system grob)) (name (grob::name grob)) (str (format #f "~a_~a" name ;;;(reformat-moment (grob::when grob)) ;;;(ly:grob-relative-coordinate grob sys X) ;;;(ly:grob-relative-coordinate grob sys Y) (ly:grob-properties grob) ;;;'test "" )) (props (ly:grob-properties grob))) (cond ((eq? name 'Clef) (let ((glyph (assoc-get 'glyph-name props)) (pos (assoc-get 'staff-position props))) (display glyph) (string-append str (get-clef-string glyph pos))) ) ((eq? name 'NoteHead) (string-append (string-append str "") (reformat-moment (ly:prob-property (ly:grob-property grob 'cause) 'duration)) )) ((eq? name 'Flag) (string-append str (assoc-get 'glyph-name props) ) ) ((eq? name 'TimeSignature) (string-append (string-append (string-append str " ") (number->string (car (assoc-get 'fraction props) ))) (number->string (cdr (assoc-get 'fraction props) )) ) ) ((eq? name 'Rest) (string-append (string-append str "") (reformat-moment (ly:prob-property (ly:grob-property grob 'cause) 'duration)) )) ((eq? name 'Script) (string-append (string-append str (number->string (ly:grob-property grob 'direction))) (ly:prob-property (ly:grob-property grob 'cause) 'articulation-type ) )) ((eq? name 'Stem) str) ((eq? name 'Dots) (string-append str (number->string (ly:grob-property grob 'dot-count)))) ;;; dots for dotted notes? ((eq? name 'BarLine) (string-append str (ly:grob-property grob 'glyph-name) )) ;;; Decomposed key sign or cancellation? ((eq? name 'KeySignature) (string-append (string-append str "") (concat_alist (assoc-get 'alteration-alist props)) )) ((eq? name 'KeyCancellation) (string-append (string-append str "") (concat_alist (assoc-get 'alteration-alist props)) )) ((eq? name 'Accidental) (string-append str (number->string (assoc-get 'alteration props)) )) ;;; Add fermata --> done by scrpt ;;; Add trill --> done by script ;;; Add dynamics ((eq? name 'DynamicText) (string-append str (ly:prob-property (ly:grob-property grob 'cause) 'text ))) ;;; Add appregio ((eq? name 'Arpeggio) str) ;;; Add fingering ((eq? name 'Fingering) (string-append str (ly:grob-property grob 'text))) (else (string-append "Unknown_" str)) ) )) assignIDs = #(let ((grob-names (map car all-grob-descriptions))) #{ #@(map (lambda (x)#{ \override #(list 'Score x 'id) = #get-unique-id #}) grob-names) #}) { \assignIDs \acciaccatura d2 c1 \slashedGrace a8 g16 }