Re: Aleatoric / modern notation

2012-12-08 Thread David Nalesnik
Hi Jeffrey,

I'm copying this to the list since I myself am not sure about something here.

On Sat, Dec 8, 2012 at 5:13 AM, Jeffrey Trevino
 wrote:
> Hi David,
>
> Thanks for revising this more for me. I really appreciate your efforts, and
> I will take a look at this asap and write back. For my learning, could you
> please explain what exactly you changed between versions 4 and 5 that got it
> working in parallel?
>

Well, I must say that I was a bit mystified by this, and I don't
understand why the original form wouldn't work on multiple staves.

I spent a good deal of time trying to figure out the sequence of the
various "methods" within the engraver--i.e., when is "process-music"
called in relation to "listeners" and "acknowledgers".  The order
these methods appear is not necessarily the order in which they are
called in a timestep, and a method may be called more than once within
a single timestep--process-music, for example.  You have to understand
the sequence to know what information you have to work with at any
given time.  (For example, process-music will be called in a timestep
before any grobs are "acknowledged" and afterwards as well.  Trying to
work with grobs that aren't there yet necessitates some sort of check,
so you don't get errors.)

I don't see any problem with the engraver here.

I did notice something which I can't account for.  You'll notice that
`frameEngraver4.ly' uses a variable "event-drul".  When a frame-event
is heard (created by \frameStart/\frameEnd), that event is stored in
this variable.  I then use the contents of this variable to determine
what to do: start a frame, end a frame, create a stub (for spacing) at
the beginning, create a stub at the end.

This doesn't work here, and I don't know why.  The version of the
engraver I last sent you substitutes a system of setting variables
called "stop?" and "go?" to control the steps.  It works.  BUT... when
you substitute the earlier method, it doesn't work. I've attached this
simple substitution so you can see what I mean. (The "ignoring weird
minimum distance" stems from the fact that a FrameStub has nothing in
its 'elements array--it should contain the last grobs within the
frame--this info is used for assessing its dimensions).

[If anyone reading this knows how to get the event-storing method how
to work, please let me know.  This seems to be a better technique.]

I hope this is useful...

-David


frameEngraver_why_wont_this_work.ly
Description: Binary data
___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Aleatoric / modern notation

2012-12-08 Thread David Nalesnik
Hi again,

On Sat, Dec 8, 2012 at 7:21 AM, David Nalesnik  wrote:
> Hi Jeffrey,
>
> I'm copying this to the list since I myself am not sure about something here.
>
> On Sat, Dec 8, 2012 at 5:13 AM, Jeffrey Trevino
>  wrote:
>> Hi David,
>>
>> Thanks for revising this more for me. I really appreciate your efforts, and
>> I will take a look at this asap and write back. For my learning, could you
>> please explain what exactly you changed between versions 4 and 5 that got it
>> working in parallel?
>>
>
> Well, I must say that I was a bit mystified by this, and I don't
> understand why the original form wouldn't work on multiple staves.
>

[snip]

>
> I did notice something which I can't account for.  You'll notice that
> `frameEngraver4.ly' uses a variable "event-drul".
>

It turns out that the my definition of event-drul as '(() . ()) was
the problem.  I substituted (cons '() '()) and everything works just
fine...even with the file that gave you the issues with multiple
staves.  I don't understand why '(() . ()) and (cons '() '()) aren't
equivalent.

Trying to work out the problem, I've done a little rewriting so I'll
include the engraver here.  You can just substitute this in the
problematic file.

frameEngraver =
#(lambda (context)
  (let ((span '())
(stub '())
(event-drul (cons '() '(
(make-engraver
  (listeners ((frame-event engraver event)
  (if (= START (ly:event-property event 'span-direction))
  (set-car! event-drul event)
  (begin
(set-cdr! event-drul event)
(set-car! event-drul '())
  (acknowledgers
((note-column-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (begin
   (ly:pointer-group-interface::add-grob span 'elements grob)
   (add-bound-item span grob)))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((script-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((dynamic-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((inline-accidental-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob

  ((process-music trans)
   (if (ly:stream-event? (car event-drul))
   (begin
 (set! span (ly:engraver-make-grob trans 'Frame (car event-drul)))
 (set! stub (ly:engraver-make-grob trans 'FrameStub (car
event-drul)))
 (ly:grob-set-object! stub 'frame span)
 (ly:grob-set-property! stub 'direction LEFT)
 (set-car! event-drul '(
   (if (ly:stream-event? (cdr event-drul))
   (if (null? span)
   (ly:warning "No start to this box.")
   (begin
 (set! stub (ly:engraver-make-grob trans 'FrameStub
(cdr event-drul)))
 (ly:grob-set-property! stub 'direction RIGHT)
 (ly:grob-set-object! stub 'frame span)
 (ly:engraver-announce-end-grob trans span (cdr event-drul))
 (set-cdr! event-drul '())

  ((stop-translation-timestep trans)
   (set! stub '())

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


Re: Aleatoric / modern notation

2012-12-08 Thread David Kastrup
David Nalesnik  writes:

> It turns out that the my definition of event-drul as '(() . ()) was
> the problem.  I substituted (cons '() '()) and everything works just
> fine...even with the file that gave you the issues with multiple
> staves.  I don't understand why '(() . ()) and (cons '() '()) aren't
> equivalent.

The problem is rather that '(() . ()) is equivalent, like eq?, with
itself.  It is a constant, meaning that on a second run, the _same_ cons
cell is being used as in the first run, even if you changed its car and
cdr in the mean time.

(cons '() '()) allocates a new cons cell for every run.  '() itself is
not a pair and so it is immutable and not susceptible to this problem.

-- 
David Kastrup


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


Re: Aleatoric / modern notation

2012-12-10 Thread David Nalesnik
David,

On Sun, Dec 9, 2012 at 12:34 AM, David Kastrup  wrote:
> David Nalesnik  writes:
>
>> It turns out that the my definition of event-drul as '(() . ()) was
>> the problem.  I substituted (cons '() '()) and everything works just
>> fine...even with the file that gave you the issues with multiple
>> staves.  I don't understand why '(() . ()) and (cons '() '()) aren't
>> equivalent.
>
> The problem is rather that '(() . ()) is equivalent, like eq?, with
> itself.  It is a constant, meaning that on a second run, the _same_ cons
> cell is being used as in the first run, even if you changed its car and
> cdr in the mean time.
>
> (cons '() '()) allocates a new cons cell for every run.  '() itself is
> not a pair and so it is immutable and not susceptible to this problem.
>

Thank you for this explanation.  I've searched around for more
information about Scheme constants, and learned that an error message
ought to be returned when applying set-car! and the like to a
constant.  However, using the guile sandbox I'm able to do this:

guile> (define my-constant-pair '(73 . 88))
guile> (set-car! my-constant-pair 3)
guile> my-constant-pair
(3 . 88)

(I'm trying an example given here:
http://jayreynoldsfreeman.com/Aux/Tutorials/Modifying%20Lists.html)

I don't understand this--because clearly using set-car! and set-cdr!
with a constant led to problems within the engraver; why will the
sandbox allow me to do this?

-David

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


Re: Aleatoric / modern notation

2012-12-10 Thread David Kastrup
David Nalesnik  writes:

> (I'm trying an example given here:
> http://jayreynoldsfreeman.com/Aux/Tutorials/Modifying%20Lists.html)
>
> I don't understand this--because clearly using set-car! and set-cdr!
> with a constant led to problems within the engraver; why will the
> sandbox allow me to do this?

The behavior is undefined if I remember correctly: an error is not
guaranteed by the standard.  I think Guilev2 will produce an error, but
LilyPond is still at Guilev1.

-- 
David Kastrup

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


Re: Aleatoric / modern notation

2012-12-11 Thread David Nalesnik
On Mon, Dec 10, 2012 at 11:30 PM, David Kastrup  wrote:

> The behavior is undefined if I remember correctly: an error is not
> guaranteed by the standard.  I think Guilev2 will produce an error, but
> LilyPond is still at Guilev1.

OK, thanks!

-David

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


Re: Aleatoric / modern notation

2012-12-11 Thread David Nalesnik
On Sat, Dec 8, 2012 at 7:21 PM, David Nalesnik  wrote:

[...]

>
> Trying to work out the problem, I've done a little rewriting so I'll
> include the engraver here.  You can just substitute this in the
> problematic file.
>

Well, I did break something.  Here's the fix:

frameEngraver =
#(lambda (context)
  (let ((span '())
(stub '())
(event-drul (cons '() '(
(make-engraver
  (listeners ((frame-event engraver event)
  (if (= START (ly:event-property event 'span-direction))
  (set-car! event-drul event)
  (begin
(set-cdr! event-drul event)
(set-car! event-drul '())
  (acknowledgers
((note-column-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (begin
   (ly:pointer-group-interface::add-grob span 'elements grob)
   (add-bound-item span grob)))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((script-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((dynamic-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob)))
((inline-accidental-interface engraver grob source-engraver)
 (if (ly:spanner? span)
 (ly:pointer-group-interface::add-grob span 'elements grob))
 (if (ly:item? stub)
 (ly:pointer-group-interface::add-grob stub 'elements grob

  ((process-music trans)
   (if (ly:stream-event? (car event-drul))
   (begin
 (set! span (ly:engraver-make-grob trans 'Frame (car event-drul)))
 (set! stub (ly:engraver-make-grob trans 'FrameStub (car
event-drul)))
 (ly:grob-set-object! stub 'frame span)
 (ly:grob-set-property! stub 'direction LEFT)
 (set-car! event-drul '(
   (if (ly:stream-event? (cdr event-drul))
   (if (null? span)
   (ly:warning "No start to this box.")
   (begin
 (set! stub (ly:engraver-make-grob trans 'FrameStub
(cdr event-drul)))
 (ly:grob-set-property! stub 'direction RIGHT)
 (ly:grob-set-object! stub 'frame span)
 (ly:engraver-announce-end-grob trans span (cdr event-drul))

  ((stop-translation-timestep trans)
   (if (ly:stream-event? (cdr event-drul))
   (begin
 (set! span '())
 (set-cdr! event-drul '(
   (set! stub '())

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