Le 28/05/2021 à 22:45, Ivanov Dmitry a écrit :
I need to add staccato signs to all the notes in a group. I read this
thread:
http://lilypond.1069038.n5.nabble.com/Function-to-add-articulation-to-all-notes-td208433.html
and copied addArticulation function from it. But unfortunately when I
try to use it I get and error. Here is my attempt:
addArticulation =
#(define-music-function (scripts music) (list? ly:music?)
(define (add mus)
(let* ((art (ly:music-property mus 'articulations))
(types (map (lambda (a) (ly:music-property a 'articulation-type))
art)))
(for-each
(lambda (x)
(if (not (member x types))
(ly:music-set-property! mus 'articulations
(append! (ly:music-property mus 'articulations)
(list (make-articulation x))))))
scripts)))
(for-some-music
(lambda (mus)
(cond
((music-is-of-type? mus 'event-chord) (add mus))
((music-is-of-type? mus 'note-event) (add mus))
(else #f)))
music)
music)
%music = \addArticulation #'("staccato") { | c4 d e f | }
upper = \relative c' {
\clef violin
\key c \major
\time 4/4
c4 d e f | %\music
}
\score {
\new PianoStaff \with { instrumentName = "Piano" }
<<
\new Staff = "upper" \upper
>>
\layout { }
}
This works. But as soon as I uncomment "music" definition, it starts
to give an error:
./test.ly:23:50: error: unrecognized string, not in text script or \lyricmode
music = \addArticulation #'("staccato") { | c4 d e f | }
/usr/local/lilypond/usr/share/lilypond/current/scm/ly-syntax-constructors.scm:56:23:
In expression (apply (ly:music-function-extract fun) parser ...):
/usr/local/lilypond/usr/share/lilypond/current/scm/ly-syntax-constructors.scm:56:23:
Wrong number of arguments to #<procedure #f (scripts music)>
How can I process a list of notes, save it into a variable and output it?
Hello,
You are apparently using an outdated version of LilyPond (hence the
importance of \version statements). Try the latest stable release,
2.22.1, which happily processes your file:
lilypond.org/download.html
Regards,
Jean