Automatic click track
Appearance
	
	
Here is a simple function to automatically add a MIDI click track to any music expression, without altering the graphical output.
\version "2.24.0"
%%LSR contributed by vv on https://lists.gnu.org/archive/html/lilypond-user/2020-06/msg00070.html
addTicks =
#(define-music-function (m) (ly:music?)
   #{ << $m 
         \new Devnull \with {
           \consists Drum_note_performer
           \consists Staff_performer
           \consists Dynamic_performer
           midiInstrument = #"woodblock"
         } \drummode {
           <>\ff \repeat unfold
           $(ly:moment-main-numerator
             (ly:moment-div
              (ly:music-length m)
              (ly:make-moment 1 4)))
           rb4 }>> #})
music = \relative  c' { c2\pp d e f g a b c }
\score {
  \new Staff \addTicks \music
  \layout {}
  \midi {}
}