Re: How to define a macro that expands to a percussion "pitch"?

2023-01-28 Thread Pierre-Luc Gauthier
m = \drummode { hh }

Le sam. 28 janv. 2023, à 02 h 01, Darren Ng  a écrit :
>
> [subject] How to define a macro that expands to a percussion "pitch"?
>
> input is
>
> m = hh
> \drummode { \m 8 \m  r4 \m  }
>
> expected output should be equivalent to
>
> \drummode { hh8  hh8 r4 hh4 }
>
> actual output (console)
>
> percussion.ly:*:*: warning: Ignoring non-music expression
>
> \m 8 \m r4 \m
> percussion.ly:*:*: warning: Ignoring non-music expression
> \m 8
>  \m r4 \m
> percussion.ly:*:*: warning: Ignoring non-music expression
> \m 8 \m r4
>\m
>
> actual output (midi)
>
> (I hear no percussion at all)
>


-- 
Pierre-Luc Gauthier



Re: Clef change after end-repeat before break -- how?

2023-01-28 Thread Ole V. Villumsen
Furthermore, for the record, the same trick also works in the case where there 
is no break after the end-repeat sign. In this case the second of the three 
inner lists in Score.BreakAlignment.break-align-orders governs the order. So I 
want to modify both the 1st and the 2nd list. From the documentation:

> This is a vector of 3 lists: #(end-of-line unbroken start-of-line).

Having different scores and parts of the same music I now end up with clearly 
more readable and sensible Lilypond source than I had before. And nicer typeset 
music. Hallelujah, as Mr. Handel wrote.

/Ole

Sent with Proton Mail secure email.

--- Original Message ---
On Saturday, January 28th, 2023 at 06:52, Ole V. Villumsen 
 wrote:


> Thanks, everyone, for your contributions.
> 
> First of all Jean. Your code gives me exactly what I wanted. I haven’t 
> learned to use the internals, but see here that it’s useful.
> 
> > Not sure, but my guess is that LilyPond might be trying to make different
> > measures have not-too-distant lengths. This is just a guess; ...
> 
> 
> I am skeptical. There’s no separate measure there.
> When I move the setting of the measure position to later in the bar,
> I still get the same space (but then not the measure number, 5,
> on the 2nd line, which makes sense). So still curious.
> 
> @Mark
> 
> > Under 2.22 I do not get extra space.
> 
> 
> That’s still more curious. On 2.22.2 I get a warning
> that the break is overwritten by another event, so we
> don’t get the line break that I had specified and wanted.
> 
> @Ralph Palmer, you may have forgot to put content into your message? At least 
> none arrived here.
> 
> Best, Ole
> 
> Sent with Proton Mail secure email.
> 
> --- Original Message ---
> On Saturday, January 28th, 2023 at 00:09, Jean Abou Samra j...@abou-samra.fr 
> wrote:
> 
> 
> 
> > On 27/01/2023 22:35, Ole V. Villumsen wrote:
> > 
> > > Hi, I am typesetting a movement with a repeat and a clef change right 
> > > after the repeat. I have a suitable line break where the repeat ends and 
> > > the clef change happens. Default Lilypond sets the new clef within the 
> > > repeat, before the end-repeat sign, which I don’t want and find 
> > > meaningless in my case since there is no clef change when repeating from 
> > > the beginning, only when continuing after the repeated section. Instead I 
> > > want the clef after the end-repeat and before the line break. I can do 
> > > that by setting the clef change off from the repeated section by a small 
> > > space. Only the space comes out much larger than expected.
> > > 
> > > Tiny example:
> > > 
> > > \version "2.24.0"
> > > 
> > > \relative c' {
> > > \repeat volta 2 {
> > > g'4 4 4 4 | 4 4 4 4 | 4 4 4 4 | 4 4 4 8 8 |
> > > }
> > > s1024
> > > \clef bass
> > > \break
> > > \set Timing.measurePosition = #(ly:make-moment 0/4)
> > > c,,4 4 4 4 | 4 4 4 4 | 4 4 4 4 | 4 4 4 4 |
> > > }
> > > 
> > > I enclose the output as png. My 1024th spacer rest is broader than the 
> > > two preceding quavers (8th notes) combined.
> > > 
> > > * Curious question: why is that?
> > 
> > Not sure, but my guess is that LilyPond might be trying to make different
> > measures have not-too-distant lengths. This is just a guess; I didn't try
> > to investigate, because:
> > 
> > > * Constructive question: how to avoid it?
> > 
> > Don't use a spacer rest in the first place. See below.
> > 
> > > * Real question: How do I set the clef nicely immediately> after the 
> > > end-repeat with minimal space between?
> > 
> > Use
> > 
> > \version "2.24.0"
> > 
> > \relative c' {
> > \repeat volta 2 {
> > g'4 4 4 4 | 4 4 4 4 | 4 4 4 4 | 4 4 4 8 8 |
> > }
> > \once \override Score.BreakAlignment.break-align-orders =
> > ##((left-edge staff-ellipsis cue-end-clef ambitus breathing-sign 
> > signum-repetitionis cue-clef staff-bar clef key-cancellation key-signature 
> > time-signature custos)
> > (left-edge staff-ellipsis cue-end-clef ambitus breathing-sign 
> > signum-repetitionis clef cue-clef staff-bar key-cancellation key-signature 
> > time-signature custos)
> > (left-edge staff-ellipsis ambitus breathing-sign signum-repetitionis clef 
> > key-cancellation key-signature time-signature staff-bar cue-clef custos))
> > \clef bass
> > \break
> > c,,4 4 4 4 | 4 4 4 4 | 4 4 4 4 | 4 4 4 4 |
> > }
> > 
> > I just took the default on
> > https://lilypond.org/doc/v2.24/Documentation/internals/breakalignment
> > and moved "clef" after "staff-bar" in the first list.
> > 
> > Best,
> > Jean



Re: How to define a macro that expands to a percussion "pitch"?

2023-01-28 Thread Lukas-Fabian Moser

Hi Pierre-Luc,

Am 28.01.23 um 14:02 schrieb Pierre-Luc Gauthier:

m = \drummode { hh }


Unfortunately not: This turns m into "music" including a duration. 
Hence, \m 8 will be interpreted as "first \m" (with its own pitch), then 
another one of duration 8.


Compare:

\version "2.24.0"

m = \drummode { hh }

\drummode { \m 8 \m r4 \m  }
\drummode { hh8  hh8 r4 hh4 }

But what you can do is:

\version "2.24.0"

drumPitchNames.m = #'hihat

\drummode { m8 m r4 m }

(which might be even better than the OP hoped for).

Lukas




Re: How to define a macro that expands to a percussion "pitch"?

2023-01-28 Thread Jean Abou Samra


> Le 28 janv. 2023 à 08:01, Darren Ng  a écrit :
> 
> [subject] How to define a macro that expands to a percussion "pitch"?


It may be worth noting that LilyPond does not have macros, only variables and 
regular functions. Call me pedantic, but I think it is helpful not to conflate 
the two. There is no way in LilyPond to make a variable "just be replaced by 
this code". Sometimes users get confused by this (I remember a question about 
defining a chord modifier, which was similar to this one). Instead, there are 
functions, as well as some other mechanisms like drumPitchNames.

Lukas already gave the solution, so I don’t have anything more to add.

Jean





Re: How to define a macro that expands to a percussion "pitch"?

2023-01-28 Thread David Kastrup
Jean Abou Samra  writes:

>> Le 28 janv. 2023 à 08:01, Darren Ng  a écrit :
>> 
>> [subject] How to define a macro that expands to a percussion "pitch"?
>
>
> It may be worth noting that LilyPond does not have macros, only
> variables and regular functions. Call me pedantic, but I think it is
> helpful not to conflate the two.

It's a hybrid, actually.  In Lispy terms, the difference between a
function and a macro is that a function evaluates its arguments while a
macro evaluates the result of executing the macro body on the
unevaluated arguments.

LilyPond evaluates a music/event/scheme/void function's body after
reading its arguments but the reading/interpretation of the arguments is
directed by the predicates.

So a music/event/scheme/void function does evaluate some of its parts
(the predicates) in order to direct the syntactic interpretation of its
arguments.

> There is no way in LilyPond to make a variable "just be replaced by
> this code". Sometimes users get confused by this (I remember a
> question about defining a chord modifier, which was similar to this
> one). Instead, there are functions, as well as some other mechanisms
> like drumPitchNames.

In general, things are not purely functional but the categories and
interpretation change around more by ad-hoc conditions than a cohesive
macro mechanism.

-- 
David Kastrup



Re: Clef change after end-repeat before break -- how?

2023-01-28 Thread Jean Abou Samra
On 28/01/2023 16:51, David Kastrup wrote:
> Jean Abou Samra  writes:
> 
>>> Le 28 janv. 2023 à 08:01, Darren Ng  a écrit :
>>>
>>> [subject] How to define a macro that expands to a percussion "pitch"?
>>
>>
>> It may be worth noting that LilyPond does not have macros, only
>> variables and regular functions. Call me pedantic, but I think it is
>> helpful not to conflate the two.
> 
> It's a hybrid, actually.  In Lispy terms, the difference between a
> function and a macro is that a function evaluates its arguments while a
> macro evaluates the result of executing the macro body on the
> unevaluated arguments.
> 
> LilyPond evaluates a music/event/scheme/void function's body after
> reading its arguments but the reading/interpretation of the arguments is
> directed by the predicates.
> 
> So a music/event/scheme/void function does evaluate some of its parts
> (the predicates) in order to direct the syntactic interpretation of its
> arguments.



OK, I grant you that. Still very different from the concepts of
"macros" found in Scheme, Lisp, C, TeX or Rust, though.


>> There is no way in LilyPond to make a variable "just be replaced by
>> this code". Sometimes users get confused by this (I remember a
>> question about defining a chord modifier, which was similar to this
>> one). Instead, there are functions, as well as some other mechanisms
>> like drumPitchNames.
> 
> In general, things are not purely functional but the categories and
> interpretation change around more by ad-hoc conditions than a cohesive
> macro mechanism.


Yup.



OpenPGP_signature
Description: OpenPGP digital signature


Re: Clef change after end-repeat before break -- how?

2023-01-28 Thread Jean Abou Samra
On 28/01/2023 06:52, Ole V. Villumsen wrote:
> Thanks, everyone, for your contributions.
> 
> First of all Jean. Your code gives me exactly what I wanted. I haven’t 
> learned to use the internals, but see here that it’s useful.
> 
>> Not sure, but my guess is that LilyPond might be trying to make different
>> measures have not-too-distant lengths. This is just a guess; ...
> 
> I am skeptical. There’s no separate measure there.
> When I move the setting of the measure position to later in the bar,
> I still get the same space (but then not the measure number, 5,
> on the 2nd line, which makes sense). So still curious.



OK, I dug a bit, and although I still find your original code dubious,
it turns out that there is a genuine bug. See

https://gitlab.com/lilypond/lilypond/-/issues/6524




OpenPGP_signature
Description: OpenPGP digital signature


Re: Clef change after end-repeat before break -- how?

2023-01-28 Thread Jean Abou Samra
>> Under 2.22 I do not get extra space.
> 
> That’s still more curious. On 2.22.2 I get a warning
> that the break is overwritten by another event, so we
> don’t get the line break that I had specified and wanted.


It's expected. 2.22 doesn't accept mid-measure breaks without
a bar line. You need \bar "" to allow a break in that version.




OpenPGP_signature
Description: OpenPGP digital signature


Re: substitution function variable name

2023-01-28 Thread Jean Abou Samra
On 22/01/2023 18:31, Jean Abou Samra wrote:
> Le 22/01/2023 à 18:22, Darren Ng a écrit :
>> Thanks. The following works:
>>
>>    accOne =
>>    #(define-music-function
>>    (x    )
>>    (ly:pitch?)
>>  #{
>>    $x 8 $x 8
>>  #})
>>
>> My ultimate goal is a function which does the following
>>
>>    accTwo =
>>    #(define-music-function
>>    (x    )
>>    (ly:pitch?)
>>  #{
>>    $x 8 r8
>>    <($x+4) ($x+7)>8 r8
>>    ($x-5) 8 r8
>>    <($x+4) ($x+7)>8 r8
>>  #})
>>
>> E.g.
>>
>>    \accTwo c expands to { c8r8 8r8  g,8r8 8r8 }
>>    \accTwo f expands to { f8r8 8r8 c8r8  8r8 }
>>
>> What material should I read so that I'll be able to achieve this?
> 
> 
> Spoiler: you can do that with just
> 
> \version "2.24.0"
> 
> accTwo =
> #(define-music-function
>     (x    )
>     (ly:pitch?)
>   #{
>     $x 8
>     r8
>     <\transpose c e $x \transpose c g $x >8
>     r8
>     <\transpose c g, $x >8 r8
>     <\transpose c e $x \transpose c g $x >8
>     r8
>   #})
> 
> \accTwo c'


Not sure why I didn't think of this much simpler solution a week ago:

\version "2.24.0"

accTwo =
#(define-music-function (x) (ly:pitch?)
  #{ \transpose c $x { c8 r  r g, r  r } #})

\accTwo c'


Jean



OpenPGP_signature
Description: OpenPGP digital signature


Re: Choir-Parts - working with \tag#' - Mulitmeasure Rests not printed

2023-01-28 Thread kieren

Hi Christian,

Unless I'm misunderstanding what you want, it really seems to me like 
this would be better solved by building the scores independently, rather 
than using tags and “breaking down” the scores late in the process.


Have you considered that option?
Do you know about \partCombine, etc.?

Cheers,
Kieren.