lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to reference paper variables in a music function


From: David Wright
Subject: Re: how to reference paper variables in a music function
Date: Thu, 29 Nov 2018 10:26:19 -0600
User-agent: NeoMutt/20170113 (1.7.2)

On Wed 28 Nov 2018 at 23:12:20 (-0700), Jeff Olson wrote:
> I have a complex Mutopia submission that requires different formatting
> for A4 and Letter sized paper (it's too tight on the page to trust
> lilypond's spacing algorithms on the same source without paper
> specific tweaks).
> 
> So I'd like to define a music function (see "ifLetter" below) that can
> sense the paper choice and select either of two music definitions
> accordingly.
> 
> In the demo below, I'd like to switch output between music-one (one
> system) and music-two (two systems) depending upon which paper size is
> set.  But I'm just guessing about how to reference the documented
> variable "paper-width" to compare to the value 8.5\in.  In the attempt
> below, the condition always evaluates to ##f and produces two systems
> on letter size paper (I want music-one for letter paper).
> 
> I'd prefer testing a variable whose value was "letter" (rather than
> 8.5 inches) but I couldn't find such a variable documented
> (paper-size?, default-paper-size?).
> 
> I've seen ly:output-def-lookup, but that requires a props or layout
> that is not obvious how to access within a music function.
> 
> The code below produces the expected results when the condition (eqv?
> 'paper:paper-width (* 8.5 25.4))is rewritten as(eqv? 1 1) or (eqv? 1
> 2).
> 
> BTW, documented spacing examples suggest that the construct (* 8.5 in)
> should be effective in scheme, but I get a compile error indicating
> that "in" is unbound, so I've written in 25.4 as a literal.
> 
> BTW2, I've similarly been unable to access the paper variable
> page-count within a music function.

> \paper{
>   page-count = #1
>   %#(set-paper-size "a4")      %uncomment to test specific paper size
>   #(set-paper-size "letter")  %uncomment to test specific paper size
> }

> ifLetter =
> #(define-music-function (parser location musL musE) (ly:music? ly:music?)
>    (if (eqv? 'paper:paper-width (* 8.5 25.4)) musL musE )
>    )
> 
> \score { \ifLetter \music-one \music-two }

You're editing one % character to switch between paper sizes, so why not:

% ifLetter = <whatever LP's false is> \paper { #(set-paper-size "a4") } % 
uncomment for A4
 ifLetter = <whatever LP's true is> \paper { #(set-paper-size "letter") } % 
uncomment for Letter

Cheers,
David.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]