lilypond-user
[Top][All Lists]
Advanced

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

Can't use addArticulation function


From: Ivanov Dmitry
Subject: Can't use addArticulation function
Date: Fri, 28 May 2021 23:45:18 +0300

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?



reply via email to

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