Hello everyone,
Functions in Lilypond can also be written in pure Sheme syntax like this
#(define abcd
(lambda (x y ... )
PROCEDURE USING x y ...))
and then called within Lilypond with the syntax
\abcd x y ...
or within a Sheme fucntion with the syntax
(abcd x y ...)
If anyone is interested, I made an exercise for myself to explore *the use of
functions*
and create a score of the *first Prelude of Book I of J.S. Bach's Well-Tempered
Clavier*
As this piece has 32 bars using the same pattern based on 5 notes, plus an
ending in 3 bars,
I used a simple list of notes (without any rythmic indications) as my main data
and designed functions to extract the groups of 5 notes, apply the patterns to create
voices and scores, including a chord version on the piece in addition to the standard score.
notes = {
c e g c e
c d a' d f
b d g d' f ... etc.
)
Files (Lilypond, PDF and midi) are in this online folder
(midi files need to be downloaded to listen to them)
<https://nextcloud.silvain-dupertuis.net/index.php/s/oQJfcgZP9PKY9ca>
Silvain Dupertuis
Merci
This is a perfect solution, and, a clear explanation about why my solution
failed.
Thank you very much
Ken Ledeen
Mobile: 617-817-3183
www.nevo.com <http://www.nevo.com>
www.bitsbook.com <http://www.bitsbook.com>
tiny.cc/KenLedeen <http://tiny.cc/KenLedeen>
tiny.cc/KenLedeenAmazon <http://iny.cc/KenLedeenAmazon>
ᐧ
On Sat, Feb 27, 2021 at 10:43 AM Jean Abou Samra <[email protected]
<mailto:[email protected]>> wrote:
Le 27/02/2021 à 02:16, Ken Ledeen a écrit :
> I am struggling to understand the restrictions on substitution functions.
>
> For example:
>
> 1) can a function include "\score { ...}" or can it only be invoked
> INSIDE a \score?
>
> 2) is it possible to include \header { ...} inside a substitution
> function? It fails when I try, but I don't understand why.
>
> I assume I am missing some basic concepts regarding their use.
>
> Thanks!
Hello,
Music functions must return music objects; \score blocks are not music
but general containers that enclose music as well as other objects such
as \header and \layout blocks.
However, replacing define-music-function with define-scheme-function,
you can define more versatile functions that are allowed to return any
kind of object for interpretation. For example:
\version "2.23.1"
failingFunction =
#(define-music-function () ()
#{
\score {
\header {
piece = "Piece A"
}
{ c' }
}
#})
% \failingFunction
succeedingFunction =
#(define-scheme-function () ()
#{
\score {
\header {
piece = "Piece B"
}
{ c' }
}
#})
\succeedingFunction
Hope that helps,
Jean