lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding markup from event listeners


From: Maurits Lamers
Subject: Re: adding markup from event listeners
Date: Fri, 16 Feb 2018 22:50:00 +0100

Hi,

Thanks for your suggestion!

I have been looking at edition-engraver and I tried to come up with something 
which mimics what edition-engraver is doing. That something however crashes 
Lilypond with a segmentation fault.

As I am doing my analysis on the finalize event, I can only add the markup 
after the analysis in the same event. In the edition-engraver this is done in 
the process-music part of the engraver, which might be causing my issue.

What I did is take the bit of code I found which matches attaching a form of 
text script to some other music event (found at 
https://github.com/openlilylib/edition-engraver/blob/master/engine.scm#L924). I 
use an object property to add an error message to the wrapper alist I use for 
my bookkeeping, which also contains a reference to the original event.

Then immediately after the processing I run through my event list (filtered for 
only note events), detect whether an error-msg property value is set, then try 
to create the text script event and use the music cause from the original 
event. The code used:

(for-each (lambda (note)
    (if (not (equal? #f (error-msg note)))
      (let (
        (grob (ly:engraver-make-grob trans 'TextScript
          (ly:make-stream-event 'text-script-event
            `((origin . ,(assoc-ref note 'origin))
              (music-cause . ,(ly:event-property (assoc-ref note 'event) 
'music-cause)))))))
        (ly:grob-set-property! grob 'text (markup (error-msg note)))
        ))

    )
    (filter (lambda (x) (equal? (assoc-ref x 'type) 'note)) (reverse 
eventList)))

However this causes Lilypond to segfault. Any clue what I am doing wrong here? 
Is this perhaps because the trans provided in the finalize is different from 
the one given to process-music? Could it be that this code running in the Score 
context is the problem?

Thanks in advance!

cheers

Maurits

> Op 16 feb. 2018, om 14:54 heeft Kieren MacMillan <address@hidden> het 
> volgende geschreven:
> 
> Hi Maurits,
> 
> Have you looked at how the edition-engraver works? I use it to add markup to 
> my scores all the time. Either you can use it as is, or perhaps the code will 
> give you hints as to how to tweak your Scheme code to get the desired effect.
> 
> Hope that helps!
> Kieren.
> ________________________________
> 
> Kieren MacMillan, composer
> ‣ website: www.kierenmacmillan.info
> ‣ email: address@hidden
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]