Jump to content

Automatic click track: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
Line 1: Line 1:
Here is a simple function to automatically add a MIDI click track to any music expression, without altering the graphical output.
Here is a simple function to automatically add a MIDI click track to any music expression, without altering the graphical output.


<lilypond version="2.24.0">
<lilypond version="2.24">
%%LSR contributed by vv on https://lists.gnu.org/archive/html/lilypond-user/2020-06/msg00070.html
%%LSR contributed by vv on https://lists.gnu.org/archive/html/lilypond-user/2020-06/msg00070.html



Revision as of 18:45, 16 November 2025

Here is a simple function to automatically add a MIDI click track to any music expression, without altering the graphical output.

\version "2.24"

%%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 {}
}