summaryrefslogtreecommitdiff
path: root/dalos-tee.lua
blob: b5193c0fc67db6694464e9f1d0926c6f7428105f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
dalosp.tee = {
    NTEE = 16,
    
    set_out = function (self, h, ind)
        local name = h:getname()
        local obj = {
            h = h,
            size = h:getsize(),
            getname = function () return name end,
            do_read = function (self, count, userdata)
                self.h:seek(self.offset, SEEK_SET)
                return self.h:read(count, userdata)
            end,
        }
        self:set_houtput(dalos.luahandle(obj), ind)
    end,
    
    input_change = function (self, ind)
        local h = self:get_linked_input(1)
        if h then
            self.color = cd.GREEN
            for ind = 1, 16 do self:set_out(h, ind) end
            self.dcanvas:draw()
        else
            self.color = cd.YELLOW
            for i = 1, dalosp.tee.NTEE do
                self:set_houtput(nil, i)
            end
            self.dcanvas:draw()
        end
    end,
    
    create = function (d, tab, settings)
        tab.ninputs = 1
        tab.noutputs = dalosp.tee.NTEE
        tab.otype = dalos.objtype.LUA_FILTER
        tab.input_change = dalosp.tee.input_change
        tab.default_name = "Tee"
        tab.ntype = "Tee"
        
        local obj = dalos.object(d, tab)
        
        obj.set_out = dalosp.tee.set_out
        
        return obj
    end,
}

dalos.tee = dalosp.tee.create
dalos:register_obj("Tee", dalos.tee, "Basic Filters")