lilypond-user
[Top][All Lists]
Advanced

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

Re: Basic function question


From: David Kastrup
Subject: Re: Basic function question
Date: Tue, 26 Jul 2011 12:25:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Urs Liska <address@hidden> writes:

> Hello list members,
>
> after fiddling around too long and getting lost with the basics, I
> decided to ask my question here.
> I know it's basic, and I wonder why I get stuck this way, but
> obviously I'm confused and unable to find the right place in the docs.
>
> I want to write a function "instr" to produce formatted markup that I
> can use like
>
> { c d e f^\instr "Vl." }
>
> which should be translated to (e.g.)
>
> { c d e f^\markup \bold \italic \huge { "Vl." } }
>
> Unfortunately I seem absolutely unable to find out how to define the
> function so I can attach it to the note like in the example.
>
> Hopefully someone can either give me a working example or point me to
> the exact location in the docs where I can fully understand this
> issue.

The docs are not useful for this.  A sequential music expression like
that generated with #{ #} can't be attached in this manner.  But you
should be able to do

instr=#(define-music-function (parser location instrument) (string?)
        (make-music
         'TextScriptEvent
         'direction
         UP
         'text
         (markup #:bold #:italic #:huge instrument)))

Note that this has the upward direction builtin.  If you don't want to
have the direction fixed in advance (you can always override it with
explicit ^ and _ instead of -, however), remove 'direction UP.

How do you arrive there?

Take a look what
\displayMusic { c^\markup { whatever } }
produces and go from there by stripping the layers that don't belong in
your expression.

-- 
David Kastrup




reply via email to

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