[Top][All Lists]

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

Re: how to reference paper variables in a music function

From: Jeff Olson
Subject: Re: how to reference paper variables in a music function
Date: Thu, 29 Nov 2018 23:20:12 -0700
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Thanks, David, for your prompt reply.  Unfortunately I do not have the ability to alter the source in any way (including commenting out lines) once the source has been submitted to Mutopia.  Their process is to specify the paper size on the lilypond command line; any code like those set-paper-size commands that would interfere has to be commented out.  I think Harm's solution would help lots of frustrated Mutopia people who tear their hair out over trying to make the exact same source file generate satisfactory output on two different paper sizes.

Thx again,

On 11/29/2018 9:26 AM, David Wright wrote:
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

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

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.

  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


      o_         Jeff Olson
 (\___\/_____/)   jjocanoe
~ ~ ~ / ~ ~ ~ ~

reply via email to

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