lilypond-user
[Top][All Lists]
Advanced

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

Re: how to repeat a scheme function that creates a Score


From: Valentin Petzel
Subject: Re: how to repeat a scheme function that creates a Score
Date: Wed, 06 Apr 2022 08:26:51 +0200

Hello Jeff,

A scheme-function will only be able to output a single top-level-score like 
this. You should rather do a void-function that calls (add-score #{ \score 
{...} #}) directly. Similarly you can use (add-text ...) to add top-level 
markups.

Cheers,
Valentin

Am Mittwoch, 6. April 2022, 07:40:00 CEST schrieb Jeff Olson:
> Two questions below re: (a) looping and (b) random seed.
> 
> 
> In order to investigate some other problems I'm having in a large
> project (pagination, memory usage) I learned enough scheme (barely) to
> define a function that generates a new score with each invocation:
> 
> --
> 
> \version "2.22.0"
> 
> \include "gen-music.ily"
> 
> % each invocation of scr generates a new score of different length
> pcn = 0
> scr = #(define-scheme-function () ()
>     (set! pcn (1+ pcn))
>     #{
>       \score {
>         \header { piece = \markup{ "Piece " #(number->string pcn) } }
>         { \gen-music \bar "|."} }
>     #} )
> 
> --
> 
> (The include file, gen-music.ily, is attached, and the above ~MWE is
> also attached as MWE-do-scr.ly.)
> 
> Question (a):
> 
> My main question is how to write a scheme function that will invoke my
> scr function N times, where N could be a number like 1000.
> 
> So far the only way I know how to do multiple invocations is by
> explicitly hard-coding "\scr \scr ..." in blocks and copy/pasting those
> blocks.
> 
> Looking for a better way, I realized I don't even know how to get one
> line of scheme to do 2 invocations (needed for tail recursion
> approach).  I can make them execute, in some cases, but not to produce
> pdf output (never gets to "Interpreting music...").  Part of this may be
> #(scr) vs $(scr).  The attached MWE file has lots of my failed attempts
> commented out (I'm at a teachable moment if someone has a moment to
> teach).  Or just point me to the right manual page(s).
> 
> Question (b):
> 
> My secondary question is very simple.  How do you set the seed for
> scheme's "random" function (used in my gen-music.ily).  I'd like to get
> the repeatability of a pseudo-random number generator.
> 
> TIA,
> Jeff
> 
> P.S. May you smile when you see the generated music.

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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