lilypond-user
[Top][All Lists]
Advanced

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

Doing \score { <<...>... } and \context Staff << .... >> in scheme?


From: Reinhold Kainhofer
Subject: Doing \score { <<...>... } and \context Staff << .... >> in scheme?
Date: Wed, 13 Feb 2008 15:29:00 +0100
User-agent: KMail/1.9.7

Hi all,

In the large vocal and orchestral piece that I'm currently typesetting, I have 
lots of score and staff definitions, which look exactly the same, except for 
the variable names. Thus it would make tremendous sense to not hard-code 
them, but generate them on the fly by some scheme function. Unfortunately, 
all my attempts so far have failed...


In particular, what is the scheme equivalent, producing the same as the 
following lilypond code?

IChorObIScore = \score {
  << \IChorObIStaff >>
  \header { piece = \IChorPieceName }
}

I simply want a scheme function "generate-intrument-score piece instr", which 
I would then call as 
\generate-instrument-score #"IChor" #"ObI"

Tha scheme function would then use 
   (string->symbol (string-concat piece instr #"Staff"))
to generate \IChorObIStaff and (eval (string->symbol....)) to insert the 
definition of \IChorObIStaff. So, basically, all I need is how to generate 
the \score { <<...>> } in scheme.


I tried 
generate-score = #(define-music-function (parser location piece instr) 
                        (string string)
  #{
    \score {
      << #(eval (string->symbol (string-append piece instr #"Staff"))) >>
      \header { piece = #(eval (string->symbol (string-append piece 
#"PieceName"))) }
      >>
    }
  #}
)

But that does not work and results in an error message, which is not helpful 
at all:
lisp_score.ly:34:62: Unknown # object: #\"
lisp_score.ly:31:14: Fehler: syntax error, unexpected '-', expecting '='
scr = #(define-music-function (parser location piece instr) (string string) )

Attached is my current attempt.



The other lilypond code that I want to auto-generate by scheme is

IChorFlIIStaff = \context Staff = IChorFlIISt <<
    \clefFlII
    \context Voice = IChorFlIIVoice { \IChorSettings\IChorKey\IChorFlII }
    \set Staff.instrumentName = \instrumentFlII
    \set Staff.shortInstrumentName = \shortInstrumentFlII
>>

Again, the \IChorFlII will be generated from the passed strings, and the same 
for the instrument names.


Thanks a lot,
Reinhold
-- 
------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: address@hidden, http://reinhold.kainhofer.com/
 * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
 * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
 * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/

Attachment: lisp_score.ly
Description: Text Data


reply via email to

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