-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLorenz.lua
123 lines (102 loc) · 2.75 KB
/
Lorenz.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
121
122
123
local chaos = require "chaoticmods.libchaoticmods"
local Class = require "Base.Class"
local Encoder = require "Encoder"
local GainBias = require "Unit.ViewControl.GainBias"
local OptionControl = require "Unit.ViewControl.OptionControl"
local Unit = require "Unit"
local Lorenz = Class {}
Lorenz:include(Unit)
function Lorenz:init(args)
args.title = "Lorenz"
args.mnemonic = "Lo"
Unit.init(self, args)
end
function Lorenz:onLoadGraph(channelCount)
local lorenz = self:addObject("lorenz", chaos.Lorenz())
local rate = self:addObject("rate", app.ParameterAdapter())
local rho = self:addObject("rho", app.ParameterAdapter())
local sigma = self:addObject("sigma", app.ParameterAdapter())
local beta = self:addObject("beta", app.ParameterAdapter())
tie(lorenz, "Rate", rate, "Out")
self:addMonoBranch("rate", rate, "In", rate, "Out")
tie(lorenz, "Rho", rho, "Out")
self:addMonoBranch("rho", rho, "In", rho, "Out")
tie(lorenz, "Sigma", sigma, "Out")
self:addMonoBranch("sigma", sigma, "In", sigma, "Out")
tie(lorenz, "Beta", beta, "Out")
self:addMonoBranch("beta", beta, "In", beta, "Out")
connect(lorenz, "Out", self, "Out1")
if channelCount > 1 then
connect(lorenz, "Out", self, "Out2")
end
end
local views = {
expanded = {
"rate",
"rho",
"sigma",
"beta",
"outvar",
},
collapsed = {}
}
local map100 = app.LinearDialMap(0, 100)
map100:setSteps(10, 5, 0.5, 0.1)
local map10 = app.LinearDialMap(0, 10)
map10:setSteps(1, 0.5, 0.1, 0.025)
function Lorenz:onLoadViews(objects, branches)
local controls = {}
controls.rate = GainBias {
button = "Rate",
description = "Rate",
branch = branches.rate,
gainbias = objects.rate,
range = objects.rate,
biasUnits = app.unitNone,
biasMap = Encoder.getMap("[-5,5]"),
initialBias = 0,
}
controls.rho = GainBias {
button = "Rho",
description = "Rho",
branch = branches.rho,
gainbias = objects.rho,
range = objects.rho,
biasUnits = app.unitNone,
biasMap = map100,
initialBias = 28,
}
controls.sigma = GainBias {
button = "Sigma",
description = "Sigma",
branch = branches.sigma,
gainbias = objects.sigma,
range = objects.sigma,
biasUnits = app.unitNone,
biasMap = map100,
initialBias = 10,
}
controls.beta = GainBias {
button = "Beta",
description = "Beta",
branch = branches.beta,
gainbias = objects.beta,
range = objects.beta,
biasUnits = app.unitNone,
biasMap = map10,
initialBias = 8/3,
}
controls.outvar = OptionControl {
button = "OutVar",
description = "Output Var",
option = objects.lorenz:getOption("OutVar"),
choices = {
"x",
"y",
"z"
},
muteOnChange = true
}
return controls, views
end
return Lorenz