lilypond-devel
[Top][All Lists]
Advanced

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

Re: tempoMark - documentation and use


From: Carl D. Sorensen
Subject: Re: tempoMark - documentation and use
Date: Mon, 11 May 2009 22:25:25 -0600



On 5/10/09 4:43 PM, "Anthony W. Youngman" <address@hidden>
wrote:

> In message <address@hidden>, Carl D. Sorensen
> <address@hidden> writes
>> 
>> 
>> 
>> On 5/9/09 4:21 PM, "Anthony W. Youngman" <address@hidden>
>> wrote:
>>> So - is there a function that combines stencils? Or where can I find the
>>> code for \default (I did look ...) so I can try and write a defaultPlus
>>> function that takes a string argument ... I found the LSR example that
>>> combines the rehearsal mark with segnos, codas etc but that looks an
>>> awful palaver...
>> 
>> There is a function that combines stencils:
>> 
>> (ly:stencil-add stencil-one stencil-two)
>> 
>> There are also functions (stack-stencils axis dir padding stils) and
>> (stack-stencils-padding-list axis dir padding-list stils)
>> 
>> You can find these functions in
>> 
>> scm/stencil.scm
>> 
>> and
>> 
>> lily/stencil-scheme.cc (which is only available in the source code, but
>> can be found at the git repository if you don't have the source code on your
>> machine).
>> 
> Thanks again, but now I've tried to use this ...
> 
> I'm assuming that \default and \markup return stencils, but I don't seem
> to be able to pass them to stencil-add.
> 
> Reading the manual, I tried the following two:#
> 
> stencilAdd = #(define-music-function (parser location stencila stencilb)
> (ly:stencil? ly:stencil?)
>         stencil-add stencila stencilb
> )

I don't think this will work, because you don't have stencils in your input
file; stencils occur after processing through the LilyPond engine.

Your file would be something like

\stencilAdd \markup{"abc"} \markup{"DEF"}

and what comes after the stencilAdd call is two markups, not two stencils.

> 
> #(define (combineStencils stencil-a stencil-b)
>         stencil-add stencil-a stencil-b
> )

OK, so this one is almost valid Scheme.

#(define (combineStencils stencil-a stencil-b)
   (ly:stencil-add stencil-a stencil-b))

But you won't be satisfied with this one, even if it works, because it will
put the stencils on top of each other.  But note two things: 1) the name of
the scheme function is ly:stencil-add, and 2) you need to surround the
scheme function call with parentheses so that it will be evaluated.

> 
> which seem to compile fine (and I get the impression they're actually
> identical, just defined differently :-) But both of them object when I
> try to pass them any arguments. I get "unexpected \default" or
> "unexpected \markup" or "unexpected STRING" or whatever ...
> 
> \stencilAdd { \default \markup "Little Bird, Little Bird" }
> \combineStencils \markup "123" \markup "abc"
> \combineStencils  "123"  "abc"
> 
> E:/Documents and Settings/Anthony/My Documents/My
> Music/lilypond/Concert/_ManOfLaMancha/voiceStaff.ly:71:22: error: syntax
> error, unexpected STRING
> \combineStencils  "123
>                       "  "abc"
> 
> Am I wrong in thinking \default and \markup return stencils? Or what's
> going wrong? It seems clear to me that I'm not passing in what's
> expected to the function, but, to my (very limited) understanding, it
> all appears correct...
> 

They return stencils only after processing by LilyPond, and the music
function substitution happens *before* processing by LilyPond.

To turn a markup into a stencil, you have to call

(interpret-markup layout props markup)

And I don't know how to get layout from a music function (although I'm sure
it's possible; perhaps somebody will enlighten us).

So I need to do it with a markup-command.

#(define-markup-command (combinedMarkups layout props markup1 markup2)
    (string? string?)
    (ly:stencil-add
     (interpret-markup layout props markup1)
     (interpret-markup layout props markup2)))

{
  c^\markup \combinedMarkups #"123" #"DEF"
}


This works, but not as well as I'd like.  I can only make it work with
string? arguments.  I can't figure out how to get it to work with markup?
arguments, because I don't know how to pass them in.

And you will see that the two stencils lie on top of one another, because
that's what ly:stencil-add does.

But hopefully, it's at least a framework for you to get started on.

Good luck,

Carl





reply via email to

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