lilypond-user
[Top][All Lists]
Advanced

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

Re: Need help with Scheme code


From: Paolo Prete
Subject: Re: Need help with Scheme code
Date: Wed, 18 Dec 2019 03:01:52 +0100

And thanks again to the Scheme-master Aaron.

One last thing: 

how can I arrange that function so to obtain output-attributes = output-attributes + id ?

For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it must become:    (('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))




On Wed, Dec 18, 2019 at 2:07 AM Aaron Hill <address@hidden> wrote:
On 2019-12-17 4:21 pm, Paolo Prete wrote:
> Hi Stefano,
>
> unfortunately, it doesn't increment the counter globally, and the two
> ids
> in the SVG file are identical

You will need to define a music function so that the (serial) procedure
is called on each occurrence.  Here's an option that rolls in the
counter logic:

%%%%
\version "2.19.83"

token = #(let* ((ctr 0) (ctr! (lambda () (set! ctr (1+ ctr)) ctr)))
   (define-music-function (mus) (ly:music?)
     (let ((id (format #f "foobar_~a" (ctr!))))
       #{ \tweak output-attributes #`((id . ,id)) #mus #})))

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }
%%%%


-- Aaron Hill


reply via email to

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