Re: music starting with afterGrace breaks layout

2017-02-28 Thread David Kastrup
David Kastrup  writes:

> Thomas Morley  writes:
>
>> 2017-02-22 18:44 GMT+01:00 Klaus Rettinghaus
>> :
>>> Hi there,
>>>
>>> when the music starts with an \afterGrace the layout is broken:
>>>
>>> \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }
>>>
>>>
>>> You have to put something before that to make it work:
>>> \relative { \time 2/4 s2*0 \afterGrace g'2 { f8[ g] } f2 }
>>>
>>> This is present in 2.18.2. and 2.19.55 (Mac).
>>>
>>> Cheers,
>>> Klaus
>>
>> Hi Klaus,
>>
>> thanks for the report.
>>
>> \afterGrace returns simultaneous music.
>> If no context exists before, LilyPond creates them. In the case of
>> afterGrace Staves for each musical expression in the created list.
>> Another example would be: << c c >>
>>
>> So I don't think it qualifies as a bug, but expected (though
>> undesired) behaviour. Not sure whether it's fixable in the
>> afterGrace-definition.
>
> Easy enough: wrap a (descend-to-context ... 'Bottom) around its
> definition.  However, this breaks \displayLilyMusic in bewildering ways.
>
> Still trying to figure out what's happening there.

Tracker issue: 5079 (https://sourceforge.net/p/testlilyissues/issues/5079/)
Rietveld issue: 314590043 (https://codereview.appspot.com/314590043)
Issue description:
  Let \afterGrace start a Bottom context  Previously, an \afterGrace
  as the first expression of music outside of an existing Bottom
  context caused quite weird results.   Also contains commits:  with-
  music-match: lists should match completely  Previously music
  properties that were matched to a list of wildcards could contain
  fewer elements than the list they were matched to, leading to an
  error when the wildcard variable was being assigned to.  Now the
  list lengths have to be matched exactly: a shorter pattern than the
  actual list length of the matched property cannot match any more.
  Fix \displayLilyMusic \partcombine...  Strictly speaking this
  oversight in issue 4356 did not actually manifest itself as a bug
  because of another bug masking it.

-- 
David Kastrup

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


Re: music starting with afterGrace breaks layout

2017-02-28 Thread David Kastrup
David Kastrup  writes:

> Easy enough: wrap a (descend-to-context ... 'Bottom) around its
> definition.  However, this breaks \displayLilyMusic in bewildering ways.
>
> Still trying to figure out what's happening there.

Here is the minimal breaking example (should break with pretty much
every version):

\displayLilyMusic #(make-music 'GraceMusic 'element #{ {} #})


I assume that this is a bug in the internals of with-music-match but
it's not exactly easy to track down.

-- 
David Kastrup
___
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond


Re: music starting with afterGrace breaks layout

2017-02-22 Thread David Kastrup
Thomas Morley  writes:

> 2017-02-22 23:08 GMT+01:00 David Kastrup :
>
>> Easy enough: wrap a (descend-to-context ... 'Bottom) around its
>> definition.  However, this breaks \displayLilyMusic in bewildering ways.
>
>
> Doing so, i.e.:
>
> afterGrace =
> #(define-music-function (fraction main grace) ((fraction?) ly:music? 
> ly:music?)
>(_i "Create @var{grace} note(s) after a @var{main} music expression.
>
> The musical position of the grace expression is after a
> given fraction of the main note's duration has passed.  If
> @var{fraction} is not specified as first argument, it is taken from
> @code{afterGraceFraction} which has a default value of @code{3/4}.")
>(let ((main-length (ly:music-length main))
>  (fraction (or fraction (ly:parser-lookup 'afterGraceFraction
> (descend-to-context
>  (make-simultaneous-music
>   (list
>main
>(make-sequential-music
> (list
>
>  (make-music 'SkipMusic
>  'duration (ly:make-duration
> 0 0
> (* (ly:moment-main main-length)
>(/ (car fraction) (cdr fraction)
>  (make-music 'GraceMusic
>  'element grace)
>  'Bottom)))
>
> \displayLilyMusic \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }
>
> returns:
>
> { \time 2/4
>   \context Bottom \afterGrace g'2 { f'8[ g'8] } f'2 }
>
> Is this not correct?

No, it isn't.  Because the original input did not contain \context
Bottom.  Now outcomment the definition in
scm/define-music-display-methods.scm for \afterGrace.  This should make
the original definition of \afterGrace surface when using
\displayLilyMusic in the above manner, but it rather bombs out with
strange errors:

Backtrace:
In /usr/local/tmp/lilypond/out/share/lilypond/current/scm/display-lily.scm:
 105: 56  (let* (# # #) (if result-string # #))
 109: 57* (and procs (any (lambda (proc) (proc expr)) procs))
 109: 58  [any # (# #)]
In 
/usr/local/tmp/lilypond/out/share/lilypond/current/scm/define-music-display-methods.scm:
...
 338: 59  [format #f "~a~a{~v%~v_~{~a~^ ~}~v%~v_}" "" "" 0 1 ...
 374: 60*  [with-parameters* (#) (7) ...]
In /usr/share/guile/1.8/srfi/srfi-39.scm:
 112: 61   [more (#) (7) ...]
 ...
 119: 62   [with-fluids* (#) (7) #]
In unknown file:
   ?: 63*  [#]
   ?: 64*  [map-in-order # (# #)]
   ?: 65*  [# #]
   ?: 66*  [music->lily-string #]
In /usr/local/tmp/lilypond/out/share/lilypond/current/scm/display-lily.scm:
 104: 67   (if (ly:music? expr) (let* (# # #) (if result-string # ...)) ...)
 105: 68   (let* (# # #) (if result-string # #))
 109: 69*  (and procs (any (lambda (proc) (proc expr)) procs))
 109: 70   [any # #]
In /usr/share/guile/1.8/srfi/srfi-1.scm:
 ...
 459: 71   (or (pred (car ls)) (lp (cdr ls)))
 459: 72*  [# #]
In /usr/local/tmp/lilypond/out/share/lilypond/current/scm/display-lily.scm:
 110: 73   [# #]
In unknown file:
 ...
   ?: 74   (let ((?start #) (?music #) (?stop #)) (and (null? #) (null? #) ...))
   ?: 75*  [list-ref (# #) {2}]

: In procedure list-ref in expression (list-ref 
(ly:music-property # #) 2):
: Argument 2 out of range: 2

Basically this seems to trigger the code responsible for recognizing
\appoggiatura et al, and that indexes some list beyond its limits.  It
should have been possible to trigger this error previously (not
everything falling through this test would have looked like an
\afterGrace) but I have no idea how.

-- 
David Kastrup

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


Re: music starting with afterGrace breaks layout

2017-02-22 Thread Thomas Morley
2017-02-22 23:08 GMT+01:00 David Kastrup :

> Easy enough: wrap a (descend-to-context ... 'Bottom) around its
> definition.  However, this breaks \displayLilyMusic in bewildering ways.


Doing so, i.e.:

afterGrace =
#(define-music-function (fraction main grace) ((fraction?) ly:music? ly:music?)
   (_i "Create @var{grace} note(s) after a @var{main} music expression.

The musical position of the grace expression is after a
given fraction of the main note's duration has passed.  If
@var{fraction} is not specified as first argument, it is taken from
@code{afterGraceFraction} which has a default value of @code{3/4}.")
   (let ((main-length (ly:music-length main))
 (fraction (or fraction (ly:parser-lookup 'afterGraceFraction
(descend-to-context
 (make-simultaneous-music
  (list
   main
   (make-sequential-music
(list

 (make-music 'SkipMusic
 'duration (ly:make-duration
0 0
(* (ly:moment-main main-length)
   (/ (car fraction) (cdr fraction)
 (make-music 'GraceMusic
 'element grace)
 'Bottom)))

\displayLilyMusic \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }

returns:

{ \time 2/4
  \context Bottom \afterGrace g'2 { f'8[ g'8] } f'2 }

Is this not correct?

Cheers,
  Harm

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


Re: music starting with afterGrace breaks layout

2017-02-22 Thread David Kastrup
Thomas Morley  writes:

> 2017-02-22 18:44 GMT+01:00 Klaus Rettinghaus
> :
>> Hi there,
>>
>> when the music starts with an \afterGrace the layout is broken:
>>
>> \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }
>>
>>
>> You have to put something before that to make it work:
>> \relative { \time 2/4 s2*0 \afterGrace g'2 { f8[ g] } f2 }
>>
>> This is present in 2.18.2. and 2.19.55 (Mac).
>>
>> Cheers,
>> Klaus
>
> Hi Klaus,
>
> thanks for the report.
>
> \afterGrace returns simultaneous music.
> If no context exists before, LilyPond creates them. In the case of
> afterGrace Staves for each musical expression in the created list.
> Another example would be: << c c >>
>
> So I don't think it qualifies as a bug, but expected (though
> undesired) behaviour. Not sure whether it's fixable in the
> afterGrace-definition.

Easy enough: wrap a (descend-to-context ... 'Bottom) around its
definition.  However, this breaks \displayLilyMusic in bewildering ways.

Still trying to figure out what's happening there.

-- 
David Kastrup

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


Re: music starting with afterGrace breaks layout

2017-02-22 Thread Thomas Morley
2017-02-22 18:44 GMT+01:00 Klaus Rettinghaus
:
> Hi there,
>
> when the music starts with an \afterGrace the layout is broken:
>
> \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }
>
>
> You have to put something before that to make it work:
> \relative { \time 2/4 s2*0 \afterGrace g'2 { f8[ g] } f2 }
>
> This is present in 2.18.2. and 2.19.55 (Mac).
>
> Cheers,
> Klaus

Hi Klaus,

thanks for the report.

\afterGrace returns simultaneous music.
If no context exists before, LilyPond creates them. In the case of
afterGrace Staves for each musical expression in the created list.
Another example would be: << c c >>

So I don't think it qualifies as a bug, but expected (though
undesired) behaviour. Not sure whether it's fixable in the
afterGrace-definition.

Easiest workaround would be to explicitely declare a context:
\new Voice \relative { \time 2/4 \afterGrace g'2 { f8[ g] } f2 }

Cheers,
  Harm

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