[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Getting started with music functions
From: |
Stephan Schöll |
Subject: |
Getting started with music functions |
Date: |
Sun, 8 Mar 2020 23:57:21 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
Hi all
When working with larger scores / several voices/instruments, I would
like to "loop through every single instrument" to produce the
\book-blocks in order to avoid duplicate lilypond code.
Let's take the following MVE:
--- MVE START ---
\version "2.19.83"
notesI = \relative c' {
c4 d e f
}
notesII = \relative c {
e4 f g b
}
generateBook =
#(define-music-function
(parser location notes)
(ly:music?)
#{
\book {
\score {
$notes
\layout {}
}
}
#})
\generateBook \notesI
\generateBook \notesII
--- MVE END ---
Lilypond exits with error:
.../document.ly:24:1: error: music function cannot return ##<Book>
\generateBook \notesI
.../document.ly:26:1: error: music function cannot return ##<Book>
\generateBook \notesII
It looks as if the "output" (return value) of a function can only be of
type "music", not "score", "book" aso, which would disappoint me. Am I
right? Or is there a way to define/change the type of the return value?
What I expect from the MVE is two PDFs, one with a notesI score, one
with a notesII score. I have been inspired to do so by the rehearsalMidi
function generated by Frescobaldi. I further intend to extend the music
function with additional parameters.
I'm currently on Win10 and prefer working with lilypond alone - without
shell scripting, Python, etc.
What I have already studied:
NR, chapter 5.6 and sub-chapters
Extending, chapter 2.3 and sub-chapters
Urs Liskas blogposts on music functions (1-4, 2014)
TIA&Regards
Steff
- Getting started with music functions,
Stephan Schöll <=