[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to repeat a scheme function that creates a Score
From: |
Jeff Olson |
Subject: |
how to repeat a scheme function that creates a Score |
Date: |
Tue, 5 Apr 2022 23:40:00 -0600 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
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.
MWE-do-scr.ly
Description: Text Data
gen-music.ily
Description: Text document
- how to repeat a scheme function that creates a Score,
Jeff Olson <=