Re: Getting a function to accept a string or a markup

2024-05-11 Thread Lukas-Fabian Moser

Hi Vaughan,

Am 10.05.24 um 07:44 schrieb Vaughan McAlley:

Hi,

I have a text spanner function that shows a player that they are
playing in simultaneous rhythm with one or more other players. I
adapted it from code I used for indicating colouration in renaissance
music. It works fine, but if it begins on the last note of a line, and
the attached string is long, it can extend right to the edge of the
page (see picture attached).

What would be good is to be able to say

\sim \markup \left-column { "Vln 1," "Vln 2" }

if needed. Otherwise I could have it require a markup and get it to
concatenate within the function, but my Scheme skills are not up to
this...


Strings _are_ markups! So basically, it suffices to change the function
signature to:

#(define-music-function (annotation) (markup?)

This function still accepts strings! But when you call it with an actual
non-string markup, it fails because of

(string-append mySimBeginning annotation)

since such a markup can't be handled by string functions like
string-append. So simply replace this by the corresponding scheme macro
to concatenate markups:

#:concat (mySimBeginning annotation)

Lukas




Re: Solving espressivo problem

2024-05-11 Thread Lukas-Fabian Moser

Here’s one approach:

%%%  SNIPPET BEGINS
\version "2.25.11"

esp = \markup \lower #1 \scale #'(1.375 . 1) \musicglyph #"scripts.espr"

stuff = \relative {
\time 4/4
  r4 b'4 a2-\tweak self-alignment-X #-1.25 _\esp ~
  a2 b4 4(
  c1)-\tweak self-alignment-X #-0.5 _\esp
  b2-\tweak self-alignment-X #-1.125 _\esp d2
  c1-\tweak self-alignment-X #-0.5 _\esp
 \bar "|"
}

\score {
<<
\new Staff
\stuff
>>
}%
%%  SNIPPET ENDS


Or equivalently, saving some keystrokes:

%%%  SNIPPET BEGINS
\version "2.25.9"

esp = _\markup \lower #1 \scale #'(1.375 . 1) \musicglyph #"scripts.espr"

shift = \tweak self-alignment-X \etc

stuff = \relative {
   \time 4/4
 r4 b'4 a2\shift -1.25 \esp ~
 a2 b4 4(
 c1)\shift -0.5 \esp
 b2\shift -1.125 \esp d2
 c1\shift -0.5 \esp
    \bar "|"
}

\score {
   <<
   \new Staff
   \stuff
   >>
}%
%%  SNIPPET ENDS

Lukas


Re: \after … \beforeLast?

2024-05-02 Thread Lukas-Fabian Moser

Maybe one addition:


fromEnd =
#(define-music-function (delta ev mus) (ly:duration? ly:music? ly:music?)
(_i "Add music @var{ev} with a distance of @var{delta} before the end of

@var{ev} is usually a post-event.")
#{
  \context Bottom
  <<
{
  \skip $(make-duration-of-length (- (ly:music-length mus)
 (ly:duration-length delta)))
  <> $ev
}
#mus
>> #})


{
<>(
<>\<
\after 2 \>
\after 16*15 )
\fromEnd 16 \!
\fromEnd 8 ->
\repeat unfold 8 {e''16 d''} |
}


In ordner to make this work with slightly older LilyPond versions, one
has to replace "-" by "ly:moment-sub":

 \skip $(make-duration-of-length (ly:moment-sub
(ly:music-length mus)
(ly:duration-length delta)))

The operator overloading that allows for "naive" arithmetic with moments
was only added sometime in the 2.25.x series.

Lukas


Re: \after … \beforeLast?

2024-05-02 Thread Lukas-Fabian Moser

Hi Pierre-Luc,

Am 02.05.24 um 17:02 schrieb Pierre-Luc Gauthier:

Rambling here :

So, I *love* the simplicity and elegance of the \after command and I
am using it pretty much everywhere.

{
   <>(
   <>\<
   \after 2 \>
   \after 16*15 )
   \after 16*15 \!
   \repeat unfold 8 {e''16 d''} |
}

and since then I often end up doing head math to figure out what I
must add to \after for it to end up e.g. an 8th *before* the end of
the expression. In the above example it is quite easy :
a 16th before the end is... 16*#(- 16 1).

So what about a \beforeLast command that would do sort of the \after
job but starting from the end of the expression rather from the start
?
e.g. :
\beforeLast 16 \!

…
\pænultimus 16 )
\preantepenultimate 16 \!
^ Both above are strictly for laughing usage (provided it could have
such effect).

Should I :
https://gitlab.com/lilypond/lilypond/-/issues/new
and flag as Enhancement ?


Something like this?

%%%

\version "2.25.9"

fromEnd =
#(define-music-function (delta ev mus) (ly:duration? ly:music? ly:music?)
  (_i "Add music @var{ev} with a distance of @var{delta} before the end of

@var{ev} is usually a post-event.")
  #{
    \context Bottom
    <<
  {
    \skip $(make-duration-of-length (- (ly:music-length mus)
   (ly:duration-length delta)))
    <> $ev
  }
  #mus
  >> #})


{
  <>(
  <>\<
  \after 2 \>
  \after 16*15 )
  \fromEnd 16 \!
  \fromEnd 8 ->
  \repeat unfold 8 {e''16 d''} |
}



\beforeLast (in the sense of "before the last note of the given music
argument") isn't likely to work though, since it's not guaranteed that
the music given is SequentialMusic: What is the last note of a << >>
expression?

Lukas




Re: Bend

2024-04-21 Thread Lukas-Fabian Moser
Hi Brian,

if you know \bendBefore, you're probably referring to the semi-finished
improved bendAfter/bendBefore pair that I reposted recently. This supports
an arbitrary contour for the bend line by giving a list of tone relations.
See the examples that come with it.

I'll not be at my computer for the rest of the day (German time zone), but
maybe this pointer is already helpful?

Lukas

 schrieb am Sa., 20. Apr. 2024, 22:39:

> Hello friends,
>
> I thought this was recently covered, but I haven't been able to find
> what I need.
>
> I'm looking for an articulation to add that will indicate a note is
> supposed to bend down, before bending back up again. Usually I see it
> looking something like an upside-down fermata, without the dot. I can
> do this in Musescore easily, but I've never found a satisfactory bend
> like this in Lilypond. I have a script for a scoop, and I know about
> \bendBefore, but not this one.
>
> Thanks!
>
> Brian
>
>


Re: score with dynamic beats

2024-04-13 Thread Lukas-Fabian Moser

Hi,

Am 12.04.24 um 17:36 schrieb Kieren MacMillan:

Hi Raphael,


I note that in one solution one uses \remove and in the other \omit to achieve 
the same thing.

Is there any prospect of  moving to a situation where only one operator is used 
to achieve a result, possibly by having a preferred and deprecated options 
first? This is a general point, not just  restricted to this one case.

I wouldn’t think so…

They are two different — both quite useful — commands, used in different 
contexts/situations:

1. \remove is a general function for eliminating an engraver from a whole 
context (in this example, the Time_signature_engraver from the Staff context).

2. \omit is both a handy short form [when used in the identical location as the 
\remove] as well as a one-off function/action (e.g., \once \omit 
Staff.TimeSignature, used “inline” in a music expression).


To elaborate on what Jean already demonstrated:

0) \hide only switches on "invisible ink", so to speak. Which means
everything takes up space as usual.

1) \omit disables the "stencil" callback of a Grob. This means that when
it comes to creating the actual graphical object belonging to the grob,
nothing is produced; in particular, the object does not take up space
anymore (insofar as the spacing takes the actual stencil extent into
account).

2) Removing the engraver completely removes the infrastructure creating
the graphical object. Since an engraver does not only print objects, but
does all sorts of bookkeeping (and maybe even janitorial jobs that other
engravers rely upon), removing an engraver can have all kinds of
(desired or undesired) side effects. Of course, LilyPond is constructed
in a modular way, and we can remove many engravers without actually
harming LilyPond's normal function, but the effect is definitely more
than just refraining from printing some graphical object.

Lukas




Re: sheet music

2024-04-13 Thread Lukas-Fabian Moser

Hi Michael,


Do you mean the keyboard ostinato motiv?
Chords an lyrics you should easily find on the internet.

Anyway, here's the keyboard motiv. Might have to be transposed.

Thanks for transcribing the keyboard line!

Just one suggestion: While avoiding ces and fes might seem to simplify
the notation, I think in reality it's easier to keep to the actual
diatonic structure so as to avoid suggesting chromaticism where there's
none.

Basically, one might view this piece (its chords being G♭ F♭ C♭ or, if
you prefer, F♯ E B) as
- having G♭/F♯ as a root, with a double plagal harmonic pattern I ♭VII IV
- having C♭/B as a root with a harmonic pattern starting on the
dominant: V IV I
(I hope I can get away without a flamewar about which of those
viewpoints is "more correct" :-).)

In the first case, the "natural" key would be

\key ges \mixolydian (or \key fis \mixolydian),

in the second case

\key ces \major (or \key b \major),

both of which lead to the same key signatures. Since you 5 sharps are
more common than 7 flats, I'd suggest the following:

\version "2.25.13"

\paper {
  indent = 0
}

\header {
  title = "Kim Smoltz"
  subtitle = \markup \override-lines #'(baseline-skip . 2.5) {
    \column \center-align {
  "from the „Mollusk Sessions“"
    }
  }
  composer = \markup \override-lines #'(baseline-skip . 2.5) {
    \column \right-align {
  %"Ween, 1995"
  "Ween"
    }
  }
}

global = {
  \key ges \mixolydian
  \time 4/4
  \partial 2
  \accidentalStyle modern
}

keyboard = \relative f' {
  \global
  \repeat volta 2 {
    r8 ges8 as bes~ |
    bes8 as  ges fes~ fes8 es fes8 ges~ |
    ges8 fes es des~  des8 ces  des8 es~ |
    es8 des  ces bes~  bes8 as  bes8 ces~ |
    ces2
  }
}

\score {
  \transpose fes e \keyboard
  \layout {}
  \midi {
    \tempo 4=108
  }
}

And of course one might also opt for a tonality of \key ges \major (or
\key fis \major) which shows the explicit flat 7 if one wants to
underline the "mixolydian" interpretation, for example like this:

Lukas



Re: Glissandos into Note

2024-04-13 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Ben, hi Greg,

thanks for bringing this up - in fact I started this morning to dig up
my old work, prompted by Greg's question.

It seems I only developed the functions a but further back then
(unfortunately I don't have time at the moment to look into it in
detail) - the difference seems to be that now, bends also avoid Dots.
See the attached version.

Lukas

Am 13.04.24 um 10:58 schrieb Benjamin Tordoff:

Hi Greg, the conversation on this list back in Dec'22 and Jan'23 ended
up with Lukas-Fabian Moser sending me the attached script and example.
I was able to use this successfully to typeset a range of scoops,
bends, and falls. It'd be better to get the latest version from
Lukas-Fabian in case he has done more work on it, but this might do
what you need. You can see the results I got using this here:
https://pluralsax.com/music-entry/147/alabamy-bound.

Whilst the script is complicated (and well beyond my understanding),
using it was not.

There was some discussion of whether this script (or something like
it) could make it into the main lilypond install but I don't think it
has yet.

Cheers

Ben






On 13 Apr 2024, at 08:23, Hans Aikema  wrote:




On 13 Apr 2024, at 01:07, Greg Lindstrom  wrote:


Hello -

I would like to write a glissando leading into a note without a
starting note. Perhaps the term is not glissando, but we encounter
it often in jazz where the trumpets and trombones will "slide" up to
a note to accentuate. It may be called a "scoop" but that's
speculation on my part.  Here's an example: Can this be done (by a
mortal)?


Should be possible by tricking lilypond like in
https://lists.gnu.org/archive/html/lilypond-user/2009-06/msg00132.html
In that and other threads on scoops there are a few other tricks to
achieve the same goal, but I think the approach in that message is
the easiest to comprehend.

My impression (no time to validate now) is that the trick from that
post would pollute the midi file. So in case you need a more or less
clean midi (which will nit contain any effect for the scoop) rather
than just display in the sheet music the more complex workaround given in
https://lists.nongnu.org/archive/html/lilypond-user/2022-12/msg00314.html
 might be worth a try


HTH

Hans






\version "2.24.0"

#
(define-public (number-or-number-list? x)
  (or (number? x) (number-list? x)))



#(set-object-property! 'contour 'backend-type? number-or-number-list?)
#(set-object-property! 'maximum-length 'backend-type? ly:dimension?)



#(define-public (ly:event-length ev now)
;;; quick'n'dirty variant of proper C++ function
   (ly:event-property ev 'length))



#
(define (hash-move target source key)
  (let ((value (hash-ref source key)))
(when value
  (hash-set! target key value)
  (hash-remove! source key

#
(define (Bend_after_engraver context)
  (let
   ((bend-after-ev #f)
(current-note-column #f)
(note-heads '())
(bend-after-grobs (make-hash-table))
(finished-bend-after-grobs (make-hash-table)))
   (make-engraver
((start-translation-timestep engraver)
 (hash-clear! finished-bend-after-grobs))
(listeners
 ((bend-after-event engraver event)
  (set! bend-after-ev event)))
(acknowledgers
 ((note-column-interface engraver grob source-engraver)
  (set! current-note-column grob))
 ((note-head-interface engraver grob source-engraver)
  (set! note-heads (cons grob note-heads
((stop-translation-timestep engraver)
 (let ((now (ly:context-current-moment context)))
   (hash-for-each
(lambda (grob alist)
  (when
   ;; For falls starting in grace time, compare actual
   ;; moments to make sure the band spans the full (grace)
   ;; length of the main note.
   ;; For falls starting in non-grace time, compare only
   ;; moment-main's to make sure the fall gets terminated
   ;; before any grace notes coming before the next note.
   (if (assq-ref alist 'start-in-grace)
   (not (ly:moment= (ly:moment-main now)
   (ly:moment-main (assq-ref alist 'stop-moment
   (ly:spanner-set-bound!
grob RIGHT
(if (ly:grob? (ly:context-property context 'currentBarLine))
;; don't cross a barline!
(ly:context-property context 'currentCommandColumn)
(if current-note-column
current-note-column
(ly:context-property context 'currentMusicalColumn
   (hash-move finished-bend-after-grobs bend-after-grobs grob)))
bend-after-grobs)

   (for-each
(lambda (head)
  (let
   ((head-bend-after-ev
 (find
  (lambda

Re: Get name of music object

2024-04-02 Thread Lukas-Fabian Moser

Hi Morten,

Am 02.04.24 um 10:56 schrieb Morten Lemvigh:

Music objects are created with a name and some properties:
make-music name music-properties

I know how to get the properties from a music object - but how about
the name? I cannot figure out how to get the name from a music object.

It is difficult to search for since the word "name" pops up
everywhere. The only thing I found was a function to search by name:
extract-named-music.


In addition to Jean's reply: In practice one often wants to know how
certain constructs well-known in LilyPond syntax are represented in
Scheme. For this, \displayMusic is useful. For example, \displayMusic
\time 3/4 displays:

(make-music 'TimeSignatureMusic 'beat-structure '() 'denominator 4
'numerator 3)

Lukas


Re: Can't compile Lilypond files

2024-03-24 Thread Lukas-Fabian Moser
Hi David,

David Sumbler  schrieb am So., 24. März 2024, 21:29:

> I am running xubuntu  22.04.  When I last used Lilypond (November 2023) I
> was probably running a recent version of Ubuntu Unity.  But my /home folder
> has not changed significantly, and Lilypond 2.24.1, downloaded from
> lilypond.org, is installed there.
>
> I don't quite understand the question about PATH.  The command lilypond is
> set up to invoke bin/lilypond in my home folder; this is a short script to
> call my latest version of lilypond in its folder which is a subfolder of my
> home folder.  And clearly it is doing this.
>
> What do I get as an error message?  I as sorry if I was not clear, but I
> do not get any error message at all.  No error reported, no warnings, no
> compilation; merely the same output I would get if I simply typed the
> command 'lilypond'.
>

But this sounds as if your script in bin does not pass command line
arguments to lilypond, doesn't it?

So, is this script self-written? And what does its source code look like?

Lukas


Re: Time measurement

2024-03-14 Thread Lukas-Fabian Moser

Hi,

Am 14.03.24 um 17:27 schrieb Kieren MacMillan:

Hi Matthew,


Is there any easy way to find out the time in seconds from the start of a
score to a specified point, corresponding to the timing of the MIDI
output?  I can count measures and do math on the tempo, but that's
less than ideal in the face of multiple tempo changes.  Another idea would
be to just cut the score at the desire point and then measure the length
of the MIDI output file.  I can already manually examine the MIDI output,
find the desired point in the music, and record its timing, but that's
a fair bit of work.

I only really need to do this for a few points, a few times, and I just
want to know the numbers, not necessarily typeset them.  But a more
automated method along the lines of a \midiTime markup that would actually
typeset the time to that point automatically, would be fun too.

“This sounds like a job for… Custom Engraver!!”  :)


It sure does.

\version "2.25.3"

#(set-object-property! 'physicalTime 'translation-type? real?)

Time_measuring_engraver =
#(lambda (context)
   (let
    ((previous-timestep #f)
 (now ZERO-MOMENT)
 (current-tempo #f)
 (elapsed-time 0.0))

    (make-engraver
 ((initialize engraver)
  (ly:context-set-property! context 'physicalTime elapsed-time))
 ((start-translation-timestep engraver)
  (set! now (ly:context-current-moment context))
  (let*
   ((current-delta (- now previous-timestep))
    (current-timespan (/ current-delta current-tempo)))
   (set! elapsed-time (+ elapsed-time (* 60 current-timespan
  (ly:context-set-property! context 'physicalTime elapsed-time))
 ((stop-translation-timestep engraver)
  (set! previous-timestep now)
  (set! current-tempo (ly:context-property context
'tempoWholesPerMinute))

\layout {
  \context {
    \Score
    \consists #Time_measuring_engraver
    tempoWholesPerMinute = \musicLength 1*15 % LilyPond's default
  }
}

displayPhysicalTime = \applyContext
#(lambda (context)
   (ly:message "Elapsed time: ~as" (ly:context-property context
'physicalTime)))

{
  \tempo 4 = 120
  \tuplet 3/2 { a4 \displayPhysicalTime a a } \displayPhysicalTime a2
  \displayPhysicalTime
  \tempo 4 = 80
  a1 \displayPhysicalTime
}

Look at LilyPond's log.

It would be absolutely possible to also let this number be typeset (e.g.
as a TextMark), but this needs a dedicated engraver again as far as I
can see: They form the link between time-dependent context information
and grobs. A general \midiTime markup can't work conceptually, I think,
as markups may live independently of any music.

Lukas

Lukas




Re: Alternate bars in different time signatures

2024-02-02 Thread Lukas-Fabian Moser



Am 02.02.24 um 01:35 schrieb Leo Correia de Verdier:

If you want to avoid some of the jiggery pokery you could do something like:

\version "2.25.12"

#(define ((time-alternate-time upa downa upb downb) grob)
(grob-interpret-markup grob
   (markup #:override '(baseline-skip . 0) #:number
   (#:line (
 (#:center-column (upa downa))
 (#:center-column (upb downb)))

global = {
   \override Score.TimeSignature.stencil =
   #(time-alternate-time "6" "8" "3" "4")
   \time 6/8 s2.
   \omit Score.TimeSignature
   \repeat unfold 5 {
 \time 3/4
 \set Timing.beamExceptions = #'() %so 3/4 isn't beamed in whole measures
 s2.
 \time 6/8 s2.
}}

\score {
   \new Staff <<
 \global
 { \repeat unfold 66 a'8 }
   >>
}
%


... and without any new insight, but with a healthy dose of syntactic sugar:

\version "2.25.9"

#(define-markup-command (timeSignature layout props fraction) (fraction?)
   (interpret-markup layout props
 (markup #:override '(baseline-skip . 0)
 #:number
 #:center-column ((number->string (car
fraction))
  (number->string (cdr
fraction))


alternateTime =
#(define-music-function (one two) (fraction? fraction?)
   #{
 \once \override Timing.TimeSignature.stencil =
#ly:text-interface::print
 \once \override Timing.TimeSignature.text =
 \markup \line { \timeSignature #one \timeSignature #two }
 \time #one
   #})

secretTime = \tweak TimeSignature.stencil #f \time \etc

global = {
  \alternateTime 6/8 3/4
  s2.
  \repeat unfold 5 {
    \secretTime 3/4
    \set Timing.beamExceptions = #'()
    s2.
    \secretTime 6/8 s2.
  }
}

\new Staff
<<
  \global
  { \repeat unfold 66 a'8 }
>>

Lukas




Re: Numérotation des versets

2024-01-27 Thread Lukas-Fabian Moser

Hi Silvain,

Am 27.01.24 um 11:12 schrieb Silvain Dupertuis:


/Sorry for my question in French on an English-speaking forum... here
is an Englsh version/

Hello,

Is there a way to automatically repeat the verse numbers on each line
when it is defined by \set stanza = "1."
without repeating this instruction within the verse text

with this structure in the score part, lyrics being defined in variables

\new Lyrics \lyricsto "VoiceOne" { \set stanza = "1." \VerseOne }
\new Lyrics \lyricsto "VoiceOne" { \set stanza = "2." \VerseTwo }
...

For a 5-verse song, it's best to repeat these verse numbers!


Not to my knowledge, but this is something that's quite high on my list
of LilyPond enhancements I'd like to try my hands at. Stay tuned.

(As far as I can see, it's not completely trivial to implement since we
have to wait until the line breaking is known, and then horizontal
spacing has to take the additional stanza numbers into account.)

Lukas


Re: { } not sounding right.

2024-01-19 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Werner, hi Pierre-Luc,

Am 19.01.24 um 08:43 schrieb Werner LEMBERG:

Try this with and without the \new Voice commented.

\version "2.25.12"

\language "english"

\score {
   %\new Voice
   <<
 {bf bqf bf}
 {g gqs g}
   >>
   \layout {}
   \midi {}
}

Obviously you would need to listen to the MIDI output.

This is a limitation of MIDI: You can only have a single pitch bend
per time step per channel.  LilyPond's rather primitive MIDI 1.0
output provides no means to circumvent this limitation.

Looking into MIDI 2.0 I see that there exists a 'per-note pitch bend'
feature, so maybe someone is going to implement that in LilyPond.


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).


I was never able (in terms of spare time and/or ability) to bring this 
to LilyPond's C++ coding level, but if I have time in february 
(university break), I could dig that branch up and see if I can share it 
in such a way that we can get it into LilyPond proper.


My overall impression was that LilyPond's MIDI code is quite old and 
didn't get as much polishing over the last decades as the main 
typesetting engine did.


Lukas


Re: zero-duration s to hold marks

2024-01-12 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Raphael,

Am 12.01.24 um 13:32 schrieb Raphael Mankin:
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.


I agree that <> isn't obvious. But in a complex language like LilyPond, 
there's always something like "idioms". I remember that I learned about 
<> quite late in my acquaintance with LilyPond, and it changed my input 
habits a bit - namely for standalone dynamics: <>\p s4 instead of s4\p. 
I had the project of introducing this idiom into the examples in the 
notation manual, but don't remember right now whether I ever finished this.


Lukas




Re: Transpose from major to minor key

2024-01-12 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Matthew,

Am 12.01.24 um 00:29 schrieb msk...@ansuz.sooke.bc.ca:

You need to remember lilypond thinks in terms of pitch, not note names. Unlike
some (most?) other music software. So "\transpose g e" says "transpose EVERY
note up A TONE".

I'm not sure it's quite right to say that Lilypond thinks in terms of
pitch, not note names, because it selects the spelling of transposed notes
based on the note names.  For instance, \transpose c cis fis gives fisis ,
not g , whereas \transpose b, c fis gives g.  The one-semitone
transposition of the same note is different depending on the note names
used to specify it.


It depends on what one takes the term "pitch" to mean.

Your remark sounds as if you take "pitch" to be physical frequency, 
which obviously is a valid stance. But, LilyPond's "pitch" data type 
carries much more information, namely octave, "note name" and alteration.


Wol's remarks (I think) alluded to the difference between LilyPond and, 
e.g., MuseScore, in that in LilyPond the meaning of naked note names 
does not change when selecting a new key signature: In MuseScore, if I 
switch to e-flat major and hit "e", I get the pitch e-flat; in LilyPond, 
"e" still creates e-natural.


Lukas


Re: Cut time/half-time/alle breve & 8/4 time

2024-01-12 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Stanton,

I’m setting various short organ pieces from an old Peters edition, 
mostly to prevent my aging brain from forgetting…


One piece is in 8/4 time -the first measure has a whole note and 2 
half notes. However, the time signature as printed is the cut time 
symbol. How can I reproduce this? I’m using Lilypond 2.25.11.
The solutions given so far seem to be more complicated than necessary, I 
think.


\relative c' {
  \time 4/2
  \set Timing.timeSignatureFraction = 2/2
  c4 d e f g a b c d
}

Lukas




Re: Manually control note spacing?

2024-01-05 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Robert,


I'm trying to make an example showing mordent symbols with text
labels. I want the note positions spaced so that the text is all on
one line, with notes placed as needed to fit around it.

The easiest way I can think of doing that would be to put manually
sized 'gap fillers' between the notes which is something I often do in
LaTeX, but I can't find any way of doing that in lilypond - it only
seems possible to change spacing globally?

\version "2.18.2"

\header {tagline = ""}
{
 \numericTimeSignature
 \time 4/4
 a'4\mordent^"Mordent"
 a'4\upmordent^"Upper Mordent"
a'4\downmordent^"Lower Mordent"
}


There's a dedicated feature for this: just issue \textLengthOn.

Since this doesn't guarantee equal Y position of the text scripts, I 
usually handle situations like these by putting my text elements in a 
Lyrics context, which has all the right features.


\version "2.18.2"

\layout {
  %%% uncomment for better spacing:
  % \override LyricText.extra-spacing-width = #'(-1 . 1)
}

<<
  \new Lyrics \lyricmode {
    "Mordent"4
    "Upper Mordent"
    "Lower Mordent"
  }
  \new Staff {
    \numericTimeSignature
    \time 4/4
    a'4\mordent
    a'4\upmordent
    a'4\downmordent
  }
>>

And: If you have any chance, I'd encourage you to update LilyPond to a 
more current version. LilyPond has experienced huge improvements since 
2.18.2 (which admittedly was the official stable version for quite some 
time).


Lukas




Re: Aligning offset quintuplets and triplets

2023-12-27 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Knute, hi Mark,

here's an example of what I mean. The "cheating" system should create 
what the original engraving suggests, even if it's wrong mathematically. 
I didn't check the difference in MIDI; of course the "conductor" part 
(consisting of eigths throughout) shows a significant difference.


Of course I took advantage of the fact that the original engraving stops 
bothering with tuplet brackets/numbers starting from the second bar; it 
should be possible to get them back, but this will involve some further 
tweaking in the "cheating" version.


Lukas

Am 27.12.23 um 09:17 schrieb Lukas-Fabian Moser:


Hi Mark,

Am 27.12.23 um 01:54 schrieb Mark Stephen Mrotek:


Knute,

In the original the first beat of the second measure is three against 
2. The 5 against 3 does not start until the second beat.


Unfortunately, that can't be true, as with this interpretation, the 
measure is over-full. Rather, the groups of quintuplets/triplets 
continue, with a beaming not in sync with the measure's beat structure.


This also implies that the original engraving isn't mathematically 
correct (as the beginnings of the bems groups look as if they're 
aligned). Situations like that are hard to approximate with LilyPond, 
as Lily has a strict binary notion of two notes being simultaneous or 
not. One can try cheating a bit by engraving the measure according to 
its visual apperance (3-vs-2 in the first beat, exact 4-vs-1 in the 
last quaver of the measure), but then it will be necessary to compress 
whatever will be in the measure to the duration of one whole note, and 
it's not certain what LilyPond's spacing algorithm will make of it.


Sorry for describing the situation verbally; I'll try to cook up an 
example as soon as I have time (later today).


Lukas
\version "2.24.3"

\paper {
  #(set-paper-size "a4landscape")
}

%{
% a useful function:
showLength =
#(define-music-function (mus) (ly:music?)
   (pretty-print (ly:music-length mus))
   mus)

% of course, one can also write a function calculating
% the correct value for scaleDurations automatically
%}

rightHand = \relative {
  r2 \tuplet 5/4 4 {
r8. e'16[ e  e e e] e[ e |
\repeat unfold 2 {
  e e e] e[ e  e e e] e[ e  e e e] e[ e  e e e] e32[ e e e |
}
  }
  e]
}

leftHand = \relative {
  \clef bass
  r2 \tuplet 3/2 4 {
r8 r c'[  c c] c[ |
\repeat unfold 2 {
  c c] c[  c c] c[  c c] c[  c c] c[ |
}
  }
  c]
}

rightHandCheat = \relative {
  r2 \tuplet 5/4 4 { r8. e'16[ e  e e e] e[ e | }
  \repeat unfold 2
  {
\scaleDurations 8/9
{
  e16*4/3 e e] e16*4/5[ e  e e e] e[ e  e e e] e[ e e e e] e32[ e e e
  |
}
  }
  e]


}

leftHandCheat = \relative {
  \clef bass
  r2 \tuplet 3/2 4 { r8 r c'[  c c] c[ | }
  \repeat unfold 2 {
\scaleDurations 8/9
{
  c8 c] c8*2/3[ c c] c[  c c] c[  c c] c8[ |
}
  }
  c]
}

<<
  \new PianoStaff \with { instrumentName = "honest" }
  <<
\new Staff \rightHand
\new Staff \leftHand
  >>
  \new RhythmicStaff \with {
instrumentName = "conductor"
\omit Stem
\omit Beam
  }
  {
s1
\repeat unfold 16 { 8 }
  }
  \new PianoStaff \with { instrumentName = "cheating" }
  <<
\new Staff \rightHandCheat
\new Staff \leftHandCheat
  >>
>>

\new PianoStaff \with {
  instrumentName = \markup\center-column{cheating only "(spacing check)" }
}
<<
  \new Staff \rightHandCheat
  \new Staff \leftHandCheat
>>


Re: Aligning offset quintuplets and triplets

2023-12-27 Thread Lukas-Fabian Moser via LilyPond user discussion

Hi Mark,

Am 27.12.23 um 01:54 schrieb Mark Stephen Mrotek:


Knute,

In the original the first beat of the second measure is three against 
2. The 5 against 3 does not start until the second beat.


Unfortunately, that can't be true, as with this interpretation, the 
measure is over-full. Rather, the groups of quintuplets/triplets 
continue, with a beaming not in sync with the measure's beat structure.


This also implies that the original engraving isn't mathematically 
correct (as the beginnings of the bems groups look as if they're 
aligned). Situations like that are hard to approximate with LilyPond, as 
Lily has a strict binary notion of two notes being simultaneous or not. 
One can try cheating a bit by engraving the measure according to its 
visual apperance (3-vs-2 in the first beat, exact 4-vs-1 in the last 
quaver of the measure), but then it will be necessary to compress 
whatever will be in the measure to the duration of one whole note, and 
it's not certain what LilyPond's spacing algorithm will make of it.


Sorry for describing the situation verbally; I'll try to cook up an 
example as soon as I have time (later today).


Lukas


Re: function to force accidentals on a subset of notes

2023-10-30 Thread Lukas-Fabian Moser

Hi Michael,

Am 30.10.23 um 10:42 schrieb Michael Winter:
But I am confused about what you said. For me, it is posting the 
accidental on tied notes after line breaks.


No I'm confused. :-) If I do

\transpose a c' \relative
{
  a8 gis~ gis g fis g gis a
  gis1~ \break gis2 gis
}

in my example file, I get:

(To wit, no natural sign on the first b in measure 3).

Is this different for you?

Lukas


Re: function to force accidentals on a subset of notes

2023-10-28 Thread Lukas-Fabian Moser

Hi Michael,


Thanks Lukas!

This works but also forces the accidental on tied notes.


Sorry for not getting back to you sooner.

The following version registers ties and removes our auto-generated 
accidentals for notes in which a tie ends. (It's a bit overeager and 
also removes tied accidentals after line breaks, so we get a behaviour 
as if Accidental.hide-tied-accidental-after-break is set to ##t. Please 
give word if you want me to change that.)


Lukas

\version "2.24.0"

forced-accidentals-pitches =
#(music-pitches #{ bes b #})

#(define (diatonic-pitch-class= p q)
   (and (= (ly:pitch-notename p) (ly:pitch-notename q))
    (= (ly:pitch-alteration p) (ly:pitch-alteration q

Force_accidentals_engraver =
#(lambda (context)
   (let
    ((ties '())
 (affected-note-events '()))
   (make-engraver
    (end-acknowledgers
 ((tie-interface engraver grob source-engraver)
  (set! ties (cons grob ties
    ((stop-translation-timestep engraver)
 (for-each
  (lambda (tie)
    (let* ((right-notehead (ly:spanner-bound tie RIGHT))
   (right-notehead-cause (ly:grob-property right-notehead 
'cause)))

  (if (member right-notehead-cause affected-note-events)
  (ly:grob-suicide!
   ;;; the accidental grob should be guaranteed to
   ;;; exist since we forced it into existence...
   (ly:grob-object
    right-notehead 'accidental-grob)
  ties)
 (set! ties '())
 (set! affected-note-events '()))
    (listeners
 ((note-event engraver event)
  (when (member (ly:event-property event 'pitch)
    forced-accidentals-pitches
    diatonic-pitch-class=)
    (ly:event-set-property! event 'force-accidental #t)
    (set! affected-note-events
  (cons event affected-note-events

\layout {
  \context {
    \Voice
    \consists #Force_accidentals_engraver
  }
}

\transpose a c' \relative
{
  a8 gis~ gis g fis g gis a
  gis1~ gis2 gis
}




Re: function to force accidentals on a subset of notes

2023-10-22 Thread Lukas-Fabian Moser

Hi Michael,

this is easily accomplished with an custom engraver. (I perfectly 
understand that the terms "easily" and "custom engraver" don't seem to 
go well together at first - I thought so for many years as well -, but 
after some getting used to it, the concept is actually quite simple and 
elegant.)


\version "2.24.0"

forced-accidentals-pitches =
#(music-pitches #{ bes b #})

#(define (diatonic-pitch-class= p q)
   (and (= (ly:pitch-notename p) (ly:pitch-notename q))
    (= (ly:pitch-alteration p) (ly:pitch-alteration q

Force_accidentals_engraver =
#(lambda (context)
   (make-engraver
    (listeners
 ((note-event engraver event)
  (if (member (ly:event-property event 'pitch)
  forced-accidentals-pitches
  diatonic-pitch-class=)
  (ly:event-set-property! event 'force-accidental #t))

\layout {
  \context {
    \Voice
    \consists #Force_accidentals_engraver
  }
}

\transpose a c' \relative
{
  a8 gis g fis g gis a4
}

Lukas

Am 21.10.23 um 11:37 schrieb Michael Winter via LilyPond user discussion:

Thanks Jean,

I am not sure I completely follow.

Lets say I have a music sequence:

a b c d e f g a bes c d e f g ...

How do I apply what you have written as a function to only show the 
flats and naturals for b and bes. Again. I do not want to apply this 
to individual notes.


Sorry if I am missing something.

Best,

Michael


Oct 21, 2023, 01:37 by j...@abou-samra.fr:

Try

|\displayMusic c'! |

This shows you that the |!| syntax corresponds to setting the
|force-accidental| property to true. Thus, if you have identified
the note events you want to force accidentals on, you can do

|(ly:music-set-property! the-note-event 'force-accidental #t) |

on each of them.

Best,

Jean



Re: custom replace/map of one set of pitches to another

2023-09-01 Thread Lukas-Fabian Moser

Hi Valentin,

Am 01.09.23 um 00:41 schrieb Valentin Petzel:

I don’t think this is a particularly good idea. Lilypond conceptually first
creates data for the sementic meaning of the music (or the actual content) and
have engravers turn this into graphical content.

Mapping pitches to other pitches is not a layout option, but a musical
transformation and should thus be done on the music level, not the layout
level. Using an engraver will mean it is hard to combine this with other
musical transformations, and it will also cause order issues as soon as you
have an engraver that depends on the pitch property.


I agree about the possible problems, and to be honest, I wasn't aware 
that a music function solution like yours can deal with \transpose and 
\relative gracefully (since the assignment of actual pitches is complete 
when the music function is applied on the outside).


What I don't necessarily agree with is the philosophical notion of 
engravers being tied to the layout level (which is admittedly suggested 
by their name): As long as I work with listeners (as opposed to 
acknowledgers), I see no problem in using them for "semantic" 
transformations that need the music sorted by timestep (which 
nevertheless is not the case in the current situation).


Lukas




Re: custom replace/map of one set of pitches to another

2023-08-31 Thread Lukas-Fabian Moser

Hi Michael,

over time, I found that doing something like this in an engraver (as 
opposed to a music function) is actually much easier and conceptually 
clear, in spite of the seeming difficulty of the engraver syntax. The 
advantage of using an engraver being that you see the "actual" pitches 
and don't have to fight with problems of \relative, \transpose and so on.


\version "2.24.0"

pitch-replace-dictionary =
#(list
  (cons #{ c #} #{ cis #})
  (cons #{ d #} #{ des #})
  )

#(define (pitch-class= p q)
   (and
    (= (ly:pitch-notename p) (ly:pitch-notename q))
    (= (ly:pitch-alteration p) (ly:pitch-alteration q

Pitch_replace_engraver =
#(lambda (context)
   (make-engraver
    (listeners
 ((note-event engraver event)
  (let*
   ((pitch (ly:event-property event 'pitch))
    (rule (assoc pitch pitch-replace-dictionary pitch-class=)))

   (if rule
   (ly:event-set-property!
    event 'pitch
    (ly:make-pitch (ly:pitch-octave pitch)
   (ly:pitch-notename (cdr rule))
   (ly:pitch-alteration (cdr rule))

\layout {
  \context {
    \Score
    \consists #Pitch_replace_engraver
  }
}

\relative {
  c'4 d e c8 8
  \transpose f c \relative {
    f'4 g a
  }
}

This engraver can also be added to just a single score (\layout inside 
\score {}) or even a single Staff or Voice. At the moment, the 
replacement dictionary is global, but this could be changed if needed.


At the moment the mechanism I chose is too crude to do replacements that 
involve changing the pitch-octave (eg from c to b,). Do you need this?


Lukas

Am 31.08.23 um 12:53 schrieb Michael Winter via LilyPond user discussion:
I would like to do something (hopefully simple), which is basically a 
custom find and replace for a set of notes in an entire score.


For example {c cis d dis fih g aih} -> {c cis dih dis f gis a}

So basically on arbitrary list of pitches / scale to another.

Is this possible without writing a custom function. If not, any hints 
on how to tackle the problem would be much appreciated. Thanks in advance.


-Michael




Re: "Slash" in figured bass

2023-08-17 Thread Lukas-Fabian Moser



Am 17.08.23 um 13:05 schrieb Jean Abou Samra:

Le jeudi 17 août 2023 à 12:28 +0200, Lukas-Fabian Moser a écrit :

(The even friendlier syntax variant  would require changing the
lexer/parser, I think.)

Why don't you just do

   <"/">

?


Two reasons:

- I wasn't aware that figures support " " without a \markup
- To me, <_/> and in particular  feel closer to having semantic input.

But thanks, in particular for the nice design using \beam! :-)

Lukas




Re: "Slash" in figured bass

2023-08-17 Thread Lukas-Fabian Moser




The slash is pronounced the best of several possibilites by
C. Ph. E. Bach [...]

Thanks.  Please open an issue for SMuFL at

   https://github.com/w3c/smufl/issues

so that this slash symbol gets added to the figured bass glyphs.

https://github.com/w3c/smufl/issues/279



"Slash" in figured bass

2023-08-16 Thread Lukas-Fabian Moser

Folks (& especially: Dear Werner),

in his "Anleitung zum Generalbasse" (and the accompanying "Practische 
Beyspiele") from the early 1800s, E. A. Förster uses a "slash" symbol in 
figured bass to denote a chord that is being described relative not to 
the current but to the next bass note.


From Förster's book: 
https://www.digitale-sammlungen.de/view/bsb10527178?page=64 ex. 141
I also attach an example from his "Practische Beyspiele", in which a 
slightly different layout is being used in which the slash and the 
figure are put separately over their respective notes.


Of course it wouldn't be hard to cook up a solution (using \markup in 
figures) for both styles, but I'd like to do it "the right way": Do we 
already have a suitable slash symbol? If not, how should it be designed? 
Has anybody of you already used this symbol?


Lukas

PS. Let me take this opportunity to say huge thanks again to Werner for 
his massive recent improvements in figured bass: With the new proper 
glyphs for slashed and plussed figures LilyPond can finally be used for 
scientifically accurate figured bass engraving.


Re: s-curve slurs across staves?

2023-08-16 Thread Lukas-Fabian Moser

Hi Jin,

Am 16.08.23 um 04:48 schrieb Jin Choi:

Is it possible to get this style of s-curve shaped slurs across staves?


It's possible, but it's not fun.

\version "2.24.0"

\new PianoStaff
<<
  \new Staff = upper {
    <<
  {
  r8
  \shape #'((0 . 0) (4 . -2) (0 . 6) (1 . 3)) Slur
  8_(   \change Staff = lower 4)
  }
  \new Voice { s2 r }
    >>
  }
  \new Staff = lower \with { \clef bass } {
    cis,4 r s r

  }
>>

Slurs live in a single voice (that's something I'm working on, but I 
don't have much time for LilyPond work at the moment), so we have to 
create one voice that switches to the other staff on the way. Then we 
have to adjust the control points manually, a task which is made harder 
by the need to manually move the right tip of the slur from "under the 
note" to "above the note".


There's definitely room for improvement, both in my example and in 
LilyPond proper.


Lukas




Re: Polyphonic piano writing - beam directions

2023-08-09 Thread Lukas-Fabian Moser



Am 09.08.23 um 13:34 schrieb David Kastrup:

Lukas-Fabian Moser  writes:


   \new Staff = down \with { \clef bass } {

That sentiment was part of why I chose to switch from tenor to male alto
instead of bass.  An easier change for sight-reading.


:-) :-)

All the clefs (and all the keys) are our good friends. At least that's 
what I tell my students... who obviously don't believe me.





Re: Polyphonic piano writing - beam directions

2023-08-09 Thread Lukas-Fabian Moser



Am 09.08.23 um 03:12 schrieb William Rehwinkel via LilyPond user discussion:

\version "2.25.7"

\new PianoStaff <<
  \new Staff = "up" \relative g' { \voiceTwo g16 e c \change Staff = 
"do" \voiceOne g e g \change Staff = "up" \voiceTwo c e}

  \new Staff = "do" \with {\clef bass } s2
>>


This combination (\change Staff = ... \voiceXX) is so common that I tend 
to abbreviate it:


\version "2.25.7"

up = { \change Staff = up \voiceTwo }
down = { \change Staff = down \voiceOne }

\new PianoStaff <<
  \new Staff = up <<
    \new Voice {
  \voiceOne
  e''4 c'' c''2
  d''4 b'2 c''4
    }
    \new Voice \relative {
  \voiceTwo
  g'8 e c \down g e g \up c e
  f e f d e c g g'
  }
  >>
  \new Staff = down \with { \clef bass } {
    \voiceTwo c4 c c c
    \oneVoice c c c c
  }
>>

Lukas




Re: A query about tablature

2023-08-08 Thread Lukas-Fabian Moser

Hi David,

Am 08.08.23 um 15:26 schrieb David Kastrup:

As a side remark: In order to put music into a RhythmicStaff, one
doesn't even have to remove the pitches, they will just be
ignored. But I noticed yesterday that LilyPond does not behave very
well with chords in that situation:

\version "2.24.0"

mus = { c' d' 4. f'8 }

<<
   \new RhythmicStaff \mus
   \new Staff \mus
I'm not sure whether that should be called a bug: one would have to
think a bit about the most natural way to deal with chords here.

\new RhythmicStaff #(event-chord-reduce (music-clone mus))


Yes, sure, that's what I did in my code for Alasdair. But I was more 
wondering whether or not RhythmicStaves (RhythmicStaff's?) should do 
this automatically.


By the way, I didn't know about music-clone. What's its advantage over 
ly:music-deep-copy?


Lukas




Re: A query about tablature

2023-08-08 Thread Lukas-Fabian Moser

Hi Alasdair,


Thank you very much - that is quite amazing!

You're very welcome.
But it does show what I have long suspected: that without some extra 
programming, Lilypond does not have a current facility to extract the 
rhythm from a music definition.  All of the tablatures I've seen in 
Lilypond require the music to be entered twice: once fully, and the 
other as durations only.   As well, the tablature section in the 
documentation nowhere shows how to do this: to create a tablature 
score with just the rhythm above it.   Maybe this will be amended in 
future versions?

[...]
I should add that those remarks of mine were not meant as complaints 
about Lilypond; merely as observations.  I'm very aware that as an 
open-source project, Lilypond's strength derives from the hard, 
unpaid, tireless and often thankless work by its developers.  It is 
often said about open source projects that if you want some 
particular functionality, you should write it yourself and submit it 
for review.  However, my programming skills (at least in scheme) are 
too poor for this myself.
Well, I think the point with LilyPond is that - unlike other open-source 
projects - you actually don't have to modify the program itself in order 
to add new functionality, but instead, you can implement the function 
you want _inside_ your own .ly file which you can re-use, share and put 
on a snippet repository. I have lots of custom-tailored functions like 
this in an include file (.ily) on my computer which I simply \include in 
any project where I need them.


So that's what I recommend for you: Just copy the relevant parts of my 
code into a .ily file and \include it whenever you need to use tablature.


Of course I concede that I needed to know a bit about LilyPond's inner 
workings and about Scheme to write a function like this. But nowadays 
there's even lots of well-written documentation that can get you 
started; do you know Jean's manual on https://extending-lilypond.gitlab.io ?



But maybe your code could be submitted to be part of Lilypond in future?
That's always a possibility, but the way I see it, there are two 
requirements for this:


1) The desired functionality should be sufficiently "general" or 
"standard" that there's a chance that it'll actually be being used. I 
don't know much about tabulature, so I can't really judge if the 
notation you want to use is standard in some area.


2) The submitted code should be of high quality. That's definitely not 
the case with the function I wrote yesterday; it would need quite a bit 
of polishing in order to gracefully deal with special cases and so on. 
(E.g. how should we deal with polyphony inside the given music?)


At the moment I feel that my function would probably best be put in a 
LSR snippet, so maybe I should do this.


As a side remark: In order to put music into a RhythmicStaff, one 
doesn't even have to remove the pitches, they will just be ignored. But 
I noticed yesterday that LilyPond does not behave very well with chords 
in that situation:


\version "2.24.0"

mus = { c' d' 4. f'8 }

<<
  \new RhythmicStaff \mus
  \new Staff \mus
>>

I'm not sure whether that should be called a bug: one would have to 
think a bit about the most natural way to deal with chords here.


Lukas





Re: Is there a Scheme macro(?) to use fretboards to generate a generic guitar strum?

2023-08-07 Thread Lukas-Fabian Moser

Hi David,


arpeggiateChord = #
(define-music-function (chord) (ly:music?)

Just a warning: inventing unconventional formattings like this (putting
# on a different line as the opening paren) carries the danger of
keeping convert-ly (and syntax highlighters and syntax-sensitive
editors) from recognizing the construct.


Good point, thanks. I got into the habit of adding a newline after # in 
order to let Frescobaldi's autoformatter create Scheme code that I can 
copy into .scm files. But of course there's fixscm.sh, and we 
don't deal with .scm files here anyway.


Lukas




Re: A query about tablature

2023-08-07 Thread Lukas-Fabian Moser

Hi Alasdair,

Am 07.08.23 um 07:05 schrieb Alasdair McAndrew:
In fact you can just look at the snippet at 
https://lsr.di.unimi.it/LSR/Item?id=848 I've set mine up slightly 
differently, with letters between the lines, but the principle is the 
same.  But as you see from this snippet, you have to enter the notes 
and values for the tablature stave, and the note durations again (with 
appropriate "silent" notes) for the rhythm stave.  And both these 
staves have to be created independently and put together at the end.


I want to know if you can do this without having to enter the rhythm 
durations and stave separately - the information in "myNotes" in the 
snippet contains all the information needed. I'm hoping for a solution 
where all you need to enter is "myNotes", and then both the tablature 
staff and the rhythm staff would be created in one go.


Thank you again.


That's basically a matter of programmatically turning the given music 
into bare (pitch-less) durations while skipping repeated durations.


Question: What should be done for actual rests in the input?

One possible approach might be:

\version "2.24.0"

%% http://lsr.di.unimi.it/LSR/Item?id=848
%LSR modified by P.P.Schneider on Feb.2014 for v2.18
% modified by L.-F. Moser in Aug. 2023
% (added \extractRhythm and \tabStaves)

%{ Tablature layout for viol music

The snippet defines a specialized group of rhythmic and
tablature staves able to handle old english viol tablature
scores.

The string tunings defaults to the most common viol in d
but other usual tunings are also available.

The rhythm part is used to provide only the pace changes,
and therefore must be provided as a supplementary voice.
%}

viol-in-d-tuning = \stringTuning 

viol-in-d-scord-tuning = \stringTuning 

viol-in-g-tuning = \stringTuning 

ViolTabLayout = \layout {
  \context {
    \RhythmicStaff
    \type "Engraver_group"
    \name "ViolTabRhythmicStaff"
    \alias "RhythmicStaff"

    \description "Handles rhythm part of viol tablature."

    \remove "Time_signature_engraver"
    \remove "Staff_symbol_engraver"
    \remove "Bar_engraver"

    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
    \override Stem.length = #5
    \override VerticalAxisGroup.staff-staff-spacing =
    #'((basic-distance . 1)
   (minimum-distance . 1)
   (padding . 1))

    % useful to merge chords noteheads
    \override NoteHead.X-offset = #0
  }

  \context {
    \TabStaff
    \type "Engraver_group"
    \name "ViolTabFingeringStaff"
    \alias "Staff"

    \description "Handles fingering part of viol tablature."

    tablatureFormat = #fret-letter-tablature-format
    stringTunings = #viol-in-d-tuning

    % useful for tablature only scores
    \revert TimeSignature.stencil
    \override TimeSignature.style = #'single-digit
  }

  \context {
    \type "Engraver_group"
    \name "ViolTabStaff"
    \consists "Vertical_align_engraver"
    topLevelAlignment = ##f

    \description "Handles viol tablature."

    \defaultchild "ViolTabFingeringStaff"
    \accepts "ViolTabRhythmicStaff"
    \accepts "ViolTabFingeringStaff"
  }

  \context {
    \Score
    \accepts "ViolTabStaff"
  }
}

%

#(define rest-or-skip?
   (music-type-predicate '(skip-event general-rest-event)))

extractRhythm =
#(define-music-function (mus) (ly:music?)
   (make-music
    'SequentialMusic
    'elements
    (let loop
  ((remaining-notes
    (extract-typed-music (event-chord-reduce mus)
 'rhythmic-event))
   (current-duration #f))

  (if
   (null? remaining-notes)
   '()
   (let*
    ((note (car remaining-notes))
 (duration (ly:music-property note 'duration)))
    (cons
 (make-music
  (if (or (rest-or-skip? note)
  (equal? duration current-duration))
  'SkipEvent
  'NoteEvent)
  'duration duration)
 (loop (cdr remaining-notes)
   (if (rest-or-skip? note) current-duration duration

%

tabStaves =
#(define-music-function (mus) (ly:music?)
   #{
 <<
   \new Staff \with { \clef bass } {
 #mus
   }
   \new ViolTabStaff {
 <<
   \new ViolTabRhythmicStaff {
 \extractRhythm $mus
   }
   \new ViolTabFingeringStaff { #mus }
 >>
   }
 >>
   #})

myNotes = \relative c {
  4 e f8 g a4
  2. c4
  d4. e8 f4 g
  r8 g g f e4 a
}

%

\score {
  \tabStaves \myNotes
  \layout {
    \ViolTabLayout
  }
}

Lukas




Re: Is there a Scheme macro(?) to use fretboards to generate a generic guitar strum?

2023-08-05 Thread Lukas-Fabian Moser

Hi Kevin,


But right now,
there's nothing other than constructing it by hand each time, for
every chord. I think something would be better than nothing.
The problem has two parts: 1) Generate a sensible voicing for a given 
chord; 2) create the arpeggio. (Maybe you intended to do 1) manually 
anyway?)


Here is a possible approach for 2) using LilyPond's (not ideal) 
automatic voicings for 1):


\version "2.24.0"

arpeggiateChord = #
(define-music-function (chord) (ly:music?)
  (define (make-tied-note p) #{ $p 32~ #})
  (if (music-is-of-type? chord 'event-chord)
  #{
    \set tieWaitForNote = ##t
    \grace {
  $@(map make-tied-note (drop-right! (music-pitches chord) 1))
    }
    \unset tieWaitForNote
    #chord
  #}
  chord))


\score {
  \musicMap #arpeggiateChord {
    \chordmode { c2:7.9- f4:m bes4:m6 f2:m/c c:7 f1 }
  }
  \layout {}
  \midi {}
}

This is very basic, it doesn't support relative mode etc., but maybe it 
gives you an idea.


Lukas




Re: for-each?

2023-07-03 Thread Lukas-Fabian Moser

That has an awkward look.  I'd rather use

```
\version "2.25.6"

parts = {
   {c'}
   {d'}
   {e'}
   {f'}
 }

group =
#(define-music-function
   (parts) (ly:music?)
   #{\new StaffGroup << #@(ly:music-property parts 'elements) >>#})

\group \parts
```


Or maybe even:

\version "2.25.6"

parts = {
  { c' }
  { d' }
  { e' }
  { f' }
}

group = #
(define-music-function (parts) (ly:music?)
  #{
    \new StaffGroup
    $(make-music 'SimultaneousMusic parts)
  #})

\group \parts

? But I'm surprised (a bit) that I need $ here - the \new commands still 
puzzle me sometimes.


Lukas




Re: Small note between staves as time signature

2023-05-11 Thread Lukas-Fabian Moser

Hi Jakob,

The Danish book of chorales to accompany the official hymnal uses a 
peculiar "time signature" (which isn't really a time signature) for 
some hymns.


It's a small note, in this case a 텞  but elsewhere its a compound 
signature like 텞♩, to indicate the metre.

Maybe also use an actual TimeSignature living in a Dynamics context?

\version "2.24.0"

#(add-simple-time-signature-style
  'note
  (lambda (frac)
    (let ((den (cdr frac)))
  #{ \markup \tiny \note #(ly:make-duration (ly:intlog2 den)) #UP #})))

\layout {
  \context {
    \Dynamics
    \consists Time_signature_engraver
    \override TimeSignature.break-align-symbol = #'key-signature
    \override TimeSignature.style = #'note
  }
  \context {
    \Staff
    \remove Time_signature_engraver
  }
}

\score {
  \new PianoStaff <<
    \new Staff {
  \key d \major
  \after 1*6 { \break \time 2/2 }
  \repeat unfold 100 << d'4 \\ a4 >>
    }
    \new Dynamics {
  s1*25
    }
    \new Staff \with { \clef bass } {
  \key d \major
  \repeat unfold 100 << fis4 \\ d4 >>
    }
  >>
}

Lukas




Re: help with Wrong type of argument

2023-05-01 Thread Lukas-Fabian Moser

Hi Michael,

To say I'm no expert in Scheme is a vast understatement. However, I 
think I found the answer to this one. 

Just in order to reassure you a bit:


 Basically, as I understand things, this bit:

   #'((lineto 0 hgt)


Accosrding to my rather vague understanding of Scheme syntax the ' 
between the # and the 1st ( is saying don't interpret anything in that 
expression, just pass it as is. Which means that your variable hgt 
isn't getting passed as a variable but is getting passed as simply a 
series of three characters.
Better make that: hgt is passed as the "symbol" hgt (usually entered as 
'hgt in Scheme). Other than that, you're right.
What seems to be needed (and what made this appear to work here) is to 
use what's called quasiquoting. Basically, it lets you designate 
certain bits within an expression as "this part should be interpreted 
before getting passed on". This entails changing the above line to:


#`((lineto 0 ,hgt)

By changing the ' into a ` (BTW, that's the one that on my keyboard is 
up near the top left, just under the Escape key) you say that there's 
something in the following expression that will need interpreted. Then 
the comma before the variable name points out which item to interpret.


That's correct (modulo the term "interpret" where "evaluate" is more 
common), and quasiquoting indeed is the right way to construct 
complicated list/pair structures containing lots of symbols and some 
variables that should be evaluated.


There's one other way which is sometimes useful (but admittedly won't 
simplify the present use case much):


#`((lineto 0 ,hgt) (closepath))

is the a list with two elements, namely
- the 3-element list containing 'lineto, 0 and the value of the variable hgt
- the 1-element list containing the symbol 'closepath.

This may also be written as:

#(list (list 'lineto 0 hgt) (list 'closepath))

or, mixing the two styles,

#(list (list 'lineto 0 hgt) '(closepath))

Lukas


Re: Lyluatex: Font selection

2023-04-15 Thread Lukas-Fabian Moser

Hello,


This bug was introduced by an attempt to fix an incompatibility with 
polyglossia, as this one removes proper familyname informations that 
are normally available from lua.


@Jean Abou Samra  : I’m the main author of 
lyluatex (I say the main one, as Urs Liska did an awesome work to make 
it what it has become). Not a developer nor a professional musician, 
but a priest and teacher in a French school, and "accidentally" 
choirmaster in this school.


The bug has been fixed now with 
https://github.com/jperon/lyluatex/commit/4fc51067217dc0e6c0361a5c34994067e6205bdb 
- thank you very much, Fr Jacques!


Lukas


Lyluatex: Font selection

2023-04-15 Thread Lukas-Fabian Moser

Folks,

that's probably more of a Lyluatex issue, but since LilyPond's font 
handling is involved (and it's being changed right now and it's 
something I know nothing about, and we have proper font experts among 
us), maybe it's a good idea to discuss this also on the LilyPond side.


When reviving and old Lyluatex project of mine I stumbled over the 
following: When using "EB Garamond" from 
https://github.com/octaviopardo/EBGaramond12/tree/master/fonts/otf as 
main document font as in


\documentclass{article}

\usepackage[program=/home/lukas/lilypond-versions/lilypond-2.24.0/bin/lilypond,debug=true]{lyluatex}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\setluaoption{ly}{pass-fonts}{true}

\begin{document}
Test

\lily{
\fixed c'{c\mark "Hallo" d e f^"Test"}
\addlyrics{c d e f}
}
Noch ein Test

\end{document}

then Lyluatex's commit e55a3832e30cd364c4 ("Fix compatibility with 
polyglossia") makes the temporary .ly file contain the following font 
selection code:


  #(define fonts
    (make-pango-font-tree "EB Garamond Regular"
  "LMSans10"
  "LMMono10"
  (/ staff-height pt 20)))

while without that commit it is:

    #(define fonts
    (make-pango-font-tree "EB Garamond"
  "Latin Modern Sans"
  "Latin Modern Mono"
  (/ staff-height pt 20)))

Only the second one works (LilyPond doesn't find the font with the added 
"Regular"). So for now I've reverted that commit in my local copy of 
Lyluatex.


So, my questions basically are:

- Is it the font's fault for not registering itself as "Regular" by name?
- Is it LilyPond's fault for not finding the font if "Regular" is added?
- Is any of this touched by Jean's ongoing work on restructuring 
LilyPond's font selection mechanism? (I don't think so, at least 
fonts.roman = "EB Garamond Regular" fails with 2.25.4)

- Or is this simply a bug in Lyluatex introduced with e55a3832e?

As an additional data point, both "LMSans10" and "LMMono10" _are_ being 
accepted and work the same as do "Latin Modern Sans" and "Latin Modern 
Mono".


Lukas




Re: Policy for posts from non-members

2023-02-22 Thread Lukas-Fabian Moser

Hi,

Am 22.02.23 um 12:45 schrieb Andrew Bernard:
Most employed people who work use email daily and countless people 
understand folders and filters.
Well... I cordially invite you to come visit us and marvel at what one 
encounters when working in a thoroughly non-technical environment like, 
for example, a music university :-). E-Mail, yes; folders, probably; 
automatic filtering, no way.
[Re Musescore, that may have been an offhand reference just to a 
random competing application but on the forum page it is stated: "Log 
in to post new content in the forum."


https://musescore.org/en/forum

]


Yes, it was a more-or-less random reference to the most important 
"competing" (if that term is applicable at all) free software music 
typesetting system. But not because MuseScore offers a more accessible 
forum - I have no idea how that works there -, but because MuseScore 
looks to non-technical people more like what they expect from a music 
typesetting system. LilyPond _is_ esoteric. And although I'm quite 
skeptical about its suitability as engraving program for 
non-technically-minded musicians, I think we don't have to increase the 
barrier more than necessary.
Frankly, even I myself am using MuseScore for a lot of "simple music 
typesetting" tasks these days (having gotten to know it better during 
the pandemic): I only turn to LilyPond now for "serious stuff that 
should look seriously great".


But of course this discussion borders on being OT.

Lukas




Re: Policy for posts from non-members

2023-02-22 Thread Lukas-Fabian Moser

Hi Jean,


I've not been an admin of this list for very long, yet I'm already 
weary of telling people who post without being subscribed to the list 
that they should subscribe in order to avoid each of their messages 
being manually approved. I wonder what you (meaning everyone, but 
especially Mark, the other admin) would think about changing the list 
configuration to reject post from non-members instead of holding them 
on moderation, with a message such as


“Welcome to the lilypond-user mailing list. We apologize, but in order 
to prevent spam, we need you to subscribe to the list before you post. 
Please fill out the subscription form on 
https://lists.gnu.org/mailman/listinfo/lilypond-user.


Once you are subscribed, you will receive all posts to the list, so 
you can help out other people as well. However, if you only wish to 
interact with this list infrequently, you may disable mail 
subscription in your membership preferences after you have subscribed.


If you believe you are already subscribed to the list, it probably 
means that you accidentally posted from a different email address than 
the one you are subscribed with.


If you have any question or encounter problems, feel free to contact 
the list admins at lilypond-user-ow...@gnu.org”


On the plus side, this means that instead of delaying the message 
until Mark or me looks at it, the feedback will come instantly.


I'm a bit late to the party, but nevertheless: I think I'm with Wol and 
Werner (and David K.?) here.


Of course, considering the unbelievable number of things you're 
contributing to LilyPond as a whole, you're perfectly free to design 
things in a fashion that is least cumbersome to you.


But I'm afraid a message like the one you proposed (although its wording 
is perfectly friendly and polite) will turn new users away, who just 
might say: Don't bother, I'll stick to MuseScore then. Mailing lists are 
old, yes (like Andrew said), but this does not mean that by now, 
everybody should be accustomed to them: It could just as well mean (and 
I think it does) that younger people are not acquainted with them anymore.


So, I think a better solution would be to keep things as they are, but 
let non-subscribed users automatically (if that's possible!) receive an 
e-mail saying:


- welcome
- you're not subscribed, so it might take longer until you get an 
answer, as your message has to be approved manually
- also, you might not see answers given to you, if somebody who helps 
you doesn't "reply to all" but sends his reply to the user list only.
- so you might just consider subscribing to the list, which you can do 
here: [link]


I don't think that this is would be a moral problem in the sense of a 
canned reply disguised as a human interaction. It would keep your 
moderation task to a mere minimum (namely, approving the message), but 
without giving the new users the feeling that their message has actually 
been rejected.


I've said this already, and I'm happy to say this again: To me, the 
LilyPond community is likely the most friendly, helpful place I've ever 
encountered on "the internet". We shouldn't erect too high a barrier to 
entering it, and for people who are not familiar (e.g.) with automatic 
e-mail filtering/sorting rules etc., I think subscribing to an e-mail 
list does look like a barrier: We should advertise doing it, but not 
force people contacting us for the first time to do it.


Lukas




Re: Documentation: Should we possibly have aliases for current stable and current devel?

2023-02-13 Thread Lukas-Fabian Moser

Hi,


From https://lilypond.org/help-us.html

“Mailing list support: answer questions from fellow users. (This may 
entail helping them navigate the online documentation; in such cases 
it may sometimes be appropriate to point them to version-agnostic URL 
paths such as |/latest/| 
or|/stable/| 
, which are 
automatically redirected.)”


Thanks for pointing this out, I never knew about this.

But: If I open 
https://lilypond.org/doc/stable/Documentation/notation/proportional-notation.html, 
I get redirected to 
http://lilypond.org/doc/v2.24/Documentation/notation/proportional-notation.html 
- so if I copy the URL from my browser into an e-mail, I'm with a 
version-specific link again.


Wouldn't it be better (if that's at all possible) if the URL display in 
the browser could keep the explicit "stable" / "latest", and in turn add 
a button returning a permanent link to the page as currently displayed 
(which then contains the explicit version and language tag)?


Lukas


Re: Documentation: Should we possibly have aliases for current stable and current devel?

2023-02-13 Thread Lukas-Fabian Moser

Hi Kevin,


On the other hand, I strongly favor sticking with a distribution's
package rather than starting every day with a "git pull". So, I'm
always slightly behind the latest and greatest.


Just for the record: Your description omits the (actually quite 
convenient) middle between the two extremes: Namely, that it's quite 
easy to keep up with current LilyPond development by downloading and 
using the respective (unstable) builds that are released every few weeks 
to months.


Distribution packages often are lagging behind quite a bit, while doing 
"git pull" (and self-compiling) is much more complicated to set up.


The naming of the development releases as "unstable" is a bit 
misleading: They are unstable more in the sense that features might 
change back and forth (which sometimes, but not often, happens), not 
that they are much more likely to burn your computer than the "stable" 
releases. Actually, the quite rigorous testing standard we have for 
merging code contributions by developers goes a long way to ensure that 
even the daily current master (the one from git pull and self-compiling) 
is usually perfectly fine for everyday production use.


Lukas




Re: `\afterGrace` and clef problem

2023-02-13 Thread Lukas-Fabian Moser

Hi Werner,


Alternatively you may try to use \afterGrace to insert the \clef
before the bar line, although this would probably require some
manual spacing too.

This doesn't work at all: `\afterGrace` doesn't accept a clef, as the
image shows.


afterGrace is defined as

#(define-music-function (fraction main grace) ((scale?) ly:music? 
ly:music?) ...)


You write

\afterGrace 1 { s8 \clef "bass" } | c,1

but 1 is a valid scale? because of

(define-public (scale? x)
  (or (and (rational? x) (exact? x) (not (negative? x)))
  (fraction? x)
  (and (ly:moment? x) (scale? (ly:moment-main x)

in scm/c++.scm.

Lukas




Re: Vertical placement ChoirStaff

2023-02-08 Thread Lukas-Fabian Moser

Hi Johannes,

Am 08.02.23 um 14:05 schrieb Johannes Roeßler:


Hi Group,

I'd like to know how I can place a staff group vertically centered on 
a page.
I don't want to use "ragged bottom" or the system group to be 
stretched - just centered vertically.


I hope you understand, what I'm trying to achieve.

Thx,
Joei


Maybe something like the following?

\version "2.24.0"

\paper {
  system-system-spacing.stretchability = 0
  top-system-spacing.stretchability = 1
  last-bottom-spacing.stretchability = 1
  ragged-bottom = ##f
  ragged-last-bottom = ##f
  systems-per-page = 3 % may also be set to 1, for example
}

\layout {
  \override Score.VerticalAxisGroup.staff-staff-spacing.stretchability = 0
}

\new PianoStaff
<<
  \new Staff \repeat unfold 160 { c'2 }
  \new Staff \repeat unfold 160 { c'2 }
>>

Lukas




Re: single system output in 2.24

2023-02-05 Thread Lukas-Fabian Moser



You’re right, and probably I should help with the translation. (I 
tried, some years ago, and gave up; AFAIR didn’t even get the workflow 
running...)


If you're on Linux (I used to have Mint, now I'm on Ubuntu 22.10), it 
shouldn't be too hard to get the infrastructure running. Of course it's 
complex, but there's a lot of people around who would be willing to help.


Lukas




Re: single system output in 2.24

2023-02-05 Thread Lukas-Fabian Moser

Hi Hraban,

(BTW the German translation of the CLI documentation is outdated and 
thus partly wrong, and it really makes no sense that I must 
reconfigure my browser to access different languages.)


I agree that the current situation (both the state of the German 
translation and the mechanism for language selection) is not ideal, but 
it's not true that you must reconfigure your browser to access the 
English original: There's a language selection link at the bottom of 
every manual page. (Admittedly, it's a bit annoying that you have to 
re-make your choice after clicking on a link.)


Lukas




Re: German notation

2023-01-30 Thread Lukas-Fabian Moser




By the way, there also
exists the opposite: In (older?) scores of symphonies by Anton
Bruckner, the violoncello part, if using the violin clef, is notated
one octave higher than sounding.


This is also common in Dvorak, for example. Strauss-Berlioz describe a 
precise rule for this (according to them, violin clef for cello is 
written one octave higher if it occurs i) right at the start of a piece 
or ii) after music in bass clef; it's written _loco_ if it comes after a 
passage in tenor clef). But then they (i.e. probably Berlioz) continue:


"Dieser durch nichts zu rechtfertigende Gebrauch führt um so häufiger zu 
Mißverständnissen, als manche Violoncellisten keine Notiz davon nehmen 
und den G-Schlüssel stets nur in seiner wirklichen Bedeutung nehmen."


(Roughly: There's no justification for this usage which often leads to 
confusion, in particular since some cellists are unaware of it and 
always read the treble clef in its standard meaning.)



Strange transposition rules also exist for horns, where in the violin
clef you transpose down, and in the bass clef you transpose up.


... and what's even worse, as soon as one has gotten used to this rule, 
one stumbles across (recent) scores that don't adhere to it any more. 
Cf. https://colindorman.com/old-vs-new-notation-bass-clef/


Lukas




Re: German notation

2023-01-29 Thread Lukas-Fabian Moser



Am 29.01.23 um 18:20 schrieb Wol:

On 29/01/2023 10:03, Mark Knoop wrote:

I think Wim may be referring to the various standards of transposing the
B-flat bass clarinet.

- either in bass clef a major 2nd higher than sounding (as in this
   Strauss excerpt)


IME (I'm a trombone player) this is extremely unusual. I've met maybe 
two pieces (could have been the same one twice) in bass clef Bb. 
That's in 50 years of playing ... Even worse, it was without key 
signature (ie all parts had accidentals only) and it didn't say it was 
transposed...


Every instrument has its own (sometimes historically quite involved) 
notation conventions.


Bass clef for bass clarinet is not mentioned in Strauss-Berlioz (Study 
of instrumentation), but e.g. Rachmaninoff uses it routinely (2nd 
symphony, Symphonic Dances, Isle of the Dead). I'm certain Werner will 
be able to provide more details :-).


Lukas




Re: autobeaming over rests,Re: autobeaming over rests

2023-01-29 Thread Lukas-Fabian Moser



Am 29.01.23 um 17:36 schrieb Valentin Petzel:

Hello David,

in most cases definitely, but I suppose there might be some cases in say piano
music where something like this would make sense.


Additionally, Schenker graphs would be an obvious example where beaming 
over skips is useful. (But of course these are strange enough that one 
wouldn't likely make use of autobeaming.)


Lukas




Re: autobeaming over rests,Re: autobeaming over rests

2023-01-29 Thread Lukas-Fabian Moser


Am 29.01.23 um 17:54 schrieb David Kastrup:

Valentin Petzel  writes:


Hello David,

in most cases definitely, but I suppose there might be some cases in
say piano music where something like this would make sense.

I'd say that proportion seems low enough that providing automatisms for
it is more likely to cause confusion than help.


I disagree.

Of course the feature is never actually _needed_ as it only saves a 
couple of [ ] signs. But the example I gave in my earlier mail to Werner 
is fairly common, actually - I attach some bars from Bach's 
Ratswahlkantate BWV 29, and there are much more of these in the violin 
original from BWV 1006. I'd wager it's fairly standard notation to have 
beams over skips in piano music, actually.


I don't quite see how the existence of a context property (switched off 
by default) enabling non-ubiquitous, but established notation could 
cause confusion. And after all, I think


c'8[ s s d']

without a second voice in between isn't that much more confusing than 
without the beam.


Lukas


Re: autobeaming over rests, Re: autobeaming over rests, Re: autobeaming over rests,Re: autobeaming over rests

2023-01-29 Thread Lukas-Fabian Moser

Hi Werner,

Am 29.01.23 um 11:30 schrieb Werner LEMBERG:

IMHO, there are definitely valid situations where
automatic beaming over rests does make sense.

this would not be hard to get done. Here’s an experimental commit:
[...]

Veeery nice, thanks!  I only wonder what situation you envision to add
a special property for skips...

\version "2.24.0"

\new Staff \relative
<<
  { c'8[ s s c] }
  \\
  { s c c s }
>>

doesn't seem unreasonable to me (for example in piano music).

Lukas




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

2023-01-28 Thread Lukas-Fabian Moser

Hi Pierre-Luc,

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

m = \drummode { hh }


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


Compare:

\version "2.24.0"

m = \drummode { hh }

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

But what you can do is:

\version "2.24.0"

drumPitchNames.m = #'hihat

\drummode { m8 m r4 m }

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

Lukas




Re: Slurs not being followed in one vocal part

2023-01-22 Thread Lukas-Fabian Moser

Hi Jon,

Am 22.01.23 um 03:31 schrieb Jon Arnold:
Thanks all! Separating the voices did fix the problem. I used this 
score a long time ago and then updated the layout, so I feel like an 
update several years ago must have changed the behavior, which is 
interesting.


Compare:

\version "2.24"

mel = \relative {
  g''4.( f8 f e) d( c)
  d2 r
}

lyr = \lyricmode { Glo -- ri -- a! }

stuff = {
  \dynamicUp % try commenting this out!
  <>\f\>
  s1
  <>\!
}

\new Staff << \mel \stuff >> \addlyrics \lyr
\new Staff << \stuff \mel >> \addlyrics \lyr
\new Staff << \mel \addlyrics \lyr \stuff >>

But if you remove the \dynamicUp you'll see that LilyPond's behaviour in 
<< \A \B >> \addlyrics { ... } constructions is a bit volatile.


Lukas




Re: Completion_heads_engraver for line-ends only?

2023-01-17 Thread Lukas-Fabian Moser




I am afraid this would be exceedingly difficult technically.
Engravers run way earlier than line breaking, so the only
option would be to let the engraver create both notations
(with notes straddling over bar lines and with tied notes),
and remove one of them later, but there is a lot of code in
between that is not prepared for ignoring the collisions
that will unavoidably ensue, it would have consequences on
horizontal spacing, etc.


That's what I thought as well, but I think one wouldn't need to create 
both notations: Just create the tied notes only and, if not needed, 
tweak the note heads and kill some ties/other notes as late as possible. 
I _think_ this should be possible, involving some cheating for creating 
dots for situations of the type 2~ 4.


Still a mess, though, and spacing would be messed up by all the 
un-needed ties and extra notes.


Lukas




Re: Completion_heads_engraver for line-ends only?

2023-01-17 Thread Lukas-Fabian Moser

Hi,


As a secondary question: Is there a straightforward way to avoid collisions of 
mensurstriche with beams?


Do you have an example?

Here's an extract from the de Wert, that illustrates the "problem" (lilypond 
2.25.0):


The way I see it, this would be a case for just accepting the crossing 
and maybe making it look nice using whiteout.


Lukas




Re: Conflict between articulate.ly and \accacciatura in 2.24.0

2023-01-07 Thread Lukas-Fabian Moser

Hi Gordon,

Am 07.01.23 um 10:00 schrieb Gordon Bower:


When I tried to recompile a piece I had written in 2.22.1 with 2.24.0, 
I got a mysterious error message:

"Exited with return code -1073741784."

Commenting out things until it would compile, I found the problem was 
specifically when articulate was applied to a music group with an 
accacciatura:


\version "2.24.0"
\language "deutsch"

acctest = {\time 6/8
           \relative c' {
            d8 e f g a \acciaccatura c h}}

\score {
 \articulate
 \acctest
\layout{}
\midi{}
}


Three questions:

a) Are you sure that is exactly the file causing the abort? (It doesn't 
even compile on my system if I don't add an \include for articulate.ly.)


b) Are you on Windows?

c) Does the crash happen reproducibly every time you compile the file?

Lukas




Re: \sustainOff on \alternative

2023-01-06 Thread Lukas-Fabian Moser



Could you consider upgrading to LilyPond 2.24? That's the current 
stable version (and my code was written for it). If that's 
impossible, I can sidestep the use of \after, but frankly, it's 
easier to help you if you provide a working example yourself.


I am fairly certain David K. wrote \after back in the 2.19 era, so 
there should be no particular need to run 2.24.  I found this version 
on an old thread:



after =
#(define-music-function (t e m) (ly:duration? ly:music? ly:music?)
  #{
    \context Bottom <<
  #m
  { \skip $t <> -\tweak extra-spacing-width #empty-interval $e }
    >>
  #})



When I researched variants of \after while working on getting it into 
standard LilyPond (which happened somewhere in the 2.23 line), the 
earliest incarnation I could find was 
https://lists.gnu.org/archive/html/lilypond-devel/2012-09/msg00342.html 
- so that's 2.16 era.


Of course you're right that I might just as well have provided the OP 
with a simple implementation of \after. (But upgrading is a good idea 
anyway, I think - there has been marvelous progress during 2.23.xx I 
think, all due to the work done by Jean, Dan and others.)


Lukas




Re: \sustainOff on \alternative

2023-01-06 Thread Lukas-Fabian Moser



Hi, I am using 2.22.2,
\after 4 \sustainOff b2 r
​is useless, because of *unknown escaped string*


"Useless" sounds a bit harsh.

Could you consider upgrading to LilyPond 2.24? That's the current stable 
version (and my code was written for it). If that's impossible, I can 
sidestep the use of \after, but frankly, it's easier to help you if you 
provide a working example yourself.


Lukas


Re: \sustainOff on \alternative

2023-01-06 Thread Lukas-Fabian Moser

Hi,

Am 06.01.23 um 07:54 schrieb cc0_knight--- via LilyPond user discussion:

Hi Everyone, Sorry for my english.
Skip the first pedal stop(Because it's off-topic), when I write like this:

\repeat volta 2 {
   \sustainOn
}
\alternative {
  {  \sustainOff }
  {  \sustainOff }
}


(Please always give short and compilable code examples!)

Perhaps something like:

\version "2.24.0"

{
  \repeat volta 2 \relative {
    r4 e'\sustainOn d c
  }
  \alternative {
    {
  \after 4 \sustainOff b2 r
    }
    {
  \once\omit Staff.SustainPedal
  <>\sustainOn
  \after 4 \sustainOff b2 r
    }
  }
}

Of course, in a perfect world, spanners like the sustain pedal would be 
"reset" to their pre-alternative state at the start of each alternative. 
IIRC the world of LilyPond's alternatives handling has gotten much 
closer to perfection thanks to Dan's work over the last few months, but 
this does not seem to have been part of it.


Lukas


Re: \stopStaff \startStaff bug

2023-01-05 Thread Lukas-Fabian Moser

Hi Tomasz,

Am 05.01.23 um 13:16 schrieb Tomasz Bauć:

I also checked version without the Scheme:

    \stopStaff
    \repeat unfold 9 {s8}
    \startStaff
    \stopStaff
    \repeat unfold 3 {s8}
    \startStaff
    \stopStaff
    \repeat unfold 11 {s8}
    \startStaff


(Please always give complete, compilable examples!)

The Staff_symbol_engraver is not really equipped to deal with multiple 
\startStaff / \stopStaff events at the same point of time. For a 
workaround, (there's probably an easier method, but) since I couldn't 
find a way of "killing" events in the time step cycle, I decided to wrap 
the startStaff/stopStaff commands into a custom event type that counts 
the simultaneous (start-/stop-)Staff commands and goes by the majority, 
so to speak:


\version "2.24"

#(define-event-class 'custom-staff-span-event 'span-event)

#(define my-types
   '((CustomStaffSpanEvent
  . ((description . "Custom wrapper to StaffSpanEvent.")
 (types . (event span-event custom-staff-span-event))

#(set!
  my-types
  (map (lambda (x)
 (set-object-property! (car x)
   'music-description
   (cdr (assq 'description (cdr x
 (let ((lst (cdr x)))
   (set! lst (assoc-set! lst 'name (car x)))
   (set! lst (assq-remove! lst 'description))
   (hashq-set! music-name-to-property-table (car x) lst)
   (cons (car x) lst)))
   my-types))

#(set! music-descriptions
   (append my-types music-descriptions))

#(set! music-descriptions
   (sort music-descriptions alist>

Lukas




Re: how to alias commands?

2022-12-31 Thread Lukas-Fabian Moser


Am 31.12.22 um 13:05 schrieb David Kastrup:

Quite often, one wants a shorthand for a function that actually needs
an argument. This is possible using David Kastrup's ingenious \etc:

My mother has developed an annoying habit of ending a lot of sentences
with "und so weiter" ("and so on") even when it makes no sense.


My sisters and I often tease our mother about her habit of starting 
sentences with "No...", especially when she actually wants to agree with 
you. Please don't turn that into a feature. (The same goes for the 
additional strategy of starting nesting sub-clauses in speech without 
ever returning.)



Now I fear that I am a bad influence on LilyPond.


I think it's safe to say that the sum of your contributions amounts to 
quite a healthy influence, actually.


But LilyPond deals with the habit the same way a good son would: Not 
utterly without complaint, but obediently.


\version "2.24.0"

mom = \trill \etc

{
  a4\mom b
}

Starte lilypond 2.24.0 [Ohne Titel (3)]...
»/tmp/frescobaldi-4xutm9ts/tmp6omjml8q/document.ly« wird verarbeitet
Analysieren...
/tmp/frescobaldi-4xutm9ts/tmp6omjml8q/document.ly:3:14: Fehler: syntax 
error, unexpected \etc

mom = \trill
 \etc
Interpretation der Musik...
Vorverarbeitung der grafischen Elemente...
Ideale Seitenanzahl wird gefunden...
Musik wird auf eine Seite angepasst...
Systeme erstellen...
Konvertierung nach »document.pdf«...
schwerer Fehler: gescheiterte Dateien: 
"/tmp/frescobaldi-4xutm9ts/tmp6omjml8q/document.ly"

Wurde mit dem Return-Code 1 beendet.

Lukas


Re: how to alias commands?

2022-12-31 Thread Lukas-Fabian Moser

One addition:

Am 31.12.22 um 12:45 schrieb Lukas-Fabian Moser:

Hi Kenneth,

Am 31.12.22 um 11:26 schrieb Kenneth Flak:
Is there a way to alias a command in lilypond? F.x. I would like to 
substite `\markup \rN` with simply `\rn`. Defining `rn` as a variable 
doesn't work, so what are the ways?


Usually it does actually work:

\version "2.24.0"

something = \trill

{
  a'4\something
}


Quite often, one wants a shorthand for a function that actually needs an 
argument. This is possible using David Kastrup's ingenious \etc:


\version "2.24.0"

col = \once\override NoteHead.color = \etc
our = \tweak color \etc

{
  \col #red a4 b
  \our #blue a\our #green ^"Test"
}

Lukas




Re: how to alias commands?

2022-12-31 Thread Lukas-Fabian Moser

Hi Kenneth,

Am 31.12.22 um 11:26 schrieb Kenneth Flak:

Is there a way to alias a command in lilypond? F.x. I would like to substite 
`\markup \rN` with simply `\rn`. Defining `rn` as a variable doesn't work, so 
what are the ways?


Usually it does actually work:

\version "2.24.0"

something = \trill

{
  a'4\something
}

The problem is that \rN (I assume you refer to David Nalesnik's roman 
numeral library) is a markup function, and these are special. If you 
want to have a shorthand for situations where you use \markup \rN ... in 
music (or lyrics), you can do:


rN = #(define-scheme-function (arg) (markup?) (markup #:rN arg))

For example:

\version "2.24.0"

% Some arbitrary definition of rN as a markup command
#(define-markup-command (rN layout props arg) (markup?)
   (interpret-markup layout props
   #{ \markup { \huge \italic #arg } #}))

rN = #(define-scheme-function (arg) (markup?) (markup #:rN arg))

{
  a'-\rN Text
}

\new Lyrics \lyricmode {
  \rN test
}

I'm not 100% sure if there might be some disaster lurking if you (like 
me) take the exact name of the markup function for the shorthand; if you 
want to be on the safe side, just take a different name (like rn, as you 
proposed).


Lukas




Re: problems with release 2.24 on iMac M1 with Ventura 13.0.1

2022-12-30 Thread Lukas-Fabian Moser

Hi Mario,

Am 30.12.22 um 18:31 schrieb Mario Bolognani:
overriding mensural staff is an optimal solution, but have a look in 
future to baroque music transcriptors, like me…


So can you confirm that you actually want incipits that are not in 
"Renaissance" mensural style (like 
https://lilypond.org/doc/v2.22/Documentation/notation/working-with-ancient-music_002d_002dscenarios-and-solutions.html#incipits) 
but with "modern" clefs, time signatures, rests and note heads?


Note that the example


\version "2.24.0"

\language italiano

\new Staff \with {
  instrumentName = ""
} <<
  \incipit {
    \clef soprano
    \key do\major
    \numericTimeSignature
    \time 3/2
    r2.}
  la4
>>


is _not_ completely "modern" since it uses Mensural rests.

Can you provide a picture (or pdf) of what you aim for resp. what you 
created with old versions of LilyPond? I'd be willing to implement a 
possibility to select "modern" or "mensural" style for incipits, but 
this requires some evidence that it is actually needed.


Lukas


Re: problems with release 2.24 on iMac M1 with Ventura 13.0.1

2022-12-30 Thread Lukas-Fabian Moser

Hi Mario,

Am 30.12.22 um 17:37 schrieb Mario Bolognani:

Hi Lukas,

this is the example where I’m using \numericTimeSignature

 \new Staff <<
                    \set Staff.instrumentName = \markup \center-column{""}
                    \incipit { \clef soprano \key do\major\time 
3/2\numericTimeSignature  r2.^\markup \right-align"[Soprano]"}

                    \clef violin
                    \set Staff.midiInstrument = #"voice oohs"
                    \IIIsoprano
                    \set Staff.shortInstrumentName = "sop"
                    \new Lyrics \lyricsto "sovrana" \IIItesto
                >>


Please always aim for short-yet-compilable examples like:

\version "2.24.0"

\language italiano

\new Staff \with {
  instrumentName = ""
} <<
  \incipit {
    \clef soprano
    \key do\major
    \numericTimeSignature
    \time 3/2
    r2.}
  la4
>>

At any rate: Yes, this is a complicated case. We noted that the change 
to \numericTimeSignature (which I made in order to make it work on the 
score-wide timing) stops it from working in MensuralStaff contexts, and 
incipits internally use a MensuralStaff, as Jean explained.


You can replace \numericTimeSignature by \override 
MensuralStaff.TimeSignature.style = #'numbered, or - if you want to have 
it for your whole score - you can also do:


\layout {
  \context {
    \MensuralStaff
    \numericTimeSignature
  }
}

I think the proper fix would be to make \incipit configurable: It's not 
self-evident to me that incipits should always be created in mensural 
style (but it is of course a sensible default, given the editing 
tradition of Renaissance music.)


Lukas




Re: problems with release 2.24 on iMac M1 with Ventura 13.0.1

2022-12-30 Thread Lukas-Fabian Moser

Hi Mario,
Regarding \numericTimeSignature in \incipit I’m using it with baroque 
music with clefs not currently in use for voice staffs, not in a 
mensural context. This feature was working correctly with the 2.20 
version.


I'm the one responsible for the change in \numericTimeSignature, and as 
far as I can recall, the interaction with incipits was not investigated 
at that time, indeed.


Can you please provide an example ly file?

Lukas


Re: Which timesteps are created?

2022-12-24 Thread Lukas-Fabian Moser

Am 09.11.22 um 22:07 schrieb Jean Abou Samra:

Le 09/11/2022 à 19:22, Lukas-Fabian Moser a écrit :
Anyway: Thanks to both of you (Jean and David); I'm a bit swamped at 
the moment and have to postpone further work on this, but will 
definitely follow the directions you gave me.

I'm not sure what you mean by "working" on this (writing .ly code
for yourself, or writing a patch for LilyPond?), but
Global_context::add_moment_to_process strikes me as a function
for which a Scheme interface could make sense.

I'm not sure if this would require a regtest, but instead of writing
one, you could port, say, Measure_grouping_engraver (which is rather
simple) to Scheme.


For the record: https://gitlab.com/lilypond/lilypond/-/merge_requests/1778

Lukas



Re: extension fingerings, key sigs

2022-12-21 Thread Lukas-Fabian Moser

Hi Matthew,

How do I keep the new key signature from also appearing at the end of 
the previous line?


Also, how can I write { 1 x 2 4 } in the fingering font, adding an "x" 
between the notes to signify the extension between "1" and "2"?


One possibility would be

\version "2.24.0"

\relative {
  \clef bass
  \after 8. \finger "x" a,-1 b-2 cis-4 d-0 e-1 fis gis a\thumb % ;-)
}

but \after only became available during the 2.23.xx series. (But I'd 
recommend to update to 2.24.0 anyway.)


To be honest: I'm not perfectly happy about the need to use 8. in the 
after command; it would be best if LilyPond had support for "fingering 
instructions ranging over more than one one". As far as I know, there's 
only the "gliding finger" functionality; it might be possible to hijack 
that infrastructure.


Lukas


Re: Changing Header Mid-Score

2022-12-11 Thread Lukas-Fabian Moser



Am 11.12.22 um 10:32 schrieb Jacques Menu:

Thumbs up, Jean, this is worth being in the LPNR!


If I'm not mistaken, this marvelous code could easily be generalized to 
provide a command (during music) which sets arbitrary variables that may 
be retrieved in header/footer definitions, and which could be made part 
of core LilyPond.


My list of "stuff to do for LilyPond over the holidays" is already 
overlong, and I'm sure I couldn't do it half as well, but I'm putting it 
on my list anyway - unless Jean himself feels enticed to do it himself?


Lukas




Re: Dotted rests overlaid in voices show two dots, one above the other

2022-11-27 Thread Lukas-Fabian Moser

Hi Mark,

Am 27.11.22 um 04:01 schrieb Mark Mathias:
Using \rest, I can place rests from each of two voices on a staff on 
top of each other without interference, thereby allowing use of the 
material from each voice in separate scores elsewhere without editing. 
Cf:


To explicitly specify a rest’s vertical position, write a note
followed by |\rest|. A rest of the duration of the note will be
placed at the staff position where the note would appear. This
allows for precise manual formatting of polyphonic music, since
the automatic rest collision formatter will not move these rests.


The problem is that if the rests are dotted, the automatic rest 
collision formatter forces the dots to be moved even though the rests 
stay in place:


\version "2.22.2"
\relative c'' {
  <<
  b2.\rest
  \\
  b2.\rest
  >>
  }

Perhaps I'm doing something wrong? Or maybe it's a bug?


You might do

\version "2.22.2"

\relative c'' {
  <<
    b2.\rest
    \\
    \once\omit Dots
    b2.\rest
  >>
}

but there's a probably better way: Namely, we now have the 
Merge_rests_engraver. So you can do:


\version "2.22.2"

\layout {
  \context {
    \Staff
    \consists Merge_rests_engraver
  }
}

{
  <<
    \relative {
    r2. d''8 e
    f4 r r8 e d e
    c4 r
    }
  \\ \relative {
    r2. b'8 c
    d4 r b a8 b
    c4 r
  }
  >>
}

See also 
https://lilypond.org/doc/v2.23/Documentation/notation/multiple-voices.html#merging-rests


Lukas


Re: Bar line at beginning of piece

2022-11-20 Thread Lukas-Fabian Moser

Hi Jean,


Hm.


\version "2.23.81"

{
  \once \set Timing.measureStartNow = ##t
  \once \set Timing.measureBarType = "|-s"
  c'1
  \break
  c'1
}


Thank you very much - this works from 2.23.8 on, I assume because of 
Dan's additions. Great!


I still have to read up on the bar type definition codes which I never 
actually managed to understand. For example, in scm/bar-line.scm, I read:



;; predefined bar lines
;;
;; definition of bar lines goes as follows:
;;
;; (define-bar-line "mid-line bar[-annotation]"
;;  "end-of-line bar[-annotation]"
;;  "beginning-of-line bar[-annotation]"
;;  "span bar")
;;
;; Each argument must be a string or #f.  The string "" calls for a
;; zero-width stencil.  The string "x" or the value #f call for no
;; stencil.  "x" may be annotated, unlike #f.

From this explanation, it find it hard to understand the the "mid-line" 
bar is taken as kind of an "identifier", which becomes clear only after 
reading


(define-public (define-bar-line bar-glyph eol-glyph bol-glyph span-glyph)
  "Define a bar glyph @var{bar-glyph} and its substitutes at the end of
a line (@var{eol-glyph}), at the beginning of a line (@var{bol-glyph})
and as a span bar (@var{span-glyph}).  The substitute glyphs may be
either strings or booleans: @code{#t} calls for the same value as
@var{bar-glyph} and @code{#f} calls for no glyph."

Also, "each argument must be a string or #f" seems strange when reading

(define-bar-line "|" #t #f #t)

So probably the comments on predefined bar lines don't reflect very 
faithfully what's actually happening?


Lukas




Bar line at beginning of piece

2022-11-20 Thread Lukas-Fabian Moser

Hi,

is there an "idiomatic" way of forcing LilyPond to print a bar line "|" 
at the beginning of the piece other than doing the hack of adding


\grace s1 \bar "|"

before the music?

My problem is that I need to do this programmatically with a large 
number of short scores. If any of those starts with a time signature, 
e.g. \time 3/4, then the result will be the usual issue #34 problem of


C | 3/4

Now, obviously I could write a function that extracts an initial time 
signature from a music variable and moves it in front of the \grace s1 
bit, which amounts to more hacking in order to gloss over the problems 
of the initial hack :-).


Hence my question: Is there a mechanism for allowing a barline at the 
beginning of the piece not involving grace notes? (If not, I _think_ 
that the behaviour of not printing any bar lines at the beginning should 
be made an overridable default, so I'd add this to my already over-long 
list of "things I'd like to add to core LilyPond as soon as I have time".)


Lukas




Re: Hide Notes but display Accidental

2022-11-17 Thread Lukas-Fabian Moser

Hi Raj,

probably easiest:

\version "2.22.0"

\language english

\header {
  tagline = ##f
}

\score {
  \new Staff \with { \omit TimeSignature } {
    \set Staff.midiInstrument = "Acoustic Grand Piano"
    \key c \major
    \time 5/1
    \clef bass

    \hideNotes
    \undo \hide Accidental  % <---

    f1 g a bf c' \bar "||"
  }
  \layout {
    \context {
  \Score
  proportionalNotationDuration = #(ly:make-moment 1/2)
    }
  }
  \midi { \tempo 1 = 72}
}

I also took the liberty of making some other changes I would recommend.

Lukas




Re: Multi-measure spacer rests

2022-11-13 Thread Lukas-Fabian Moser

Hi Jean,


Alternatively, you could attach the dynamic to a so-called
"empty chord". The above is equivalent to

\version "2.23.80"

\new Dynamics {
  s1 \p
  s \>
  s \!
  s1*6
  <>\mf
  s1
}


I think we should advocate the "empty chord" style even more 
consistently (and I have a long standing plan of going through the 
documentation and doing this - actually I do not even remember whether I 
already started this, I'm so out of touch with the general improvements 
I wanted to tackle): To me it just seems very non-intuitive to write 
"print a piano, then skip a bar" as "s1 \p2" meaning "before skipping a 
bar, add a piano".


So, for Sámuel: My bet would be

\version "2.23.80"

\new Dynamics {
  <>\p s1
  <>\> s
  <>\! s
  s1*6
  <>\mf s1
}

or even something like

\version "2.23.80"

\new Dynamics {
  <>\p \after 1 \> \after 1*2 \! s1*9
  <>\mf s1
}

Lukas




Re: Adding durations (for \after)

2022-11-11 Thread Lukas-Fabian Moser

Hi Kieren,


It's one of the reasons I first suggested the "anchors" idea over 13 years ago (see 
https://lists.gnu.org/archive/html/lilypond-user/2009-07/msg00498.html); when I picked up the idea 
again (search for "addAt"), that thread eventually revealed the edition-engraver, and may 
have led eventually to David's \after function (?).


The thread on "addAt" was in 2014 
(https://lists.gnu.org/archive/html/lilypond-user/2014-01/msg00660.html).


When I was working on making \after "official", I searched for the 
earlist version (basically I wanted to take stock of the various 
versions that came up over the years to decide which elements to use); 
the first incarnation I could find was from 2012: 
https://lists.gnu.org/archive/html/lilypond-devel/2012-09/msg00342.html


Lukas




Re: Adding durations (for \after)

2022-11-11 Thread Lukas-Fabian Moser

Hi Joel,

Am 11.11.22 um 15:37 schrieb Joel C. Salomon:
But if that can be done from a Scheme function, it’s probably 
sufficient; no need to tamper with Lilypond grammar.


To use Lucas’s example:
[which was wrong, as I forgot the tied notes, sigh - but that doesn't 
matter.]



r8 es2.-8 f2 ges8~
8 as2.-8 8


can

    r8 es \duration_subtract{2.}{8} f2 …

be made to work?  (With whatever syntax.)


This seems to be difficult, as it seems a scheme function returning a 
duration is not accepted in this position:


\version "2.23.5"

test = #
(define-scheme-function () ()
  (ly:make-duration 1 1))

{
  c'\test
}

% this works:
{
  c' $(test)
}

Which is a pity since this makes for a much less convenient syntax: It 
would look something like


c' $(duration_substract #{ 2. #} #{ 8 #})

As far as I know there's no LilyPond syntax equivalent to $(...) for a 
LilyPond scheme function...?


Lukas



Re: Adding durations (for \after)

2022-11-10 Thread Lukas-Fabian Moser



Well, duration-or-music? already exists and it's used by \skip.
Ah, my bad, I didn't think of looking whether it might already exist. 
I'm surprised that such an either-/or type predicate doesn't wreak havoc 
with the parser.
However, this makes for the slight oddity that \skip 4 ... does not 
set the

default duration for the following music, whereas \skip {4} does.


Which reminds me: Making the current parser default duration 
scheme-accessible is a long-standing project of mine. This might 
creating well-behaved music functions a little easier.



[...]

This allows writing

  \after 2.+4. \!

Something like the edition-engraver might benefit from this as well.

Admittedly, I was surprised not to get Bison screaming at me about
parser conflicts.

I don't know if this is actually useful enough and the right concept
to warrant adding. Also, it can hardly be extended to accepting "-"
as well as "+", since { 4-16 } is already valid.


I think this might actually be quite useful - but maybe the (not easily 
implemented) "minus" operation might be even better. I had to think of 
the last piece of Schumann's /Dichterliebe/ op. 48:


Of course, we could just ask Schumann to finally sit down and learn a 
bit about the basic rules of notation :-), but I'd love to be able to do 
something like (with \language deutsch)


r8 es2.-8 f2 ges8~
8 as2.-8 8

etc. Obviously, "2.-8" would need to use a different operator symbol, 
not -, for the reason you gave.


Lukas


Re: Which timesteps are created?

2022-11-09 Thread Lukas-Fabian Moser

Hi,

Am 06.11.22 um 20:49 schrieb David Kastrup:

Lukas-Fabian Moser  writes:


a) We see a timestep at the end of events even in _other_ contexts
than the one the engraver lives in.
b) We see a timestep at every bar boundary.

Only if context property Score.skipBars is ##f .


I'm interested in b): Can I increase the density and, e.g., force a
timestep to be created at each 1/4 moment? (Apart from the obvious
possibilty of adding a Voice consisting of \repeat unfold ... { s4 }.)

You can add some context with its own Time_performer and a different
measure length.


(What is Time_performer? Do you mean Timing_translator?)

Anyway: Thanks to both of you (Jean and David); I'm a bit swamped at the 
moment and have to postpone further work on this, but will definitely 
follow the directions you gave me.


Lukas




Re: Adding durations (for \after)

2022-11-09 Thread Lukas-Fabian Moser

Hi all,

Am 09.11.22 um 16:11 schrieb David Kastrup:


says:


Factors may also be added by using Scheme expressions evaluating to a
number or musical length like `*#(ly:music-length music)`.

Is there an example of such addition handy?

The stripped-down example below works, but `\after 8*9' would be
better written `\after #(  )`.

The best I could glean from the documentation looks something like:

   \after #(ly:moment-add (ly:make-duration 2 1) (ly:make-duration 4 1))

... except that yields a type error because I’m creating durations not
moments.

Maybe something like

\after #(make-duration-of-length (ly:music-length #{ 2. 4. #}))


Or, with a bit of added sugar:

\version "2.23.4"

duration =
#(define-scheme-function (mus) (ly:music?)
   (make-duration-of-length (ly:music-length mus)))

{
  \after \duration { 2 8 } ->
  \repeat unfold 16 { 8 }
}


Arguably it would make sense for \after to just accept example music as
the delay specification.


I thought along the same lines, but seeing as

{
  \after \duration 2 ->
  \repeat unfold 16 { 8 }
}

does not work, I'm not sure that would be easy - and of course we have 
the ambiguity with respect to { 2-> }.


So it doesn't seem like we can just let after expect ly:music? for the 
duration. I'm a bit surprised that


\version "2.23.4"

#(define (duration-or-music? x)
   (or (ly:duration? x) (ly:music? x)))

duration =
#(define-scheme-function (x) (duration-or-music?)
   (if (ly:duration? x)
   x
   (make-duration-of-length (ly:music-length x

{
  \after \duration 2. ->
  \repeat unfold 16 { 8 }
}

actually seems to work, but to me it looks kind of fishy...

Lukas




Which timesteps are created?

2022-11-06 Thread Lukas-Fabian Moser

Folks,

I'm not quite sure how to phrase my question resp. whether it's 
meaningful at all, but here goes: Which mechanisms control the creation 
of time steps?


Consider:

\version "2.23.10"

\new Staff
<<
  \new Voice \with {
    \consists #
    (lambda (ctx)
  (make-engraver
   ((start-translation-timestep engraver)
    (ly:message "Seen timestep: ~a\n" (ly:context-current-moment 
ctx)

  } { s1*5 }
  \new Voice { s4 }
>>

Output:


Seen timestep: #
Seen timestep: #
Seen timestep: #
Seen timestep: #
Seen timestep: #
Seen timestep: #


This shows:

a) We see a timestep at the end of events even in _other_ contexts than 
the one the engraver lives in.

b) We see a timestep at every bar boundary.

I'm interested in b): Can I increase the density and, e.g., force a 
timestep to be created at each 1/4 moment? (Apart from the obvious 
possibilty of adding a Voice consisting of \repeat unfold ... { s4 }.)


Lukas




Re: ChoirStaff with spanning bar lines at breaks

2022-10-18 Thread Lukas-Fabian Moser




\version "2.22.1"

\layout {
  \context {
    \ChoirStaff
    \consists Span_bar_engraver
    \override SpanBar.break-visibility = ##(#t #f #f)
  }
}


... or, if you want to have the illusion of being able to talk to 
LilyPond in English, equivalently:


\layout {
  \context {
    \ChoirStaff
    \consists Span_bar_engraver
    \override SpanBar.break-visibility = #end-of-line-visible
  }
}

:-)

Lukas




Re: Lyric extender in RhythmicStaff

2022-10-08 Thread Lukas-Fabian Moser




Why is there no LyricExtender in the RhythmicStaff? What's missing? (Followup
question: Is this behaviour intended?)

\displayMusic
\new RhythmicStaff \with { \consists Grob_pq_engraver } {
   1 ~ 2 4
}
\addlyrics { hey __ you }
Thanks much - I would never haved guessed that this one is the culprit! 
(Is the \displayMusic an artifact of your research, or do you want to 
point something out?)

If you take a look at the definition of RhythmicStaff in
engraver-init.ly in comparison to the definition of Staff (they are
separate and independent), you'll find that RhythmicStaff is missing a
lot of material that actually would be needed for proper operation.

Sigh.

It would probably make some sense to try deriving it from Staff .


Yes, that's what I sometimes thought as well. I can't try this at the 
moment, but ... another item on the "to do/to try" list.


Thanks again!
Lukas




Lyric extender in RhythmicStaff

2022-10-08 Thread Lukas-Fabian Moser

Folks,

please forgive me for asking something that I'm sure I could find out by 
myself, but I'm in a bit of a hurry:


\version "2.23"

\new RhythmicStaff {
  1 ~ 2 4
}
\addlyrics { hey __ you }

\new Staff {
  1 ~ 2 4
}
\addlyrics { hey __ you }

Why is there no LyricExtender in the RhythmicStaff? What's missing? 
(Followup question: Is this behaviour intended?)


Lukas


Re: Solfege Syllables Easy Notes

2022-10-08 Thread Lukas-Fabian Moser

Hi Craig,

Am 08.10.22 um 14:44 schrieb Craig Bakalian:

Thank you for the solution.  You are a generous person!


You're welcome. Actually, this is something that I've wanted to do for 
quite some time now (and it's a comparatively simple task, once you have 
got accustomed to Scheme, Contexts and Engravers in LilyPond).


All is great with the code, with one exception; dorian is re as the 
resting tone, do does not become the resting tone in d dorian. So, the 
tonic in dorian is re,fa,la.  The tonic in mixolydian is mi,so,ti.  
And, I am not apologizing here, I am a pretty well respected music 
teacher in the US, European and Asian fixed do is ignorant.  Just an 
aside comment, your code is not creating fixed do.


Solfege is for students to learn the syntax of music; tonic - dominant 
- subdominant relationships, with a movable resting tone within each 
key or keyality.  So, you can have an e based dorian coupled into d 
major.   I think Arnold Schoenberg was pretty strong on this issue.


Yes, I know. (But I suspect you meant to say the mixolydian tonic is 
so,ti,re, while mi,so,ti is Phrygian?)


The problem is that there's really a large number of different "solfege" 
methods, some being considered as "natural" in a couple of countries or 
by a certain school of theoreticians, and in fact I have to deal with 
the issue of finding a common ground for students from many different 
backgrounds quite often, being a theory teacher at a major European 
music university with a very international student base. For example, I know


- do as tonic in major, la in minor (and sometimes re in Dorian etc. in 
contexts where these modes are important)

- lowering notes by "ti->ta", "mi->ma", "la->lo"
- lowering notes by "ti->te", "mi->me", "la->le"
- lowering notes by "ti->tu", "mi->mu", "la->lu"
- do as tonic in every mode (so Dorian becomes, for instance, 
do-re-mu-fa-so-la-tu-do)
- minor using do-re-mi-fa-so-la-ti (yes indeed! I have an older German 
aural training textbook that does this)


and so on, and that's not even talking about the completely different 
(fixed do) system used, for instance, in France, Italy, Spain, Russia, 
Romania, China, other movable tonic systems (ja le mi ni ro su wa ja), 
strange beasts like the one developed by Eitz, and so on.


I long ago stopped considering one of these to be the "correct" one. Of 
course it's true that "movable do" systems lead to a quite different way 
of thinking about pitch and tonality than "fixed do" systems do, and 
actually I think I have good reasons to emphasise "movable tonic" 
systems in my teaching - so we agree here.


(And to give another example complicating things further: Jazz musicians 
often seem to be using a movable do system that is not rooted in the 
current tonality, but in the current chord; and in doing so, they set 
"do = root of the current chord". This seems to be helpful for 
improvising in a certain Chord-related mode in chord scale theory. And 
in the cases I have seen, they use "-e" for lowering steps 
chromatically. - If I'm not mistaken, that's the style taught at Berklee 
College, for instance.)


To the point, and it is resolvable by making everything \key "anykey" 
\major, but, how would we change the code to make \dorian re based, 
\lydian fa based?


I think the proper approach to doing this would be to introduce a new 
context property: We already have "tonic", but we should also have a 
"solfeggio-do" giving the pitch of the current do. A possible syntax 
would be:


\key e \dorian
\setDo d

(and we could also modify \key to do the \setDo step automatically).

The problem is that internally, \dorian and \lydian are nothing but a 
bunch of "alterations":


#(display dorian)

returns

((0 . 0) (1 . 0) (2 . -1/2) (3 . 0) (4 . 0) (5 . 0) (6 . -1/2))

which just means "third and seventh steps are lowered with respect to 
the major scale". From this, it's not completely trivial to 
automatically find the "do" in the system you prefer, so probably the 
proper route would be to enrich the information encapsuled in the 
"dorian" variable. This would actually be a change that might be 
incorporated into LilyPond proper.


I'm happy to play around with this if you - as I would understand 
perfectly well - are not convinced of simply writing "\key d \major" 
instead of "\key e \dorian" in order to get the syllables the way you 
want them to be.


Lukas



Re: Solfege Syllables Easy Notes

2022-10-08 Thread Lukas-Fabian Moser

Hi,

Am 08.10.22 um 02:36 schrieb Valentin Petzel:

note that easy notes heads will make use of the note heads note-names property
if set. This allows us to make an arbitrary NoteHead use arbitrary names.

So to achieve what you intend to do you could simply rewrite the key music
function to also override this property on a Staff level (key affects the whole
staff) as you can see in the appended file.

A different option would be to write an engraver that acknowledges NoteHeads,
derives the tonic from the context and sets the note-names property.


... which probably is the "cleaner" solution, as it does not require 
re-defining standard functions.


One can take the example engraver given in 
https://lilypond.org/doc/v2.23/Documentation/notation/note-heads#easy-notation-note-heads 
as a basis:


\version "2.23.6"

#(define solfeggio-list (list "do" "re" "mi" "fa" "so" "la" "ti"))

#(define sharp-vowel #\i)
#(define flat-vowel #\e)

Solfeggio_engraver =
#(lambda (context)
   (make-engraver
    (acknowledgers
 ((note-head-interface engraver grob source-engraver)
  (let* (
     (tonic-pitch (ly:context-property context 'tonic))
     (tonic-name (ly:pitch-notename tonic-pitch))
     (grob-pitch
      (ly:event-property (event-cause grob) 'pitch))
     (delta (ly:pitch-diff grob-pitch tonic-pitch))
     (syllable
      ; use string-copy because of later in-place modification
      (string-copy
       (list-ref solfeggio-list (ly:pitch-notename delta)
    (case (ly:pitch-alteration delta)
  ((0) (noop))
  ((1/2) (string-set! syllable 1 sharp-vowel))
  ((-1/2) (string-set! syllable 1 flat-vowel))
  (else (string-set! syllable 1 #\?)))
    (ly:grob-set-property! grob 'note-names (make-vector 7 syllable)))

#(set-global-staff-size 26)

\layout {
  ragged-right = ##t
  \context {
    \Voice
    \consists \Solfeggio_engraver
  }
}

\relative c' {
  \easyHeadsOn
  c4 d e f
  g4 a b c
  c b bes a
  fis g as g
  \break

  \key a \major
  a,4 b cis d
  e4 fis gis a \break

  \key d \dorian
  d,4 e f g
  a4 b c d
}

This uses "do" for the tonic (and -i for raised and -e for flat notes), 
regardless of the mode (major/minor etc.)


For la-based minor, one would need to take a different approach: 
Currently LilyPond (to my knowledge) only saves the tonic in the context 
(and a list of alterations). I have been thinking for a while that \key 
should store more explicit information in the context.


Lukas




Re: Need help with two tweaks

2022-10-01 Thread Lukas-Fabian Moser

Hi Sam,


*Tweak 2*

current result:

tweak-2-ties.jpg

soprano line:  | bf2 af4 |
alto line:  | f( ef) c |
tenor line:  ||
bass line: | g2 d4 |

problem: I want to add a slur between the two 1st tenor notes and 
another one between the two second tenor notes.


Please always give a compilable example; it's much easier to help that way.

So I give just a pointer: You could do \set doubleSlurs = ##t - but I 
wonder if you wouldn't rather use one slur (tenor I) and one tie (tenor II)?


Lukas


Re: pitch-class sets in lilypond

2022-09-20 Thread Lukas-Fabian Moser

Hi Stefan,

Am 20.09.22 um 13:00 schrieb Stefan Thomas:

Dear community,
sorry, it's a bit an off topic: If You are not interested in 
pitch-class set theory, You don't have to read the following.
I've worked on a python module dealing with pitch-class set theory as 
I've read in "The structure of atonal music" by Allen Forte.
I know that there already exists some modules like that but I want to 
integrate it in lilypond.

I'm still working on this module, but at the  moment I can do:

  * Getting the normal form and prime form of a pcs.
  * Transposing and inverting a pcs
  * Finding subsets of a pcs given in primeform.

I'm working on:

  * Finding different kinds of similarity of pcs.
  * Getting subcomplexes k and kh of a pcs.
  * Finding primeform and so on, when pitches in lilypond-style are given.
  * Getting pitches in lilypond-style when pitches in midinote-nums or
as pcs are given.

Let me know it if You are interested. Maybee it's only something of 
interest for nerdy persons like me, but maybee for others too.


I don't know if this is of use to you, but I created a bunch of LilyPond 
routines for dealing with PC sets (like in Forte, but also with a finer 
equivalence relation not identifying a set with its inverse) last year. 
I attach it unchanged, as I don't have time to clean it up at the 
moment; you'll probably want to uncomment some of the routines at the 
end to see what the functions do.


I'm curious: You write that you are working on a Python module; how does 
this integrate in LilyPond?


Lukas
\version "2.22.0"

\include "dodeka.ily"

% -- Forte number dictionaries --

forte-distinct-inverses = % Taken from https://en.wikipedia.org/wiki/List_of_pitch-class_sets
#'((0-1 . ())
   (1-1 . (0))
   (2-1 . (0 1))
   (2-2 . (0 2))
   (2-3 . (0 3))
   (2-4 . (0 4))
   (2-5 . (0 5))
   (2-6 . (0 6))
   (3-1 . (0 1 2))
   (3-2A . (0 1 3))
   (3-2B . (0 2 3))
   (3-3A . (0 1 4))
   (3-3B . (0 3 4))
   (3-4A . (0 1 5))
   (3-4B . (0 4 5))
   (3-5A . (0 1 6))
   (3-5B . (0 5 6))
   (3-6 . (0 2 4))
   (3-7A . (0 2 5))
   (3-7B . (0 3 5))
   (3-8A . (0 2 6))
   (3-8B . (0 4 6))
   (3-9 . (0 2 7))
   (3-10 . (0 3 6))
   (3-11A . (0 3 7))
   (3-11B . (0 4 7))
   (3-12 . (0 4 8))
   (4-1 . (0 1 2 3))
   (4-2A . (0 1 2 4))
   (4-2B . (0 2 3 4))
   (4-3 . (0 1 3 4))
   (4-4A . (0 1 2 5))
   (4-4B . (0 3 4 5))
   (4-5A . (0 1 2 6))
   (4-5B . (0 4 5 6))
   (4-6 . (0 1 2 7))
   (4-7 . (0 1 4 5))
   (4-8 . (0 1 5 6))
   (4-9 . (0 1 6 7))
   (4-10 . (0 2 3 5))
   (4-11A . (0 1 3 5))
   (4-11B . (0 2 4 5))
   (4-12A . (0 2 3 6))
   (4-12B . (0 3 4 6))
   (4-13A . (0 1 3 6))
   (4-13B . (0 3 5 6))
   (4-14A . (0 2 3 7))
   (4-14B . (0 4 5 7))
   (4-z15A . (0 1 4 6))
   (4-z15B . (0 2 5 6))
   (4-16A . (0 1 5 7))
   (4-16B . (0 2 6 7))
   (4-17 . (0 3 4 7))
   (4-18A . (0 1 4 7))
   (4-18B . (0 3 6 7))
   (4-19A . (0 1 4 8))
   (4-19B . (0 3 4 8))
   (4-20 . (0 1 5 8))
   (4-21 . (0 2 4 6))
   (4-22A . (0 2 4 7))
   (4-22B . (0 3 5 7))
   (4-23 . (0 2 5 7))
   (4-24 . (0 2 4 8))
   (4-25 . (0 2 6 8))
   (4-26 . (0 3 5 8))
   (4-27A . (0 2 5 8))
   (4-27B . (0 3 6 8))
   (4-28 . (0 3 6 9))
   (4-z29A . (0 1 3 7))
   (4-z29B . (0 4 6 7))
   (5-1 . (0 1 2 3 4))
   (5-2A . (0 1 2 3 5))
   (5-2B . (0 2 3 4 5))
   (5-3A . (0 1 2 4 5))
   (5-3B . (0 1 3 4 5))
   (5-4A . (0 1 2 3 6))
   (5-4B . (0 3 4 5 6))
   (5-5A . (0 1 2 3 7))
   (5-5B . (0 4 5 6 7))
   (5-6A . (0 1 2 5 6))
   (5-6B . (0 1 4 5 6))
   (5-7A . (0 1 2 6 7))
   (5-7B . (0 1 5 6 7))
   (5-8 . (0 2 3 4 6))
   (5-9A . (0 1 2 4 6))
   (5-9B . (0 2 4 5 6))
   (5-10A . (0 1 3 4 6))
   (5-10B . (0 2 3 5 6))
   (5-11A . (0 2 3 4 7))
   (5-11B . (0 3 4 5 7))
   (5-z12 . (0 1 3 5 6))
   (5-13A . (0 1 2 4 8))
   (5-13B . (0 2 3 4 8))
   (5-14A . (0 1 2 5 7))
   (5-14B . (0 2 5 6 7))
   (5-15 . (0 1 2 6 8))
   (5-16A . (0 1 3 4 7))
   (5-16B . (0 3 4 6 7))
   (5-z17 . (0 1 3 4 8))
   (5-z18A . (0 1 4 5 7))
   (5-z18B . (0 2 3 6 7))
   (5-19A . (0 1 3 6 7))
   (5-19B . (0 1 4 6 7))
   (5-20A . (0 1 5 6 8))
   (5-20B . (0 2 3 7 8))
   (5-21A . (0 1 4 5 8))
   (5-21B . (0 3 4 7 8))
   (5-22 . (0 1 4 7 8))
   (5-23A . (0 2 3 5 7))
   (5-23B . (0 2 4 5 7))
   (5-24A . (0 1 3 5 7))
   (5-24B . (0 2 4 6 7))
   (5-25A . (0 2 3 5 8))
   (5-25B . (0 3 5 6 8))
   (5-26A . (0 2 4 5 8))
   (5-26B . (0 3 4 6 8))
   (5-27A . (0 1 3 5 8))
   (5-27B . (0 3 5 7 8))
   (5-28A . (0 2 3 6 8))
   (5-28B . (0 2 5 6 8))
   (5-29A . (0 1 3 6 8))
   (5-29B . (0 2 5 7 8))
   (5-30A . (0 1 4 6 8))
   (5-30B . (0 2 4 7 8))
   (5-31A . (0 1 3 6 9))
   (5-31B . (0 2 3 6 9))
   (5-32A . (0 1 4 6 9))
   (5-32B . (0 3 5 8 9))
   (5-33 . (0 2 4 6 8))
   (5-34 . (0 2 4 6 9))
   (5-35 . (0 2 4 7 9))
   (5-z36A . (0 1 2 4 7))
   (5-z36B . (0 3 5 6 7))
   (5-z37 . (0 3 4 5 8))
   (5-z38A . (0 1 2 5 8))
   (5-z38B . (0 3 6 7 8))
   (6-1 . (0 1 2 3 4 5))
   (6-2A . (0 1 2 3 4 6))
   (6-2B . (0 2 3 4 5 6))
   (6-z3A . (0 1 2 3 5 6))
   (6-z3B . (0 1 

Re: function to recognise voice crossings?

2022-09-17 Thread Lukas-Fabian Moser

Hi Eef,

Am 17.09.22 um 10:52 schrieb Eef Weenink:
PS; I you might change the engraver, consider to NOT colour equal 
notes. (or make it an option). Equal notes do not harm the harmonic 
line. (for seeing where the lowest notes are, it might be set to #t). 


Yes, I suspected that this might not be fitting for your need.

In my case, I wanted to mark the notes in a canon where the current line 
takes over the bass function: This is an interesting question in the 
construction of a canon, where the composer might add the bass notes 
"all at the same time" (usually at the end, creating additional 
voice-leading constraints for the voices entering before that) like in 
Mozart's /Bona Nox/:


or the bass might be constituted in different parts of the pieces by 
different bits in the melody like in Mozart's /Gehn wir im Prater, gehn 
wir in'd Hetz/:


Anyway: See attached. The engraver (now called in LilyPond syntax with 
\) now takes a mandatory argument indicating if only strict lowest notes 
should be coloured (#t) or not (#f). (I think the meaning of #t and #f 
is switched with respect to what you proposed.)


Lukas
\version "2.23"

%  Bass_highlighter_engraver =

#(set-object-property! 'bass-notehead-callback 'backend-type? procedure?)
#(set-object-property! 'bass-notehead-callback 'backend-doc "Function to be called on grob if it is a bass notehead")

#(define (is-lowest? el lst less? strict)
   (every
(lambda (x)
  (or ((if strict eq? equal?) el x)
  (less? el x))) lst))

Bass_highlighter_engraver =
#(define-scheme-function (strict) (boolean?)
   (lambda (context)
   (define (is-over? note moment)
 (not (ly:moment q q q
  }
>>

Re: function to recognise voice crossings?

2022-09-17 Thread Lukas-Fabian Moser
Ah, thanks, I hadn't considered the possibility of using solo tuning. 
Sorry for the noise.
(I don't think my engraver currently supports setting \transposition to 
accommodate for solo tuning, though.)


Lukas

Eef Weenink  schrieb am Fr., 16. Sept. 2022, 22:05:

   PS: The double bass is in solo tuning (major second above normal) so
   the score for the double bass is written a major second down) so you
   hear the correct pitches.
   Purcell (original) is in D minor (1 flat) and the double bass score
   has 3 flats (C minor)

   PS2, in fact to do the real check, I have to also transpose the
   double score 1 octave down, because the double bass is written 1
   octave higher then sounding.

   regards, Eef



Op 16 sep. 2022, om 21:47 heeft Lukas-Fabian Moser 
het volgende geschreven:

Hi Eef,

Am 16.09.22 um 21:22 schrieb Eef Weenink:

Great, it does exactly what I need, see image. (red noteheads are
the lowest in score)!
So on this spot I have to lower the bassline in the left hand of
piano.



I'm glad it helps!

But there's something strange, as the f-e cadenza in the melody
doesn't really fit the f major cadenza in the piano.

I looked up Purcell's original (thanks for including the text,
otherwise I wouldn't have recognized it): The final note of the
melody line should coincide (up to octave) with the final note of
the piano left hand. So it seems something's wrong in your score
(unless you have some quite unusual clefs, but then again, the red
markings seem to indicate that melody and piano left hand are both
written in bass clef).

Could you maybe post your full score so I could take a look?

Lukas



Re: function to recognise voice crossings?

2022-09-16 Thread Lukas-Fabian Moser

Hi Eef,

Am 16.09.22 um 21:22 schrieb Eef Weenink:
Great, it does exactly what I need, see image. (red noteheads are the 
lowest in score)!

So on this spot I have to lower the bassline in the left hand of piano.


I'm glad it helps!

But there's something strange, as the f-e cadenza in the melody doesn't 
really fit the f major cadenza in the piano.


I looked up Purcell's original (thanks for including the text, otherwise 
I wouldn't have recognized it): The final note of the melody line should 
coincide (up to octave) with the final note of the piano left hand. So 
it seems something's wrong in your score (unless you have some quite 
unusual clefs, but then again, the red markings seem to indicate that 
melody and piano left hand are both written in bass clef).


Could you maybe post your full score so I could take a look?

Lukas


Re: function to recognise voice crossings?

2022-09-16 Thread Lukas-Fabian Moser

Hi Eef,

Am 16.09.22 um 13:53 schrieb Eef Weenink:

I write mostly arrangements where I bring a melody voice down to the double 
bass (my instrument :-))

Double bass is written an octave higher then sounding, so a lot of times, the 
score lookes OK, but in fact there are voice crossings between lefthand of 
piano and the double bass (what gives unwanted/unpleasant voice crossings.

To check this, I transpose the double bass voice down an octave and manually 
check the boths voices.

Wonder if there is a function in lilypond to do this fastly. Like the coloured 
noteheads when checking a voice against the ambitus of an instrument.


This reminds me of a function I wrote last year to automatically 
colourise the lowest sounding pitch in a score. (In my case, this was 
for harmonic analysis of canons.) See attached.


Maybe this could be used or at least adapted?

Lukas\version "2.23"

%  Bass_highlighter_engraver =

#(set-object-property! 'bass-notehead-callback 'backend-type? procedure?)
#(set-object-property! 'bass-notehead-callback 'backend-doc "Function to be called on grob if it is a bass notehead")

#(define (is-lower-bound? el lst less?)
   ; returns #t if no element of lst is less? than el.
   (if (pair? lst)
   (if (less? (car lst) el)
   #f
   (is-lower-bound? el (cdr lst) less?))
   #t))

Bass_highlighter_engraver =
#(lambda (context)
   (define (is-over? note moment)
 (not (ly:moment q q q
  }
>>

Re: Context question

2022-09-11 Thread Lukas-Fabian Moser

Hi Johan,

Am 11.09.22 um 23:01 schrieb John Schlomann:


Can someone please explain why the following won’t work. I want get 
the current moment at the end of the music expression. Is this not a 
valid thing to do? Or perhaps I don’t know how to specify the context. 
This code gives an unbound variable error.


\version "2.22.2"

\score {

  \relative c'' {

    \new Staff {

  a b c d

  #(display (ly:context-current-moment Staff))

    }

  }

}



Try:

\version "2.22.2"

\score {
  \relative c'' {
    \new Staff {
  a b c d
  \applyContext #(lambda (ctx)
   (display (ly:context-current-moment ctx)))
    }
  }
}

There are better people than I on this list to explain _why_ it has to 
be done this way - I'm sure I'd get the explanation not 100% correct. 
Basically, if my mental image is somewhat correct, it has to do with the 
fact that at the point of time where LilyPond interprets your music, 
there is no context (yet) and no current moment. So we have to provide a 
_function_ that is evaluated later, depending on the (then current) 
context. That context will usually be a Voice context, as can be seen by 
adding a


(display (ly:context-name ctx))

command in your function. If you want to force your lambda function to 
be evaluated in another context (e.g. Staff), you can write \context 
Staff \applyContext ... - but this is rarely needed, since (again: in my 
understanding) contexts form a hierarchy, and you can access 
higher-level context properties also from your Voice context.


And now I'll get ready for a bunch of corrections from Jean, David K., 
Valentin and others :-).


Lukas


Re: Conditional fermata padding

2022-09-08 Thread Lukas-Fabian Moser

Hi Martín,

Am 08.09.22 um 10:52 schrieb Martín Rincón Botero:
I would like to have less padding for a fermata when a note has an 
accidental. Say, if the fermata has a padding of x, I would like it be 
x-0.1 or so when the note in question has an accidental. I would be 
thankful for a snippet :-).


Scripts (like a fermata) can be added to a chord (instead of a single 
note head); which note's accidentals should then be considered?


Anyway, the following snippet changes the padding of a fermata if _any_ 
of the note heads in the fermata's note column has an accidental:


\version "2.23.10"

mus = \relative {
  f''4 fis fis 
   
}

{
  \override Script.before-line-breaking =
  #(lambda (script-grob)
 (let*
  ((script-cause (ly:grob-property script-grob 'cause))
   (articulation-type (ly:event-property script-cause 
'articulation-type))

   (default-padding (ly:grob-property script-grob 'padding))
   (note-column (ly:grob-parent script-grob X))
   (note-heads (ly:grob-array->list
    (ly:grob-object note-column 'note-heads)))
   (accidentals
    (map
 (lambda (note-head) (ly:grob-object note-head 'accidental-grob))
 note-heads)))
  (if (and (eq? articulation-type 'fermata)
   (any ly:grob? accidentals))
  (ly:grob-set-property! script-grob 'padding
 (+ default-padding 2)

  \time 2/4
  << \mus \repeat unfold 6 s4\fermata >>
  % tenuto (and staccato, ...) should not be changed
  << \mus \repeat unfold 6 s4\tenuto >>

}

Note that this needs a fairly recent LilyPond version, since we changed 
the 'articulation-type from a string to a symbol at the end of 2021.


Lukas


Re: Displaying bar numbers for repeats

2022-08-28 Thread Lukas-Fabian Moser

Hi Joe,

Am 28.08.22 um 01:11 schrieb Joseph Srednicki:
I looked at the Lilypond documentation and snippet library but did not 
find an answer to the question that I am asking in this message.


I am typesetting my personal performer's edition of Bach's Schmüke 
Dich (BWV 654). The first 34 measures are repeated with an alternate 
ending. (I am using a two-volta repeat.)


For only the repeated first section, is there a mechanism for 
displaying the bar number for volta 1 followed by the bar number for 
volta 2 in parentheses?


For example, measure 7 of the volta 1 is measure 41 of volta 2.

In this situation, I would like the bar number to appear as: 7 (41)

I am attaching a PNG image showing what I would like to do.

I am currently displaying bar numbers at the beginning of ever line 
except the first.


If this topic is covered in the snippets or Lilypond mail archive and 
I missed it, please refer me to the appropriate section.


Thanks for any help that anyone is willing to provide.


This is not very elegant (as it is almost no automatic involved), but it 
does what I think you want to achieve:


\version "2.22"

barNumberWithOffset =
#(define-scheme-function (offset) (integer?)
   (lambda (barnum measure-pos alt-number context)
 (let ((default
    (robust-bar-number-function barnum measure-pos alt-number 
context)))

   (if (zero? offset)
   default
   (format #f "~a (~a)" default (+ barnum offset))

increaseBarNumber =
#(define-music-function (offset) (integer?)
   #{
 \context Timing {
   \applyContext
   #(lambda (ctx)
  (ly:context-set-property!
   ctx
   'currentBarNumber
   (+ (ly:context-property ctx 'currentBarNumber) offset)))
 }
   #})

\relative {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible % 
for diagnostics

  \override Score.BarNumber.self-alignment-X = #LEFT % for positioning
  \set Score.barNumberFormatter = \barNumberWithOffset 20
  \repeat volta 2 {
    \repeat unfold 20 {
  c'4 d e d
    }
  }
  \increaseBarNumber 20
  \set Score.barNumberFormatter = \barNumberWithOffset 0
  \repeat unfold 20 {
    c'4 d e d
  }
}

Lukas


Re: Coloring just one note in a chord

2022-08-20 Thread Lukas-Fabian Moser

Hi Felix,

Am 20.08.22 um 19:24 schrieb DoubleFelix:

I have a basic staff defined like so:

\version "2.22.2"
\language "english"
\new Staff {
\key c \major
\clef treble
\numericTimeSignature
<
f'
g'
d'
>1
\bar "|."
}

I want to make the g' note head colored in green, but if I try this, I 
get syntax errors about an unexpected \override:

\override NoteHead.color = SeaGreen
\override Stem.color = SeaGreen
g'
\revert NoteHead.color
\revert Stem.color


Single notes in a chord can be influenced using \tweak's instead of 
\override's. Tweaks can be made out of overrides using \single, but they 
also lend themselves to creating very convenient shorthands:


\version "2.22.2"

gr =
\tweak color SeaGreen
\tweak Stem.color SeaGreen
\etc

\new Staff {
  1
  \gr 2
}

Lukas




Re: completely filling a page, but not too compact, how?

2022-08-19 Thread Lukas-Fabian Moser

Hi Ken,


So I disabled all the forced line breaks.

Now it consumes less than 3/4 of one page and is a little too dense to
read on an iPad.

I'd like to fill the first and only page.

How to do this?


For filling the page, you can do

\paper {
  ragged-last-bottom = ##f
}

In your case, this spreads the systems too far apart on the page, so I 
increased the total amount of systems via


\layout {
  system-count = 7
}

where 7 was found by trial and error. This way, the bars are made wider, 
but I think they still look acceptable.


I took the liberty of making some other small adjustments; feel free to 
ignore them if you do not like them (especially since I realise that my 
changes are very much influenced by middle-European classical music 
notation conventions):


- added \accidentalStyle modern for warning accidentals
- changed the left hand rest in the beginning of the piece (r2. do not 
usually start at crotchet-valued position in a bar)
- bar 4/35a: in "classical" enharmonic spelling, this is usually written 
as f-sharp, not as g-flat (that's an instance where the usual rule of 
thumb "use flats when moving downwards" oversimplifies things)
- markup-system-spacing.padding = 3 to add some space between the title 
and the first system

- added final bar line
- paranoid warning accidentals ('!') in mm. 10 and 29

What I didn't change: Classical convention would probably give the final 
bar a length of only 4 (with fermata), not 1. But I wouldn't put too 
much stock in this, I know that a crotchet final chord would probably 
look strange, and there are plenty of counterexamples to that convention.


Lukas
\version "2.22.2"

% Danny Boy (Londonderry Air)

global = {
  \language "english"
  \numericTimeSignature
  \time 4/4
  \key c \major
  \tempo "Smoothly, with expression"
  \partial 2.
}

\header {
  title = "Danny Boy"
  subtitle = "(Londonderry Air)"
}

\paper {
  ragged-last-bottom = ##f
  markup-system-spacing.padding = 3
}

\layout {
  system-count = 7
  \accidentalStyle modern
}

rh = {
  \global
  \clef treble
  b'4^2 c''^1 d''  | % m01
  e''4 a'' g'' e'' | % m02
  d''4^1 c''^3 a' c''  | % m03
  g'2  | % m04
%\break
  4\fermata b^2 c'^1 d'  | % m05
  \repeat volta 2 {
e'2. d'4| % m06
%\break
e'4 a' g' e'| % m07
%\break
d'4^1(c')^2 a2^1 ~  | % m08
a4 c' e' f' | % m09
g'2. a'4| % m10
%\break
g'4 e' c' e'^3   | % m11
%\break
d'1 ~| % m12
d'4 b^2 c'^1 d'  | % m13
%\break
e'2. d'4| % m14
%\break
e'4 a' g' e'| % m15
d'4^1(c'^2) a2^1 ~  | % m16
%\break
a4 b^2 c'^1 d'  | % m17
2. f'4   | % m18
e'4 d' c' d'| % m19
%\break
c'1 ~   | % m20
c'4 g'^2 a' b'  | % m21
2. b'4  | % m22
b'4 a' g' a'| % m23
%\break
g'4(e') c'2 ~   | % m24
c'4 g'^2 a' b'  | % m25
2. b'4  | % m26
%\break
b'4 a' g' e'| % m27
d'1 ~   | % m28
d'4 g'^2  q  | % m29
%\break
2. d''4   | % m30
4 c'' a' c''  | % m31
g'4(e') c'2   | % m32
%\break
r4 b^2 c'^1 d'  | % m33
e'4 a' g' e'^2  | % m34
d'4^1 c'^2 a b  | % m35
  }
%\break
  \alternative {
{
  c'2 | % m36
  4\fermata b^2 c' d'  | % m37
}
{
  c'1 | % m38
  1\fermata  | % m39
  \bar "|."
}
  }
}

piano_dynamics = {
  \global
  s8\mp s2 s8  | % m01
  s1   | % m02
  s1   | % m03
  s1   | % m04
%\break
  s1| % m05
  \repeat volta 2 {
s1  | % m06
%\break
s1  | % m07
%\break
s1  | % m08
s1  | % m09
s1  | % m10
%\break
s1  | % m11
%\break
s1  | % m12
s1  | % m13
%\break
s1  | % m14
%\break
s1  | % m15
s1  | % m16
%\break
s1  | % m17
s1  | % m18
s1  | % m19
%\break
s1  | % m20
s1  | % m21
s1  | % m22
s1  | % m23
%\break
s1  | % m24
s1  | % m25
s1  | % m26
%\break
s1  | % m27
s1  | % m28
s1  | % m29
%\break
c4 g c'2  | % m30
f2 c' | % m31
e2 a  | % m32
%\break
s1  | % m33
s1  | % m34
s1  | % m35
  }
%\break
  \alternative {
{
  s1  | % m36
  s1  | % m37
}
{
  s1  | % m38
  s1  | % m39
}
  }
}

lh = {
  \global
  \clef bass
  r4 r2| % m01
  c'2_1 bf | % m02
  2   | % m03
  2 fs   | % m04
%\break
  f4\fermata r r2  | % m05
  \repeat volta 2 {
c4_5 g c'2 | % m06
%\break
b2 bf  | % m07
%\break
a2 f4 e   | % m08
d2   | % m09
c2 b! | % m10
%\break
a2_1 fs_2| % m11
%\break
f4_3 d c' a  | % m12
g1   | % m13
%\break
c4 g b2  | % m14
%\break
bf1  | % m15
a2 f4 e  | % m16
%\break
d2   | % m17
g2 g,  | % m18
1 | % m19
%\break
g2 e| % m20
c2 | % m21
c4 g c'2| % m22
2   | % m23
%\break
2 b  | % m24
a2| % 

Re: ragged-right and \rhythm

2022-08-18 Thread Lukas-Fabian Moser



I can try this. Is it necessary to first create an issue (I assume for 
keeping track of the "motivation" for the MR)?


But if I am to take the route of messing with get_paper_systems etc. 
I'm probably going to need some help or at least bother everybody with 
questions.


... and here we go with the questions: Do we not have this already, by 
way of issuing \layout { system-count = 1 } inside \markup \score ?


Lukas



  1   2   3   4   5   6   7   >