Hi (Claude),
inspired by Matteo's question I briefly tried to implement a [pipe] clone in pdlua, however I ran into problems which might hint at either some design issues with clock support in pdlua or, more likely, my lack of understanding how clocks work.
Anyway here's the problem: [pipe] in Pd is an object which as far as I understand the code creates lots of pd-clocks as part of a "hang-list" where pending events are collected. So the workflow is like this:
Everytime [pipe] receives a message, it creates a new "t_hang" structure item (in a list of these) with the message payload and a new clock inside. That clock is set to call back hang_tick(t_hang *h) after a delay. When its time has come, hang_tick sends the payload to the outlet and destroys the t_hang-object including the clock afterwards.
For the luapipe [lpipe] I thought I'd mimick that approach and collect the scheduled events in a table as member of the pdlua-class, like self.events.
So the method to add an event could look like this in pseudo-Lua:
function M:in_1(sel, atoms) local deltatime = atoms[1] -- delay local e = event.new() e.payload = atoms e.clock = makeclock(deltatime) table.insert(self.events, e) end
My problem is the hypothetical "makeclock". It should be a clock that somehow is tied to the event. But as I see it, clocks in pdlua are supposed to be tied to a pdclass object itself, and their callback methods don't accept any additional arguments to specify which of the event they should handle.
Any ideas how to work around this?
Frank Barknecht _ ______footils.org__