Re: Accidental style in presence of mid-bar line breaks.

2018-06-28 Thread Richard Shann
On Thu, 2018-06-28 at 14:52 +0100, Richard Shann wrote:
> On Thu, 2018-06-28 at 09:09 +0100, Richard Shann wrote:
> > On Wed, 2018-06-27 at 17:00 +0200, Simon Albrecht wrote:
> > > On 26.06.2018 09:11, Richard Shann wrote:
> > > > In this connection, I noticed that LilyPond skips printing the
> > > > bar
> > > > number at the beginning of each line if the bar is being split
> > > > over
> > > > a
> > > > line.
> > > 
> > > That’s configurable:
> > > 
> > > %%%
> > > \version "2.19.80"
> > > 
> > > \layout {
> > >    \context {
> > >  \Score
> > >  barNumberVisibility = #(every-nth-bar-number-visible 1)
> > >  \override BarNumber.break-visibility = #begin-of-line-
> > > visible
> > >    }
> > > }
> > > 
> > > {
> > >    1 2 \bar "" \break 2
> > > }
> > > %%%
> > > 
> > 
> > Thanks - that's useful, I've added it to Denemo's "Allow breaks at
> > half
> > bar" command. It also suggests that if I look for where the
> > parenthesized measure numbers are generated in LilyPond's sources I
> > might be able to trigger a warning to the user that a bar has been
> > broken, and they (or Denemo) can look for possible repeat
> > accidentals
> > to add.
> 
> I've had a go at finding where the "(" is added to the bar number
> markup and found that 
> 
> \version "2.19.43"
> 
> #(define-public ((every-nth-bar-number-visible n) barnum mp)
>    (display "\n\n\nhello\n\n\n")
>   (= 0 (modulo barnum n)))
> 
> \layout {
>    \context {
>  \Score
>  barNumberVisibility = #(every-nth-bar-number-visible 1)
>  \override BarNumber.break-visibility = #begin-of-line-visible
>    }
> }
> 
> {
>    a1 a2 \bar "" \break a2
> }
> 
> Does issue "hello" on standard out, so I could issue a warning there,
> but the only place the "(" seems to be added is at
> 
> (define-public (robust-bar-number-function ...)
> 
> in scm/translation-functions.scm 
> 
> and this procedure does *not* seemed to be called in compiling that
> example. Anyone any clues about where in the source code the "(" is
> added to a bar numbering?

Ha!
I find that the following code

\version "2.19.43"

#(define-public ((every-nth-bar-number-visible n) barnum mp)
   (if (positive? (ly:moment-main-numerator mp))
   (format #t "Warning bar ~A is broken\n" barnum))
  (= 0 (modulo barnum n)))

\layout {
   \context {
 \Score
 barNumberVisibility = #(every-nth-bar-number-visible 1)
 \override BarNumber.break-visibility = #begin-of-line-visible
   }
}

{
  
   a1 a2 \bar "" \break a2  a1  
}

Gives the needed warning when a bar is broken, but I guess it is not
going to be possible to identify which \score {} block the mid bar
break occurred ... The user knows a bar number n has been broken, but
not which movement that was in.

Richard






___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-28 Thread Richard Shann
On Thu, 2018-06-28 at 09:09 +0100, Richard Shann wrote:
> On Wed, 2018-06-27 at 17:00 +0200, Simon Albrecht wrote:
> > On 26.06.2018 09:11, Richard Shann wrote:
> > > In this connection, I noticed that LilyPond skips printing the
> > > bar
> > > number at the beginning of each line if the bar is being split
> > > over
> > > a
> > > line.
> > 
> > That’s configurable:
> > 
> > %%%
> > \version "2.19.80"
> > 
> > \layout {
> >    \context {
> >  \Score
> >  barNumberVisibility = #(every-nth-bar-number-visible 1)
> >  \override BarNumber.break-visibility = #begin-of-line-visible
> >    }
> > }
> > 
> > {
> >    1 2 \bar "" \break 2
> > }
> > %%%
> > 
> 
> Thanks - that's useful, I've added it to Denemo's "Allow breaks at
> half
> bar" command. It also suggests that if I look for where the
> parenthesized measure numbers are generated in LilyPond's sources I
> might be able to trigger a warning to the user that a bar has been
> broken, and they (or Denemo) can look for possible repeat accidentals
> to add.

I've had a go at finding where the "(" is added to the bar number
markup and found that 

\version "2.19.43"

#(define-public ((every-nth-bar-number-visible n) barnum mp)
   (display "\n\n\nhello\n\n\n")
  (= 0 (modulo barnum n)))

\layout {
   \context {
 \Score
 barNumberVisibility = #(every-nth-bar-number-visible 1)
 \override BarNumber.break-visibility = #begin-of-line-visible
   }
}

{
   a1 a2 \bar "" \break a2
}

Does issue "hello" on standard out, so I could issue a warning there,
but the only place the "(" seems to be added is at

(define-public (robust-bar-number-function ...)

in scm/translation-functions.scm 

and this procedure does *not* seemed to be called in compiling that
example. Anyone any clues about where in the source code the "(" is
added to a bar numbering?

Richard



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-28 Thread Richard Shann
On Wed, 2018-06-27 at 17:00 +0200, Simon Albrecht wrote:
> On 26.06.2018 09:11, Richard Shann wrote:
> > In this connection, I noticed that LilyPond skips printing the bar
> > number at the beginning of each line if the bar is being split over
> > a
> > line.
> 
> That’s configurable:
> 
> %%%
> \version "2.19.80"
> 
> \layout {
>    \context {
>  \Score
>  barNumberVisibility = #(every-nth-bar-number-visible 1)
>  \override BarNumber.break-visibility = #begin-of-line-visible
>    }
> }
> 
> {
>    1 2 \bar "" \break 2
> }
> %%%
> 

Thanks - that's useful, I've added it to Denemo's "Allow breaks at half
bar" command. It also suggests that if I look for where the
parenthesized measure numbers are generated in LilyPond's sources I
might be able to trigger a warning to the user that a bar has been
broken, and they (or Denemo) can look for possible repeat accidentals
to add.

Richard


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-27 Thread Simon Albrecht

On 26.06.2018 09:11, Richard Shann wrote:

In this connection, I noticed that LilyPond skips printing the bar
number at the beginning of each line if the bar is being split over a
line.


That’s configurable:

%%%
\version "2.19.80"

\layout {
  \context {
    \Score
    barNumberVisibility = #(every-nth-bar-number-visible 1)
    \override BarNumber.break-visibility = #begin-of-line-visible
  }
}

{
  1 2 \bar "" \break 2
}
%%%

Best, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-26 Thread Richard Shann
On Mon, 2018-06-25 at 22:48 +0200, Simon Albrecht wrote:
> On 25.06.2018 13:25, Richard Shann wrote:
> > In 18th c. mss and prints it is quite common to create line breaks
> > during bars - I've found this much improves the legibility of some
> > florid slow movements.
> > 
> > However, it seems that the available accidental styles only take
> > account of barlines and ignore line breaks,
> 
> It’s not what you ask for, but of course in the 18th century
> accidentals 
> generally pertained only to one note and its immediate repetitions – 
> with exceptions according to common sense. Except for the exceptions 
> this can be modelled very well using a LilyPond accidental style –
> see 
> attachment.

Thank you very much for this code - it affords a good guide to the sort
of thing you can do to add accidental styles.  

As you observe it's not what I asked for, going rather in the direction
of mimicking old prints rather than easing the task for the modern
reader of the old music. (OT : I've had fun playing from facsimiles and
the biggest problems are not accidental style but the lack of alignment
of parts between barlines and - killer - the joining up of ledger lines
which makes the top line of the staff appear higher than it is.
Evidence that until the 19th c. musicians played by interval rather
than position - see https://www.jstor.org/stable/841141?refreqid=robots
txt-
sitemaps:b3d7f2442648678c96dec5651ef07226=1#page_scan_tab_contents
for this old story).

Anyway, back to the topic: even if it's not possible to coax LilyPond
to flag up when it takes advantage of \bar "" to break a line, it would
help if it could emit a list of line-breaks - in what form I'm not sure
- that could be post-processed to determine if an a bar was split. (For
example if it could print the bar number before and after each line
break). 

In this connection, I noticed that LilyPond skips printing the bar
number at the beginning of each line if the bar is being split over a
line. This is better than the behavior you can see in another program
(Finale? Sib?) at 
https://imslp.org/wiki/Special:ImagefromIndex/323673
where the split bar gets assigned *two* bar numbers!

Thanks again for your engagement in this problem!

Richard


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-25 Thread Simon Albrecht

On 25.06.2018 13:25, Richard Shann wrote:

In 18th c. mss and prints it is quite common to create line breaks
during bars - I've found this much improves the legibility of some
florid slow movements.

However, it seems that the available accidental styles only take
account of barlines and ignore line breaks,


It’s not what you ask for, but of course in the 18th century accidentals 
generally pertained only to one note and its immediate repetitions – 
with exceptions according to common sense. Except for the exceptions 
this can be modelled very well using a LilyPond accidental style – see 
attachment.


Best, Simon
\version "2.19.35"
%% LOCAL FUNCTIONS FROM scm/music-functions.scm
%%{
#(define (key-entry-notename entry)
   "Return the pitch of an @var{entry} in @code{localKeySignature}.
  The @samp{car} of the entry is either of the form @code{notename} or
of the form @code{(octave . notename)}.  The latter form is used for special
key signatures or to indicate an explicit accidental.

The @samp{cdr} of the entry is either a rational @code{alter} indicating
a key signature alteration, or of the form
@code{(alter . (barnum . measurepos))} indicating an alteration caused by
an accidental in music."
   (if (pair? (car entry))
   (cdar entry)
   (car entry)))

#(define (key-entry-octave entry)
   "Return the octave of an entry in @code{localKeySignature}
  or @code{#f} if the entry does not have an octave.
See @code{key-entry-notename} for details."
   (and (pair? (car entry)) (caar entry)))

#(define (key-entry-alteration entry)
   "Return the alteration of an entry in localAlterations

For convenience, returns @code{0} if entry is @code{#f}."
   (if entry
   (if (number? (cdr entry))
   (cdr entry)
   (cadr entry))
   0))

#(define (key-entry-bar-number entry)
   "Return the bar number of an entry in @code{localKeySignature}
  or @code {#f} if the entry does not have a bar number.
See @code{key-entry-notename} for details."
   (and (pair? (cdr entry)) (caddr entry)))

#(define (key-entry-measure-position entry)
   "Return the measure position of an entry in @code{localKeySignature}
  or @code {#f} if the entry does not have a measure position.
See @code{key-entry-notename} for details."
   (and (pair? (cdr entry)) (cdddr entry)))
%}

#(define-public (find-pitch-entry keysig pitch accept-global accept-local . oi)
   "Return the first entry in @var{keysig} that matches @var{pitch}
by notename and octave (or only notename if @var{oi} is set to @code{#t}).
Alteration is not considered.
@var{accept-global} states whether key signature entries should be included.
@var{accept-local} states whether local accidentals should be included.
If no matching entry is found, @var{#f} is returned."
   (and (pair? keysig)
(let* ((entry (car keysig))
   (entryoct (key-entry-octave entry))
   (entrynn (key-entry-notename entry))
   (nn (ly:pitch-notename pitch))
   ;; When in doubt, use octave-sensitive form
   (octave-insensitive (if (eq? oi '()) #f oi)))
  (if (and (equal? nn entrynn)
   (or (not entryoct)
   (= entryoct (ly:pitch-octave pitch))
   octave-insensitive)
   (if (key-entry-bar-number entry)
   accept-local
   accept-global))
  entry
  (find-pitch-entry (cdr keysig) pitch accept-global accept-local 
oi)

%%% END COPIED STUFF 

#(define-public (baroque-rule context pitch barnum measurepos)
   "An accidental rule to simulate the practice in 18th century manuscripts and
prints. Don’t remember local accidentals, except with immediate repetitions
(disregarding barlines) and chromatic steps.
Will cease to work properly after time signature changes (if they change 
@var{measureLength})."
   ;; 18th century practice is somewhat inconsistent, so it’s impossible to
   ;; handle all cases in an automated manner.  This is especially true
   ;; for pitches repeated with only one note inbetween.
   ;; But there is no mechanism for that anyway.
   (let* ((keysig (ly:context-property context 'localAlterations))
  (global-entry (find-pitch-entry keysig pitch #t #f))
  (local-entry (find-pitch-entry keysig pitch #f #t #t))

  (ml (ly:context-property context 'measureLength))
  (ml-main (ly:moment-main ml))
  (total-pos (let* ((measurepos-main (ly:moment-main measurepos))
(total-main (+ (* barnum ml-main) measurepos-main))
(measurepos-grace (ly:moment-grace measurepos)))
   (ly:make-moment total-main measurepos-grace)))

  (entrymp (if local-entry (key-entry-measure-position local-entry)))
  (entrybn (if local-entry (key-entry-bar-number local-entry)))
  (entry-total-pos (if local-entry
 

Re: Accidental style in presence of mid-bar line breaks.

2018-06-25 Thread Richard Shann
On Mon, 2018-06-25 at 13:53 +0200, David Kastrup wrote:
> Richard Shann  writes:
> 
> > In 18th c. mss and prints it is quite common to create line breaks
> > during bars - I've found this much improves the legibility of some
> > florid slow movements.
> > 
> > However, it seems that the available accidental styles only take
> > account of barlines and ignore line breaks, which is not very
> > practical, since the brain, seeing a start of line with key
> > signature
> > and a note following without any accidental, will naturally play
> > the
> > note according to the key signature, not holding over any
> > accidental
> > from earlier in the bar on the previous line.
> > 
> > I don't know if this is covered in Gould, but it would be nice if
> > LilyPond could handle this.
> 
> LilyPond's accidental styles are not sufficiently married with the
> line
> breaking decisions to allow for this. 

Ah, I suspected this might be so. I wonder if it would be possible to
alert the user if the \bar "" invitation to create a line break had
been taken up by LilyPond? If LilyPond issued some message then the use
would only need to examine those bars that had actually been broken to
tidy up (with the inevitable danger that the tidying up may cause the
line-breaking to change!).
Is there some hook-point where such a warning could be issued?

Richard


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Accidental style in presence of mid-bar line breaks.

2018-06-25 Thread David Kastrup
Richard Shann  writes:

> In 18th c. mss and prints it is quite common to create line breaks
> during bars - I've found this much improves the legibility of some
> florid slow movements.
>
> However, it seems that the available accidental styles only take
> account of barlines and ignore line breaks, which is not very
> practical, since the brain, seeing a start of line with key signature
> and a note following without any accidental, will naturally play the
> note according to the key signature, not holding over any accidental
> from earlier in the bar on the previous line.
>
> I don't know if this is covered in Gould, but it would be nice if
> LilyPond could handle this.

LilyPond's accidental styles are not sufficiently married with the line
breaking decisions to allow for this.  In fact, LilyPond already has
problems with treating ties over line breaks at barlines: it does repeat
the accidental after the line break in that case but then fails to omit
it for any following occurence of it (there is some issue for that).
The basic accidental style mechanism does not actually include line
breaks: this particular case is already handled as an (incomplete) hack
afterwards.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Accidental style in presence of mid-bar line breaks.

2018-06-25 Thread Richard Shann
In 18th c. mss and prints it is quite common to create line breaks
during bars - I've found this much improves the legibility of some
florid slow movements.

However, it seems that the available accidental styles only take
account of barlines and ignore line breaks, which is not very
practical, since the brain, seeing a start of line with key signature
and a note following without any accidental, will naturally play the
note according to the key signature, not holding over any accidental
from earlier in the bar on the previous line.

I don't know if this is covered in Gould, but it would be nice if
LilyPond could handle this.

Richard



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user