Strange isRest behaviour when used in custom Event type

Hm, actually, that’s not the only way.

The Event:play method always calls the event’s play function. This does a bunch of things:

  1. Retrieves a set of defaults for the event type.
  2. Sets the server variable.
  3. Calls a \finish hook (finish preparation before playing).
  4. Updates tempo, if \tempo is set.
  5. Calls the event type function, if the event is not a rest.
  6. Calls a \callback hook (giving the caller access to the event’s final state).

Of these, only #5 is skipped for rests. All of the other ones are done for every event.

So you could also do \finish, { |event| ... send your OSC here ... } in the Pbind (note, that is not \finish, Pfunc { ... } – the finish key should get the literal function). \callback might be OK too, but rest events will not do pitch or duration calculations (that is, if you specify \degree, sounding events will end up with a \freq value, but rest events will not – so your callback function cannot assume that \freq will always be there).

hjh

1 Like