lilypond-user
[Top][All Lists]
Advanced

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

Re: Passing a parameter to Scheme


From: Paul Hodges
Subject: Re: Passing a parameter to Scheme
Date: Sat, 29 Oct 2022 11:30:46 +0100

On further thought, I suspect that I can't aim at "\speak #-3.8 c" because #-3.8 isn't a music _expression_ so LilyPond won't let me.  I guess I'll need to use a \tweak or \set on the parameter variable instead.  But that leaves me even further from knowing how to write it, largely because my brain's model of computing (honed over 55 years) is entirely based on procedural languages with nested scopes (Algol, C) or Assembly language with everything global.  I simply don't know how scopes and namespaces work in Scheme, and thus how to define that parameter in a way that I can access it to tweak.

Paul


From: Paul Hodges <pwh@cassland.org>
To: lilypond-user <lilypond-user@gnu.org>
Sent: 29/10/2022 10:50
Subject: Passing a parameter to Scheme

I am trying to make my first steps in actually modifying some Scheme.  I am using a procedure taken from the snippets repository to add a cross to a stem (e.g. to indicate sprechgesang):

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
speak = {
  \once \override Stem.stencil =
    #(lambda (grob)
       (let* ((x-parent (ly:grob-parent grob X))
              (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
         (if is-rest?
             empty-stencil
             (ly:stencil-combine-at-edge
              (ly:stem::print grob)
              Y
              (- (ly:grob-property grob 'direction))
              (grob-interpret-markup grob
                                     (markup #:center-align #:fontsize -2
                                             #:musicglyph "noteheads.s2cross"))
              -2.3))))
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This works fine, writing "\speak c4" for instance.

However, I'd like to be able to parameterise the position of the cross which is hard-coded as -2.3, so that I can write "\speak #-3.8 c" for instance.  I've tried a couple of ways to write it, but I can't find one that works.  I suppose that I will need something like "lambda (grob posn)" to define the parameter for use at the end, but I can't see how to get the value of posn from the LilyPond source into the Scheme procedure.

Help?

Thanks,
Paul

reply via email to

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