lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't use addArticulation function


From: Jean Abou Samra
Subject: Re: Can't use addArticulation function
Date: Fri, 28 May 2021 22:53:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1



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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]