Re: Getting grob Y position (spacing error)

2022-11-18 Thread Gregory Evans
Hello Jean,
thank you for the information about after-line-breaking and the timing of
skyline computing. Is there an equivalent property to trigger callback
after the skylines are calculated? I am trying to use (ly:stencil-add ...)
to add to the stencil of a notehead by drawing a line from one notehead in
one staff to a notehead in another staff. The notehead grob does not appear
to have a cross-staff property to delay stencil callback.

\language "english"
\version "2.23.14"

#(set-global-staff-size 12)

\score {
<<
\new Staff {
\override NoteHead.cross-staff = ##t
\once \override NoteHead.after-line-breaking = #(lambda (grob)
(let*
(
   (sys (ly:grob-system grob))
   (x-extent (ly:grob-extent grob sys X))
   (y-extent (ly:grob-extent grob sys Y))
)
(display (list x-extent ))
)
)
c'1
c'1
c'1
c'1
}
\new Staff {
c'1
c'1
c'1
c'1
}
>>
}

A larger example of the function (without a great deal of context) looks
like this:

interrupt = #(define-music-function (value) (number?)
  #{
  \once \override Staff.NoteHead.after-line-breaking = #(lambda (grob)
  (let* (
(stem (ly:grob-object grob 'stem))
(stem-dir (ly:grob-property stem 'direction))
(stem-thickness (ly:grob-property stem 'thickness))
(thickness (/ stem-thickness 10))
(notecol (ly:grob-parent grob X))
(meta  (assoc 'other-grob (ly:grob-property notecol 'meta)))
(other (if meta
  (cdr meta)
  grob
  ))
(notehead-width (cdr (ly:grob-property grob 'X-extent)))
(sys (ly:grob-system grob))
(now-pos (ly:grob-extent grob sys X))
(next-pos (ly:grob-extent other sys X))

;;the offending lines
(now-pos-y (ly:grob-extent grob common Y))
(next-pos-y (ly:grob-extent other common Y))

(x-distance
(if (= stem-dir -1)
  (+ (- (get-distance now-pos next-pos)
notehead-width ) (/ thickness 2))
  (- (get-distance now-pos next-pos) (/ thickness 2))
))
(y-distance
(if (= stem-dir -1)
  (+ (- (get-distance now-pos-y next-pos-y)
notehead-width ) (/ thickness 2))
  (- (get-distance now-pos-y next-pos-y) (/ thickness 2))
))

;; alternative which takes input number
;(ps-bracket
;(if (= stem-dir -1)
;  (draw-ps-bracket x-distance notehead-width (-
value 0.5) thickness)
;  (draw-ps-bracket x-distance notehead-width
value thickness)
;))
(ps-bracket
(if (= stem-dir -1)
  (draw-ps-bracket x-distance notehead-width (-
y-distance 0.5) thickness)
  (draw-ps-bracket x-distance notehead-width
y-distance thickness)
))
(ps-line (draw-ps-line x-distance notehead-width thickness))
(grob-stencil (ly:grob-property grob 'stencil))
(stencil-bracket (ly:stencil-add grob-stencil ps-bracket ))
(stencil-line (ly:stencil-add grob-stencil ps-line))
)
(if (assoc 'is-lower-in-chord (ly:grob-property grob 'meta))
(ly:grob-set-property! grob 'stencil stencil-line)
(ly:grob-set-property! grob 'stencil stencil-bracket)
  )
  )
)
  #}
)

best,
greg

On Fri, Nov 18, 2022 at 5:22 AM Jean Abou Samra  wrote:

> Le 18/11/2022 à 00:29, Gregory Evans a écrit :
> >
> > Hi lilypond users,
> > I have a question about getting the Y position of a grob. I saw this
> > question has been asked previously but I could not find if it had been
> > answered. In the following example, an after-line-breaking function is
> > defined such that no change on the output should occur. The grob is
> > only queried with |(ly:grob-extent grob ... Y)| but this value is not
> > used. There is a difference in the vertical spacing between the staves
> > of the staff group based on whether this query is present or not. The
> > intention is to be able to query a grob for its Y position relative to
> > another grob in order to draw cross-staff spanners, where it is
> > necessary to calculate the distance between grobs not only on the X
> > axis but also on the Y axis. Here, the system is being used to
> > accurate

Re: Change in titling-init.ly and corresponding document

2022-11-18 Thread Jean Abou Samra
Le 18 nov. 2022 à 23:10, Eric Benson  a écrit :I'm testing 2.23.81 with my scores that have been working in 2.22.2, and I notice that the file titling-init.ly and the corresponding documentation page notation/custom-titles-headers-and-footers have changed a great deal. Is there any guidance available for how to change our scores from the old interface to the new interface? I've been using a solution derived from the example inhttps://music.stackexchange.com/questions/75802/lilypond-v2-19-how-do-i-add-a-title-to-the-second-page-of-the-same-scorewhich no longer works.
Please read the very top of https://lilypond.org/doc/v2.23/Documentation/changes/index.htmlBest,Jean

Change in titling-init.ly and corresponding document

2022-11-18 Thread Eric Benson
I'm testing 2.23.81 with my scores that have been working in 2.22.2, and I
notice that the file titling-init.ly and the corresponding documentation
page notation/custom-titles-headers-and-footers have changed a great deal.
Is there any guidance available for how to change our scores from the old
interface to the new interface? I've been using a solution derived from the
example in

https://music.stackexchange.com/questions/75802/lilypond-v2-19-how-do-i-add-a-title-to-the-second-page-of-the-same-score

which no longer works.


Re: Hide Notes but display Accidental

2022-11-18 Thread Rajesh Baskar

Hi Lukas,

Thanks for your help, this really worked and also thanks for the other 
recommendations.


On 11/17/2022 11:55 PM, Lukas-Fabian Moser wrote:

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: Hide Notes but display Accidental

2022-11-18 Thread Rajesh Baskar

Thanks that worked like a charm.

On 11/17/2022 11:02 PM, Rip _Mus wrote:

\version "2.22.0"
\include "english.ly "

newHideNotes = {
\override NoteHead.transparent = ##t
\override NoteHead.no-ledgers = ##t %optional
\override Stem.transparent = ##t
}

\header { tagline = "" }
\score {
\new Staff
\with {\remove "Time_signature_engraver" }
{
\set Staff.midiInstrument = #"Acoustic Grand Piano"

\key c \major \time 5/1 \clef bass

\newHideNotes

f1 g a bf c' \bar "||"}

\layout {
\context {
\Score proportionalNotationDuration = #(ly:make-moment 1/2)
}
 }
\midi { \tempo 1 = 72}
}

Re: Double lyrics in part of composition

2022-11-18 Thread Jogchum Reitsma

Hi David,

How simple! That did the trick, many thanks!

regards, Jogchum

Op 18-11-2022 om 18:08 schreef David Wright:

On Fri 18 Nov 2022 at 16:52:41 (+0100), Jogchum Reitsma wrote:

With the help of Frescobaldi, I try to set du Prez' El Grillo.

It has a two-verse piece in the middle, which I can't get right.

Iǘe added the jpeg of the piece to be set in lilypond, and the
.ly-file create so far.

Anyoane an idea how this might be coded in lilypond? Preferable
without disrupting the structure created b frescobaldi too much, but
I'm not sure that is possible.

Perhaps just set a second verse as normal, but with circa four
dozen skips at the start of the second verse lyrics. (The number
will likely need adjusting individually for each part.) The
\repeat unfold 48 _ construction saves typing.

Cheers,
David.






Re: Double lyrics in part of composition

2022-11-18 Thread David Wright
On Fri 18 Nov 2022 at 16:52:41 (+0100), Jogchum Reitsma wrote:
> 
> With the help of Frescobaldi, I try to set du Prez' El Grillo.
> 
> It has a two-verse piece in the middle, which I can't get right.
> 
> Iǘe added the jpeg of the piece to be set in lilypond, and the
> .ly-file create so far.
> 
> Anyoane an idea how this might be coded in lilypond? Preferable
> without disrupting the structure created b frescobaldi too much, but
> I'm not sure that is possible.

Perhaps just set a second verse as normal, but with circa four
dozen skips at the start of the second verse lyrics. (The number
will likely need adjusting individually for each part.) The
\repeat unfold 48 _ construction saves typing.

Cheers,
David.


Re: Checkpoints (was re: Adding durations (for \after))

2022-11-18 Thread Mark Knoop


At 11:01 on 18 Nov 2022, Kieren MacMillan wrote:
> Hi Jean,

>> Well, it's not too hard to implement them.

> In the hopes that it’s also not too hard for Super-Jean to implement
> anchors… ;)

> Is there a world in which one could write something like

> global = {
>   \anchor #'intro
>   s1*8
>   \anchor #'verse
>   s1*8
>   \anchor #'chorus
>   s1*8
> }

> and then

> chorusMusic = {
>   \gotoAnchor #'chorus
>   c'1
> }

> would make a whole note c' appear in the 17th measure of the score?

I have been using \alignTo for years for this purpose, I think originally from 
this thread:

https://lists.gnu.org/archive/html/lilypond-user/2013-12/msg01296.html



--
Mark Knoop



Re: Checkpoints (was re: Adding durations (for \after))

2022-11-18 Thread David Kastrup
Kieren MacMillan  writes:

> Hi Jean,
>
>> Well, it's not too hard to implement them.
>
> In the hopes that it’s also not too hard for Super-Jean to implement anchors… 
> ;)
>
> Is there a world in which one could write something like
>
> global = {
>   \anchor #'intro
>   s1*8
>   \anchor #'verse
>   s1*8
>   \anchor #'chorus
>   s1*8
> }
>
> and then
>
> chorusMusic = {
>   \gotoAnchor #'chorus
>   c'1
> }
>
> would make a whole note c' appear in the 17th measure of the score?

It takes an iterator to wait an unspecified amount of time, and those
can only be written in C++ right now.

There actually is some ancient local branch in my repository with a
sketch of an idea, but it likely doesn't work at all for anything.

But maybe it gives someone an idea...

>From 4f86263cb78f33ad56706f0f9b6668622c417870 Mon Sep 17 00:00:00 2001
From: David Kastrup 
Date: Fri, 17 Jul 2015 17:23:17 +0200
Subject: [PATCH] Create a wait music function.

---
 lily/wait-iterator.cc  | 112 +
 ly/music-functions-init.ly |  11 
 scm/define-music-types.scm |   6 ++
 3 files changed, 129 insertions(+)
 create mode 100644 lily/wait-iterator.cc

diff --git a/lily/wait-iterator.cc b/lily/wait-iterator.cc
new file mode 100644
index 00..939ba34c9b
--- /dev/null
+++ b/lily/wait-iterator.cc
@@ -0,0 +1,112 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2016 David Kastrup 
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see .
+*/
+
+#include "lily-guile.hh"
+#include "context.hh"
+#include "input.hh"
+#include "international.hh"
+#include "moment.hh"
+#include "music.hh"
+#include "music-iterator.hh"
+
+class Wait_iterator : public Music_wrapper_iterator
+{
+  bool triggered_;
+  SCM procedure_;
+protected:
+  virtual void derived_mark () const;
+  virtual Moment pending_moment () const;
+  virtual void process (Moment);
+  virtual bool ok () const;
+  virtual bool run_always () const;
+public:
+  Wait_iterator ();
+  DECLARE_SCHEME_CALLBACK (constructor, ());
+  virtual void construct_children ();
+};
+
+Wait_iterator::Wait_iterator ()
+  : triggered_ (false), procedure_ (SCM_UNDEFINED)
+{
+}
+
+void
+Wait_iterator::derived_mark () const
+{
+  scm_gc_mark (procedure_);
+}
+
+Moment
+Wait_iterator::pending_moment () const
+{
+  if (triggered_)
+return Moment (0);
+  Moment m;
+  m.set_infinite (1);
+  return m;
+}
+
+bool
+Wait_iterator::run_always () const
+{
+  return triggered
+|| !Music_wrapper_iterator::ok ()
+|| Music_wrapper_iterator::run_always ();
+}
+  
+void
+Wait_iterator::process (Moment m)
+{
+  if (triggered_)
+return;
+  if (scm_is_true (scm_call_1 (procedure_, get_outlet ()->self_scm (
+{
+  triggered_ = true;
+  return;
+}
+  if (!Music_wrapper_iterator::ok ())
+{
+  Music_wrapper_iterator::construct_children ();
+  if (!Music_wrapper_iterator::ok ())
+return;
+}
+  Music_wrapper_iterator::process (m);
+}
+
+bool
+Wait_iterator::ok () const
+{
+  return !triggered_;
+}
+
+void
+Wait_iterator::construct_children ()
+{
+  procedure_ = get_music ()->get_property ("procedure");
+  if (!ly_is_procedure (procedure_))
+{
+  get_music ()->origin ()->warning (_ ("Bad procedure"));
+  triggered_ = true;
+  return;
+}
+
+  Music_iterator::construct_children ();
+}
+
+IMPLEMENT_CTOR_CALLBACK (Wait_iterator)
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index aaea08d83f..b74fc11a14 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -2226,6 +2226,17 @@ vshape =
 ease of tweaking."
(once (propertyTweak 'show-control-points #t (shape offsets item
 
+waitFor =
+#(define-music-function (music) (ly:music?)
+   (_i "Wait for the occurence of the given @var{music} in the
+current context.  Use it, for example, as
+@example
+\\context Score \\waitFor \\mark "A"
+@end example
+")
+   (make-music 'WaitMusic
+   'element music))
+
 withMusicProperty =
 #(define-music-function (sym val music)
(symbol? scheme? ly:music?)
diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm
index e61667de3c..97b7b93e7e 100644
--- a/scm/define-music-types.scm
+++ b/scm/define-music-types.scm
@@ -913,6 +913,12 @@ brackets start and stop.")
 (start-callback . ,ly:music-wrapper::start-callback)
 (types . (volta-specification music-wr

Re: Checkpoints (was re: Adding durations (for \after))

2022-11-18 Thread Kieren MacMillan
Hi Jean,

> Well, it's not too hard to implement them.

In the hopes that it’s also not too hard for Super-Jean to implement anchors… ;)

Is there a world in which one could write something like

global = {
  \anchor #'intro
  s1*8
  \anchor #'verse
  s1*8
  \anchor #'chorus
  s1*8
}

and then

chorusMusic = {
  \gotoAnchor #'chorus
  c'1
}

would make a whole note c' appear in the 17th measure of the score?

Thanks,
Kieren.


Double lyrics in part of composition

2022-11-18 Thread Jogchum Reitsma

Hi,

With the help of Frescobaldi, I try to set du Prez' El Grillo.

It has a two-verse piece in the middle, which I can't get right.

Iǘe added the jpeg of the piece to be set in lilypond, and the .ly-file 
create so far.


Anyoane an idea how this might be coded in lilypond? Preferable without 
disrupting the structure created b frescobaldi too much, but I'm not 
sure that is possible.


Thanks for any help in advance!

regards, Jogchum Reitsma




Re: Checkpoints (was re: Adding durations (for \after))

2022-11-18 Thread Jean Abou Samra

Le 17/11/2022 à 17:50, Joel C. Salomon a écrit :
Yes.  And I already have tags for MIDI vs print output, so I can give 
different checks for the version with unrolled repeats.


A complication is that I've copied the piece so it produces scoreA, 
scoreB, scoreC, and a combined scoreABC, and it's only in the long 
combined score that I'm getting trouble; and I guess I can try adding 
another tag group.  But everything *looks* visually in the right bars


Checkpoints would also allow for finer granularity.  But now that I've 
thought my way through how to use `\barNumberCheck`, I'll try the tool 
I actually have rather than wishing for a tool that doesn't exist.




Well, it's not too hard to implement them.



\version "2.23.81"

#(define-event-class 'event 'StreamEvent) % cough, how is this supposed 
to work?


checkpoint =
#(define-music-function (label) (symbol?)
   (make-music 'Event 'checkpoint label))

\layout {
  \context {
    \Score
    \consists
  #(lambda (context)
 (let ((seen (make-hash-table))
   (new (make-hash-table))
   (warned (make-hash-table)))
   (make-engraver
    (listeners
 ((event engraver event)
  (let ((checkpoint (ly:event-property event 'checkpoint #f)))
    (when checkpoint
  (let ((previous-ev (hashq-ref seen checkpoint)))
    (if previous-ev
    (when (not (hashq-ref warned checkpoint))
  (ly:event-warning
   event
   "checkpoint ~a already seen at an earlier point"
   checkpoint)
  (ly:event-warning
   previous-ev
   "first seen here")
  (hashq-set! warned checkpoint #t))
    (hashq-set! new checkpoint event)))
    ((stop-translation-timestep engraver)
 (hash-for-each
  (lambda (k v)
    (hashq-set! seen k v))
  new)
 (hash-clear! new)
  }
}

<<
  \new Staff {
    c'1 \checkpoint A c'1 c'1 \checkpoint B c'1 c'1 \checkpoint C
  }
  \new Staff {
    e'1 \checkpoint A e'1 e'1 \checkpoint B c'1 \checkpoint C c'1
  }
  \new Staff {
    c'1 \checkpoint A c'1 \checkpoint B c'1 \checkpoint C c'1 c'1
  }
>>




Best,
Jean



OpenPGP_signature
Description: OpenPGP digital signature


Re: Getting grob Y position (spacing error)

2022-11-18 Thread Jean Abou Samra

Le 18/11/2022 à 00:29, Gregory Evans a écrit :


Hi lilypond users,
I have a question about getting the Y position of a grob. I saw this 
question has been asked previously but I could not find if it had been 
answered. In the following example, an after-line-breaking function is 
defined such that no change on the output should occur. The grob is 
only queried with |(ly:grob-extent grob ... Y)| but this value is not 
used. There is a difference in the vertical spacing between the staves 
of the staff group based on whether this query is present or not. The 
intention is to be able to query a grob for its Y position relative to 
another grob in order to draw cross-staff spanners, where it is 
necessary to calculate the distance between grobs not only on the X 
axis but also on the Y axis. Here, the system is being used to 
accurately get the X position, but using the system to get the Y 
position triggers this spacing error but appears to return the correct 
position before the spacing shift.





Because you are requesting it in after-line-breaking, which is earlier
than LilyPond can provide it to you. At this point of the compilation,
line breaking has just happened and page spacing (vertical spacing
of systems and staves in each system) has not happened yet. The
next thing LilyPond will do is computing the skylines (outlines) of the
staves in order to be able to space them. If you ask for the offset of some
staff relative to the system, it triggers these things prematurely
while they're not ready.

If you are writing a stencil callback, it is usually not OK to ask
for the coordinate of a staff relative to the whole system, because
it is a cyclic dependency: the coordinate depends on the spacing,
which depends on the outline, which depends on the stencil of your
grob. However, for cross-staff grobs, it is necessary, so if you
are writing one, you need to \override YourGrob.cross-staff = ##t,
and then LilyPond will completely ignore it for vertical spacing
purposes, and the stencil callback will only be run at a later point
where vertical spacing is already done.


\version "2.23.81"

\language "english"

#(set-global-staff-size 12)

\score {
    <<
    \new Staff {
    %% See what weird things happen to the beam if it's not
    %% properly marked cross-staff.
    \override Beam.cross-staff = ##f
    c'8[
    \change Staff = down
    c''8]
    }
    \new Staff = down {
    s4
    }
    >>
}


Best,
Jean





OpenPGP_signature
Description: OpenPGP digital signature