Adding articulation marks using Scheme (simple): Difference between revisions
Appearance
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 |
m New category |
||
| (One intermediate revision by the same user not shown) | |||
| Line 42: | Line 42: | ||
[[Category:Scheme]] | [[Category:Scheme]] | ||
[[Category:Really cool]] | [[Category:Really cool]] | ||
[[Category:Snippet]] | |||
Latest revision as of 23:15, 21 November 2025
Using make-music, you can add various stuff to notes. In this example staccato dots are added to the notes. For this simple case, it is not necessary to use scm constructs.
\version "2.24"
%% http://lsr.di.unimi.it/LSR/Item?id=82
%% see also https://github.com/lilypond/lilypond/blob/master/scm/music-functions.scm#L2036
#(define (make-script x)
(make-music 'ArticulationEvent
'articulation-type x))
#(define (add-script m x)
(case (ly:music-property m 'name)
((NoteEvent) (set! (ly:music-property m 'articulations)
(append (ly:music-property m 'articulations)
(list (make-script x))))
m)
((EventChord)(set! (ly:music-property m 'elements)
(append (ly:music-property m 'elements)
(list (make-script x))))
m)
(else #f)))
#(define (add-staccato m)
(add-script m 'staccato))
addStacc = #(define-music-function (music)
(ly:music?)
(map-some-music add-staccato music))
%%% ............................................
\score {
\relative c'' {
c c c c
\addStacc { c\p <c e> c-> c }
}
}