[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: Defining event classes
From:       David Nalesnik <david.nalesnik () gmail ! com>
Date:       2015-03-31 23:41:45
Message-ID: CANn-nX=1uT2iOPLCJv2rcvD6Y3hvQDqpvfPpftBczEy9X_kOmw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Nathan,

On Tue, Mar 31, 2015 at 3:53 PM, Nathan Ho <when.possible@gmail.com> wrote:

> On Mon, Mar 30, 2015 at 1:44 PM, Nathan Ho <when.possible@gmail.com>
> wrote:
>
>> Hi list,
>>
>> What is the most up-to-date way to define my own event classes?
>>
>> I've looked at frameEngraver as a model but none of the old versions
>> seem to be working. The most up-to-date one I could find
>> (https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00373.html)
>> gives me numerous "Event class should be a list" errors and the frames
>> don't show up in the output, while this one
>> (https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00554.html)
>> spits out a few errors and segfaults. I'm using 2.19.17.
>>
>
> Not hugely surprised to see that didn't get a quick answer :)
>
> With some trial and error and fumbling around I came up with the following
> code. Unlike the frame engraver code, this returns no errors or warnings,
> but the engraver doesn't seem to notice the BangEvent at all. If I change
> the listener to listen to music-event, then bang-trigger calls four times
> (once per note) seemingly ignoring the \bang. What's going on here?
>

If you're listening to 'music-event, you'll hear all sorts of events
because it's the parent of many event-classes.  If you add an articulation
to a note, for example, you'll hear that too.  Your invocation of
define-event-class makes it the parent of bang-event.


>
> \version "2.19.17"
>
> #(define-event-class 'bang-event 'music-event)
>
> #(define bang-types
>    '(
>      (BangEvent
>       . ((description . "BANG!")
>          (types . (bang-event music-event))
>          ))
>      ))
>

You need to add 'event' to types for your event to register.  (I'd have to
investigate why.)  Also, 'music-event' should be replaced with
'general-music'.

#(define bang-types
   '(
     (BangEvent
      . ((description . "BANG!")
         (types . (general-music event bang-event))
         ))
     ))

Hope this helps!
David

[Attachment #5 (text/html)]

<div dir="ltr">Hi Nathan,<div class="gmail_extra"><br><div class="gmail_quote">On \
Tue, Mar 31, 2015 at 3:53 PM, Nathan Ho <span dir="ltr">&lt;<a \
href="mailto:when.possible@gmail.com" \
target="_blank">when.possible@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, \
Mar 30, 2015 at 1:44 PM, Nathan Ho <span dir="ltr">&lt;<a \
href="mailto:when.possible@gmail.com" \
target="_blank">when.possible@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi \
list,<br> <br>
What is the most up-to-date way to define my own event classes?<br>
<br>
I&#39;ve looked at frameEngraver as a model but none of the old versions<br>
seem to be working. The most up-to-date one I could find<br>
(<a href="https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00373.html" \
target="_blank">https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00373.html</a>)<br>
 gives me numerous &quot;Event class should be a list&quot; errors and the frames<br>
don&#39;t show up in the output, while this one<br>
(<a href="https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00554.html" \
target="_blank">https://lists.gnu.org/archive/html/lilypond-user/2013-07/msg00554.html</a>)<br>
 spits out a few errors and segfaults. I&#39;m using \
2.19.17.<br></blockquote><div><br></div></span><div>Not hugely surprised to see that \
didn&#39;t get a quick answer :)</div><div><br></div><div>With some trial and error \
and fumbling around I came up with the following code. Unlike the frame engraver \
code, this returns no errors or warnings, but the engraver doesn&#39;t seem to notice \
the BangEvent at all. If I change the listener to listen to music-event, then \
bang-trigger calls four times (once per note) seemingly ignoring the \bang. \
What&#39;s going on here?</div></div></div></div></blockquote><div><br></div><div>If \
you&#39;re listening to &#39;music-event, you&#39;ll hear all sorts of events because \
it&#39;s the parent of many event-classes.   If you add an articulation to a note, \
for example, you&#39;ll hear that too.   Your invocation of define-event-class makes \
it the parent of bang-event.   </div><div>  </div><blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><font \
face="monospace, monospace">\version &quot;2.19.17&quot;</font></div><div><font \
face="monospace, monospace"><br></font></div><div><font face="monospace, \
monospace">#(define-event-class &#39;bang-event \
&#39;music-event)</font></div><div><font face="monospace, \
monospace"><br></font></div><div><font face="monospace, monospace">#(define \
bang-types</font></div><div><font face="monospace, monospace">     \
&#39;(</font></div><div><font face="monospace, monospace">        \
(BangEvent</font></div><div><font face="monospace, monospace">         . \
((description . &quot;BANG!&quot;)</font></div><div><font face="monospace, \
monospace">              (types . (bang-event music-event))</font></div><div><font \
face="monospace, monospace">              ))</font></div><div><font face="monospace, \
monospace">        ))</font></div></div></div></div></blockquote><div><br></div><div>You \
need to add &#39;event&#39; to types for your event to register.   (I&#39;d have to \
investigate why.)   Also, &#39;music-event&#39; should be replaced with \
&#39;general-music&#39;.</div><div><br></div><div><div>#(define bang-types</div><div> \
&#39;(</div><div>        (BangEvent</div><div>         . ((description . \
&quot;BANG!&quot;)</div><div>              (types . (general-music event \
bang-event))</div><div>              ))</div><div>        \
))</div></div><div><br></div><div>Hope this \
helps!</div><div>David</div></div><br></div></div>



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic