Re: Bad bar check warning with two voices, appoggiatura, and articulate

2024-09-16 Thread David Kastrup
Knute Snortum  writes:

> I have discovered that LilyPond 2.25.19 produces a bad bar check warning
> under certain circumstances.  The three parts are 1) using two voices, 2)
> an appoggiatura, 3) using articulate.ly.  Below is my example code:
>
> %%%
> \version "2.25.19"
>
> rightHand = \relative {
>   \time 3/4
>   <<
> { \voiceOne e'4. d'8 }
> \new Voice { \voiceFour e,2 }
>   >>
>   \oneVoice \appoggiatura { c'16 d e } d8 c |
> }
>
> % This score block is not necessary to produce the warning but
> % it shows how the measure is correct.
> % \score {
> %   \new Staff \rightHand
> %   \layout {}
> % }
>
> \include "articulate.ly"
>
> \score {
>   \articulate <<
> \new Staff \rightHand
>   >>
>   \midi {}
> }
> %%%
>
> This may be related to the problems with creating the MIDI output of an
> appoggiatura with articulate.

In my book, an appoggiatura is executed at least with the written
duration, and here you take 3/16 of time from 1/8.  How is that supposed
to work?  You probably want \acciaccatura or \grace instead.

What does the music glossary say about LilyPond's idea?

1.20 appoggiatura
=

ES: apoyatura, I: appoggiatura, F: appoggiature, (port de voix), D:
Vorschlag, Vorhalt NL: (korte) voorslag, DK: forslag, S: förslag, FI:
appoggiatura, etuhele.

   Ornamental note, usually a second, that is melodically connected with
the main note following it.  In music before the 19th century
appoggiature were usually performed on the beat, after that mostly
before the beat.  While the short appoggiatura is performed as a short
note regardless of the duration of the main note the duration of the
long appoggiatura is proportional to that of the main note.

Ok, it woulkd appear that my idea (and possibly that of articulate.ly's
author) corresponds with what is described here as "long appoggiatura",
namely being written in the timing of normal notes and taking from the
following note.

-- 
David Kastrup



Re: Question re: scheme, \transpose function

2024-09-16 Thread David Kastrup
Yoshiaki Onishi  writes:

> Dear LilyPonders,
>
> I am grateful for all your input. Synthesizing all the points raised
> in this thread, I realized the solution was to make the .ly file in
> which I made the function in the absolute pitch mode. Then the
> original function worked as expected.

Once you make a coherent summary of your expectations in relative mode,
it is comparatively straightforward to implement it appropriately.

Making such a summary is easier in absolute mode.

However, the principal problem that you should not be using the same
music twice in potentially modifying context without creating copies
will remain even in relative mode.

-- 
David Kastrup



Re: Question re: scheme, \transpose function

2024-09-13 Thread David Kastrup
William Rehwinkel via LilyPond user discussion 
writes:

> Dear Yoshi,
>
> Actually, I think the procedure is working correctly, but using the
> \transpose function within a \relative is causing some weird
> output. For example, the file
>
> % 
> \version "2.25.18"
> \relative c' {
>   c16 
>   c16 
> }
> % 
>
> does not result in the output that I was expecting. Maybe someone else
> can say why this is, but I'll investigate more later.

I have no idea what you were expecting, but transposition produces
absolute music that is impervious to the effects of \relative.

And it is hard to see how this could be otherwise since

\relative c' { c c c }

repeats the same note while

\relative c' { c' c' c' }

generated three different notes, so translating

\relative c' { \transpose c c' { c } }

would produce { c'' c''' c'''' } if it were behaving like you appear to
think it should.

That is not what people expect from transposition.

You can of course write \transpose c c' \relative c' { c c c }
and that will work as expected.

The next thing to remember is that #music does not create a copy of
music while $music and \music do.  And any music function (specifically
\transpose ) is allowed to change its arguments at will.  Which means
that anything that is used more than once in a music function in a
manner that may modify it (like passing it to \transpose) _has_ to be
copied in order not to affect other uses of it.

-- 
David Kastrup



Re: Creating score with unfolded repeats in scheme

2024-09-09 Thread David Kastrup
Morten Lemvigh  writes:

> So the question is: what have I misunderstood? :-)
>
> Best regards,
> Morten
>
> \version "2.24.2"
>
> choirScore = \score {
> \new Staff {
> \relative c' {
> \repeat volta 2 {
> c d e f
> }
> }
> }
> }
>
> make-rehearsal =
> #(define-scheme-function
>   (the-score)
>   (ly:score?)
>   (ly:make-score (unfold-repeats-fully (ly:score-music the-score
>
> new-score = #(make-rehearsal choirScore)
> \new-score

If you define the function with define-scheme-function instead of
#(define ...), why not call it as

new-score = \make-rehearsal \choirScore

?  That's just a detail.  The main problem is that ly:make-score is an
internal function that does not do the full required job of creating a
score from unprepared music.

To get the full preparation necessary, use scorify-music instead of
ly:make-music .  It uses ly:make-music internally but does other
required things.

-- 
David Kastrup



Re: Question about Scheme's syntax

2024-09-05 Thread David Kastrup
Paolo Prete  writes:

> On Thu, Sep 5, 2024 at 2:07 PM David Kastrup  wrote:
>
>> Paolo Prete  writes:
>>
>>
>> Still scheme? instead of markup?
>>
>> Still a scheme function instead of a markup command.
>>
>> >   #{
>> > \markup \with-dimensions #'(0 . 0)
>> #'(0
>> > . 0){
>> >   \override #'(baseline-skip . 0)
>> >   \translate #(cons x y)
>> >   #obj
>> > }
>> >   #})
>> >
>> >
>> > % GOOD
>> > \floating-markup 15 -60 "some string"
>> >
>> > % ERROR
>> > \floating-markup 15 -60 #{ \markup { \circle 1 } #}
>>
>> I made a number of points.  Your "I see" only addressed a single one.
>>
>> To wit, you are still putting a Scheme expression instead of a LilyPond
>> expression in a place only admitting LilyPond syntax.
>>
>> The straightforward way of calling this as-is would be
>>
>> \floating-markup 15 -60 \markup \circle #1
>>
>>
>
> \version "2.24.1"
>
> floating-markup = #(define-scheme-function (parser location x y obj)
> (number? number? scheme?)
>   #{
> \markup \with-dimensions #'(0 . 0) #'(0
> . 0){
>   \override #'(baseline-skip . 0)
>   \translate #(cons x y)
>   #obj
> }
>   #})
>
>
> % GOOD
> \floating-markup 15 -60 "some string"
>
> % ERROR
> \floating-markup 15 -60 \markup \circle #1
>
> %%%
>
> Doesn't seem to compile this way. Did I miss something?

You are again fixing only a single thing from all those I mention.
Other than that, my mistake for not looking up what \circle does.
Indeed, this has to be

\floating-markup 15 -60 \markup \circle 1

because 1 is supposed to be a markup, not a number.  Sorry for that.

As for the other problems: I will not keep telling you them one by one.

-- 
David Kastrup



Re: \omit multiple/list

2024-09-05 Thread David Kastrup
Kieren MacMillan  writes:

> Hi Damian,
>
>> how would I reduce e.g.
>> 
>> \once \omit TupletBracket 
>> \once \omit TupletNumber 
>> \once \omit Stem
>> 
>> to a structure conceptually like:
>> 
>> \once \omit (TupletBracket, TupletNumber, Stem)
>> 
>> i.e. put the grobs in a list
>
> Maybe something like this (but something that actually works LOL):
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> omitt =
>   #(define-scheme-function (groblist) (grob-list?)
>   (for-each
> (lambda (gr)
>   #{ \omit gr #})
>  groblist))
>
> \omitt #'(TimeSignature NoteHead)
> %%%  SNIPPET ENDS

How about

omitt =
#(define-music-function (groblist) (symbol-list?)
  #{ #@(map omit (map list groblist)) #})

\void \displayLilyMusic \omitt TimeSignature,NoteHead

I'll admit that the need for the "map list" surprised me.  You can of
course write the non-surprising

omitt =
#(define-music-function (groblist) (symbol-list?)
  #{ #@(map (lambda (gr) #{ \omit $gr #}) groblist) #})

\void \displayLilyMusic \omitt TimeSignature,NoteHead

> This snippet “works”, in that it iterates through the list and correctly 
> outputs the grob name:
>
> %%%  SNIPPET BEGINS
> omitt =
>   #(define-scheme-function (groblist) (list?)
>   (for-each
> (lambda (gr)
>   (ly:message
>(format #f "~y" gr)))
>  groblist))
>
> \omitt #'(TimeSignature NoteHead)
> %%%  SNIPPET ENDS
>
> I’m just not sure the precise incantation to make the first snippet Do
> The Right Thing™.

You need to return music (instead of pretending that calling omit will
achieve anything by side-effect).

And of course you need a music function.

-- 
David Kastrup



Re: How can I reuse an outline in a score

2024-09-05 Thread David Kastrup
Sebastian Menge  writes:

> I used an "\outline" consisting of silence and the time signatures and
> marks and put it in parallel inside the staff but then the layout gets
> wrong, because the "silence" somehow influences the layout algorithm. (see
> below)

It doesn't.

> Is there a more clever way to organize this?

You can just remove the blunder in your code and try again.

To wit:

>   \clef "treble"
>   \global
>   <<
>  \musicAII  \\
>  \outline
>   >>

<< ... ... >>

makes music parallel.  In contrast,

<< ... \\ ... >>

creates an upper and lower voice context with appropriate settings for
an upper and lower voice context for the left and the right expression
and puts those separate voice contexts with their special settings in
parallel.

That is most definitely not what you want or need here.  Remove the \\ .

-- 
David Kastrup



Re: Question about Scheme's syntax

2024-09-05 Thread David Kastrup
Paolo Prete  writes:

>> On Wed, Sep 4, 2024 at 9:56 PM David Kastrup  wrote:
>>
>>> Paolo Prete  writes:
>>>
>>> > Hello,
>>> >
>>> > Given:
>>> >
>>> > floating-markup = #(define-scheme-function (parser location x y obj)
>>> > (number? number? scheme?)
>>> >   #{
>>> > \markup \with-dimensions #'(0 . 0)
>>> #'(0
>>> > . 0){
>>> >   \override #'(baseline-skip . 0)
>>> >   \translate #(cons x y)
>>> >   #obj
>>> > }
>>> >   #})
>>>
>>> That makes no sense at all.  Obviously #obj cannot be anything but a
>>> markup here but you declare it as scheme? which just asks for obscure
>>> runtime errors.  Then there is no point in not using a markup command
>>> here in the first place.
>>>
>>> >
>>> > I can invoke it with:
>>> >
>>> > \floating-markup 15 -60 "some string"
>>> >
>>> > But how can I pass to the same function the following expression: { 
>>> > \circle
>>> > 5 } as #obj?
>>>
>>> { \circle 5 } is not a LilyPond expression.  It is a fragment of markup.
>>> You can turn it into a LilyPond expression by writing
>>>
>>> \markup { \circle 5 }
>>>
>>> in which case you'll get out an actual markup.  Outside of markup,
>>> \circle is not defined.
>>>
>>> > Something like (pseudo-syntax) :
>>> >
>>> > \floating-markup 15 -60 #{ \circle 5 #}
>>>
>>> #{ ... #} is a Scheme construct, not a LilyPond expression.  It is used
>>> for using LilyPond syntax inside of a Scheme expression.
>>>
>>> If you want to use it (in Scheme!) for writing in markup syntax, again
>>> you need to enter markup mode by writing
>>>
>>> #{ \markup ... #}
>>>
>>> in a Scheme expression.  If you are in LilyPond entry mode, you can just
>> write \markup ... instead.
>>
>
> I see but the problem remains.

That may be because you are not heeding any of my advice.

> I would like to found a way to pass a more structured object to that
> function, not only a string:
>
> %%
> \version "2.24.1"
>
> floating-markup = #(define-scheme-function (parser location x y obj)
> (number? number? scheme?)

Still scheme? instead of markup?

Still a scheme function instead of a markup command.

>   #{
> \markup \with-dimensions #'(0 . 0) #'(0
> . 0){
>   \override #'(baseline-skip . 0)
>   \translate #(cons x y)
>   #obj
>         }
>   #})
>
>
> % GOOD
> \floating-markup 15 -60 "some string"
>
> % ERROR
> \floating-markup 15 -60 #{ \markup { \circle 1 } #}

I made a number of points.  Your "I see" only addressed a single one.

To wit, you are still putting a Scheme expression instead of a LilyPond
expression in a place only admitting LilyPond syntax.

The straightforward way of calling this as-is would be

\floating-markup 15 -60 \markup \circle #1

If you instead defined it as a markup command as suggested, you could
call it _inside_ of markup as, say,

\markup { ... \floating #15 #-60 \circle #1 ... }

which would be the preferable way.

-- 
David Kastrup



Re: Question about Scheme's syntax

2024-09-04 Thread David Kastrup
Paolo Prete  writes:

> Hello,
>
> Given:
>
> floating-markup = #(define-scheme-function (parser location x y obj)
> (number? number? scheme?)
>   #{
> \markup \with-dimensions #'(0 . 0) #'(0
> . 0){
>   \override #'(baseline-skip . 0)
>   \translate #(cons x y)
>   #obj
> }
>   #})

That makes no sense at all.  Obviously #obj cannot be anything but a
markup here but you declare it as scheme? which just asks for obscure
runtime errors.  Then there is no point in not using a markup command
here in the first place.

>
> I can invoke it with:
>
> \floating-markup 15 -60 "some string"
>
> But how can I pass to the same function the following expression: { \circle
> 5 } as #obj?

{ \circle 5 } is not a LilyPond expression.  It is a fragment of markup.
You can turn it into a LilyPond expression by writing

\markup { \circle 5 }

in which case you'll get out an actual markup.  Outside of markup,
\circle is not defined.

> Something like (pseudo-syntax) :
>
> \floating-markup 15 -60 #{ \circle 5 #}

#{ ... #} is a Scheme construct, not a LilyPond expression.  It is used
for using LilyPond syntax inside of a Scheme expression.

If you want to use it (in Scheme!) for writing in markup syntax, again
you need to enter markup mode by writing

#{ \markup ... #}

in a Scheme expression.  If you are in LilyPond entry mode, you can just
write \markup ... instead.

-- 
David Kastrup



Re: Layout going screwy

2024-09-04 Thread David Kastrup
Raphael Mankin  writes:

> On 04/09/2024 11:15, David Kastrup wrote:
>> Raphael Mankin  writes:
>> 
>>> For reasons that not concern us I am  re-typing Cole Porter's Anything
>>> Goes. I get as far as the key change after bar 20 but then the layout
>>> goes wild: no bar numbers, line breaks fail, stray bar on the end.
>>>
>>> I have checked and double checked this, but I cannot see what is
>>> wrong. Any help will be appreciated.
>>>
>>> See attachments
>> I just placed a bar check | before each of your % Bar xxx comments
>> (why
>> keep this important information from LilyPond by hiding it away in a
>> comment) and got the first bar check warning between those lines:
>> |  %Bar 11
>>r4 g8. a16 b8. a16. g4
>>b4 c8 d8~ d4 r4
>>c2. g4
>> |  % Bar14
>> It's easy to see that the a16. is not matched by anything else
>> producing
>> an odd multiple of a 1/32 note.
>
> I was looking for those,  but missed that one
>
> Thank you. An extra pair of eyes etc..

No extra pair of eyes.  I didn't bother combing through your source code
manually like you did.  I just added the bar checks where your comments
already indicated that a bar should be.  As I said: there is no point in
keeping the bar information from LilyPond since LilyPond is pretty good
at spotting inconsistencies.

When organisation of the source is important enough to you that you add
comments like

% Bar14

there is no point whatsoever not to write

| % Bar14 instead

or (as a coding pattern)

   |% 14

If you put the information in the source anyway, give LilyPond a chance
to utilize it.

-- 
David Kastrup



Re: Layout going screwy

2024-09-04 Thread David Kastrup
Raphael Mankin  writes:

> For reasons that not concern us I am  re-typing Cole Porter's Anything
> Goes. I get as far as the key change after bar 20 but then the layout
> goes wild: no bar numbers, line breaks fail, stray bar on the end.
>
> I have checked and double checked this, but I cannot see what is
> wrong. Any help will be appreciated.
>
> See attachments

I just placed a bar check | before each of your % Bar xxx comments (why
keep this important information from LilyPond by hiding it away in a
comment) and got the first bar check warning between those lines:

|  %Bar 11
  r4 g8. a16 b8. a16. g4
  b4 c8 d8~ d4 r4
  c2. g4
|  % Bar14

It's easy to see that the a16. is not matched by anything else producing
an odd multiple of a 1/32 note.

So from that point on, there always is a note crossing any bar line and
LilyPond refrains from breaking in the middle of a note.

Use bar checks.

-- 
David Kastrup



Re: Percussion with lyrics

2024-08-30 Thread David Kastrup
Christ van Willegen  writes:

> Before I dive into creating an MWE, is there anyone on the list who has a
> working template for:
>
> - Lyrics (either in full measure bits, or each set to their own note)
> - Melody (I have a lot of lyrics and melodies already set in Lilypond, so
> being able to re-use this would be great!)
> - PercussionStaff

Just as a note aside: the people who tend to know the internals best
also tend to spend more time working on LilyPond than on working on
compositions of their own and thus are less likely to keep templates
around rather than roll things off the cuff on an as-needed basis.

The knowledge-exchange intersection where knowledge from one type of
person solidifies into templates for another type of person tends to be
comparatively ephemeral and often involves the mailing list.  When such
an exchange leads to an exhaustively working implementation, it has a
good chance to end up as a documented case in the manual.

So trying to avoid a MWE may be a gamble that may lead to solutions that
actually work only in a restricted number of cases not necessarily
matching your own usage pattern well.

-- 
David Kastrup



Re: Null midi device

2024-08-26 Thread David Kastrup
Raphael Mankin  writes:

> Is there a null midi device so that I can say explicitly that I do not
> want midi output for this staff, as opposed to "I have forgotten to
> specify it"?

Does something like

\new Staff \with { \remove "Staff_performer" } { ... }

do what you want?

-- 
David Kastrup



Re: Change stem direction for voice?

2024-08-26 Thread David Kastrup
Timothy Lanfear  writes:

> On 25/08/2024 17:11, Stefano Antonelli wrote:
>> On Sun, 2024-08-25 at 10:47 +0100, Timothy Lanfear wrote:
>>> \version "2.24.0"
>>>
>>> \layout {
>>>\context Voice = "voiceTwo" {
>>>  \override Stem.direction = #UP
>>>  \override Slur.direction = #DOWN
>>>  \override Beam.positions = #'(5 . 5)
>>>}
>>> }
>>>
>>> \new Voice = "voiceTwo" {
>>>g'4 a' b'( c'') d''8 e'' f'' g'' r2
>>> }
>> That works just fine, but I don't want to create an explicit voice.  I
>> should have mentioned that.
>
> I think you have some misunderstandings about the way LilyPond functions.
>
> \new Voice = "voiceTwo" { ... }
>
> creates a voice and gives it an arbitrary label (voiceTwo) so it can
> be referred to later in the LilyPond code.  Labeling the voice has no
> influence on the formatting. In this case, the label happens to be the
> name of a LilyPond command, but that is of no consequence.

\new Voice = "2" { ... } on the other hand will create a voice that the
<< \\ >> construct would recycle for its second voice _if_ it is
accessible at the moment the << \\ >> is encountered.

> (Also, the label has no effect when in a layout block).

It's worthwhile to note that there is a load of difference between

\layout {
  \context {
\Voice
\override ...
  }
}

and

\layout {
  \context Voice {
 \override ...
  }
}

Cf this example:

\layout {
  \context Voice {
\override Stem.color = #red
  }
  \context {
\Voice
\override Stem.thickness = #4
  }
}

\new StaffGroup <<
  \new TabStaff \with { \tabFullNotation } {
c'8 8 8 8 8 8 8 8
  }
  \new Staff {
\clef "violin_8"
c'8 8 8 8 8 8 8 8
  }
>>

> The \\ construct automatically creates voices formatted as if
> \voiceOne, \voiceTwo etc., were present, although it seems these
> commands are not used explicitly.
>
> I can't see any method to achieve what you desire without explicitly
> creating voices and using overrides.

\\ uses make-voice-props-set and I would advise against redefining that.

-- 
David Kastrup


Re: Rhythmic pattern in MIDI

2024-08-17 Thread David Kastrup
Morten Lemvigh  writes:

> Hi,
>
> I have a small piece with a rhythmic pattern like this:
>
> \tempo \markup {
> \rhythm { 8[ 8] } = \rhythm { \tuplet 3/2 { 8(8) 8 } }
> }
>
> Does anybody know of a way I can perform the same mapping on the generated
> MIDI file? I would like to generate a rehearsal file for the piece. It
> should follow the rhythmic pattern, but I would like to avoid typing the
> music in twice.

Sounds like a job for swing.ly
<https://lilypond.org/doc/v2.25/Documentation/notation/the-swing-script>

-- 
David Kastrup



Re: Dynamics in Lyrics?

2024-08-11 Thread David Kastrup
Peter Chubb  writes:

>>>>>> "David" == David Kastrup  writes:
>
> David> if you want a
> David> context to engrave dynamics, it needs the respective engravers.
>
> Thanks David,
>This all kind-of-works.  It'll probably do for my immediate
>needs; but the output is a bit ugly.   I'll have to have a
>think about that.

The output is for normal staves.  Of course you'd want to adjust a
number of settings to make it more suitable for lyrics use.

-- 
David Kastrup



Re: Dynamics in Lyrics?

2024-08-11 Thread David Kastrup
Peter Chubb  writes:

> Hi Folks,
>Is there a simple way to add dynamic markings to lyrics?  In a
>multi-verse song, the dynamics can be different verse to verse.
>
>I'd like to do something like this:
>
> \score {
>   <<
> \new Staff \context Voice = tune {\repeat volta 2 { c c c c }}
> \new Lyrics \lyricsto tune  { \set stanza = "1." \mp get \cresc lou -- 
> der \f here }
> \new Lyrics \lyricsto tune  { \set stanza = "2."  \ff this is very loud  }
> >>
> }

First, dynamics are entered _behind_ the event they are supposed to
attach to, not before.  Second, if you want a context to engrave
dynamics, it needs the respective engravers.  Try

\layout {
  \context {
\Lyrics
\consists "Dynamic_engraver"
\consists "Dynamic_align_engraver"
  }
}

\score {
  <<
\new Staff \context Voice = tune {\repeat volta 2 { c c c c }}
\new Lyrics \lyricsto tune  { \set stanza = "1." get\mp \cresc
  lou -- der here \f }
\new Lyrics \lyricsto tune  { \set stanza = "2."  this\ff is very loud  }
>>
}


-- 
David Kastrup


Re: creating mixtures

2024-07-30 Thread David Kastrup
Stefan Thomas  writes:

> With your help, I was able to create a function that can generate sequences
> of a motif in a simple way:
>
>> multitranspose =
>> #(define-music-function (initton seq  motiv   ) (ly:pitch? ly:music?
>> ly:music?  )
>>   (music-clone seq 'elements
>>(map (lambda (p) #{ \transpose $initton #(ly:music-property p 'pitch )
>>   $motiv  #})
>> (ly:music-property seq 'elements
>
> Instead of having several transpositions of a tone sequence follow one
> another, I would like to have the option of having them sound
> simultaneously, as a mixture.
> I would like to have the possibility to do something like:
> \multitranspose c'' {e' g' c''} {c''4 d'' e'' f'' g''1 }
> With the result:
> 41

Have you tried just entering

\multitranspose << e' g' c'' >> {c''4 d'' e'' f'' g''1 }

?

It would appear like the function is already prepared for dealing with
that functionality.

-- 
David Kastrup



Re: Engravers, fingerings and acknowledgments

2024-07-29 Thread David Kastrup
Lukas-Fabian Moser  writes:

> Hi Luca,
>
> without having tested your code: You're using append! wrong.
>
> From the Guile documentation: "append! is permitted, but not required, to
> modify the given lists to form its return."
> So the exclamation mark does not imply that your list gets modified
> in-place, but rather that you don't care whether or not append! changes
> your original list. So try
>
> (set! fl (append fl ...))
>
> where you could probably also use append! instead of append (I imagine it
> might be more efficient).

Most pertinent:

(append! '() ...)

cannot modify an empty list in-place because there is only one empty
list in the whole system and it is an unchangeable constant.

Indeed Guile happens to modify the given list in-place with append!
whenever it can, but it is impossible for the empty list.

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-27 Thread David Kastrup
Luca Fascione  writes:

> Well... touché. Your talking about right hand fingering (-p) confused me :-)
> How do I dig myself out of this?
> I don't want to make poor use of your time here, I'd just need some
> pointers,
> and maybe I'll be back with questions.

I've re-checked and it would appear that the Fingering_engraver is
actually only responsible for fingerings after all.

Have you tried my other suggestion of just removing it so that its work
is taken over by the New_fingering_engraver which is what you want?

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-27 Thread David Kastrup
Luca Fascione  writes:

> Well... touché. Your talking about right hand fingering (-p) confused
> me :-)

That was actually a typo for -\p so it is likely my own fault.

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-27 Thread David Kastrup
Luca Fascione  writes:

> Hi David, I just tried out your suggestion, and it works quite well.
> One issue I found is that it moves slurs from "above the beam" to "at
> the notehead" (in fact, it seems to me the slur is actually "at the
> fingering")

Which is exactly the issue I predicted you'd want to have addressed
next.

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-25 Thread David Kastrup
Luca Fascione  writes:

> Ok, so. I tested this eventChords idea, and it seems to behave as if this
> a-4
> was entered as this
> -4
> but unfortunately I actually need this
> 
> how can I achieve that?

Uh, yes.

How about

#(define (my-chordify music)
   (map-some-music
 (lambda (m)
   (if (music-is-of-type? m 'event-chord ) m
   (and (music-is-of-type? m 'note-event)
(make-music 'EventChord 'elements (list m)
  music))

toplevel-music-functions = (cons my-chordify toplevel-music-functions)

then?  I guess that next you will be telling me that you want to map

a-4-p

into

-p

instead of



right?

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-24 Thread David Kastrup
Luca Fascione  writes:

> Hi,
> as some of you might remember, I mostly use lilypond to engrave music for
> classical guitar. And I am after a fairly specific way to engrave the
> fingering indications in particular.
>
> Cutting off a long story, one of the consequences of what I want is that I
> have to enclose all notes in a chord <> pair, which is an annoying thing to
> do: everything I need `a-2` I'm having to type ``.
>
> So I was wondering, is there a way I can intercept the input presumably
> during the early stages of parsing and process it so that all "single"
> notes get turned into one-note chords?

Of course that is also possible with a music transformation function.
You can try something like

toplevel-music-functions =
#(cons eventChords toplevel-music-functions)

which will then do this transformation on anything placed in a score.

-- 
David Kastrup



Re: Transforming lilypond input

2024-07-24 Thread David Kastrup
Luca Fascione  writes:

> Hi,
> as some of you might remember, I mostly use lilypond to engrave music for
> classical guitar. And I am after a fairly specific way to engrave the
> fingering indications in particular.
>
> Cutting off a long story, one of the consequences of what I want is that I
> have to enclose all notes in a chord <> pair, which is an annoying thing to
> do: everything I need `a-2` I'm having to type ``.
>
> So I was wondering, is there a way I can intercept the input presumably
> during the early stages of parsing and process it so that all "single"
> notes get turned into one-note chords?

Does

\layout {
  \context {
\Staff
\remove "Fingering_engraver"
  }
}

do what you want?  Note that it has other consequences because the
Fingering_engraver does not just engrave fingerings...

-- 
David Kastrup



Re: scheme: formula instead of value

2024-07-08 Thread David Kastrup
"K. Blum"  writes:

> Hi Valentin, hi Carl,
>
> yes, that does the trick.
> That quoting science is what causes me headaches all the time... ;-)

It's not really science.  You just have to accept that LISP/Scheme does
not have a programming language syntax.

It has a data representation syntax (specifically suited for
representing lists).  And it represents programs in the form of data.
It also represents data in the form of data.  The only difference is
that the former is getting evaluated after input, and quoting stops
evaluation.

-- 
David Kastrup



Re: suppressing implicit TabStaff

2024-06-26 Thread David Kastrup
Jeff Olson  writes:

> On 6/26/2024 12:45 AM, Xavier Scheuer wrote:
>> This works: \new TabStaff \with { \tabFullNotation } { \mus }
>
> Thanks, Xavier.  The NR example, that I now see, also works:
>
>\new TabStaff { \tabFullNotation \mus }

Only if \mus doesn't start with any kind of grace note.

-- 
David Kastrup



Re: suppressing implicit TabStaff

2024-06-25 Thread David Kastrup
Jeff Olson  writes:

> Sometimes guitarists want the same piece two ways: with an added
> TabStaff while learning and without the TabStaff when performing (for
> brevity).  But the code needed to tailor the tab generation also
> screws up the notation when you don't want tab.
>
> My music code has extensive use of "\set TabStaff.minimumFret" which
> works fine when generating an explicit TabStaff.
>
> But attempts to generate only an ordinary Staff from the same music
> code are garbled by the automatic TabStaff that gets generated from
> all the TabStaff settings embedded in that code.

Have you tried just writing \set Staff.minimumFret instead?  TabStaff
listens to the alias Staff as well as its germane TabStaff.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan  writes:

> I tried a few times, but got errors (about returning
> unspecified). Hints appreciated.

for-some-music does not return music.  It works on music in-place.  So
the last thing in your music function must not be for-some-music but
rather the music that you have been working on.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan  writes:

> Hi again,
>
>> There is no necessity to return a new NoteEvent; you can just change
>> pitch on the existing one.
>> 
>> Music functions are allowed to modify their music arguments in place.
>
> This is what I have so far, which appears to do what I want:
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
> (if (music-is-of-type? m 'note-event)
> (if (equal? (ly:pitch-notename (ly:music-property m 'pitch)) 
> (ly:pitch-notename pitchIn))
> (ly:music-set-property! m 'pitch (ly:make-pitch 
> (ly:pitch-octave (ly:music-property m 'pitch)) (ly:pitch-notename pitchOut) 
> 0))
> (make-music 'NoteEvent m))
> (ly:message "Not of type"))
> m)
> music))
>
> \adjustPitch ees e \fixed c' { c4 d es f g c' es' }
> %%%  SNIPPET ENDS
>
> Comments before I move to the next step…?

This will also adjust eis and eses to e.  Note names are numbers and can
be compared with = .  (make-music 'NoteEvent m) is silly and creates an
unnecessary copy.  You can just use m instead.

If you do, you don't replace any music, so music-map is unnecessary.
This can be better done with for-some-music .

-- 
David Kastrup



Re: markup function accepting either markup or markup list as argument

2024-06-22 Thread David Kastrup
Werner LEMBERG  writes:

>> The real question is what you actually are trying to achieve here.
>
> I want to write a user-friendly markup command that can accept either
> a markup or a markup list as arguments.  Example:
>
> ```
> % \ornament   
> \markup \ornament \number ♭
>   \musicglyph "scripts.turn"
>   \number ♮
> \markup \ornament { \number ♭ \number ♭ }
>   \musicglyph "scripts.turn"
>   \number ♮
> ```

So if you give a markup list here, is this supposed to be stacked
horizontally or vertically?  If horizontally, adding \line does not seem
all that terrible.

And it will be hard to explain what

\markup \ornament \with-color #red { \number ♭ \number ♭ } ...

is supposed to do: is \with-color #red applied to the numbers or to the
whole list?

-- 
David Kastrup



Re: markup function accepting either markup or markup list as argument

2024-06-21 Thread David Kastrup
Werner LEMBERG  writes:

> Folks,
>
>
> I would like to write a markup function that can either accept a
> markup or a markup list as an argument.

You mean, a markup command.

> The code below works fine, reporting
>
> ```
> bar: (#)
> baz: 1
> bar: ((#)
>   (#))
> baz: 1
> ```
>
> as expected.  (The `baz` argument is inserted in the demo code to
> avoid interference with LilyPond's special handling of a markup
> function's last argument, which can be either a markup or a markup
> list, for example, `\bold foo` or `\bold { foo bar }`.)
>
> However, if I activate the commented-out code, LilyPond aborts with
>
> ```
> error: syntax error, unexpected MARKUP_FUNCTION
> \markup \fooEither 
>\flat #1
> ```
>
> It seems to me that this is a limitation built into LilyPond's parser,
> and it is not possible to do what I would like to achieve, probably
> due to the above-mentioned special handling of the last argument.  Has
> someone more insight?

The documentation clearly states:

<http://lilypond.org/doc/v2.25/Documentation/extending/markup-command-definition-syntax>

   Arguments are distinguished according to their type:
   • a markup, corresponding to type predicate ‘markup?’;
   • a list of markups, corresponding to type predicate ‘markup-list?’;
   • any other scheme object, corresponding to type predicates such as
 ‘list?’, ‘number?’, ‘boolean?’, etc.

You use a predicate other than markup? or markup-list?, so this counts
as any other scheme object.

The real question is what you actually are trying to achieve here.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Lukas-Fabian Moser  writes:

> Elaborating on David's explanation, it might be instructive to study the
> output of:
>
> \version "2.25.9"
>
> mappingFunction =
> #(define-music-function (music) (ly:music?)
>(music-map
> (lambda (m)
>   (ly:message "Considering music:\n~a\n-\n"
>   ((@@ (lily) music->lily-string) m))
>   m)
> music))
>
> \mappingFunction
> \new PianoStaff
> <<
>   \new Staff \relative { c'4 d e c }
>   \new Staff \relative { c' g c c }
>>>

If you don't want to call upon undocumented internals of LilyPond (the
(@@ (lily) ...) bit), you can just use

\version "2.25.9"

mappingFunction =
#(define-music-function (music) (ly:music?)
   (music-map
(lambda (m)
 (ly:message "Considering music:~a-\n"
  (with-output-to-string (lambda () (displayLilyMusic m
  m)
    music))

\mappingFunction
\new PianoStaff
<<
  \new Staff \relative { c'4 d e c }
  \new Staff \relative { c' g c c }
>>


-- 
David Kastrup


Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Lukas-Fabian Moser  writes:

> But: Whether you use music-map or map-some-music, your helper function
> (your lambda) is expected to return the new music into which the given
> argument m should be transformed. So in any case, your lambda function
> should return music - in the trivial case, it could return m itself
> without change, but in the long run, you want to return a new
> note-event, i.e. (make-music 'NoteEvent ...).
>
> For this, it will come in handy that it's possible to do
>
> (make-music 'NoteEvent m)
>
> i.e. create a new NoteEvent that takes its 'pitch (which you're going to
> overwrite using an additional 'pitch ), 'articulation etc.
> properties from m. (This is explained somewhere in Jean's guide.)

There is no necessity to return a new NoteEvent; you can just change
pitch on the existing one.

Music functions are allowed to modify their music arguments in place.

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan  writes:

> Hi all,
>
> Thank you for the rapid-iteration non-isochronous Scheme class!  :)
>
> Before I do the next step, is this optimal at this point?
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
> (if (music-is-of-type? m 'note-event)
> (ly:message "Pitch is: ~a" (ly:music-property m 'pitch))
> #f)
> m)
> music))
>
> \adjustPitch es es \fixed c' { c4 d e f g a b c' }
> %%%  SNIPPET ENDS

To say something is "optimal", you have to state your objective.
music-map is used for changing music, and you don't appear to do any
useful changes to the music.  In fact, you replace note events with
*undefined* which appears comparatively useless.

So what are you trying to achieve here?

-- 
David Kastrup



Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan  writes:

> Hi again,
>
> I’m a little confused that the output of
>
> %%%  SNIPPET BEGINS
> \version "2.25.11"
>
> adjustPitch = 
> #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? 
> ly:music?)
>(music-map
> (lambda (m)
>   (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)
> music))
>
> \adjustPitch es es \fixed c' { c4 d e f g a b c' }
> %%%  SNIPPET ENDS
>
> is
>
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: #
> Pitch is: ()
> Pitch is: ()
>
> What is causing the last two output lines?

Well, what do you think should be the pitch of

{ c4 d e f g a b c' }

and of

\fixed c' { c4 d e f g a b c' }

?

If you want to only look at note events, you need to check for them
yourself.  music-map is not discriminating.

-- 
David Kastrup



Re: accessing markup properties via \tweak?

2024-06-20 Thread David Kastrup
Werner LEMBERG  writes:

> Hello David,
>
>
>>> is it possible to access markup properties like `baseline-skip` via
>>> \tweak?
>> 
>> Have you tried?
>
> Well, yes, but ...
>
>> Check out the following example where I just add a few lines in
>> front of what you wrote:
>
> ... it didn't occur to me to go this route.  Thanks a lot!
>
> Regarding `define-grob-property`: What do you think of making this a
> public function?

Nothing in this state.

> Of course, the documentation should mention "that such additions are
> not limited in scope and will persist beyond the currently processed
> file." (as you write in
> https://lists.gnu.org/archive/html/lilypond-devel/2016-09/msg00116.html)

Which is a problem.  If the implementation is fixed so that this doesn't
occur, this would make sense.

But public functions should not meddle in session-transceding variables.

-- 
David Kastrup



Re: accessing markup properties via \tweak?

2024-06-19 Thread David Kastrup
Werner LEMBERG  writes:

> Folks,
>
>
> is it possible to access markup properties like `baseline-skip` via
> \tweak?

Have you tried?

If it is a grob property...

> In the example below, I want to set the markup property `bar` as a
> tweak to influence `\foo`.

Check out the following example where I just add a few lines in front of
what you wrote:

#(define (define-grob-property symbol type? description)
  (if (not (equal? (object-property symbol 'backend-doc) #f))
  (ly:error (G_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'backend-type? type?)
  (set-object-property! symbol 'backend-doc description)
  symbol)

#(define-grob-property 'bar number? "Werner's specialty")

#(define-markup-command (foo-markup layout props) ()
   #:properties ((bar 10))
   (interpret-markup
layout props
#{
  \markup \fontsize #bar \natural
#}))

foo =
#(define-music-function () ()
   #{
 \tweak parent-alignment-X #CENTER
 \tweak self-alignment-X #CENTER
 -\markup \foo-markup
   #})

{
  f'2-\foo
  f'2-\tweak bar #5 \foo % This tweak (expectedly) fails.
}


-- 
David Kastrup


Re: color text in markup

2024-06-10 Thread David Kastrup
Виноградов Юрий  writes:

> I'm grateful for your help. But you could not suggest the same
> solution but for the text in \lyricmode section.

\markup … can perfectly well be used for lyrics.

-- 
David Kastrup



Re: 6 and 8 string tab

2024-06-05 Thread David Kastrup
Walt North  writes:

> I occasionally write out Tab notation parts for 6 or 8 string lap
> steel guitar. I have created tuning entries for these and it works
> well using Minimum fret and max fret difference values.  Here is my
> question. 90% of the time I only need the upper six strings and just
> occasionally dip down to the 7th and 8th strings for a few
> notes. Which means most of the time there is unneeded page space used
> up.  I could use different tab staffs intermittently  but that gets
> pretty cumbersome when it is only be an occasional note or two.  And
> I've never been able to get things realigned vertically when going
> back and forth  between 6 string and 8 string tabstaff.
>
> Is there any approach that would add just a lower tabstaff line for
> the 7th or 8th string as needed - similar to the way ledger lines are
> added to regular staff when the notes go down to middle C or lower?
>
> Maybe something with markup?

Have you tried adding the Ledger_line_engraver to your TabStaff ?

Do you have any example code to work with?

-- 
David Kastrup



Re: acciaccatura on lieder set

2024-05-28 Thread David Kastrup
Stephan Schöll  writes:

> Try adding a grace spacer in the melody at the moment of the
> acciaccaturas in the piano:
>
>     \new Voice \relative c' {
>   \global
>   \grace s8 g'2. |
>     }

<https://gitlab.com/lilypond/lilypond/-/issues/34>

The day will come when this will get smited.

-- 
David Kastrup



Re: Distinguishing semibreve and minim rests without a staff

2024-05-27 Thread David Kastrup
Cameron Horsburgh  writes:

> Hi folks,
>
> I'm writing a resource for beginner musicians, and many of the early
> exercises I'm writing don't use staff lines (Lilypond's 'easy play' feature
> is very useful here!)
>
> One problem I have--it's very difficult to distinguish minim/half-note
> rests from semibreve/full-note rests, because they're essentially the same
> glyph but situated either above or below a staff line. When displaying
> these symbols without a staff it's fairly common to add a short line at the
> appropriate place on the glyph so the type of rest can easily be
> determined. I can't think of any straightforward way to do this in LilyPond
> though.
>
> Has anyone else found a way around this problem?

I can't think of any straightforward way _not_ to do this in LilyPond.

All of

\new Staff \with { \override StaffSymbol.line-count = 0 }
{ r1 r2 r2 }

\markup { \rest { 1 } \hspace #1 \rest { 2 } }

shows clearly distinguishable rest glyphs with the respective stubs.
What did you try that _didn't_ show the line stubs?

-- 
David Kastrup



Re: Scheme help

2024-05-24 Thread David Kastrup
Valentin Petzel  writes:

> Hello Kevin,
>
> When you call a music expression like \music Lilypond will allways pass a 
> copy 
> of that music object. Thus some music functions assume it is safe to modify 
> the original music object. So when you do
>
> \keepWithTag ... #music
>
> you will first remove everything tagged without v1, then everything tagged 
> without v2 and so on. So in the end only untagged and tagged with everything 
> will persist. Then you get multiple references to that music object.
>
> What you need to do is to copy the music object passed using ly:music-deep-
> copy:
>
> %%%
> repeat-verses =
> #(define-music-function ( count music  )
> ( index? ly:music? )
>(make-music 'SequentialMusic 'elements
>  (map-in-order
>   (lambda (verse)
>(begin
> (define versenum
>  (string->symbol (string-join (list "v" (number->string verse)) "" )))
>  #{ \keepWithTag #versenum #(ly:music-deep-copy music) #})) 
>   (iota count 1

Out of shere laziness, I'd be using
$music here instead of #(ly:music-deep-copy music).  $music is the
Scheme equivalent of \music (including making a copy and suffering from
an early evaluation effect).

It is also possible to replace

#{ \keepWithTag #versenum #(ly:music-deep-copy music) #}

with

(keepWithTag versenum (ly:music-deep-copy music))

but there is a slight difference regarding point-and-click behavior and
typesetting-time error messages.  A closer equivalent would be

(ly:set-origin! (keepWithTag versenum (ly:music-deep-copy music (*location*

So the #{ ... $xxx #} variant keeps track of a few details behind the
scene that are not relevant for the function itself but that might come
in handy eventually.

> %%%
> repeat-verses =
> #(define-music-function ( count music  )
> ( index? ly:music? )
>(make-music 'SequentialMusic 'elements
>  (map-in-order
>   (lambda (verse)
>(let ((versenum (string->symbol (format #f "v~a" verse
>  (keepWithTag versenum (ly:music-deep-copy music
>   (iota count 1
>
> \repeat-verses 3 { \tag #'v1 c' \tag #'v2 d' \tag #'v3 e' f' }
> %%%

There actually is no reason to use `map-in-order' over just `map' here
since the loop body has no side effects.

Your Scheme inner construct does not touch the
point-and-click/error-location data.  That may or may not be what is
desired.  The guesses that #{ $... #} takes in that regard have a
certain chance of being what the user would prefer.

-- 
David Kastrup



Re: How to transpose?

2024-05-23 Thread David Kastrup
Kenneth Flak  writes:

> Great, thanks to both of you! Very clarifying. \transposition is, thus,
> going in the direction of instrument -> playback,

More like display pitch -> concert pitch.

> whereas \transpose goes in the opposite direction, if I understand it
> correctly.

\transpose changes the display pitch.  It does not touch the relation
between display pitch and concert pitch.

So if you want to change the relation between display pitch and
instrument pitch after already having declared a \transposition, you get
into kind of a bind.

-- 
David Kastrup



Re: DIfferent note values within a chord

2024-05-21 Thread David Kastrup
Aaron Hill  writes:

> On 2024-05-21 6:40 am, Jun Tamura wrote:
>> Hello,
>> Could someone give me a pointer for this?
>> This is a quite popular notation for bowed string instruments. I’m
>> almost certain that I saw a way to achieve this before but could not
>> find it this time.
>
>
> What you typically do is \tweak the duration-log property of the
> notehead you want to change.  In the example you provided, begin with
> all notes simply as half-notes.  The only notehead you need to adjust
> will be the low one.
>
> 
> \version "2.25.13"
>
> {
>   \clef bass \omit Staff.Clef
>   \omit Staff.TimeSignature
>   \stemDown
>
>   <\tweak duration-log 2 d, d a>2
>   <\tweak duration-log 2 d a f'>2
>   <\tweak duration-log 2 e, c e>2 \fermata
> }
> 

Frankly, someone™ should put in the work to make

\version "2.25.13"

{
  \clef bass \omit Staff.Clef
  \omit Staff.TimeSignature
  \stemDown

  << d,4 d2 a >>
  << d4 a2 f' >>
  << e,4 c2 e \fermata >>
}


just work.  There is an additional bit of ickiness for per-note
articulations as compared to per-chord articulations since per-note
articulations would require an extra < > bracketing around the note in
question in addition to << >> around the chord.

Also you need to take care when using that construct in \relative since
< ... > conveys the _first_ pitch in the chord as the current relative
pitch to the next note while << ... >> conveys the _last_ pitch.  So
switching between the two does involve some editing.

-- 
David Kastrup



Re: Conditional code in the midi block

2024-05-20 Thread David Kastrup
Jean Abou Samra  writes:

> Alternatively, you can do it more like you were envisioning, but for
> technical reasons, you have to start the Scheme code with $ , not # ,
> and you also have to include an extra \midi { } around the \context
> blocks (basically because \context outside \layout or \midi is a
> different command).


> The # vs $ issue is explained here:
> https://extending-lilypond.gitlab.io/en/extending/lily-and-scheme.html#hash-vs-dollar

No, it isn't.  What happens here is actually not as much a "technical
reason" as a design decision.  The difference between $ and # explained
in the manual entry is orthogonal to it.

Here is the rundown:

$ produces a token category based on the type of the expression.  That
means that the type of the expression can change the way the parser
parses an expression, and that can be important since the parser may use
lookahead to make its decisions, and that may mean that the type of the
token (and thus the underlying expression) may need to be known before
the previous expression is given its place in the grammar.

# does produce a single token category.  That means that the parsing can
go ahead without even knowing the value of the expression, and the
expression is only evaluated once its value is actually needed, making
for more predictable evaluation order.

That much is sort of in the manual.  But what isn't there is that
whenever # is going to be accepted, there must be an explicit rule in
the grammar accepting it, and that essentially means that when that rule
is considered applicable, the grammar is fixed.

That still is sort of in the manual.  But here is where the design
decision comes into play: Scheme may be executed for the purpose of
creating a side effect, like assigning a value to a variable.  When a
Scheme function is being called, it doesn't know whether its return
value is going to get used for anything, and a Scheme function executed
for its side effect may or may not return a meaningful value.

The most prominent side effect is a variable assignment.  So as kind of
a design rule, at any place in the grammar where you could conceivably
write an assignment, the value returned by #... is getting ignored
because the expression may only have been called for its side effect,
like an assigment.

Now $ should never be called just for a side effect (because it is kind
of a sledgehammer you should not be using unnecessarily).  Function
calls introduced by \ are explicitly declared to be of the kind where
LilyPond knows when it is supposed to be using the return value.  And
calling a variable by its name \... does not cause a side effect, so it
is safe to assume that you are not invoking its name for the purpose of
getting a side effect.

So this "I am ignoring the result in contexts where assignments may
occur" rule only is made to affect # as a way of invoking Scheme
expressions.

Where and how should we document/put this rationale so that future
contributors and power users are able to understand the current behavior
and make qualified decisions about future behavior?

I am not sold on this being the best/simplest/most logical that LilyPond
can be made to behave.  But at the current point of time, I don't know
how to do better.  And when someone wants to change it, I'd like them to
be aware of the rationale behind the current behavior.

-- 
David Kastrup



Re: Key signatures in MIDI output

2024-05-14 Thread David Kastrup
Giles Boardman  writes:

> Hello,
>
> I have figured "it" out - Cakewalk expects Key Signature to be in
> Track 0 of a Midi file and Lilypond puts it in whichever track has it
> in, which is much more sensible. I realized this while compiling the
> cry for help below, so I've left my workings out in the message, but
> that seems to be the long and short of it.

Using a tool to convert the MIDI file to format 0 (or what it was
called) might help?

-- 
David Kastrup



Re: Key signatures in MIDI output

2024-05-11 Thread David Kastrup
Giles Boardman  writes:

> You are, of course, right. Your evidence is clear. The position of the \key 
> command seems a strong candidate but I can't get it into the .MID even in the 
> simplest of snippet.
>
> As I mentioned I also have other behaviour I can't explain so it could also 
> be version related. I reinstalled the latest version I could find before the 
> release date of Windows 10, but it hasn't changed anything. I prefer to keep 
> my music-related work on a Windows 8.1 machine but that can  change .
>
> What I am trying to do is this:
>
> I have a big "library" of small, simple tunes that are variables, named for 
> their name and reference.
> I have "compiled" the library and found errors, which I have corrected.
> Now I can create medleys and audition them much more quickly than otherwise 
> possible by referring to the pieces by their variable name.
> Like this .
>
> \version "2.18.2"
> % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly"
> % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly"
>
> "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time 
> 1/8 \partial 8  g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. 
> d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 
> \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } }
> \score {
> {
> \key d\major
> \"1K002-1a-_WILLIE_SHAW"
> }
>
>  \layout { }
>
>   \midi { }
> }

Filename: /tmp/xxx.midi
MIDI format:  1 (one or more simultaneous tracks)
Divisions:1536 per whole note
#Tracks:  2

Track 1:
Time 0:
Text:   creator: 
Text:   LilyPond 2.25.12  
Time signature: 1/8, metronome 1/8
Marker: 1K002-1a-
Tempo:  100 msec/quarter
Time 192: 
Time signature: 4/4, metronome 1/4
Time 4800: 
Time signature: 7/8, metronome 1/8
Time 6144: 
End of Track

Track 2:
Time 0:
Track name: \new:
Key signature: D major
Note on: Channel 0, G5(79)@90
Time 192: 
Note off: Channel 0, G5(79)
Note on: Channel 0, Fis5(78)@90
Time 288: 
Note off: Channel 0, Fis5(78)
Note on: Channel 0, D5(74)@90
Time 576: 
Note off: Channel 0, D5(74)
Note on: Channel 0, B4(71)@90
Time 864: 
Note off: Channel 0, B4(71)
Note on: Channel 0, D5(74)@90
Time 960: 
Note off: Channel 0, D5(74)
Note on: Channel 0, A4(69)@90
Time 1344: 
Note off: Channel 0, A4(69)
Note on: Channel 0, Fis4(66)@90
Time 1728: 
Note off: Channel 0, Fis4(66)
Note on: Channel 0, Fis4(66)@90
Time 1824: 
Note off: Channel 0, Fis4(66)
Note on: Channel 0, A4(69)@90
Time 2112: 
Note off: Channel 0, A4(69)
Note on: Channel 0, D5(74)@90
Time 2400: 
Note off: Channel 0, D5(74)
Note on: Channel 0, Fis5(78)@90
Time 2496: 
Note off: Channel 0, Fis5(78)
Note on: Channel 0, G5(79)@90
Time 2592: 
Note off: Channel 0, G5(79)
Note on: Channel 0, E5(76)@90
Time 2880: 
Note off: Channel 0, E5(76)
Note on: Channel 0, E5(76)@90
Time 3168: 
Note off: Channel 0, E5(76)
Note on: Channel 0, G5(79)@90
Time 3264: 
Note off: Channel 0, G5(79)
Note on: Channel 0, Fis5(78)@90
Time 3360: 
Note off: Channel 0, Fis5(78)
Note on: Channel 0, D5(74)@90
Time 3648: 
Note off: Channel 0, D5(74)
Note on: Channel 0, B4(71)@90
Time 3936: 
Note off: Channel 0, B4(71)
Note on: Channel 0, D5(74)@90
Time 4032: 
Note off: Channel 0, D5(74)
Note on: Channel 0, A4(69)@90
Time 4416: 
Note off: Channel 0, A4(69)
Note on: Channel 0, Fis4(66)@90
Time 4800: 
Note off: Channel 0, Fis4(66)
Note on: Channel 0, Fis4(66)@90
Time 4896: 
Note off: Channel 0, Fis4(66)
Note on: Channel 0, A4(69)@90
Time 5184: 
Note off: Channel 0, A4(69)
Note on: Channel 0, D5(74)@90
Time 5472: 
Note off: Channel 0, D5(74)
Note on: Channel 0, E5(76)@90
Time 5568: 
Note off: Channel 0, E5(76)
Note on: Channel 0, Fis5(78)@90
Time 5664: 
Note off: Channel 0, Fis5(78)
Note on: Channel 0, D5(74)@90
Time 5952: 
Note off: Channel 0, D5(74)
Note on: Channel 0, D5(74)@90
Time 6144: 
Note off: Channel 0, D5(74)
End of Track

As you can see, the key signature is right with the content track (track
2) and right at the start.

You really need to figure out which part of your processing then loses
it.

-- 
David Kastrup



Re: Key signatures in MIDI output

2024-05-11 Thread David Kastrup
msk...@ansuz.sooke.bc.ca writes:

> On Sat, 11 May 2024, Giles Boardman wrote:
>
>> When I create MIDI output from Lilypond, if I have imported a MIDI file and
>> then resaved it with changes made in LilyPond, the output is like that, too.
>
> Lilypond as such does not import MIDI files.  I think you must be using
> some piece of software other than Lilypond, and that is relevant to the
> issues you're experiencing.
>
> On the off chance that you might be using midi2ly, I tried round-tripping
> my example code through that, and got suggestive results.

A good viewer of MIDI file content is

lilymidi --pretty

followed by the MIDI file name on the command line.

-- 
David Kastrup



Re: Key signatures in MIDI output

2024-05-11 Thread David Kastrup
Giles Boardman  writes:

> However, when I create new files, I am getting output that is as if I
> have chosen to write everything in C major, with all the flats and
> sharps shown explicitly. Nevertheless, the screen and pdf output are
> written in, for example G, with no sharps on the individual fis notes.

This is when further discussion becomes pointless without an actual
example illustrating the problem.

-- 
David Kastrup



Re: Key signatures in MIDI output

2024-05-10 Thread David Kastrup
Giles Boardman  writes:

> Hello,
>
> I am reading that I can create MIDI output which is different from the
> printed output. For example, I can unfold repeats in the midi output
> but use alternative endings and double barlines in my score. Awesome!
>
> So, I tried it and I notice that my MIDI output doesn't reflect the
> key signatures (everything is in C with accidentals) while my
> on-screen preview (even when I only have a midi block and no layout
> block) and the .pdf have sharps and flats at the beginning of the
> staff.
>
> The snippet about midi output in the documentation show the key
> signature as written in the example, but as mentioned, that doesn't
> mean it has made it into the MIDI file. Before I troubleshoot further,
> can anyone confirm what I should expect, please?

Key signatures are a facet of MIDI files, not of a live MIDI stream.  If
you play music via a sequencer, the sequencer knows the signature, the
instrument doesn't.

At least that's what I remember.

-- 
David Kastrup



Re: MIDI format and MIDI resolution

2024-05-09 Thread David Kastrup
Giles Boardman  writes:

> Is that "no, you can't tell me" or "no, it can't be done? (Just
> kidding). Thanks very much. It will save me spending time looking.

It is "it is hardwired into the source code to a degree where it would
require some really heavy lifting to make it adaptable".

It would be easier (but not trivial) to hardwire it to a different fixed
value, but then your copy of LilyPond would be incompatible with
everybody else's which is a maintenance nightmare, meaning that it
should only be attempted by people who are probably versed enough as
programmers as to be able to contribute a variable-size tick.

"it can't be done" is not a thing with Free Software.  It's more like
"if you have to ask, you may be the wrong person to do this as your
first project".

-- 
David Kastrup



Re: MIDI format and MIDI resolution

2024-05-09 Thread David Kastrup
Giles Boardman  writes:

> Hello,
> Can anyone tell me if it is possible to generate Midi format 0 files

No.

> and whether it is possible to control the resolution setting.

No.

> I have been standardising resolution for midi files from different
> sources and the value I chose is not the one output by Lilypond.

Why?  You can use MIDI processors to generate format 0 and change
resolution.

-- 
David Kastrup



Re: Markuplist and formatted text

2024-05-04 Thread David Kastrup
"Fr. Samuel Springuel"  writes:

> Okay, so then I need to break up the string to create separate markups
> (except in the critical location around the italics text:
>
> \version "2.24.3"
>
> \markuplist \wordwrap-lines { test test test test test test test test
> test test test test test test test test test test test test test test
> test test test test \concat { \italic { "italic text" }"," } test test
> test test test test test test test test test test test test test test
> test test test test test test test }
>
> I can’t seem to get \wordwrap-string to work in this context (even
> after switching \markuplist to \markup).  It barfs if \concat is
> inside of it (unrecognized escape string) and if it’s put inside
> \concat, then it only applies to the immediate string, not the
> resulting concatenated whole.

What is the actual problem you are trying to solve here?

-- 
David Kastrup



Re: Markuplist and formatted text

2024-05-04 Thread David Kastrup
"Fr. Samuel Springuel"  writes:

> Word wrapping does not appear to be functioning in this solution:
>
> \version "2.24.3"
>
> \markuplist \wordwrap-lines {\concat { "test test test test test test
> test test test test test test test test test test test test test test
> test test test test test test test test test test test test test
> "\italic { "italic text" }", test test test" }}
>
> The text just runs of the page to the right.

That is as intended.  \wordwrap-lines breaks between individual markups,
and you only have one.

You probably want \wordwrap-string (there is no \wordwrap-string-lines
though that would give you a markup list).

-- 
David Kastrup



Re: Markuplist and formatted text

2024-05-04 Thread David Kastrup
"Fr. Samuel Springuel"  writes:

> How do I get the comma (which is not italicized) attached to the
> italics text just before it?

You got your question answered by another use already, so I'll just add
that typesetters will usually tend to give punctuation the shape of the
word adjacent to it for typographical rather than logical wholesomeness.

That LilyPond makes it programmatically awkward to change shape without
intervening space is not intentional; rather it is a side effect from
punctuation usually being placed immediately adjacent to the preceding
word.

-- 
David Kastrup



Re: Trouble with concat in a markup command

2024-05-04 Thread David Kastrup
Alec Bartsch  writes:

> I'm attempting to write a markup command that, in addition to other
> formatting, strips a trailing # or b character off the end of the text
> argument and replaces it with the appropriate accidental markup. I think
> I'm super-close but stuck on the proper syntax for passing a markup list to
> the concat. Here's what I've got so far:
>
> #(define-markup-command (page-header layout props text) (markup?)
> "Page header style including optional trailing accidental"
> (let* (
> (last-char (string-ref text (1- (string-length text
> (prefix (substring text 0 (1- (string-length text
> )
> (interpret-markup layout props
> (markup #:override '(font-name . "Avenir Heavy") #:fontsize 5
> (make-concat-markup (cond
> ((char=? last-char #\#) (list prefix #:hspace 0.2
> #:fontsize -2.5 #:raise 0.6 #:sharp))
> ((char=? last-char #\b) (list prefix #:hspace 0.2
> #:fontsize -2.5 #:raise 0.6 #:flat))
> (else (list text))
> ))
> )
> )
> )
> )
>
> \markup \page-header "Key of Bb"

The markup macro is something that works so-soish.  As a macro, it
doesn't wait for its arguments to be evaluated but looks at them before
they are being evaluated.  It (hopefully) won't look inside a function
call like make-concat-markup.  #{ \markup ... #} tends to behave more
predictable if slower.  Fixing this up for your use case you'd write
something akin to

#(define-markup-command (page-header layout props text) (markup?)
"Page header style including optional trailing accidental"
(let* (
(last-char (string-ref text (1- (string-length text
(prefix (substring text 0 (1- (string-length text
)
(interpret-markup layout props
(markup #:override '(font-name . "Avenir Heavy") #:fontsize 5
(make-concat-markup (cond
((char=? last-char #\#) (list prefix (markup #:hspace 0.2
#:fontsize -2.5 #:raise 0.6 #:sharp)))
((char=? last-char #\b) (list prefix (markup #:hspace 0.2
#:fontsize -2.5 #:raise 0.6 #:flat)))
(else (list text))
))
)
)
)
)

\markup \page-header "Key of Bb"


-- 
David Kastrup


Re: parenthesis around dot only (note value indication)

2024-05-01 Thread David Kastrup
Dirck Nagy  writes:

> Hi all
>
> I know this is highly unusual, but is there a way to add parentheses
> around the DOT ONLY after the notehead?
>
> see following image:
>
> [cid:85851784-8a26-48b0-b2b4-b9a8e03b517c]
> FYI, I have a piece with sequences of octaves.  Every instance has a
> note value of a dotted quarter-note.
>
> There is, however, one (only one!)  instance where the upper note
> cannot be held the full value, because it would be physically
> impossible to play.  I want to avoid splitting this into separate
> voices because it would clutter up the measure, (would require 4
> separate voices on one staff) and make reading more cumbersome.

Well, the "canonical" incantation expressing just what you want to do
would be

{
  4.
}

The problem is that this results in the left paren clashing with the
stem.  I haven't found a good fix for moving the dots.  Here is one
attempt at moving the parens instead:

{
  \tweak Dots.extra-spacing-width #'(.2 . .2)
  4.
}

Wish I could get the actual dots to move, but maybe someone else has an
idea for that.

-- 
David Kastrup



Re: How to manually set MIDI channel # for a staff?

2024-04-29 Thread David Kastrup
Jean Abou Samra  writes:

> Le lundi 29 avril 2024 à 06:31 -0500, Jason Yip a écrit :
>> Hi,
>> 
>> Does anyone know how to manually set the midi channel # for a staff to 
>> something other than the default of channel 0/1? Without having to 
>> create dummy staffs with just `s256` as the voice content preceding the 
>> desired staff? The staff in question usually only has one voice, so I 
>> modified the midi context as shown below simply made a bunch of dummy 
>> voices with only `s256` as the content so that they don't at least 
>> affect the graphical output:
>> 
>> ```
>>   \midi {
>>    \context {
>>  \Staff
>>  \remove "Staff_performer"
>>    }
>>    \context {
>>  \Voice
>>  \consists "Staff_performer"
>>    }
>>  }
>> ```
>
>
> You can do \set Score.midiChannelMapping = #'voice as an alternative to that.

We really need a plain simple way to set a fixed channel.  There is
enough hardware around using dedicated channels.

-- 
David Kastrup



Re: Overriding default text of \f, \p, etc.

2024-04-12 Thread David Kastrup
YTG 1234  writes:

> Hello List,
>
> I want to override the default text markup used with commands such as
> \f, \p, \mf, etc.
>
> However, trying to define f = #(make-dynamic-script ...) doesn't work
> because Lilypond interprets f as a note-name.

You could switch to Italian note names temporarily… Just kidding: the
sane solution of using quote marks has been already covered in two
replies.

-- 
David Kastrup



Re: English Note names alternatives

2024-04-06 Thread David Kastrup
"Fr. Samuel Springuel"  writes:

> I just discovered that in English, there’s a shorter way to name notes
> that would normally be specified with “-sharp” or “-flat”: “s” and
> “f”.  E.g. “f-sharp” can be written as “fs” and “b-flat” can be
> written as “bf”.
>
> However, I noticed that this is not documented in the Music Glossary:
> https://lilypond.org/doc/v2.24/Documentation/music-glossary/pitch-names. Only
> the “-sharp” and “-flat” name are mentioned there.  Is there a reason
> this behavior is not documented?  It is certainly much easier to type
> the shorter name than the longer one but I don’t want to rely on
> something that might break unexpectedly.

The glossary does not document LilyPond but common language.  It wrote
about "c-sharp" long before the English input language allowed the
spelling "c-sharp" (I think the original long name might have been
csharp).

-- 
David Kastrup



Re: Question regarding ChordNames

2024-03-13 Thread David Kastrup
John Helly  writes:

> Aloha.
>
> Here's an MWE to exhibit the issue.
>
> I have a flat note (bes) that I want to transpose down 4 half-tones to
> F#.  However, when the transpose is applied, the result is Gb.  I
> understand that a flat note was the initial value so maybe LP is
> preserving that specification?

In LilyPond there is no such thing as "transpose down 4 half-tones".
You transpose from one key to another, not by a distance.

> Nonetheless, short of re-writing the whole piece in A rather than C#,
> is there a way to specify the enharmonic representation for an F#
> rather than Gb, for example?
>
> bflat = \chordmode { bes1 }
> <<
> \transpose cis' a {
>  \new ChordNames { \bflat  }
> }
>>>

\transpose cis' a will remove 4 sharps, take -4 steps on the circle of
fifths.  If you'd rather add 8 steps on the circle of fifths (the
difference implying that the circle isn't actually a closed circle), you
need to write something like \transpose des' a instead.

-- 
David Kastrup



Re: Multiple connected slurs

2024-03-03 Thread David Kastrup
Gerardo Ballabio  writes:

> Hello,
> please what is the correct way to draw multiple slurs connected to
> each other? Look at example below to see what I mean (result
> attached).
>
> The following code does what I want but it gives multiple warnings like these:
>
> Parsing...
> slur.ly:4:3: warning: Unattached SlurEvent
> Interpreting music...
> slur.ly:4:13: warning: cannot end slur
>
> I tried using ties instead of slurs, that doesn't give warnings, but
> it doesn't look quite the same.
>
> Thanks
> Gerardo
>
> % slur.ly
> %%
> \version "2.24.1"
>
> \new Staff \relative {
>   ( c''1:32 ) | ( c1:32 ) | ( c1:32 ) | ( c4 ) r4 r2 |
> }
> %%

You need to use the correct syntax for slurs in the first place.  Both (
and ) come right after the note they connect to, and the reason for that
is exactly because it makes it easy to make properly connected adjacent
slurs.

You should not ignore syntax warnings LilyPond gives you: they indicate
a problem with your source file.

-- 
David Kastrup



Re: Adding to a tagGroup on the fly

2024-03-02 Thread David Kastrup
Simon Albrecht  writes:

> On 01.03.24 14:29, David Kastrup wrote:
>> Simon Albrecht  writes:
>>
>>> The downside of that is that I cannot add more tags to those groups on
>>> the fly, and always have to add them directly to the library file.)
>> Suggestions for a user interface to do that?
>>
>
> Interesting. Would of course require naming tag groups, right?

Just naming an existing member should be enough since taggroups are
exclusive.

-- 
David Kastrup



Re: extracting a single “vocal line” (including lyrics) from multiple variables

2024-03-01 Thread David Kastrup
Simon Albrecht  writes:

> The downside of that is that I cannot add more tags to those groups on
> the fly, and always have to add them directly to the library file.)

Suggestions for a user interface to do that?

-- 
David Kastrup



Re: extracting a single “vocal line” (including lyrics) from multiple variables

2024-02-29 Thread David Kastrup
Simon Albrecht  writes:

> This could be preferable if you can delineate the sections
> well. Trying out \partcombine quickly made me avoid it until
> absolutely necessary, but maybe it becomes manageable with clever and
> experienced use of \partCombineApart and friends. In choral pieces, I
> often use a single variable that contains all the lyrics, tagged
> depending on who does and doesn’t use which part and then filtered in
> the score setup. I believe that it makes a key difference to use both
> \keepWithTag _and_ \removeWithTag like this:
>
> 
> text = \lyricmode {
>   \tag A { on -- ly al -- to }
>   \tag nA { ev’ -- ry -- one ex -- cept al -- to }
> }
>
> \score {
> <<
> %{ simultaneous music expression with everything for soprano part %}
> \keepWithTag A \removeWithTag nA <<
>   \variableThatContainsAltoNotes
>   \addlyrics \text
>>>

I'd rather use

\tagGroup alto,non-alto

\lyricmode {
  \tag alto { on -- ly al -- to }
  \tag non-alto { ev’ -- ry -- one ex -- cept al -- to }
}

\keepWithTag alto ...
\keepWithTag non-alto ...

But one would need to look at the rest to see whether this kind of tag
group would end up problematic.

-- 
David Kastrup



Re: define-music-function with afterGrace and {}

2024-02-23 Thread David Kastrup
jca...@web.de writes:

> Good day,
>
> following snippet I need very frequently (with different notes instead
> of c4 and e4):
>
>\afterGrace c4 \glissando {\once \hide Stem \parenthesize e4}
>
>
> That's why I wanted to create a music function to shorten the
> expression. My previous attempt:
>
>graceGliss =
>#(define-music-function
>   (starttone endtone)
>   (ly:music? ly:music?)
>   #{
>     \afterGrace #starttone \glissando {\once \hide Stem
>\parenthesize #endtone}
>   #})
>
>
> doesn't work, Return Code 1.
>
> In order to test the general functioning of define-music-function, I tried:
>
>graceGliss =
>#(define-music-function
>   (starttone endtone)
>   (ly:music? ly:music?)
>   #{
>     \afterGrace #starttone #endtone
>   #})
>
>
> which works, what leads me to believe that the error must have something
> to do with the curly brackets {} …
>
>
> For some help I'd be very grateful!

Kind of stupid, but Scheme syntax is very simplistic (almost anything
except for parentheses needs to be space-separated) and your problem
here is that # goes into Scheme.

So you call upon one Scheme variable endtone} which does not exist.  Put
a space before the closing brace.

-- 
David Kastrup



Re: 5th anniversary conference? :)

2024-02-13 Thread David Kastrup
Kieren MacMillan  writes:

> Hello, Pond!
>
> I was just waxing nostalgic about that fabulous Salzburg conference in
> 2020, and noted that in Jan 2025 — just under a year from now! — it
> will have been five years since we got together, talked
> music/notation, and raised [more than] a few pints together.
>
> Any chance for a repeat? :)
>
> Just throwing it out into the Universe.

I'm just throwing out that my subletter has bought a house elsewhere and
moves out end of April.  The owner has let me know that I can stay here
till the end of June (he gets some rent and someone who feeds the horses
on most days).

I'm still looking for a new place, and it's not quite clear how long
I'll need.

That would not be a university setting.  It would also not be the first
time, though there is little personal overlap.

<https://web.archive.org/web/20130304040840/http://news.lilynet.net/?The-LilyPond-Report-28#impressions_from_the_waltrop_meeting>

There would be enough room to throw down sleeping bags.

Near Dortmund, within about 1.5hr of train distance from Düsseldorf and
Cologne.

It reeks like a foolish idea, for sure.  If your question hadn't had
this impeccable timing, I'd not have mentioned it.

Talk about waxing nostalgic!

-- 
David Kastrup



Re: Rest space in between fugue's voices

2024-02-10 Thread David Kastrup
Kieren MacMillan  writes:

> Hi George,
>
> [n.b. I’ve cc'ed the list, as per standard practice in the Lilypond 
> community.]
>
>> Thank you very much! It worked perfectly just by inserting "\tweak
>> X-offset #1" before the 16th rest in my original code
>
> Oh, great! I didn’t think to try only that tweak.
>
>> I didn't quite understand the reasons for changing \voiceFour and \voiceOne 
>> in the tenor part
>
> Lilypond’s \voiceX commands automatically set a lot of parameters
> (default stem/tie/slur direction, etc.) according to where the voice
> “sits” on the staff; the odd-numbered voices (\voiceOne, \voiceThree,
> etc.) act as if they are “on top” (so stems/ties/slurs go up), while
> even-numbered voices (\voiceTwo, \voiceFour, etc.) act as if they are
> “underneath” (stems/ties/slurs down, etc.).
>
> When the tenor voice is in the lower staff, it is on top, so \voiceOne
> makes the most sense (because there are only two voices); when it
> moves to the upper staff, it is (at least in your example) on the
> bottom, so \voiceFour makes the most sense (because \voiceTwo is
> already taken by the alto).

\voiceTwo is for the outermost low voice, so the alto may be better off
\voiceFour ?

-- 
David Kastrup



Re: Nested Keep_alive_together_engraver

2024-02-10 Thread David Kastrup
Julian Santander  writes:

> For the record, I believe I finally solved all my problems (with this
> particular score).
>
> About the problem I asked in my previous e-mail.
>
> The way Keep_alive_together_engraver works with the "remove-layer" property
> is confusing as it is used for two contradictory purposes removing layers
> and keeping layers and, in my case, I wanted to remove some layers but keep
> others.

For the record: remove-layer was designed as a low-level mechanism, not
a user interface.  As such, the focus was on making it versatile, not
simple to use.

But nobody has bothered defining particular use cases and giving them a
simple user interface.

-- 
David Kastrup



Re: Is this a sensible interface for temporary multiple clefs?

2024-02-05 Thread David Kastrup
Valentin Petzel  writes:

> Hello David,
>
> if I understand this correctly the intent here is to have different staff 
> behaviour in one staff. I believe that there might be a more general concept 
> here. Instead of creating a new context and mechanic to set additional clefs, 
> maybe it would make sense to have a more general concept of say sub staves, 
> which would allow us to do the same thing for a more general set of staff 
> features? So instead of
>
> \extraClef #-3 "bass" ...
>
> one could have
>
> \new SubStaff {
>   \override SubStaff.Clef.Y-offset = #-3
>   \clef "bass"
>   ...
> }
>
> This should then allow for similar things such as multiple individual 
> handlings of Accidentals, multiple bar lines, key signatures, lines and 
> brackets, ...

Have you ever seen any of those?

At the same point of time, a lot more needs to be done for an extra clef
than setting the Y-offset .  In terms of implementation, it would be
possible to split much of the work into a neutral "SubStaff" and context
mod, like doing

\new SubStaff \with \ExtraClef #-3 "violin"

but this still does not deal with reseating the current Voice to the
SubStaff and back afterwards, necessary for keeping beams and slurs
operative.  So there would need to be separate commands for that.

So instead of a targeted end-user feature limited to clefs, we are
talking about some fuzzy generic framework requiring an expert to cater
for the particular common use case.

There is something to be said for a more generic name/feature such as
SubStaff in terms of the context hierarchy, moving the necessary fixed
mods into a context mod.

-- 
David Kastrup



Is this a sensible interface for temporary multiple clefs?

2024-02-05 Thread David Kastrup
\version "2.25.10"

\header {
  tagline = ##f
}

\layout {
  \context {
\Staff
\accepts ExtraClefStaff
  }
  \context {
\name ExtraClefStaff
\type Engraver_group
\alias Staff
\accepts Voice
\consists Clef_engraver
\override Clef.font-size = #-4
%% The break-align-symbol stacks the extra clef to the right of
%% the normal clef
\override Clef.break-align-symbol = #'cue-clef
%% This break-visibility repeats the extra clef every bar.  Should
%% this be the actual default?  Or should the default just be
%% the normal #begin-of-line-visible ?
\override Clef.break-visibility = #end-of-line-invisible
%% different size for first clef in line is uncalled for
firstClef = ##f
  }
}

\midi {
  \context {
\Staff
\accepts ExtraClefStaff
  }
  \context {
\name ExtraClefStaff
\type Performer_group
\alias Staff
\accepts Voice
  }
}

extraClef =
#(define-music-function (offset clef-type) ((number?) string?)
  #{ \new ExtraClefStaff = "extraclef" { }
 \change Staff = "extraclef"
 #(if offset #{ \override Staff.Clef.Y-offset = #offset #})
 \clef #clef-type
 #})

all-clef-properties =
#(map (lambda (x) (ly:music-property x 'symbol))
  (extract-named-music (make-clef-set "treble_(8)") 'PropertySet))

extraClefEnd =
#(context-spec-music
  (make-apply-context
   (lambda (ctx)
 ;; Should be a given in context-spec-music
 (if (eq? (ly:context-name ctx) 'ExtraClefStaff)
	 (begin
	   ;; revert clef-specific settings in case some clef is still
	   ;; issued before the context dies: in that case it should
	   ;; correspond to the supervening Staff clef.
	   (for-each (lambda (p) (ly:context-unset-property ctx p))
		 all-clef-properties)
  	   ;; All children of the ExtraClefStaff are reseated to its
	   ;; parent context, removing it from the hierarchy
	   (let ((switch (ly:make-stream-event
			  (ly:make-event-class 'ChangeParent)
			  `((context . ,(ly:context-parent ctx))
	 (for-each
	  (lambda (x)
		(ly:broadcast (ly:context-event-source x) switch))
	  (ly:context-children ctx
	 (ly:programming-error "Not in ExtraClefStaff"
  'ExtraClefStaff)


\score {
\new Staff = "lower" {
\key d \minor
\numericTimeSignature
\time 3/4
\clef bass
\relative c' {
  \voices 1,""
<<
{
s2. r4 r8. \clef treble
\tuplet 3/2 16 { g'32 (a bes }
c8.) c16--
c16-- bes g a
g8. 
\omit TupletBracket
\tuplet 3/2 16 { f32 (g a }
bes8.) bes16
  } \\
{
  d,,,8.-- d16-- d2--~ 2.~
  \extraClef #-3 "bass"
  \voiceTwo
  2.~ \break 2.~2.
  \oneVoice
		  \extraClefEnd
		  c''2.
}
>>
}
}
}

If made built-in, it would affect several files and introduce a new
default context type.

I don't think it covers multiple simultanous main clefs (like sometimes
seen in compact mensural notation).  I am not sure that there'd be a
sensible common interface including this use case.

-- 
David Kastrup


Re: Compute \tempo from variables

2024-02-01 Thread David Kastrup
David Hobach  writes:

> Hi all,
>
> I'd like to compute the \tempo directive from variables, but couldn't
> yet figure out how to do it.
>
> For example, let's say I have two variables such as
> myTempoBase = 4
> myTempo = 80
>
> Then I'd like to do something such as
> global = {
>   \key c \major
>   \time 4/4
>   \tempo \myTempoBase = \myTempo
> }
>
> I'd expect it to resolve to \tempo 4 = 80. The above code however fails on 
> 2.24.1.
>
> Any ideas?

in \tempo 4 = 80 , the 4 is not a number but a duration.  This works
when writing

myTempoBase = ##{ 4 #}
myTempo = 80

global = {
\key c \major
\time 4/4
\tempo \myTempoBase = \myTempo
}

because ##{ 4 #} resolves to a duration rather than a number.

-- 
David Kastrup



Re: Numérotation des versets

2024-01-27 Thread David Kastrup
Silvain Dupertuis  writes:

> Thanks for the suggestion.
>
> This does provide a nice automatic numbering ...
> but does not repeat the verse number on subsequent lines.
>
> But I did recycle your suggestion using a modified function with one paramater
>
> #(define nextcountstanza
>    (let  ((counter 0))
>  (lambda (x)
>    (set! counter (+ x counter))
>    (string-append ( number->string counter)"."
>
> so that I can copy-paste these expressions instead of manually putting the 
> right number

Will only work for a single voice in a single piece as it uses a global
counter.

-- 
David Kastrup



Re: Incipit with default noteheads possible?

2024-01-24 Thread David Kastrup
Hajo Baess  writes:

> This works for the note heads, but if there happen to be accidentals
> around (in my project this is the case), they remain mensural style. Is
> there another override for this, too?
>
> Am Mittwoch, dem 24.01.2024 um 16:14 +0200 schrieb YTG 1234:
>> > I have tried an override ( \override
>> > Staff.NoteHead.style = #'default )
>> 
>> Note heads are drawn in Voice, so you can just omit the context name.
>> \override NoteHead.style = #'default
>> 
>> The more fundamental issue here, though, is that \incipit is
>> hardcoded 
>> to create a MensuralStaff context. Does anyone know how to replicate
>> its 
>> effect with a normal Staff, short of just substituting in its source
>> code?

How about this?

\version "2.24.2"

incipit =
#(define-music-function (incipit-music) (ly:music?)
  (_i "Output @var{incipit-music} as an incipit.

@var{incipit-music} is typeset within a @code{MensuralStaff} context; the result
is positioned before the main staff (as part of an @code{InstrumentName} grob)
to indicate the music's original notation.")
  #{
\once \override Staff.InstrumentName.stencil =
#(lambda (grob)
   (let* ((instrument-name (ly:grob-property grob 'long-text))
  (align-x (ly:grob-property grob 'self-alignment-X 0))
  (align-y (ly:grob-property grob 'self-alignment-Y 0)))

 (unless (and (music-is-of-type? incipit-music 'context-specification)
  (assq (ly:music-property incipit-music 'context-type)
(ly:output-find-context-def (ly:grob-layout grob) 'Staff)))
   ;; not a staff-like context
   (set! incipit-music (context-spec-music incipit-music 'MensuralStaff)))
 (set! (ly:music-property incipit-music 'create-new) #t)
 (set! (ly:music-property incipit-music 'property-operations)
   (append (ly:music-property incipit-music 'property-operations)
   `((push InstrumentName ,align-x self-alignment-X)
 (push InstrumentName ,align-y self-alignment-Y)
 (assign instrumentName ,instrument-name
 (set! (ly:grob-property grob 'long-text)
   #{ \markup \score { #incipit-music   
   \layout {
$(ly:grob-layout grob)
 indent-incipit-default = 15\mm
 line-width = #(primitive-eval
'(or (false-if-exception indent)
 indent-incipit-default))
 indent = #(primitive-eval
'(or (false-if-exception (- line-width incipit-width))
 (* 0.5 line-width)))
 ragged-right = ##f
 ragged-last = ##f
 system-count = 1
 }
   }
  #})
 (set! (ly:grob-property grob 'self-alignment-Y) #f)
 ;; Do 'self-alignment-X RIGHT only for the first InstrumentName, which
 ;; actually is the incipit. Otherwise self-alignment-X for the
 ;; shortInstrumentName is not longer settable.
 (let ((parts (ly:spanner-broken-into (ly:grob-original grob
   (if (and (pair? parts) (equal? grob (car parts)))
   (ly:grob-set-property! grob 'self-alignment-X RIGHT)))
 (system-start-text::print grob)))
#}
  )

\language "deutsch"

Incipit = \relative c'' {
	\clef treble \time 4/4
	\omit Staff.TimeSignature
	\hide Stem
	%\mark "A D FIS CIS"
	< a, d fis cis' >

}

noten =  \relative c'' {
	\clef treble \key f \major \time 4/4
	c4 d e f \bar "|."
}

\score {

	\new Staff
	<<
		\incipit \new Staff \Incipit
		\set Staff.instrumentName = "Violino discordato"
		\noten
	>>


	\layout {
		indent = 4\cm
		incipit-width = 1\cm
	}
}


-- 
David Kastrup


Re: Incipit with default noteheads possible?

2024-01-24 Thread David Kastrup
YTG 1234  writes:

>> I have tried an override ( \override
>> Staff.NoteHead.style = #'default )
>
> Note heads are drawn in Voice, so you can just omit the context
> name. \override NoteHead.style = #'default
>
> The more fundamental issue here, though, is that \incipit is hardcoded
> to create a MensuralStaff context. Does anyone know how to replicate
> its effect with a normal Staff, short of just substituting in its
> source code?

I think there might be a point in modifying incipit such that if it is
called as

\incipit \new staff-like-context ...

that it will not do a \new MensuralStaff but just take what is given,
add its specific context creation mods to any that might already be
there, and work with that.

-- 
David Kastrup



Re: { } not sounding right.

2024-01-19 Thread David Kastrup
Werner LEMBERG  writes:

>> I have a branch (from a few years ago) where I changed LilyPond's MIDI
>> microtonality from using Pitch Bends (which is a bad idea when using
>> chords) to using MIDI 1.0 tuning information. This works fine IIRC as
>> long as you don't construct chords containing really close notes
>> (e.g. c and c+5 cents).
>
> Sounds great.  Given that MIDI 2.0 is still rather new it probably
> makes sense to go this route.

Well, to put LilyPond into a bit more of a perspective, we are at GM1
level.  Supporting GM2 would mean fast-forwarding all the way into the
distant year 1999 (for GM2 v1.2a, even to 2007).

I actually use MIDI devices regularly that don't do GM2.

MIDI 2.0, in contrast, is from 2020.  It would be overoptimistic to
expect the average established musician to work with devices developed
as recent as that.  And it's not unreasonable to assume that many of
those interested in using the kind of workflow LilyPond offers would
pass as "old-school" and have a leaning towards old-school devices,
regardless of what biological age their ID might pronounce.

So in my book, offering support for GM2 _and_ other instrument/patch
schemes beyond GM1 would be more of a priority over going MIDI 2.0.

-- 
David Kastrup



Re: Drum notation and style

2024-01-19 Thread David Kastrup
Adrian  writes:

> Thanks for the reply, and apologies for not replying to all. However,
>
> \override Lyrics.LyricsText.font-name = "Font Name"
>
> returns the following warning:
>
> warning: not a grob name, `LyricsText'
>
> and doesn't alter the font.

It's actually LyricText .

-- 
David Kastrup



Re: chord

2024-01-18 Thread David Kastrup
Leo Correia de Verdier  writes:

> <\tweak duration-log 3 e, b, g e’>2

How about

apparent =
#(define-music-function (note) (ly:music?)
  (let ((duration (ly:music-property note 'duration)))
(tweak '(Dots dot-count) (ly:duration-dot-count duration)
(tweak '(duration-log) (ly:duration-log duration) note

{ <\apparent e,4 b, f e'>2 }

Of course it doesn't work to change the dotcount when the chord as such
has no dots scheduled.  I am also not convinced that this interface is
the best approach.

-- 
David Kastrup



Re: Error/warning when creating a piano reduction with lilypond 2.25.7 and frescobaldi 3.3.0

2024-01-15 Thread David Kastrup
Knute Snortum  writes:

> On Mon, Jan 15, 2024 at 5:28 AM David Kastrup  wrote:
>
>> Bernhard Kleine  writes:
>>
>> > Dear David,
>> >
>> > the file was created this morning from frescobaldi with the
>> > Partitur-Assistent and the pre-set version of Lilypond was 2.25.7.
>> > Nothing was done be myself apart from wrinting notes and lyrics.
>>
>> If the "Partitur-Assistent" creates those overrides, it needs to get fixed.
>>
>
> It has been:
>
> https://github.com/frescobaldi/frescobaldi/commit/fb79df399056ddd8ce2fa2b48ac36fc37bdc0588

Well, it's a start.  See my note about

git grep "override[^=]*#'[a-z]"

I get

TODO:  * drag an object to e.g. create an \override #'extra-offset command
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:\override 
DynamicLineSpanner #'staff-padding = #2.0
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:  \override 
BreathingSign #'text = \markup { \musicglyph #"scripts.rvarcomma" }
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:  \override 
TrillSpanner #'direction = #DOWN
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:  \override 
BreathingSign #'text = \markup { \musicglyph #"scripts.caesura.curved" }
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:  \override 
BreathingSign #'text = \markup { \musicglyph #"scripts.caesura.straight" }
frescobaldi_app/fonts/templates/musicfont-glyphs.ly:  \override 
BreathingSign #'text = \markup { \musicglyph #"scripts.tickmark" }
frescobaldi_app/fonts/templates/musicfont-realbook.ly:\override Score.Clef 
#'break-visibility = #'#(#f #f #f)
frescobaldi_app/fonts/templates/musicfont-realbook.ly:\override 
Score.KeySignature #'break-visibility = #'#(#f #f #f)
frescobaldi_app/fonts/templates/musicfont-realbook.ly:\override 
Score.SystemStartBar #'collapse-height = #1
frescobaldi_app/scorewiz/scoreproperties.py:
ly.dom.Line(r"\override Staff.TimeSignature #'style = #'()", node)
frescobaldi_app/symbols/arpeggio_defaults.ily:\override StaffSymbol 
#'transparent = ##t
frescobaldi_app/symbols/arpeggio_defaults.ily:\override StaffSymbol #'width 
= #4
frescobaldi_app/symbols/arpeggio_defaults.ily:\override NoteHead 
#'no-ledgers = ##t
frescobaldi_app/symbols/arpeggio_defaults.ily:\override NoteHead #'stencil 
= #empty-stencil
frescobaldi_app/symbols/arpeggio_defaults.ily:\override Stem #'stencil 
=#empty-stencil
frescobaldi_app/symbols/bar_defaults.ily:\override StaffSymbol #'width = #'4
frescobaldi_app/symbols/bar_defaults.ily:\override StaffSymbol #'thickness 
= #1.2
frescobaldi_app/symbols/bar_kievan.ly:\override StaffSymbol #'width = #1.44
frescobaldi_app/symbols/bar_repeat_angled_double.ly:\override StaffSymbol 
#'width = #5.5
frescobaldi_app/symbols/bar_repeat_angled_end.ly:\override StaffSymbol 
#'width = #5.5
frescobaldi_app/symbols/bar_repeat_angled_start.ly:\override StaffSymbol 
#'width = #5.5
frescobaldi_app/symbols/bar_segno.ly:\override StaffSymbol #'width = #7
frescobaldi_app/symbols/bar_tick.ly:\override StaffSymbol #'staff-space = 
#(/ 7 8)
frescobaldi_app/symbols/clef_defaults.ily:\override StaffSymbol #'width = #4
frescobaldi_app/symbols/clef_tab.ly:\override StaffSymbol #'width = #4
frescobaldi_app/symbols/clef_tab.ly:\override StaffSymbol #'staff-space = #1
frescobaldi_app/symbols/clef_tab.ly:\override Clef #'font-size = #-3.5
frescobaldi_app/symbols/glissando_defaults.ily:\override StaffSymbol 
#'transparent = ##t
frescobaldi_app/symbols/glissando_defaults.ily:\override StaffSymbol 
#'width = #4
frescobaldi_app/symbols/glissando_defaults.ily:\override NoteHead #'stencil 
= #empty-stencil
frescobaldi_app/symbols/glissando_defaults.ily:\override Stem #'stencil = 
#empty-stencil
frescobaldi_app/symbols/glissando_defaults.ily:\override Stem #'length = #0
frescobaldi_app/symbols/glissando_defaults.ily:\override Glissando 
#'bound-details = #
frescobaldi_app/symbols/glissando_defaults.ily:  \override Glissando 
#'style = $style
frescobaldi_app/symbols/glissando_dotted.ly:\override Glissando #'thickness 
= #1.5
frescobaldi_app/symbols/spanner_beam16.ly:  \override NoteHead 
#'extra-spacing-width = #'(0 . 1.3)
frescobaldi_app/symbols/spanner_defaults.ily:\override StaffSymbol #'width 
= #4.4
frescobaldi_app/symbols/spanner_defaults.ily:\override StaffSymbol 
#'transparent = ##t
frescobaldi_app/symbols/spanner_melisma.ly:  \override Stem #'length = #3
frescobaldi_app/symbols/spanner_melisma.ly:  \override VerticalAxisGroup 
#'

Re: Error/warning when creating a piano reduction with lilypond 2.25.7 and frescobaldi 3.3.0

2024-01-15 Thread David Kastrup
Bernhard Kleine  writes:

> Am 15.01.2024 um 14:28 schrieb David Kastrup:
>> Bernhard Kleine  writes:
>>
>>> Dear David,
>>>
>>> the file was created this morning from frescobaldi with the
>>> Partitur-Assistent and the pre-set version of Lilypond was 2.25.7.
>>> Nothing was done be myself apart from wrinting notes and lyrics.
>> If the "Partitur-Assistent" creates those overrides, it needs to get fixed.
>
> It does create them. Any idea how to get is fixed in this particular case?

Calling

git grep "override[^=]*#'[a-z]"

in the current Frescobaldi source tree delivers _way_ too many hits.  I
don't consider it sane that the current Frescobaldi will pump out
pre-2.18 syntax in droves in its templates.

And I suspect that it also splits overrides into multiple lines, making
it harder to recognize them.

-- 
David Kastrup



Re: Error/warning when creating a piano reduction with lilypond 2.25.7 and frescobaldi 3.3.0

2024-01-15 Thread David Kastrup
Bernhard Kleine  writes:

> Dear David,
>
> the file was created this morning from frescobaldi with the
> Partitur-Assistent and the pre-set version of Lilypond was 2.25.7.
> Nothing was done be myself apart from wrinting notes and lyrics.

If the "Partitur-Assistent" creates those overrides, it needs to get fixed.

-- 
David Kastrup



Re: Error/warning when creating a piano reduction with lilypond 2.25.7 and frescobaldi 3.3.0

2024-01-15 Thread David Kastrup
Bernhard Kleine  writes:

> The following MWE gave a warning
>
> C:/Users/bk/AppData/Local/Temp/frescobaldi-n7fp9iem/tmp_isr57mt/document.ly:52:25:
> Warnung: deprecated: missing `.' in property path StaffSymbol.staff-space
>
> I think maybe the frescobaldi is not aware of changes to this lilypond
> version. What do I have change to make the score compile without this
> warning?
>
> Kind regards
>
> Bernhard
>
> \version "2.25.7"

Do _NOT_ update the version header by hand.  That is the job of
convert-ly when it also updates the syntax of your file to a newer
version.

-- 
David Kastrup



Re: zero-duration s to hold marks

2024-01-15 Thread David Kastrup
Raphael Mankin  writes:

> As a more general response to this thread, I feel that the reference
> manual needs to have more cross references. I frequently get a bit
> lost trying to find a suitable construct, or discovering what a
> construct means.
>
> This thread has already shown that 1.2.2, 1.3.* and 1.5.* need to
> cross-reference each other.

Fortunately, this is Free Software.  If you feel there is a deficiency
in code or manual, you can contribute a patch to address it, and it is
likely to get accepted since volunteers contributing changes is actually
the only way in which LilyPond is getting improved.

-- 
David Kastrup



Re: zero-duration s to hold marks

2024-01-12 Thread David Kastrup
Raphael Mankin  writes:

> On 10/01/2024 10:35, msk...@ansuz.sooke.bc.ca wrote:
>> On Wed, 10 Jan 2024, Raphael Mankin wrote:
>> 
>>> That strikes me as being a programmer's response, and I speak as a 
>>> programmer
>>> for over 50 years. Using <> works, but it is unintuitive. If s0 is more
>>> intuitive then that should be considered for future inclusion.
>> It's intuitive to me that s0 means a spacer rest of infinite
>> duration,
>> because it's one whole note divided by zero.  And it opens the door
>> to using 0 as a duration denominator for other things than "s", as in "c0"
>> and "0", let alone constructions like "s0." which would seem to be
>> a spacer of one and one half times infinite duration.  I don't think it's
>> a good idea to open those doors.  There doesn't seem to be any way to
>> allow zero as the duration denominator except as a unique exception; it
>> cannot be done in a way that's consistent with other syntax.
>> 
> I agree that 0 as a denominator would seem to indicate an infinite
> duration, and allow the rest of your argument. However <> still seems
> unintuitive.

Well, there's been discussion about using z but then what would z with a
duration mean, and z is not just unintuitive in that you would not think
of writing it without knowing it but also unintuitive because you have
no way to know what it is when reading it.

<> at least is comprised of known elemeents.

-- 
David Kastrup



Re: zero-duration s to hold marks

2024-01-10 Thread David Kastrup
Jean Abou Samra  writes:

> Raphael:
>> That strikes me as being a programmer's response, and I speak as a
>> programmer for over 50 years. Using <> works, but it is unintuitive. If 
>> s0 is more intuitive then that should be considered for future inclusion.
>
> s1*0 works and is more or less equivalent to <> .

The counterexample is

\new Voice { c'4\< g' c'2 s1*0\! }
\addlyrics { What is this? }

This works when using <> instead.

-- 
David Kastrup



Re: Help with correct pitch after function call within \relative

2024-01-08 Thread David Kastrup
Artur Dobija  writes:

> Dear Experts,
>
> I am working on writing my own function which combines several notes into
> one custom symbol (ligature).
> (For the context, I now about Mensural_ligature_engraver, but I want to
> create something that will allow for more flexibility, as I try to engrave
> symbols as close to one of different manuscripts from different eras and by
> different hands)
>
> My code is like:
> \relative { a \customLigatura { b c d } f }
>
> In my approach, I want to remove all the notes except the first, which will
> receive the ligature stencil.

I can't figure out your function details, but assuming you have
sequential music mus that should (in \relative) follow relative rules
but only have the first note affect the sequence, you would wrap it in

(make-relative (mus) (make-music 'EventChord mus)
  ...)

This works by casting the expression to an EventChord before running it
through the \relative wringer (in case this occurs in \relative) but
making the permanent effect on \relative come from the first element.

The ... itself is never seen by \relative, only the EventChord is.  The
result can, of course, end up something that isn't a valid chord but it
is only used for passing through \relative and then thrown away.


-- 
David Kastrup



Re: Help with correct pitch after function call within \relative

2024-01-08 Thread David Kastrup
Artur Dobija  writes:

> Dear Lilypond-user,
> I sent this mail to the wrong mail, I should have send it to
> lilypond-user-requ...@gnu.org ! Sorry!

No, you sent it to the right address.  lilypond-user-request is the
address for sending list server commands.  Send it an Email with "help"
in the body and it will tell you what it can do for you.

-- 
David Kastrup



Re: Help using a Scheme variable in a function

2024-01-06 Thread David Kastrup
David Kastrup  writes:

> David Kastrup  writes:
>
>> Matthew Fong  writes:
>>
>>> I tried the following inside the function, and all generate errors. I would
>>> like to use the value of rubricsWidthSU in this override.
>>>
>>> \override #'(line-width . \rubricsWidthSU)
>>> \override #'(line-width . #rubricsWidthSU)
>>> \override #'(line-width . ,rubricsWidthSU)
>>
>> The third one is perfect once you fix the difference between ' ("quote")
>> and ` ("backquote").  , ("comma") is only heeded within a backquote.
>
> Oops, sorry.  The nomenclature is , ("unquote") rather than , ("comma").

Sigh.  And while I am at it: ` ("quasiquote") rather than ` ("unquote").

-- 
David Kastrup



Re: Help using a Scheme variable in a function

2024-01-06 Thread David Kastrup
David Kastrup  writes:

> Matthew Fong  writes:
>
>> I tried the following inside the function, and all generate errors. I would
>> like to use the value of rubricsWidthSU in this override.
>>
>> \override #'(line-width . \rubricsWidthSU)
>> \override #'(line-width . #rubricsWidthSU)
>> \override #'(line-width . ,rubricsWidthSU)
>
> The third one is perfect once you fix the difference between ' ("quote")
> and ` ("backquote").  , ("comma") is only heeded within a backquote.

Oops, sorry.  The nomenclature is , ("unquote") rather than , ("comma").

-- 
David Kastrup



Re: Help using a Scheme variable in a function

2024-01-06 Thread David Kastrup
Matthew Fong  writes:

> I tried the following inside the function, and all generate errors. I would
> like to use the value of rubricsWidthSU in this override.
>
> \override #'(line-width . \rubricsWidthSU)
> \override #'(line-width . #rubricsWidthSU)
> \override #'(line-width . ,rubricsWidthSU)

The third one is perfect once you fix the difference between ' (quote)
and ` (backquote).  , (comma) is only heeded within a backquote.

-- 
David Kastrup



Re: build a specific stable lillypond version with git

2024-01-04 Thread David Kastrup
CX  writes:

> Is it possible to build a specific stable lillypond version with sources
> retrieved by git clone instead of a source tarball download?
> If it is possible how can you do this (because I can not find the
> documentation to do it)?

The README in the repository references
<http://lilypond.org/doc/v2.25/Documentation/contributor/compiling>

Have you checked it?

In particular, setting it up from a clone appears to be described in
<http://lilypond.org/doc/v2.25/Documentation/contributor/configuring-make>

-- 
David Kastrup



Re: Voices, shifting and stem direction

2023-12-16 Thread David Kastrup
Jakob Pedersen  writes:

> Greetings!
>
> I've always struggled with multiple voice and getting things to align
> correctly. I assume there's some basic truth I'm missing.

\voiceOne is the topmost voice.  \voiceTwo is the bottommost voice.
\voiceThree is the voice below \voiceOne.  \voiceFour is the voice above
\voiceTwo.

The voices from the top (stem up) are counted 1, 3, 5, ...  The voices
from the bottom (stem down) are counted 2, 4, 6, ...

For anything exceeding two voices, this is not exactly intuitive.

-- 
David Kastrup



Re: Hide a note inside a drumscore

2023-12-13 Thread David Kastrup
Sebastien Richard  writes:

> Hello,
>
> How can I hide a note inside a drum score ? I tried following the doc here 
> https://lilypond.org/doc/v2.23/Documentation/notation/visibility-of-objects 
> but I did not managed to make it work
>
> Here is an example where I want to hide the snare :
>
> \version "2.24.2"
> up = \drummode {
>   \slurDown \grace {sn16 sn(} 4
> }
> \score {
>   \new DrumStaff
>   << \new DrumVoice { \voiceOne \up } >>
>   \layout {}
> }

You are thinking too complicated.

\version "2.24.2"
up = \drummode {
  \slurDown \grace {sn16 sn(} 4
}
\score {
  \new DrumStaff
  << \new DrumVoice { \voiceOne \up } >>
  \layout {}
}

But I consider it very likely that you actually don't want a slur but a
tie:

\version "2.24.2"
up = \drummode {
  \grace {sn16 sn_~} 4
}
\score {
  \new DrumStaff
  << \new DrumVoice { \voiceOne \up } >>
  \layout {}
}

-- 
David Kastrup



Re: lilypond "preprocessor"?

2023-12-12 Thread David Kastrup
Aaron Hill  writes:

> On 2023-12-12 1:04 pm, David Kastrup wrote:
>> Aaron Hill  writes:
>>> 
>>> #(define (add-midi-to-score score)
>>>   (define (has-midi? score)
>>> (any (lambda (x) (ly:output-def-lookup x 'is-midi))
>> Wouldn't that need to be (ly:output-def-lookup x 'is-midi #f) ?
>
> The default is to return '() which I thought was falsey.

In LISP it would be.  In Scheme, it isn't.  `any' is a Scheme function.

-- 
David Kastrup



Re: lilypond "preprocessor"?

2023-12-12 Thread David Kastrup
Aaron Hill  writes:

> On 2023-12-12 12:06 pm, Stefano Antonelli wrote:
>> On Tue, 2023-12-12 at 02:31 -0800, Aaron Hill wrote:
>>> Would this not work?
>>> 
>>> #(define (add-midi-to-score score)
>>>#{ \score { $score \midi {} } #})
>>> toplevel-score-handler =
>>> #(lambda (score)
>>>(collect-scores-for-book (add-midi-to-score score)))
>>> 
>> Indeed it does!
>> Without a \midi block one midi file is produced.
>> However, if there is already a \midi block, two midi files are
>> produced.  I'm not sure if that's going to be a problem aside from the
>> extra processing time.
>
> Any better?
>
> 
> #(define (add-midi-to-score score)
>   (define (has-midi? score)
> (any (lambda (x) (ly:output-def-lookup x 'is-midi))

Wouldn't that need to be (ly:output-def-lookup x 'is-midi #f) ?

>  (ly:score-output-defs score)))
>   (if (has-midi? score) score
> #{ \score { $score \midi {} } #}))

-- 
David Kastrup



Re: right enharmonic spelling

2023-12-09 Thread David Kastrup
Stefan Thomas  writes:

> Dear community,
> I'm using a lot frescobaldi with MIDI input. I would like to know is how
> could I achieve automatically the right enharmonic spelling. e.g. when I
> want to get bis instead of c'?

If I remember correctly, the MIDI entry box allowed you to set the key
it was working with.  Just bump the number of sharps until you like the
enharmonic spelling.

-- 
David Kastrup



Re: accessing current file name in markup function

2023-12-06 Thread David Kastrup
Valentin Petzel  writes:

> Am Mittwoch, 6. Dezember 2023, 23:10:11 CET schrieb Jean Abou Samra:
>> \version "2.24.2"
>> 
>> #(define-markup-command (foo layout props loc-provider) (ly:music?)
>>(display (ly:input-file-line-char-column (ly:music-property loc-provider
>> 'origin))) empty-stencil)
>> 
>> \markup \foo {{}}
>
> Maybe a bit less esoteric:
>
> \version "2.24.2"
>
> locationOf =
> #(define-scheme-function (which) (ly:music?)
>(apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column 
> (ly:music-property which 
> 'origin
>
>
> \markup { \locationOf {} }

Or even less esoteric:

\version "2.24.2"

locationOf =
#(define-scheme-function () ()
   (apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column (*location*


\markup { \locationOf }


-- 
David Kastrup


Booth on Chemnitzer Linuxtage 2024

2023-12-05 Thread David Kastrup


Hi,

if you think you'd like to help providing a booth on the Chemnitzer
Linuxtage 2024 (happening on the weekend March 16/17), please checkout
the CfP at
<https://chemnitzer.linux-tage.de/2024/en/programm/anmeldung/live>.

Note that companies but not community projects are charged for booths.
We'd need 2–4 persons manning the booth and prepare suitable
presentation material, and help people with questions and showcase
working on music and performance material.

If we have suitable people and can figure out a suitable goal, we could
think about offering a workshop.  I am not sure we'd get a talk slot
since I just held a LilyPond talk this year.  I'd probably try to land a
Shotcut video editor talk (I've not yet talked about key frames in
Shotcut which allow to the "smooth scrolling" stuff in videos like
<https://youtu.be/spAP7ODPCyg>).  Particularly if I get that talk in, it
would be good to have at least two more people for the booth.

There is a yearly bus organized from the Ruhr area if that helps.  The
conference is the largest in Germany with a similar theme (typically
about 2500 to 3000 visitors).

Interest?  The conference is a friendly meeting place, and presenters
get a nice social event on Saturday with catering.

-- 
David Kastrup



Re: Slur within a slur?

2023-12-03 Thread David Kastrup
Knute Snortum  writes:

> On Sat, Dec 2, 2023 at 6:44 AM Peter Mayes  wrote:
>
>> Here is a fragment of something I am engraving.
>>
>>   e( dis e ais, b g |
>>   e8) r \afterGrace d'!(\trill { cis32 d }  |
>>   c'!16) b^. a^. g^. fis^. e^. |
>>
>> The D following the \afterGrace is slurred up to the C at the beginning of
>> the following bar.
>>
>> I would also like the "{ cis32 d }" grace notes to be slurred, but if I
>> put "{ cis32( d) }", I get a "Warning: already have slur".
>>
>> Is there a way to get a "slur within a slur"?
>>
> When we ask for a MWE, the "w" stands for "working".  That is, you should
> be able to copy and paste the LilyPond source and get it to engrave.  You
> can't do that with your code, thus David Kastrup's reply.

It was probably easy to overlook, but my reply did contain the requested
functionality.  The output was not exactly pretty in most other regards.
I was both answering the question as well as making a point about the
example code.

Sometimes I don't answer questions at all because I am not in the mood
to write a complete example myself for the sake of someone else.  In
this case, I decided to just go with what was given and in that manner
show that a better prepared question would have made for a better
recognizable answer.

The actual recipient of the answer did get the solution.  It just
appears that I confused other readers.

Sorry for that.

-- 
David Kastrup



  1   2   3   4   5   6   7   8   9   10   >