Appending a note to the tuplet text (using a scheme wrapper function)

Sometimes you might want to show the basic beat in the tuplet number text, i.e. 3:2 quarternote, were quarternote is really a note. The quick and dirty way is to manually set \override TupletNumber #'text = #(markup #:italic "3:2" #:fontsize -5 #:note "4" 1). However, then you'll have to change it as soon as you want to use a 4/6 tuplet.

The better way is to write your own function for #'text, which extracts the tuplet fraction from the tuplet object, formats the tuplet text using the internal function and then appends the note you want. In other words, we simply write a function, which wraps the internal formatter function and modified its result:

#(define-public ((tuplet-number::append-note-wrapper function note) grob)
  (let* ((txt (function grob)))
    (markup txt #:fontsize -5 #:note note UP)))

You simply pass the normal formatter function (i.e. tuplet-number::calc-fraction-text for 3:2 or tuplet-number::calc-denominator-text for 3) and the duration of the note to append:

  \override TupletNumber #'text = #(tuplet-number::append-note-wrapper tuplet-number::calc-denominator-text "8")