-
Notifications
You must be signed in to change notification settings - Fork 3
/
VoltageVault.lua
120 lines (101 loc) · 2.92 KB
/
VoltageVault.lua
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local app = app
local libAccents = require "Accents.libAccents"
local Class = require "Base.Class"
local Unit = require "Unit"
local Gate = require "Unit.ViewControl.Gate"
local Fader = require "Unit.ViewControl.Fader"
local GainBias = require "Unit.ViewControl.GainBias"
local VoltageVault = Class {}
VoltageVault:include(Unit)
function VoltageVault:init(args)
args.title = "Voltage Vault"
args.mnemonic = "VV"
Unit.init(self, args)
end
function VoltageVault:onLoadGraph(channelCount)
local sh = self:addObject("sh", libAccents.VoltageVault())
local trig = self:addObject("trig", app.Comparator())
local bptrig = self:addObject("bptrig",app.Comparator())
local sumtrig = self:addObject("sumtrig",app.Comparator())
local index = self:addObject("index",app.ParameterAdapter())
local indexRange = self:addObject("indexRange",app.MinMax())
trig:setTriggerMode()
bptrig:setToggleMode()
sumtrig:setToggleMode()
connect(trig, "Out", sh, "Track")
connect(bptrig, "Out", sh, "Bypass")
connect(sumtrig, "Out", sh, "SumInput")
connect(self, "In1", sh, "In")
connect(index,"Out",indexRange,"In")
tie(sh, "Index", index, "Out")
connect(sh, "Out", self, "Out1")
self:addMonoBranch("trig", trig, "In", trig, "Out")
self:addMonoBranch("bypass", bptrig, "In", bptrig, "Out")
self:addMonoBranch("sum", sumtrig, "In", sumtrig, "Out")
self:addMonoBranch("index", index, "In", index, "Out")
if channelCount == 2 then
connect(sh,"Out",self,"Out2")
end
end
local views = {
expanded = {"trig","index","bypass","sum"},
collapsed = {}
}
local function intMap(min,max)
local map = app.LinearDialMap(min,max)
map:setSteps(5,1,0.25,0.25);
map:setRounding(1)
return map
end
local indexMap = intMap(0,127)
function VoltageVault:onLoadViews(objects, branches)
local controls = {}
controls.trig = Gate {
button = "store",
branch = branches.trig,
description = "Trigger to store val",
comparator = objects.trig,
}
controls.index = GainBias {
button = "index",
description = "Vault Slot",
branch = branches.index,
gainbias = objects.index,
range = objects.indexRange,
biasMap = indexMap,
biasPrecision = 0,
gainMap = indexMap,
initialBias = 0,
}
controls.bypass = Gate {
button = "bypass",
description = "Pass thru Input",
branch = branches.bypass,
comparator = objects.bptrig,
}
controls.sum = Gate {
button = "sum",
description = "Add Input to Vault Val",
branch = branches.sum,
comparator = objects.sumtrig,
}
return controls, views
end
function VoltageVault:serialize()
local t = Unit.serialize(self)
local vaults = {}
for i = 0, 127 do
vaults[i] = self.objects.sh:getVaults(i)
end
t.vaults = vaults
return t
end
function VoltageVault:deserialize(t)
Unit.deserialize(self, t)
if t.vaults then
for i = 0,127 do
self.objects.sh:setVaults(i, t.vaults[i])
end
end
end
return VoltageVault