[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Lilypond functions
From: |
Silvain Dupertuis |
Subject: |
Lilypond functions |
Date: |
Tue, 2 Mar 2021 18:56:42 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 |
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)
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
ᐧ
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Lilypond functions,
Silvain Dupertuis <=