Am Sonntag, 17. Februar 2008 schrieb Han-Wen Nienhuys:
> 2008/2/13, Reinhold Kainhofer <[EMAIL PROTECTED]>:
> > In particular, what is the scheme equivalent, producing the same as the
> > following lilypond code?
> >
> > IChorObIScore = \score {
> >   << \IChorObIStaff >>
> >   \header { piece = \IChorPieceName }
> > }
>
> You have to use the scheme bindings. There is a ly:make-score
> function. 

Thanks for the hint... Works so far (see attached example).

However, how can I define a function so that instead of scheme, i.e.
     \score { #(createscore "test") }
i can simply do:
     % This does NOT work (syntax error)
     \score { \createscore #"test"}
or even better:
     \createscore #"test"

Now that this works more or less, how can I set 'header:piece only for this 
score? I tried ly:prob-set-property! and ly:context-set-property!, but 
neither works. Which type of object is a score?


Also, how can I create a staff in scheme? A staff is no music expression, is 
it?


> 2.11.40 adds a ly:score-add-output-def function that will 
> allow you define a piece of music

What exactly does that do? There's no description, and the only use is in the 
incipit example inside a lambda function used as a stencil definition. That's 
wayyyy above my head with regards to lilypond internals.


> > generate-score = #(define-music-function (parser location piece instr)
> >                         (string string)
> >   #{
> >     \score {
>
> IIRC #{ can only contains music expressions.

Yes, using define-music-function was also not the correct approach...

> >       << #(eval (string->symbol (string-append piece instr #"Staff"))) >>
>
> Inside scheme the # before a string is not necessary.

Oops, thanks! 

Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: [EMAIL PROTECTED], 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/
\version "2.11.39"

\header { title = "Scores generated by Scheme" piece = "Scheme scores" }
testmusic = {\clef bass { d4 }}
teststaff = \new Staff << \testmusic >>
testPieceName = "Lilypond test score"

othermusic = {\clef tenor { <c e g>2 }}
otherstaff = \new Staff << \othermusic >>
otherPieceName = "Lilypond other score"

anothermusic = {\clef treble { c8[ g] }}
anotherstaff = \new Staff << \anothermusic >>
anotherPieceName = "another score"


% This is classical lilypond style, one variable per score (awkward 
% if you have hundreds of combinations, which all look the same, 
% except for the variable names, which follow a certain pattern):

% definitions in some included file, needs to be done over and over again...
lytestscore = \score { \teststaff \header { piece = \testPieceName } }
lyotherscore = \score { \otherstaff \header { piece = \otherPieceName } }
% actual inclusion in each instrument's file:
\score { \lytestscore }
\score { \lyotherscore }



% Now, how do I do that in scheme????

% This works, but it seems I'm unable to put the whole scheme expression
% into a separate function, so that it can be called with \createscore args
% instead of the scheme #(createscore arg):
#(define (createscore name) 
  (ly:export
    (ly:make-score 
      (primitive-eval (string->symbol (string-append name "staff")))
    )
  )
)
\score { #(createscore "test") }
\score { #(createscore "other") }

% This does NOT work (error message: "syntax error, unexpected SCM_IDENTIFIER")
\score { \createscore #"test"}
% Neither does this (simply no effect whatsoever...
#(createscore "another")

% But now my real problem: How do I set the 'header:piece property 
% only for that score? I.e. extend it to produce the equivelant of:
%
% testscore = \score {
%   \teststaff
%   \header { piece = \testPieceName }
% }

#(define (createscoreI name) 
  (let (
        ( thisscr (ly:make-score 
                    (primitive-eval (string->symbol (string-append name "staff")))
                  ) ))
; All of these attempts fail (prob-set-property needs a prob..., context-set-propert does not work, either)
;    (ly:prob-set-property! thisscr 'header:piece "test piece")
;    (ly:prob-set-property! (ly:export thisscr) 'header:piece "test piece")
;    (ly:context-set-property! thisscr 'header:piece "test piece")
    (ly:export thisscr)
  )
)
\score { #(createscoreI "test") }
\score { #(createscoreI "other") }

Attachment: lisp_scoreI.pdf
Description: Adobe PDF document

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to