lilypond-user
[Top][All Lists]
Advanced

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

Re: Function for rendering key textually in 3 languages


From: David Kastrup
Subject: Re: Function for rendering key textually in 3 languages
Date: Sat, 03 Nov 2012 17:54:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Olivier Biot <address@hidden> writes:

> I definitely have problems with Scheme and LilyPond interpretation. I
> now have the Scheme standard open as well.
>
> I tried to simplify the initial job by first creating a function with
> one string argument returning either a string or a markup. Does not
> work.
>
> I tried hundreds of alternatives, with musoc-function and withj
> markup-command, with a define and define-scheme-funciton, to no avail.
>
> Why is the following not working?
>
> %%% BEGIN SNIPPET
>
> \version "2.16.0"
>
> #(define-markup-command (tonicEN props layout tonic) ( string? )
>     (
>         (cond
>             ( (string=? tonic '"cis") ("C sharp") )
>             ( (string=? tonic '"dis") ("D sharp") )
>         )
>     )
> )

One reason is because markup commands have rather rudimentary argument
parsing (to make you appreciate the work done on music functions more,
ha ha) and distinguish only markup, markup list, and Scheme as argument
type.  A quoted LilyPond string counts only as "markup".  And markup
commands can only be used inside of explicit markup.

Then you use ( ) where they don't belong.  Remember: those are _not_
mere grouping constructs but form a list.  And a list of lists is
something different from a list.  In evaluated contexts (like this is),
( ) are a function call.  So you try calling "C sharp" as a function
(which does not work) and call the result of the cond as a function
again (which also does not work).

Just because Scheme seems to be crawling with parens does not mean that
you can throw in a few more and hope that nobody will notice.

'"cis" is awfully awkward (strings are self-quoting and don't need '
before them) but not actually wrong.

> \header {
>   composer = "myself"
>   title = \tonicEN "cis"
> }

You would likely have to write

    title = \markup \tonicEN #"cis"

here after fixing the above definition.  Alternatively, use

tonicEn =
#(define-scheme-function (parser layout tonic) (string?) ...

in which case title = \toniEN "cis" should work fine.  With the current
development version, you should be able to use \tonicEN pretty much
everywhere a string can be used, with 2.16.0 the uses will likely be
more restrained.  On the right side of an assignment or as a function
argument, however, should work fine all the time.

-- 
David Kastrup




reply via email to

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