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: Olivier Biot
Subject: Re: Function for rendering key textually in 3 languages
Date: Sat, 3 Nov 2012 23:36:01 +0100

On Sat, Nov 3, 2012 at 7:35 PM, David Kastrup <address@hidden> wrote:
> Olivier Biot <address@hidden> writes:
>
>> On Sat, Nov 3, 2012 at 6:11 PM, Olivier Biot <address@hidden> wrote:
>>
>> What I now need to figure out, is how to print the output in a markup,
>> like in the currently not working snippets below:
>>
>> %%% START of snippet 2
>> \header {
>>   title = \markup {\italic \tonicEN "cis" "minor"}
>
> That's inside of a markup.  I _think_ this should work in current 2.17
> with define-scheme-function, but likely not in 2.16.

Aah... I'm still using v2.16 stable for now.

> So you'll need a define-markup-command after all to use inside of
> \markup, and best give it two markup? arguments (if the arguments are
> not plain strings, you'll likely get an error then).

Okay.

> It is actually possible to both use define-scheme-function and
> define-markup-command with the same name, and LilyPond will pick the
> right one depending on context.

Hi David,

Okay, one more magic recipe I see :-)

I now have two methods sharing the same name but defined differently,
that do the job:

%%% BEGIN snippet 1
tonalityEN =
#(define-scheme-function (parser layout tonic scale) (string? string?)
   (string-append
    (cond
     ( (string=? tonic "a") "A" )
     ( (string=? tonic "b") "B" )
     ( (string=? tonic "c") "C" )
     ( (string=? tonic "d") "D" )
     ( (string=? tonic "e") "E" )
     ( (string=? tonic "f") "F" )
     ( (string=? tonic "g") "G" )
     ( (string=? tonic "aes") "A flat" )
     ( (string=? tonic "bes") "B flat" )
     ( (string=? tonic "ces") "C flat" )
     ( (string=? tonic "des") "D flat" )
     ( (string=? tonic "ees") "E flat" )
     ( (string=? tonic "fes") "F flat" )
     ( (string=? tonic "ges") "G flat" )
     ( (string=? tonic "ais") "A sharp" )
     ( (string=? tonic "bis") "B sharp" )
     ( (string=? tonic "cis") "C sharp" )
     ( (string=? tonic "dis") "D sharp" )
     ( (string=? tonic "eis") "E sharp" )
     ( (string=? tonic "fis") "F sharp" )
     ( (string=? tonic "gis") "G sharp" )
     )
    (cond
     ( (string=? scale "major") " major" )
     ( (string=? scale "minor") " minor" )
     )
    )
   )

#(define-markup-command (tonalityEN layout props tonic scale) (string? string?)
   (interpret-markup layout props
     (markup
      (cond
       ( (string=? tonic "a") "A" )
       ( (string=? tonic "b") "B" )
       ( (string=? tonic "c") "C" )
       ( (string=? tonic "d") "D" )
       ( (string=? tonic "e") "E" )
       ( (string=? tonic "f") "F" )
       ( (string=? tonic "g") "G" )
       ( (string=? tonic "aes") "A flat" )
       ( (string=? tonic "bes") "B flat" )
       ( (string=? tonic "ces") "C flat" )
       ( (string=? tonic "des") "D flat" )
       ( (string=? tonic "ees") "E flat" )
       ( (string=? tonic "fes") "F flat" )
       ( (string=? tonic "ges") "G flat" )
       ( (string=? tonic "ais") "A sharp" )
       ( (string=? tonic "bis") "B sharp" )
       ( (string=? tonic "cis") "C sharp" )
       ( (string=? tonic "dis") "D sharp" )
       ( (string=? tonic "eis") "E sharp" )
       ( (string=? tonic "fis") "F sharp" )
       ( (string=? tonic "gis") "G sharp" )
       )
      (cond
       ( (string=? scale "major") "major" )
       ( (string=? scale "minor") "minor" )
       )
      )
     )
   )
%%% END snippet 1

The difference is a single space character since the first definition
makes use of the space-eating concat function.

Next I want to try to call the new markup method in a scoreTitleMarkup
block, but there I can't yet find the proper solution:

%%% BEGIN snippet 2
scoreTitleMarkup = \markup {
  \column {
    \vspace #.5
    \rounded-box {
      \column {
        \fill-line {
          \bold { \justify-field #'header:piece }
          \italic \tonalityEN #'header:piece-tonality #'header:piece-scale
        } % \fill-line
      } % \column
    } % \rounded-box
  } % \column
} % \markup


\score {
  \new Staff {
    \relative c' {
        \key c \major
        c d e fis ges d b
    }
  }

  \header {
    piece = "The piece title comes here"
    piece-tonality = "c"
    piece-scale = "major"
  }
}
%%% END snippet 2



reply via email to

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