-
Notifications
You must be signed in to change notification settings - Fork 0
/
gain.lua
95 lines (74 loc) · 2.35 KB
/
gain.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
local libcore = require "core.libcore"
local app = app
local Class = require "Base.Class"
local Unit = require "Unit"
local Fader = require "Unit.ViewControl.Fader"
local OptionControl = require "Unit.ViewControl.OptionControl"
local Encoder = require "Encoder"
local ply = app.SECTION_PLY
local Gainer = Class{}
Gainer:include(Unit)
function Gainer:init(args)
args.title = "gain"
args.mnemonic = "GA"
Unit.init(self,args)
end
function Gainer:onLoadGraph(channelCount)
if channelCount==2 then
self:loadStereoGraph()
else
self:loadMonoGraph()
end
end
function Gainer:loadMonoGraph()
local gain = self:addObject("gain", app.ConstantGain())
gain:setClampInDecibels(-59.9)
gain:hardSet("Gain",1.0)
connect(self,"In1",gain,"In")
connect(gain,"Out",self,"Out1")
end
function Gainer:loadStereoGraph()
local gain1 = self:addObject("gain1", app.ConstantGain())
local gain2 = self:addObject("gain2", app.ConstantGain())
gain1:setClampInDecibels(-59.9)
gain1:hardSet("Gain",1.0)
gain2:setClampInDecibels(-59.9)
gain2:hardSet("Gain",1.0)
connect(self,"In1",gain1,"In")
connect(gain1,"Out",self,"Out1")
connect(self,"In2",gain2,"In")
connect(gain2,"Out",self,"Out2")
tie(gain2,"Gain",gain1,"Gain")
self.objects.gain = gain1
end
local views = {
expanded = {"gain"},
collapsed = {},
}
function Gainer:onLoadViews(objects,branches)
local controls = {}
local createMap = function (min, max, superCourse, course, fine, superFine, rounding)
local map = app.LinearDialMap(min, max)
map:setSteps(superCourse, course, fine, superFine)
map:setRounding(rounding)
return map
end
local gain_map = createMap(-60, 40, 10, 1, .1, .01, .01)
controls.gain = Fader {
button = "gain",
description = "Gain",
param = objects.gain:getParameter("Gain"),
map = gain_map,
units = app.unitDecibels
}
if self.channelCount==1 then
local outlet = objects.gain:getOutput("Out")
controls.gain:setMonoMeterTarget(outlet)
else
local left = objects.gain1:getOutput("Out")
local right = objects.gain2:getOutput("Out")
controls.gain:setStereoMeterTarget(left,right)
end
return controls, views
end
return Gainer