lilypond-user
[Top][All Lists]
Advanced

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

Re: Tracking usage of variables


From: David Kastrup
Subject: Re: Tracking usage of variables
Date: Sun, 03 Mar 2019 14:17:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Mark Knoop <address@hidden> writes:

> Often in the music I'm engraving a single variable might be used and 
> transformed in multiple contexts and repetitions throughout the piece. This 
> can become difficult to keep track of, particularly if subsequent changes are 
> made which might want to affect only one or some of the instances.
>
> It would be great to be able to display the use of variables throughout a 
> score, I imagine by writing a custom engraver for this. Such an engraver 
> would create two helpful components:
>
> 1. Add markup to every use of a variable in the music. The point-and-click 
> link of this markup would be to the use of the variable (rather than its 
> definition).
>
> 2. Output a text report listing the musical locations (bar/beat) and contexts 
> of each variable.
>
> The example below demonstrates what such an engraver would create. I don't 
> really know how to start with this, or if it is even possible - any thoughts 
> or pointers from scheme gurus would be extremely helpful.

Variable use does not sound like a use case for engravers since
engravers work at a different stage than variable use.

How about something like

motif = { c'4 e' g' c'' }

make-obvious =
#(define-void-function (x) (symbol?)
   (let ((old (ly:music-deep-copy (ly:parser-lookup x))))
     (ly:parser-define! x
       (define-music-function () ()
         #{ \context Bottom << <>-#(format "Variable: ~s" x) $old >> #}))))

\make-obvious motif

\score {
  <<
    \new Staff = "flute" \with {
      instrumentName = "flute"
    } {
      \motif
      R1
      \repeat unfold 3 \transpose c' e' \motif
      \bar "|."
    }
    \new Staff = "viola" \with {
      instrumentName = "viola"
    } {
      \clef "alto"
      R1
      \repeat unfold 4 \shiftDurations 2 0 \motif
      R1*2
      \motif
    }
  >>
}

I apologize for vandalizing your code and throwing out the bulk of
functionality and markup you put in but that was just a quick and easy
job.

-- 
David Kastrup



reply via email to

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