\vshape and custom curve-stencil for TextSpanner

2022-07-23 Thread Thomas Morley
Hi,

I'm attempting to create a s-curve stencil for TextSpanner.
While so far all works as wished and it is possibel to use \shape,
\vshape doesn't print the control-points.

What am I missing?

Code below.
Thanks to Jean how fixed make-path-stencil!

Thanks,
  Harm

\version "2.23.11"

#(define (make-s-curve-stencil line-thickness thickness control-points)
  (let* ((start-pt (car control-points))
 (end-pt (last control-points))
 (lngth (- (car end-pt) (car start-pt)))
 (second-cp (second control-points))
 (third-cp (third control-points))
 (second-delta
   (* (- (car second-cp) (car start-pt)) (/ thickness (/ lngth 2
 (second-out
   (cons (car second-cp)
 (+ (cdr second-cp) second-delta)))
 (second-in
   (cons (car second-cp)
 (- (cdr second-cp) second-delta)))
 (third-delta
   (* (- (car end-pt) (car third-cp)) (/ thickness (/ lngth 2
 (third-out
   (cons (car third-cp)
 (+ (cdr third-cp) third-delta)))
 (third-in
   (cons (car third-cp)
 (- (cdr third-cp) third-delta)))
 (coord-list
   (list
 start-pt
 second-out
 third-out
 end-pt
 third-in
 second-in)))
((@@ (lily) make-bezier-sandwich-stencil) coord-list line-thickness)))

#(define horizontal-spanner-cps
  (lambda (grob)
(let* ((left-info (ly:grob-property grob 'left-bound-info))
   (right-info (ly:grob-property grob 'right-bound-info))
   (left-x (assoc-get 'X left-info))
   (right-x (assoc-get 'X right-info))
   (lngth (- right-x left-x))
   (height 2)
   (cp-2 (cons (* lngth 0.25) height))
   (cp-3 (cons (* lngth 0.75) (- height
  (list
'(0 . 0)
cp-2
cp-3
(cons (- right-x left-x) 0)

#(define text-spanner::s-curve-stencil
  (lambda (grob)
(let* ((layout (ly:grob-layout grob))
   (line-thick (ly:output-def-lookup layout 'line-thickness))
   (thickness (ly:grob-property grob 'thickness 1.2))
   (thick (* line-thick thickness)))
;(box-stencil
 (make-s-curve-stencil line-thick thick
   (ly:grob-property grob 'control-points))
; 0 0)
)))

{
  \override TextSpanner.control-points = #horizontal-spanner-cps
  \override TextSpanner.show-control-points = ##t
  \override TextSpanner.stencil = #text-spanner::s-curve-stencil

  \vshape #'((0 . 0)(0 . 10)(0 . -10)(0 . 0)) TextSpanner
  b1\startTextSpan
  b\stopTextSpan
}



Re: Ties between voices

2022-07-23 Thread Lukas-Fabian Moser

Hi Andrew,

Am 23.07.22 um 03:49 schrieb Andrew Bernard:
I know that we can't natively make ties between notes in different 
voices. I know that there was a Google Summer of Code task that could 
not be completed.


A few weeks ago, I sent you the following privately (I was too timid to 
post in on the list):


My idea was to \consist the Tie_engraver to the Staff context not 
_instead_ of to the Voice context, but _in addition_. Then we have two 
Tie engravers and need a mechanism by which to tell if a given tie 
should be collected by the Voice-level Tie_engraver or at Staff level 
(in order to connect ties between different voices).


During my experiments I re-implemented the Tie_engraver in Scheme; 
although it turned out that (contrary to my expectations) the necessary 
adjustments could just as easily have been made in C++, the advantage is 
that we can test this approach without the need to re-compile a custom 
LilyPond build.


The attached file (requiring 2.23.6 and above) generates

as easily as:

\new Staff \with { \consists #New_tie_engraver }
{
  <<
    \relative {
  4 c8 b a g~ 4
    }
    \\
    \relative {
  s4 c'2 e4
    }
  >>
}

Of course the same mechanism might be implemented for, e.g., the 
Slur_engraver. But this requires additional work, as the slur 
positioning mechanism is not quite up to positioning Staff-level slurs 
correctly.


The attached Scheme Tie_engraver may be used as a drop-in replacement 
for the standard C++ Tie_engraver; in my local branch, it compiles the 
full regression test suite without causing differences.)


Lukas
\version "2.23.6"

% TODO: Rename variables for clarity
% TODO: Turn re-implementations of C++ helper functions into exported callbacks

% Not in guile core for 1.8 (remove for Guile2)
#(define (hash-count pred table)
   (count identity (hash-map->list pred table)))

#
(define (hash-non-empty? hash-table)
  ;; For Guile2, simplfy to
  ;; (positive? (hash-count (const #t) hash-table)))
  (pair? (hash-map->list (lambda (key handle) '()) hash-table)))

#
(define (tie-column::add_tie tie-column tie)
;;; TODO: Make callback from C++
  (if (not (grob::has-interface (ly:grob-parent tie Y) 'tie-column-interface))
  (begin
   (if
(or (null? (ly:spanner-bound tie-column LEFT))
(> (car (ly:grob-spanned-column-rank-interval tie-column))
   ; THINK: is this exactly equivalent to the C++ original?
   (car (ly:grob-spanned-column-rank-interval tie-column
(begin
 (ly:spanner-set-bound! tie-column LEFT (ly:spanner-bound tie LEFT))
 (ly:spanner-set-bound! tie-column RIGHT (ly:spanner-bound tie RIGHT

   (ly:grob-set-parent! tie Y tie-column)
   (ly:pointer-group-interface::add-grob tie-column 'ties tie

%{
head-event-alist has the fields:
   '((end-moment . #f)
 (tie-stream-event . #f)
 (tie-articulation-event . #f)
 (tie-from-chord-created . #f)
 (tie . #f)
   )
%}

#
(define (ly:enharmonic-equivalent? p1 p2)
  (= (ly:pitch-tones p1) (ly:pitch-tones p2)))

#
(define (ly:tie::head tie dir)
  (let ((it (ly:spanner-bound tie dir)))
(if (grob::has-interface it 'note-head-interface)
it #f)))

#
(define-public (New_tie_engraver context)
  (define (report-unterminated-tie notehead alist)
;; give notehead argument in order to simplify use of
;; report-unterminated-tie as a proc in hash-for-each
(if (not (assq-ref alist 'tie-from-chord-created))
(begin
 (ly:warning (G_ "unterminated tie")) ; TODO: Warn with source position
 (ly:grob-suicide! (assq-ref alist 'tie)
  (let
   ((event-processed #f)
(tie-stream-event #f)   ; corresponds to event_ in C++
(tie-column #f)
(now-heads '())
(heads-to-tie (make-hash-table))
(ties '())
(target (ly:context-name context)))

   (define (typeset-tie her)
 ;; this seems not to change anything for "her" if both bounds
 ;; are note heads ???
 (let ((left-head (ly:tie::head her LEFT))
   (right-head (ly:tie::head her RIGHT)))

   (if (not (and left-head right-head))
   (begin
(ly:warning "lonely tie")
(if (not left-head)
(set! left-head right-head)
(set! right-head left-head
   (ly:spanner-set-bound! her LEFT left-head)
   (ly:spanner-set-bound! her RIGHT right-head)))

   (define (tie-notehead engraver head enharmonic?)
 (let ((found #f))
   (hash-for-each
(lambda (registered-head alist)
  (let*
   ((right-ev (event-cause head))
(left-head registered-head)
(left-ev (event-cause left-head)))
   (if (and (not found) left-ev right-ev)
   (let ((p1 (ly:event-property left-ev 'pitch))
 (p2 (ly:event-property right-ev 'pitch)))
 (if (and
  ((if enharmonic? ly:enharmonic-equivalent? equal?) p1 p2)
  ;; Do not 

Ambitus + Cue gives spurious note column warning

2022-07-23 Thread Richard Shann
The combination of Ambitus and a cue seems to provoke a strange
warning:

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
\version "2.22"
MvmntIVoiceI = { c'1 c'}
MvmntIVoiceII = {
 \cueDuringWithClef #"1 Treble on Staff 1 Mvmnt 1"#1 #"treble" 
{ R1*4/4 }
 c1 
}

\layout { \context {  \Voice   \consists "Ambitus_engraver" }}

\addQuote "1 Treble on Staff 1 Mvmnt 1" \MvmntIVoiceI

\score { 
  <<
\new Staff  << 
  
  \new Voice  { \MvmntIVoiceI } %End of voice
>> %End of Staff

\new Staff   << 
\new Voice = "MvmntIVoiceII"  { \clef alto 
\MvmntIVoiceII }
>> 
  >>
   }
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

which gives:

Starting lilypond 2.22.0 [Ambitus-cue-notecolumnclash.ly]...
Processing `/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly'
Parsing...
Interpreting music...
Interpreting music...
Preprocessing graphical objects...
programming error: Note_column without heads and stem
continuing, cross fingers
/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: programming
error: note-column has no direction
 
 c1 
/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: continuing,
cross fingers

I cut this down from a much bigger score to make a MWE but in so doing
I see I have inadvertently triggered an extra warning, the first one
above about Note_column without heads and stem. The original only has
the warning about "note-column has no direction". I hope this won't
muddy the issue.

Any thoughts?

Richard Shann










Re: \vshape and custom curve-stencil for TextSpanner

2022-07-23 Thread Jean Abou Samra

Hi Harm,


Le 23/07/2022 à 10:59, Thomas Morley a écrit :

I'm attempting to create a s-curve stencil for TextSpanner.
While so far all works as wished and it is possibel to use \shape,
\vshape doesn't print the control-points.

What am I missing?



\shape works because it's an override/tweak to the control-points
property, and your code reads this property.

\vshape is implemented with separate grobs, ControlPoint and
ControlPolygon. This is so that you can override their basic
properties (color, layer, thickness, ...) independently from the
bezier grob. They are created by the Show_control_points_engraver,
which acknowledges bezier curve grobs and reads their
show-control-points-property. Your custom TextSpanner isn't
recognized because it doesn't have the bezier-curve-interface,
and this is what Show_control_points_engraver acknowledges.
Do you have a specific reason to use a TextSpanner? How
about using a Slur?



Code below.
Thanks to Jean how fixed make-path-stencil!



You're welcome :-)

Best,
Jean




Re: Ties between voices

2022-07-23 Thread Kieren MacMillan
Hi Lukas!

As someone who writes/engraves a LOT of keyboard music: THANK YOU!!
Excited that there might even be a Slur version in the [near] future.

Best,
Kieren.



Re: Ambitus + Cue gives spurious note column warning

2022-07-23 Thread Jean Abou Samra




Le 23/07/2022 à 15:58, Richard Shann a écrit :

The combination of Ambitus and a cue seems to provoke a strange
warning:

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
\version "2.22"
MvmntIVoiceI = { c'1 c'}
MvmntIVoiceII = {
  \cueDuringWithClef #"1 Treble on Staff 1 Mvmnt 1"#1 #"treble" 
{ R1*4/4 }
  c1
 }

\layout { \context {  \Voice   \consists "Ambitus_engraver" }}

\addQuote "1 Treble on Staff 1 Mvmnt 1" \MvmntIVoiceI

\score {
   <<
 \new Staff  <<
   
   \new Voice  { \MvmntIVoiceI } %End of voice

 >> %End of Staff

 \new Staff   <<
 \new Voice = "MvmntIVoiceII"  { \clef alto 
\MvmntIVoiceII }
 >>
   >>
}
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

which gives:

Starting lilypond 2.22.0 [Ambitus-cue-notecolumnclash.ly]...
Processing `/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly'
Parsing...
Interpreting music...
Interpreting music...
Preprocessing graphical objects...
programming error: Note_column without heads and stem
continuing, cross fingers
/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: programming
error: note-column has no direction
  
  c1

/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: continuing,
cross fingers

I cut this down from a much bigger score to make a MWE but in so doing
I see I have inadvertently triggered an extra warning, the first one
above about Note_column without heads and stem. The original only has
the warning about "note-column has no direction". I hope this won't
muddy the issue.

Any thoughts?




That sounds like https://gitlab.com/lilypond/lilypond/-/issues/1113.

The fix appears to be very simple, currently writing the regression
tests to post a patch ...

You can work around it for now using

\layout {
  \context {
\Score
\override AmbitusNoteHead.meta.interfaces =
  #'(ambitus-interface
 font-interface
 ledgered-interface
 note-head-interface
 staff-symbol-referencer-interface)
  }
}

Best,
Jean




Re: Ties between voices

2022-07-23 Thread William Rehwinkel
I second Kieren's sentiment, thanks for this extension Lukas-Fabian. 
I'll remember this extension if the need for it pops up!


-William
On 7/23/22 06:49, Lukas-Fabian Moser wrote:


Hi Andrew,

Am 23.07.22 um 03:49 schrieb Andrew Bernard:
I know that we can't natively make ties between notes in different 
voices. I know that there was a Google Summer of Code task that could 
not be completed.


A few weeks ago, I sent you the following privately (I was too timid 
to post in on the list):


My idea was to \consist the Tie_engraver to the Staff context not 
_instead_ of to the Voice context, but _in addition_. Then we have two 
Tie engravers and need a mechanism by which to tell if a given tie 
should be collected by the Voice-level Tie_engraver or at Staff level 
(in order to connect ties between different voices).


During my experiments I re-implemented the Tie_engraver in Scheme; 
although it turned out that (contrary to my expectations) the 
necessary adjustments could just as easily have been made in C++, the 
advantage is that we can test this approach without the need to 
re-compile a custom LilyPond build.


The attached file (requiring 2.23.6 and above) generates

as easily as:

\new Staff \with { \consists #New_tie_engraver }
{
  <<
    \relative {
  4 c8 b a g~ 4
    }
    \\
    \relative {
  s4 c'2 e4
    }
  >>
}

Of course the same mechanism might be implemented for, e.g., the 
Slur_engraver. But this requires additional work, as the slur 
positioning mechanism is not quite up to positioning Staff-level slurs 
correctly.


The attached Scheme Tie_engraver may be used as a drop-in replacement 
for the standard C++ Tie_engraver; in my local branch, it compiles the 
full regression test suite without causing differences.)


Lukas


--
William Rehwinkel

will...@williamrehwinkel.net
https://williamrehwinkel.net


Re: Ambitus + Cue gives spurious note column warning

2022-07-23 Thread Richard Shann
On Sat, 2022-07-23 at 16:38 +0200, Jean Abou Samra wrote:
> 
> 
> Le 23/07/2022 à 15:58, Richard Shann a écrit :
> > The combination of Ambitus and a cue seems to provoke a strange
> > warning:
> > 
> > 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> > \version "2.22"
> > MvmntIVoiceI = { c'1 c'}
> > MvmntIVoiceII = {
> >   \cueDuringWithClef #"1 Treble on Staff 1 Mvmnt
> > 1"#1 #"treble" { R1*4/4 }
> >   c1
> >  }
> > 
> > \layout { \context {  \Voice   \consists "Ambitus_engraver" }}
> > 
> > \addQuote "1 Treble on Staff 1 Mvmnt 1" \MvmntIVoiceI
> > 
> > \score {
> >    <<
> >  \new Staff  <<
> >    
> >    \new Voice  { \MvmntIVoiceI } %End of
> > voice
> >  >> %End of Staff
> > 
> >  \new Staff   <<
> >  \new Voice = "MvmntIVoiceII"  { \clef
> > alto \MvmntIVoiceII }
> >  >>
> >    >>
> >     }
> > 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> > 
> > which gives:
> > 
> > Starting lilypond 2.22.0 [Ambitus-cue-notecolumnclash.ly]...
> > Processing `/home/rshann/Skype/Ambitus-cue-notecolumnclash.ly'
> > Parsing...
> > Interpreting music...
> > Interpreting music...
> > Preprocessing graphical objects...
> > programming error: Note_column without heads and stem
> > continuing, cross fingers
> > /home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: programming
> > error: note-column has no direction
> >   
> >   c1
> > /home/rshann/Skype/Ambitus-cue-notecolumnclash.ly:6:18: continuing,
> > cross fingers
> > 
> > I cut this down from a much bigger score to make a MWE but in so
> > doing
> > I see I have inadvertently triggered an extra warning, the first
> > one
> > above about Note_column without heads and stem. The original only
> > has
> > the warning about "note-column has no direction". I hope this won't
> > muddy the issue.
> > 
> > Any thoughts?
> 
> 
> 
> That sounds like https://gitlab.com/lilypond/lilypond/-/issues/1113.
> 
> The fix appears to be very simple, currently writing the regression
> tests to post a patch ...
> 
> You can work around it for now using
> 
> \layout {
>    \context {
>  \Score
>  \override AmbitusNoteHead.meta.interfaces =
>    #'(ambitus-interface
>   font-interface
>   ledgered-interface
>   note-head-interface
>   staff-symbol-referencer-interface)
>    }
> }
> 

Thank you! That works in the original context.

Richard


> Best,
> Jean
> 





Re: Ties between voices

2022-07-23 Thread Jean Abou Samra




Le 23/07/2022 à 12:49, Lukas-Fabian Moser a écrit :


Hi Andrew,

Am 23.07.22 um 03:49 schrieb Andrew Bernard:
I know that we can't natively make ties between notes in different 
voices. I know that there was a Google Summer of Code task that could 
not be completed.


A few weeks ago, I sent you the following privately (I was too timid 
to post in on the list):


My idea was to \consist the Tie_engraver to the Staff context not 
_instead_ of to the Voice context, but _in addition_. Then we have two 
Tie engravers and need a mechanism by which to tell if a given tie 
should be collected by the Voice-level Tie_engraver or at Staff level 
(in order to connect ties between different voices).


During my experiments I re-implemented the Tie_engraver in Scheme; 
although it turned out that (contrary to my expectations) the 
necessary adjustments could just as easily have been made in C++, the 
advantage is that we can test this approach without the need to 
re-compile a custom LilyPond build.


The attached file (requiring 2.23.6 and above) generates


as easily as:

\new Staff \with { \consists #New_tie_engraver }
{
  <<
    \relative {
  4 c8 b a g~ 4
    }
    \\
    \relative {
  s4 c'2 e4
    }
  >>
}

Of course the same mechanism might be implemented for, e.g., the 
Slur_engraver. But this requires additional work, as the slur 
positioning mechanism is not quite up to positioning Staff-level slurs 
correctly.


The attached Scheme Tie_engraver may be used as a drop-in replacement 
for the standard C++ Tie_engraver; in my local branch, it compiles the 
full regression test suite without causing differences.)






Interesting, Lukas! Now, this approach fails on cases where
ties are physically but not mentally interrupted, as pianists
sometimes encounter, like

\version "2.23.10"

\new Staff <<
  \relative {
    <%{ tie this %} c' c'>2
    c'8 b a g
  }
  \\
  \relative { s2 %{ to this %} c'4 g }
  \\
  \relative { g16 a c d e a g e f4 d }
>>

but this might be rare enough that not catering for it
would be good enough?

Amusingly, I was thinking about pretty much the same concept
yesterday, but in a completely different context and without
cross-staff spanners in mind. I was musing about contributing
a "highlight" feature to colorize a music passage, and how
highlighting different contexts, like a full StaffGroup
or just a Staff, would be handled internally. I thought
that the engraver could refrain from handling an event
if it detected that context the event wanted to highlight
(stored in an event property) was not matching the engraver's
context, but I wondered if it could be more general, which
leads to thinking about your \to command being implemented
as

to =
#(define-music-function (ctx mus) (symbol? ly:music?)
   (make-music 'ContextExclusiveMusic 'target ctx 'element mus))

where ContextExclusiveMusic would be recognized by
Music_iterator::report_event (see find_above_by_music_type)
to make any event within ContextExclusiveMusic only
broadcast in engravers of the context addressed by \to.

Just in case that helps you further your idea ...

Cheers,
Jean





Re: Ties between voices

2022-07-23 Thread Stephan Schöll

Hi all

I'm neither a professional engraver nor composer. But I've already tried
to copy scores for my own use.

That's where I got in touch with many "creative" engraving situations.
One might ask how one could engrave something a manual engraver did 100
years ago. And then we have this fantastic list that comes up with ideas
solutions.

But from time to time I encounter things that don't make sense to me
from a semantical perspective. Ties across voices is such a thing. How
would that make sense? Yes, there has been a master in the past who did
it, but nevertheless, it has (in developer speak) has a smell. Should I
omit or correct that in my score? After all ties describe the
relationship between two or several notes within a voice (i.e. that can
be sung).

Just my philosophical 2 cents ;-)

Best regards

Stephan

Am 23.07.2022 um 08:04 schrieb Jean Abou Samra:

Le 23/07/2022 à 03:49, Andrew Bernard a écrit :

I know that we can't natively make ties between notes in different
voices. I know that there was a Google Summer of Code task that could
not be completed.

This is such a critical feature for keyboard music. When there are
hundreds of such ties in major pieces, it is just too tedious to do
all the workarounds with hidden notes and voices. I'm sorry to say
that I have switched to Dorico because of this significant
shortcoming, after having been a Lilypond user for a decade or more.

So, my question is this. Is the codebase just painted into a corner
that can't be gotten out of in this area due to architectural design
decisions?



I don't think so, but it's definitely not a trivial
problem either, and requires new design.



Are there any plans at all to develop this functionality in the
forseeable future?



Did you see this recent discussion?

https://lists.gnu.org/archive/html/lilypond-devel/2022-05/msg00175.html

It's not possible to answer your question, as most
plans to develop functionality are a private decision
of a particular contributor that are not public until
(perhaps a few days before) a patch is submitted.

Best,
Jean






Re: Dashed Stem Fontsize !

2022-07-23 Thread Ya Gloops
Thank you very much for your help Harm !!!
Gilles






Le vendredi 22 juillet 2022 à 19:27:50 UTC+2, Thomas Morley 
 a écrit : 





Am Fr., 22. Juli 2022 um 13:04 Uhr schrieb Ya Gloops :
>
>
> Hello ! I try to keep the proportion of the "dashed-stem" but I can't... If 
> someone can help me.
> Gilles
>
> \version "2.23.10"
>
>
> %#(set-global-staff-size 30)
>
>
> #(define (make-round-filled-box x1 x2 y1 y2 blot-diameter)
>    (ly:make-stencil (list 'round-filled-box (- x1) x2 (- y1) y2 blot-diameter)
>      (cons x1 x2)
>      (cons y1 y2)))
>
>
> #(define (build-pos-list len on off)
>    (let ((lst '(0)))
>
>      (define (helper)
>        (let ((bottom (+ (car lst) on)))
>          (if (< bottom len)
>              (begin
>              (set! lst (cons bottom lst))
>              (let ((top (+ (car lst) off)))
>                (if (< top len)
>                    (begin
>                      (set! lst (cons top lst))
>                      (helper))
>                    (set! lst (cons len lst)
>              (set! lst (cons len lst)
>      (helper)
>      (reverse lst)))
>
>
> #(define (dashed-stem on off)
>    (lambda (grob)
>      (let* ((blot (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter))
>            (stencil (ly:stem::print grob))
>            (X-ext (ly:stencil-extent stencil X))
>            (thickness (interval-length X-ext))
>            (Y-ext (ly:stencil-extent stencil Y))
>            (len (interval-length Y-ext))
>            (new-stencil empty-stencil)
>            (factors (build-pos-list len on off)))
>
>        (define (helper args)
>          (if (<= 2 (length args))
>              (begin
>              (set! new-stencil
>                    (ly:stencil-add
>                      new-stencil
>                      (ly:stencil-translate-axis
>                      (make-round-filled-box (/ thickness -2) (/ thickness 2)
>                        (car args) (cadr args)
>                        blot)
>                      (interval-start Y-ext)
>                      Y)))
>              (helper (cddr args)))
>              new-stencil))
>
>
>        (if (or (zero? on) (zero? off))
>            stencil
>            (helper factors)
>
>
> dashedStems =
> #(define-music-function (on off) (number? number?)
>    #{
>      \override Stem.stencil = #(dashed-stem on off)
>    #})
>
>
>
>
> \relative c'' {
>  \dashedStems #0.5 #0.4
>  c4
> }
>
>
> \score
> {
>  \relative c'' { \magnifyStaff #(magstep 10)
>                  \dashedStems #0.5 #0.4
>                  c4
>  }
> }
>

Scale on/off with staff-space, (ly:staff-symbol-staff-space grob).

HTH,
  Harm




Re: Ties between voices

2022-07-23 Thread Jean Abou Samra

Le 23/07/2022 à 19:14, Jean Abou Samra a écrit :

to =
#(define-music-function (ctx mus) (symbol? ly:music?)
   (make-music 'ContextExclusiveMusic 'target ctx 'element mus))



P.S. With some parser fiddling (and at the cost of making \to a
reserved identifier), it should be possible to give \to a
syntax like that of \new and \context.

\to Staff ~
\to StaffGroup = "outer" \startHighlight





Re: Ties between voices

2022-07-23 Thread William Rehwinkel
This is a good question, Stephan. I think it can be explained that when 
talking about keyboard music, even though there are abstract ideas of 
things like melody from playing one note after the previous, and other 
things such as chords, engraving techniques such as including many 
noteheads on one stem to form a chord can be considered a shorthand for 
representing different notes (voices?) that have the same start and end 
point. Furthermore, splitting a single-stem chord into an upper-stem 
group of notes and lower-stem group of notes is simply a shorthand...you 
could imagine writing each note separately (as with new German organ 
tablature for example), in which case this would not be a problem. For 
keyboard music, I don't think this is too objectionable, however this 
would of course not be acceptable for closed score choral music or other 
situations where distinct instruments are represented by different 
voices on one line.


Speaking of tie-ing notes "between voices" is a bit of a 
misrepresentation, it's referring to the way that lilypond writes 
multiple polyphonic notes on the same staff using different voices.


This thinking doesn't apply to other things like Chopin piano works with 
slurs across voices but I think those can be thought of more 
practically, to hold the first note long enough that it sounds legato 
with the last.


-William

On 7/23/22 13:27, Stephan Schöll wrote:

Hi all

I'm neither a professional engraver nor composer. But I've already tried
to copy scores for my own use.

That's where I got in touch with many "creative" engraving situations.
One might ask how one could engrave something a manual engraver did 100
years ago. And then we have this fantastic list that comes up with ideas
solutions.

But from time to time I encounter things that don't make sense to me
from a semantical perspective. Ties across voices is such a thing. How
would that make sense? Yes, there has been a master in the past who did
it, but nevertheless, it has (in developer speak) has a smell. Should I
omit or correct that in my score? After all ties describe the
relationship between two or several notes within a voice (i.e. that can
be sung).

Just my philosophical 2 cents ;-)

Best regards

Stephan

Am 23.07.2022 um 08:04 schrieb Jean Abou Samra:

Le 23/07/2022 à 03:49, Andrew Bernard a écrit :

I know that we can't natively make ties between notes in different
voices. I know that there was a Google Summer of Code task that could
not be completed.

This is such a critical feature for keyboard music. When there are
hundreds of such ties in major pieces, it is just too tedious to do
all the workarounds with hidden notes and voices. I'm sorry to say
that I have switched to Dorico because of this significant
shortcoming, after having been a Lilypond user for a decade or more.

So, my question is this. Is the codebase just painted into a corner
that can't be gotten out of in this area due to architectural design
decisions?



I don't think so, but it's definitely not a trivial
problem either, and requires new design.



Are there any plans at all to develop this functionality in the
forseeable future?



Did you see this recent discussion?

https://lists.gnu.org/archive/html/lilypond-devel/2022-05/msg00175.html

It's not possible to answer your question, as most
plans to develop functionality are a private decision
of a particular contributor that are not public until
(perhaps a few days before) a patch is submitted.

Best,
Jean





--
William Rehwinkel

will...@williamrehwinkel.net
https://williamrehwinkel.net




Re: \vshape and custom curve-stencil for TextSpanner

2022-07-23 Thread Thomas Morley
Am Sa., 23. Juli 2022 um 16:06 Uhr schrieb Jean Abou Samra :
>
> Hi Harm,
>
>
> Le 23/07/2022 à 10:59, Thomas Morley a écrit :
> > I'm attempting to create a s-curve stencil for TextSpanner.
> > While so far all works as wished and it is possibel to use \shape,
> > \vshape doesn't print the control-points.
> >
> > What am I missing?
>
>
> \shape works because it's an override/tweak to the control-points
> property, and your code reads this property.
>
> \vshape is implemented with separate grobs, ControlPoint and
> ControlPolygon. This is so that you can override their basic
> properties (color, layer, thickness, ...) independently from the
> bezier grob. They are created by the Show_control_points_engraver,
> which acknowledges bezier curve grobs and reads their
> show-control-points-property. Your custom TextSpanner isn't
> recognized because it doesn't have the bezier-curve-interface,
> and this is what Show_control_points_engraver acknowledges.

Thanks, for your detailed explanation.
To get around it one could do:

#(define (add-to-interfaces iface name grob-descriptions-alist)
  (map
(lambda (x)
  (if (eq? (car x) name)
  (let* (;; Use `list-copy' like `completize-grob-entry' in
 ;; scm/define-grobs.scm
 (grob-entry (map list-copy (cdr x)))
 ;; Though why here again?
 (meta-entry (map list-copy (assoc-get 'meta grob-entry)))
 ;; and not here?
 (ifaces-entry
  (assoc-get 'interfaces meta-entry)))
(set! ifaces-entry (cons iface ifaces-entry))
(set! meta-entry (assoc-set! meta-entry 'interfaces ifaces-entry))
(set! grob-entry (assoc-set! grob-entry 'meta meta-entry))
(cons name grob-entry))
  x))
   grob-descriptions-alist))

\layout {
  \context {
\Global
\grobdescriptions
  #(add-to-interfaces
'bezier-curve-interface
'TextSpanner
all-grob-descriptions)
  }
}

> Do you have a specific reason to use a TextSpanner? How
> about using a Slur?

Well, I need to directly connect two notes/rests, probably with a lot
of other stuff in between.
For this connection several styles are possible
(1) A straight line (maybe dashed or dotted)
Thus TextSpanner was my first thought. Alas, in most cases the line will
not be horizontal so I need some stencil override anyway.
Pretty simple, though, can be made to work automatically.
(2) A curve, probably a s-curve.
Thus current thread topic
(3) A multiple kneed line:
 
|___||
 v
(the graphic will likely not survive mail delivery unchanged, though
maybe you can imagine it)

To summarize, all three possibilities will need other stencils.
If control-points are available (Slur) it is probably not hard to get to (1).
For (2), a Slur may be good out of the box, otherwise vshape will always work.
For kneed lines (3), make connected-path-stencil may work.

All three possibilities can be made to work with TextSpanner and Slur.
I think I have to experiment, what works out better.

Thanks,
  Harm



Re: A new Scheme tutorial (Jean Abou Samra)

2022-07-23 Thread Jean Abou Samra

Thanks a lot Peter and others (privately) for your suggestions.
Sorry for the very late reply, I've been distracted by other
things. Your comments are most appreciated.


Le 13/07/2022 à 18:15, Peter Toye a écrit :
This looks great! Just what I'd needed a couple of years back when I 
was still programming.


I've only just started with it, but there are a few niggling comments 
about the English version. I've only got to page 2 (getting started) 
so far.


  * On my browser (Firefox in Windows) the 'v. latest' is too close to
the bottom of the main frame, and I can't click on the
'previous/next/index' without very careful manipulation of the
slider. Can it be moved up a cm or so?




This is a bit tricky because I don't know how to test it
locally without uploading on Readthedocs, and I'm bad at
CSS ...



  * On page 1 (Why Scheme?) it's slightly better English to say 'There
is no single implementation of Scheme'
  * On page 2 (Getting started) the comment about testing under
Windows is not translated into English! I suggest 'I am unable to
test these commands under Windows. If they do not work, write to
the list.'
  * Again on page 2, the commands don't work! You forgot to add the
'lilypond'.
C:\Program Files (x86)\LilyPond\usr\bin>lilypond
scheme-sandbox works fine on my machine.
  * On page 2 'Literals' the comment about decimal numbers isn't
translated. I'm not sure about the best translation of 'nombres
décimaux'. Personally I'd use 'floating-point numbers' on the
grounds that all numbers, including integers, are decimal.



Done.



  * The comment 'and a few others' about the characters allowed in
variable names is rather annoying. How does a user know what to
expect if they use a forbidden character? A list would be really
useful.




Um. The precise rules for valid identifiers are described
as a formal grammar on pages 12 and 13 of R6RS

(see the  production). I'll try to put
a list of a few characters that are valid and which
are useful to know about, like ? and ! because they
occur regularly at the end of function names (for
predicates and side-effecting functions), but I'd
rather not explain the full rules, as they are quite
complex ...

Best,
Jean




Re: Still struggling to understand Lilypond 2.23.10 segno repeats

2022-07-23 Thread Jean Abou Samra



Le 23/07/2022 à 03:48, Kenneth Wolcott a écrit :
Can_You_Feel_the_Love_Tonight.pdf 


Hi;

  I have a piece of music ("Can You Feel the Love Tonight") which I am 
trying to engrave using Lilypond 2.23.10.


  I have (mostly) succeeded in engraving this with Lilypond 2.22.2, 
but the many directives regarding the Coda and DS look awful.


So, I tried using the \repeat segno feature, which almost looks 
correct, but I have problems understanding how to glue in the Coda 
part (is that like a volta?).


Could someone clue me in on the Lilypond syntax that I am missing so 
that the pdf looks right and the midi sounds right?


Kenneth,

There is an example with an al coda repeat here:

https://lilypond.org/doc/v2.23/Documentation/notation/long-repeats.html#segno-repeat-structure

The syntax is

\repeat segno 2 {
  
  \alternative {
    \volta 1 {
  
    }
    \volta 2 \volta #'() {
  \section
  \sectionLabel Coda
    }
  }
  
}

Attached is your file amended to use this syntax.

Best,
Jean

\version "2.23.10"

% Can You Feel the Love Tonight
% (from the Lion King)

global = {
  \language "english"
  \numericTimeSignature
  \time 4/4
  \key c \major
  \tempo "Moderately"
}

\header {
  title = "Can You Feel the Love Tonight"
  subtitle = "(from the \"Lion King\")"
  composer = "Elton John"
}

ds_al_coda = ^\markup { \fontsize #3 "D.S. al Coda" }
rit_e_dim = _\markup { \italic "rit. e dim." }
to_coda = ^\markup { \fontsize #3 "To Coda" }
% coda = -\tweak outside-staff-priority #605 \mark \markup { \fontsize #3 "CODA" }
coda = \mark \markup { \fontsize #2 "CODA" }

rh = {
  \global
  \clef treble
  e''2^3\mp d''4 g''  | % m1
  f''2 f''8^5 e'' c'' g'  | % m2
  a'2 g'8 c'' g'4^2   | % m3
%\break
  d'4^1 e' f' g'^1 | % m4
  \repeat segno 2 {
%  \mark \markup { \musicglyph "scripts.segno" }
a'8 b' c'' d'' c'' g'4.  | % m5
a'8 b' c'' d'' c''2  | % m6
%\break
a'8 b' c'' d''16 d'' c''8 g' e''4^4  | % m7
f''8 e'' d'' e'' d''2| % m8
%\break
a'8 b' c'' d'' c'' g'4.  | % m9
a'8 b' c'' d'' c''2  | % m10
%\break
a'8 b' c'' g'16 g' g''8 e'' c'' a'  | % m11
f''8 e'' d'' e'' d''4. g'8  | % m12
%\break
\repeat volta 2 {
  g''4. e''8 e''4. g''8  | % m13
  e''4 c''8 a' ~ a'2 | % m14
  r4 g'8 c'' f''4 e''| % m15
%\break
  d''1   | % m16
  r4 a'8 b' c''4 g'8 g'  | % m17
  g''4 e'' c''8 c'' a'4  | % m18
}
%\break
\alternative {
  {
f''4 e'' d'' e'' | % m19
d''2. r8 g'  | % m20
  }
  {
f''4 e'' d'' c''8 c'' ~  | % m21
  }
}
%\break
c''2. r4  | % m22
\alternative {
  \volta 1 {
e''2^3 d''4 g''   | % m23
f''2 f''8 e'' c'' g'  | % m24
  %\break
a'2 g'8 c'' g'4^2   | % m25
d'4 e' f' g' | % m26
  }
  \volta 2 \volta #'() {
\section
\sectionLabel Coda
  }
}
  }
%  \mark \markup { \musicglyph "scripts.coda" }
  r4 a'8 b' c''4 g'8 g'  | % m27
%\break
  g''4 e'' c''8\rit_e_dim c'' a' a'   | % m28
  f''4 e'' d'' c''8 c'' ~ | % m29
  c''4 a'8 f' e''2\fermata| % m30
  \fine
}

lh = {
  \global
  \clef bass
  c'2_1 b   | % m1
  a2 g  | % m2
  f4 c' e2  | % m3
%\break
  b1| % m4
  \repeat segno 2 {
f2 e  | % m5
f2 e  | % m6
%\break
f2 e| % m7
f2 g_2  | % m8
%\break
f2 e  | % m9
f2 e  | % m10
%\break
f2 a  | % m11
bf2 b8 a g f  | % m12
%\break
\repeat volta 2 {
  e2 g   | % m13
  a2 f   | % m14
  c'2 f4 fs  | % m15
%\break
  g4 a b g_2  | % m16
  f2 e| % m17
  c'2 a   | % m18
}
%\break
\alternative {
  {
f2. fs4  | % m19
g4 b a g8 f  | % m20
  }
  {
d4 e f g | % m21
  }
}
%\break
f8 a g f e4 g  | % m22
\alternative {
  \volta 1 {
c'2 b  | % m23
a2 g   | % m24
  %\break
f4 c' e2   | % m25
b4 c' d e  | % m26
  }
  \volta 2 \volta #'() {
\section
\sectionLabel Coda
  }
}
  }
  f2 e   | % m27
%\break
  a4 g f2 | % m28
  d4 e g g| % m29
  c1\fermata  | % m30
  \fine
}

\score {
  \new PianoStaff \with { instrumentName = "Piano" }
  <<
\new Staff \rh
\new Staff \lh
  >>
  \layout {}
}

\score {
  \unfoldRepeats {
<<
  \new Staff {
\set Staff.midiInstrument = "acoustic grand"
\rh
  }
  \new Staff {
\set Staff.midiInstrument = "acoustic grand"
\lh
  }
>>
  }
 % \midi {
 %   \tempo 4=112
 % }
}


Re: Ties between voices

2022-07-23 Thread Andrew Bernard
Gosh. There's no 'smell'. In piano music that has polyphony it is very 
common, and indeed necessary  to tie across voices. Dorico enables it 
with ease (and if it did not make sense, I can assure you Dorico which 
is heavily rule bound would not allow it). Lilypond cannot do it 
natively. This is well known. Same with slurs, but that is not the 
present topic. We are not talking about singing, and 'voices' in this 
context does not relate to the human voice. Perhaps you are conflating 
sung voices with voices in polyphony for keyboards.


I'll find a few examples to post later on to illustrate.

This has been a long standing limitation with LilyPond, not something 
that I have suddenly cooked up. I encounter this extensively in the 
modernist music I set, but I am doing the JSB WTC at the moment and even 
he does it quite a lot, especially in the four and five part works.


Andrew

On 24/07/2022 3:27 am, Stephan Schöll wrote:

But from time to time I encounter things that don't make sense to me
from a semantical perspective. Ties across voices is such a thing. How
would that make sense? Yes, there has been a master in the past who did
it, but nevertheless, it has (in developer speak) has a smell. Should I
omit or correct that in my score? After all ties describe the
relationship between two or several notes within a voice (i.e. that can
be sung).





Re: Change to \rest markup in 2.23

2022-07-23 Thread David F.



> On Jul 20, 2022, at 5:13 AM, Thomas Morley  wrote:
> 
> Am Mi., 20. Juli 2022 um 05:58 Uhr schrieb David F. :
>> 
>> In 2.23, the rest markup command changed from taking a string to taking a 
>> duration.
>> 
>> \version "2.22"
>> \markup \rest #"4.."
>> 
>> \version "2.23"
>> \markup \rest { 4.. }
>> 
>> It would be nice if this change were backward compatible, at least for a 
>> version or two.
>> 
>> My primary Lilypond environment is v2.22.2-1 on macOS 10.14.  This is the 
>> environment I use for final “production” of scores.  But I’ve been trying to 
>> do as much development as possible in v2.23 on macOS 10.15.
>> 
>> Unfortunately, the change to the rest markup command makes going back and 
>> forth quite cumbersome.  Would be be possible to make this command take 
>> either a string or duration?
>> 
>> David F.
>> 
>> 
> 
> Well, going back and forth between 2.22.2 and new devel-version only
> works if you don't use devel-features and don't hit internal changes.
> 
> That said, below a coding which makes \rest always take a duration,
> transforming it to a string for 2.22.
> Once you settled with 2.23. simply delete it.
> Disclaimer: it's all a bit clumsy, cheeky and not tested in the wild.
> 
> \version "2.20.0"
> 
> #(begin
>  (define default-make-rest-markup make-rest-markup)
>  (define-markup-command (rest layout props duration) (ly:duration?)
>(let ((version-arg
>(if (stringduration
>(ly:duration->string duration
>(interpret-markup layout props
>  (default-make-rest-markup version-arg)
> 
> \markup \rest { 4.. }
> 
> Cheers,
>  Harm

Thanks Harm.  That seems to do the trick!

David F.




Re: Change to \rest markup in 2.23

2022-07-23 Thread David F.



> On Jul 20, 2022, at 5:25 AM, Jean Abou Samra  wrote:
> 
> Le 20/07/2022 à 05:57, David F. a écrit :
>> In 2.23, the rest markup command changed from taking a string to taking a 
>> duration.
>> 
>> \version "2.22"
>> \markup \rest #"4.."
>> 
>> \version "2.23"
>> \markup \rest { 4.. }
>> 
>> It would be nice if this change were backward compatible, at least for a 
>> version or two.
> 
> 
> LilyPond's general policy is that backwards-incompatible syntax
> changes are OK as long as a convert-ly rule is provided to update
> input files automatically.
> 
> Well, in this case there is no convert-ly rule ... I'll fix that soon.
> 
> 
>> My primary Lilypond environment is v2.22.2-1 on macOS 10.14.  This is the 
>> environment I use for final “production” of scores.  But I’ve been trying to 
>> do as much development as possible in v2.23 on macOS 10.15.
>> 
>> Unfortunately, the change to the rest markup command makes going back and 
>> forth quite cumbersome.  Would be be possible to make this command take 
>> either a string or duration?
> 
> 
> My answer will be a bit different from Harm's: this sounds like
> an XY problem to me. Why do you want to switch back and forth
> between two LilyPond versions for the same score? Just install
> the same version on both machines. There is no problem with having
> several different versions of LilyPond installed in parallel on
> the same machine, and in Frescobaldi, you can even choose to
> select the LilyPond version from the \version statement (the
> setting is in Edit > Preferences > LilyPond Preferences),
> making this very convenient.
> 


Installing multiple versions of Lilypond isn’t a big deal, per se.  I have 2.22 
and 2.23.10 installed on the macOS 10.14 machine.  I don’t think there is a 
standalone install of v2.22 available for macOS 10.15 and greater, so I think 
I’d have to install MacPorts on the macOS 10.15 machine in order to get 
Lilypond 2.22.  But we can call that a simple annoyance.

The issue, for me, is that I’m trying to be conservative in upgrading to newer 
Lilypond versions.  I have around 100 hymns that get turned into just over 4000 
individual slides.  I can’t realistically inspect each slide after a version 
upgrade, so I’ve been sticking to the Lilypond stable releases for “production” 
generation of my slides.

But, as I said above, I try to do as much development as possible on the latest 
“unstable” version so as to catch problems as soon as possible.  When I first 
moved to version 2.23, I found, for example, that there was an issue with 
handling file paths that contained Unicode characters.  Once I brought the 
issue to the list, Jonas Hahnfeld was able to provide a fix with 2.23.10.

If Lilypond’s policy is as you say, then I might have to reconsider my approach 
to upgrades.  But, likely as not, I’ll just carry on trying to stick with 
stable releases.  I started out on version 2.18 and haven’t really had too much 
trouble switching back and forth between stable and unstable releases.

David F.




Re: Still struggling to understand Lilypond 2.23.10 segno repeats

2022-07-23 Thread Kenneth Wolcott
HI Jean;

  As always, thank you very much for this help.

  I saw the documentation that you pointed out already, but I just
couldn't seem to grasp how to apply it to my situation.  Sometimes I
think the documentation is too "MWE" :-)

  I will study this and try to understand it to the point where I can
apply it to the other pieces that I have which these kinds of repeats
without having spoon-feeding assistance.

Thanks,
Ken

On Sat, Jul 23, 2022 at 2:03 PM Jean Abou Samra  wrote:
>
>
>
> Le 23/07/2022 à 03:48, Kenneth Wolcott a écrit :
> > Can_You_Feel_the_Love_Tonight.pdf
> > 
> > Hi;
> >
> >   I have a piece of music ("Can You Feel the Love Tonight") which I am
> > trying to engrave using Lilypond 2.23.10.
> >
> >   I have (mostly) succeeded in engraving this with Lilypond 2.22.2,
> > but the many directives regarding the Coda and DS look awful.
> >
> > So, I tried using the \repeat segno feature, which almost looks
> > correct, but I have problems understanding how to glue in the Coda
> > part (is that like a volta?).
> >
> > Could someone clue me in on the Lilypond syntax that I am missing so
> > that the pdf looks right and the midi sounds right?
>
> Kenneth,
>
> There is an example with an al coda repeat here:
>
> https://lilypond.org/doc/v2.23/Documentation/notation/long-repeats.html#segno-repeat-structure
>
> The syntax is
>
> \repeat segno 2 {
>
>\alternative {
>  \volta 1 {
>
>  }
>  \volta 2 \volta #'() {
>\section
>\sectionLabel Coda
>  }
>}
>
> }
>
> Attached is your file amended to use this syntax.
>
> Best,
> Jean
>