diff options
author | Martin Peach <mrpeach@users.sourceforge.net> | 2012-04-03 20:24:54 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@iem.at> | 2015-10-14 14:28:31 +0200 |
commit | df3ab06dfcfa99462c8d063a9ccd5d5160eb351c (patch) | |
tree | 858ce02fb5a822484110ace72558c513f6015dbc /examples/llist-drip.pd_lua | |
parent | 80ba9b7a2031d3159932eb9e306b3c110c01cea6 (diff) |
Some drippers may work faster in lua than as abstarctions...
svn path=/trunk/externals/loaders/pdlua/; revision=16108
Diffstat (limited to 'examples/llist-drip.pd_lua')
-rw-r--r-- | examples/llist-drip.pd_lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/llist-drip.pd_lua b/examples/llist-drip.pd_lua new file mode 100644 index 0000000..1d2fe79 --- /dev/null +++ b/examples/llist-drip.pd_lua @@ -0,0 +1,39 @@ +--[[ + llist-drip + Output a list as a sequence of elements, same as [list-abs/list-drip] + author Martin Peach 20120403 +--]] + +-- Pd class + +local LlistDrip = pd.Class:new():register("llist-drip") +local selectormap = {string = "symbol", number="float", userdata="pointer"} -- for lua/Pd type conversion + +function LlistDrip:initialize(name, atoms) + self.inlets = 1 + self.outlets = 1 + return true +end + +function LlistDrip:in_1(sel, atoms) -- anything + --pd.post("sel is " .. sel); + --pd.post("number of atoms is ".. #atoms) + --for i,v in ipairs(atoms) do + -- pd.post(i .. " = " .. v) + --end + if sel == "list" then -- the usual case + for i=1, #atoms do + -- map lua types to pd selectors + self:outlet(1, selectormap[type(atoms[i])], {atoms[i]}) + end + elseif sel == "float" or sel == "symbol" or sel == "pointer" or sel == "bang" then -- single element "lists" + self:outlet(1, sel, {atoms[1]}) + else -- messages are lists beginning with a selector + self:outlet(1, selectormap[type(sel)], {sel}) + for i=1, #atoms do + self:outlet(1, selectormap[type(atoms[i])], {atoms[i]}) + end + end +end +-- end of llist-drip + |