[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Putting a \layout block in a Scheme macro
From: |
Thomas Morley |
Subject: |
Re: Putting a \layout block in a Scheme macro |
Date: |
Sun, 22 Jan 2017 21:12:22 +0100 |
2017-01-22 19:30 GMT+01:00 Jérôme Plût <address@hidden>:
>
> I want to make a Scheme macro \BlankStaff that outputs a single white
> staff. (Optionnally, \BlankStaff #3 would output three of them, etc.
> In particular, using “\include "blank-staff.ly"” is a non-solution).
>
> A snippet does the white staff:
> http://lilypond.org/doc/v2.19/Documentation/snippets/staff-notation#staff-notation-creating-blank-staves
>
> However, this snippet uses a \layout { } block, which I am unable to
> include in the #{ ... #} block of a Scheme function definition:
>
> #(collect-music-for-book #{
> \score { \repeat unfold 12 { s1 } \break
> \layout { \indent = 0 \in
> \context { \Staff \remove "Bar_engraver" } } } #})
>
> produces the following error:
>
> scm/lily-library.scm:153:5:Wrong type argument in position 1 (expecting Prob):
> #<Score>
>
> So my question is this: how does the \layout{ } block translate to
> Scheme?
Well, your example fails for several reasons.
(1)
In
\score { \repeat unfold 12 { s1 } \break
the \break has to be moved into { }, otherwise the score-command sees
two musical expressions.
You should have seen:
error: Spurious expression in \score
\score { \repeat unfold 12 { s1 }
\break
(2)
In
\indent
remove the slash.
You should have seen:
error: unknown escaped string: `\indent'
\layout {
\indent = 0 \in
(3)
collect-music-for-book is the wrong command. It expects _music_ not a
score. See:
#(display (ly:music? #{ c'1 #}))
#(newline)
#(display (ly:music? #{ \score { { c'1 } } #}))
You could do:
sc =
\score {
\repeat unfold 12 { s1 \break }
\layout {
indent = 0 \in
\context {
\Staff
\remove "Bar_engraver"
}
}
}
#(add-score sc)
%% probably:
#(collect-scores-for-book sc)
Cheers,
Harm
P.S.
The actual topic of this thread, \layout in scheme, is not answered.
Though, I doubt you still need it. If I'm wrong, please shout and I'll
have a second thought