Adding articulation marks using Scheme (simple): Difference between revisions
Appearance
Import snippet from LSR |
m New category |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
Using <code>make-music</code>, 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. | Using <code>make-music</code>, 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. | ||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
%% http://lsr.di.unimi.it/LSR/Item?id=82 | %% http://lsr.di.unimi.it/LSR/Item?id=82 | ||
%% see also https://github.com/lilypond/lilypond/blob/master/scm/music-functions.scm#L2036 | %% see also https://github.com/lilypond/lilypond/blob/master/scm/music-functions.scm#L2036 | ||
| 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 }
}
}