+; The TabNoteHead stem attachment function.
+(define (tablature-stem-attachment-function style duration)
+ (cons 0.0 0.5) ;; UGH!
+)
+
+; The TabNoteHead molecule callback.
+; Create a text molecule
+(define-public (tablature-molecule-callback grob)
+ (let ((molecule (fontify-text
+ (ly:get-default-font grob)
+ (ly:get-grob-property grob 'text)
+ )))
+ molecule ; return the molecule.
+ )
+ )
+
+; The TabNoteHead tablatureFormat callback.
+; Compute the text grob-property
+(define-public (fret-number-tablature-format string tuning pitch)
+ (number->string
+ (- (ly:pitch-semitones pitch)
+ (list-ref tuning
+ (- string 1) ; remove 1 because list index starts at 0 and guitar string at 1.
+ )
+ )
+ )
+ )
+
+(define-public (hammer-molecule-callback grob)
+ (let* ((note-collums (ly:get-grob-property grob 'note-columns))
+ (note-column1 (cadr note-collums))
+ (note-column2 (car note-collums))
+ (note1 (car (ly:get-grob-property note-column1 'note-heads)))
+ (note2 (car (ly:get-grob-property note-column2 'note-heads)))
+ (fret1 (string->number (ly:get-grob-property note1 'text)))
+ (fret2 (string->number (ly:get-grob-property note2 'text)))
+ (letter (if (< fret1 fret2) "H"
+ (if (> fret1 fret2) "P"
+ "")))
+ )
+ (let ((slur (Slur::brew_molecule grob))
+ (text (fontify-text (ly:get-default-font grob) letter)))
+
+ (let ((x (/ (- (cdr (ly:molecule-get-extent slur 0))
+ (/ (cdr (ly:molecule-get-extent text 0)) 2.0)
+ )
+ -2.0)))
+
+ (ly:molecule-set-extent! text 0 (cons x x))
+ (ly:molecule-align-to! text 0 1)
+ )
+
+ (ly:molecule-combine-at-edge slur 1 1 text -0.6)
+ )
+ )
+ )
+
+
+
+(define-public guitar-tunings '(4 -1 -5 -10 -15 -20))
+
+; end of tablature functions
+
+
+(define-public (make-molecule-boxer line-thick x-padding y-padding callback)
+ "Makes a routine that adds a box around the grob parsed as argument"
+ (define (molecule-boxer grob)
+ (let*
+ (
+ (mol (callback grob))
+ (x-ext (widen-interval (ly:molecule-get-extent mol 0) x-padding))
+ (y-ext (widen-interval (ly:molecule-get-extent mol 1) y-padding))
+ (x-rule (box-molecule (widen-interval x-ext line-thick)
+ (cons 0 line-thick)))
+ (y-rule (box-molecule (cons 0 line-thick) y-ext))
+ )
+
+ (set! mol (ly:molecule-combine-at-edge mol 0 1 y-rule x-padding))
+ (set! mol (ly:molecule-combine-at-edge mol 0 -1 y-rule x-padding))
+ (set! mol (ly:molecule-combine-at-edge mol 1 1 x-rule 0))
+ (set! mol (ly:molecule-combine-at-edge mol 1 -1 x-rule 0))
+
+ mol
+ ))
+ molecule-boxer
+ )
+
+(define-public (arg->string arg)