-
Notifications
You must be signed in to change notification settings - Fork 3
/
Amie.lua
217 lines (187 loc) · 7.14 KB
/
Amie.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
-- GLOBALS: app, os, verboseLevel, connect, tie
local app = app
local libcore = require "core.libcore"
local Class = require "Base.Class"
local Unit = require "Unit"
local Pitch = require "Unit.ViewControl.Pitch"
local GainBias = require "Unit.ViewControl.GainBias"
local Fader = require "Unit.ViewControl.Fader"
local Gate = require "Unit.ViewControl.Gate"
local Encoder = require "Encoder"
local ply = app.SECTION_PLY
local Amie = Class{}
Amie:include(Unit)
function Amie:init(args)
args.title = "Amie"
args.mnemonic = "AM"
Unit.init(self,args)
end
function Amie:onLoadGraph(channelCount)
--carrier
local carrier = self:addObject("carrier",libcore.SineOscillator())
local ctune = self:addObject("ctune",app.ConstantOffset())
local ctuneRange = self:addObject("ctuneRange",app.MinMax())
local cf0 = self:addObject("cf0",app.GainBias())
local cf0Range = self:addObject("cf0Range",app.MinMax())
local climgain = self:addObject("climgain",app.ConstantGain())
local climiter = self:addObject("climiter",libcore.Limiter())
local cfdbk = self:addObject("cfdbk",app.GainBias())
local cfdbkRange = self:addObject("cfdbkRange",app.MinMax())
connect(cfdbk,"Out",cfdbkRange,"In")
-- modulator
local modulator = self:addObject("modulator",libcore.SineOscillator())
local mRatio = self:addObject("mRatio",app.GainBias())
local mRatioRange = self:addObject("mRatioRange",app.MinMax())
local mRatioVCA = self:addObject("mRatioVCA",app.Multiply())
local mlimgain = self:addObject("mlimgain",app.GainBias())
local mlimiter = self:addObject("mlimiter",libcore.Limiter())
local mfdbk = self:addObject("mfdbk",app.GainBias())
local mfdbkRange = self:addObject("mfdbkRange",app.MinMax())
connect(mfdbk,"Out",mfdbkRange,"In")
-- AM VCA
local amvca = self:addObject("amvca",app.Multiply())
local amIndex = self:addObject("amIndex",app.GainBias())
local amIndexRange = self:addObject("amIndexRange",app.MinMax())
-- wet/dry mixer
local mixer = self:addObject("mixer",app.CrossFade())
local wet = self:addObject("wet",app.GainBias())
local wetRange = self:addObject("wetRange",app.MinMax())
-- output volume control
local vca = self:addObject("vca",app.Multiply())
local level = self:addObject("level",app.GainBias())
local levelRange = self:addObject("levelRange",app.MinMax())
--tuning
connect(ctune,"Out",ctuneRange,"In")
connect(ctune,"Out",carrier,"V/Oct")
connect(ctune,"Out",modulator,"V/Oct")
connect(cf0,"Out",carrier,"Fundamental")
connect(cf0,"Out",cf0Range,"In")
connect(mRatio,"Out",mRatioRange,"In")
connect(cf0,"Out",mRatioVCA,"Left")
connect(mRatio,"Out",mRatioVCA,"Right")
connect(mRatioVCA,"Out",modulator,"Fundamental")
-- audio path
connect(carrier,"Out",climgain,"In")
connect(climgain,"Out",climiter,"In")
connect(climiter,"Out",amvca,"Left")
connect(modulator,"Out",mlimgain,"In")
connect(mlimgain,"Out",mlimiter,"In")
connect(mlimiter,"Out",amvca,"Right")
connect(amvca,"Out",mixer,"A")
connect(climiter,"Out",mixer,"B")
connect(mixer,"Out",vca,"Left")
connect(wet,"Out",wetRange,"In")
connect(wet,"Out",mixer,"Fade")
connect(level,"Out",levelRange,"In")
connect(level,"Out",vca,"Right")
connect(vca,"Out",self,"Out1")
connect(cfdbk,"Out",carrier,"Feedback")
connect(mfdbk,"Out",modulator,"Feedback")
if channelCount==2 then
connect(vca,"Out",self,"Out2")
end
self:addMonoBranch("level",level,"In",level,"Out")
self:addMonoBranch("tune",ctune,"In",ctune,"Out")
self:addMonoBranch("f0",cf0,"In",cf0,"Out")
self:addMonoBranch("ratio",mRatio,"In",mRatio,"Out")
self:addMonoBranch("wet",wet,"In",wet,"Out")
self:addMonoBranch("cfdbk",cfdbk,"In",cfdbk,"Out")
self:addMonoBranch("mfdbk",mfdbk,"In",mfdbk,"Out")
end
local views = {
expanded = {"tune","freq","ratio","csat","cfdbk","msat","mfdbk","wet","level"},
collapsed = {},
}
local function linMap(min,max,superCoarse,coarse,fine,superFine)
local map = app.LinearDialMap(min,max)
map:setSteps(superCoarse,coarse,fine,superFine)
return map
end
local ratioMap = linMap(0,24,1,0.5,0.01,0.001)
local wetMap = linMap(0,1,1,0.1,0.01,0.001)
local fdbkMap = linMap(-1,1,1,0.1,0.01,0.001)
local driveMap = linMap(1,6,1,0.1,0.01,0.01)
function Amie:onLoadViews(objects,branches)
local controls = {}
controls.tune = Pitch {
button = "V/oct",
branch = branches.tune,
description = "V/oct",
offset = objects.ctune,
range = objects.ctuneRange
}
controls.freq = GainBias {
button = "f0",
description = "Fundamental",
branch = branches.f0,
gainbias = objects.cf0,
range = objects.cf0Range,
biasMap = Encoder.getMap("oscFreq"),
biasUnits = app.unitHertz,
initialBias = 27.5,
gainMap = Encoder.getMap("freqGain"),
scaling = app.octaveScaling
}
controls.ratio = GainBias {
button = "ratio",
description = "AM Ratio",
branch = branches.ratio,
gainbias = objects.mRatio,
biasMap = ratioMap,
range = objects.mRatioRange,
initialBias = 1.0,
}
controls.csat = Fader {
button = "car sat",
description = "Carrier Saturation",
param = objects.climgain:getParameter("Gain"),
map = driveMap,
initial = 1.0
-- units = app.unitDecibels,
}
controls.msat = Fader {
button = "mod sat",
description = "Modulator Saturation",
param = objects.mlimgain:getParameter("Gain"),
map = driveMap,
initial = 1.0
-- units = app.unitDecibels,
}
controls.cfdbk = GainBias {
button = "carFdbk",
description = "Carrier Feedback",
branch = branches.cfdbk,
gainbias = objects.cfdbk,
biasMap = fdbkMap,
range = objects.cfdbkRange,
initialBias = 0.0,
}
controls.mfdbk = GainBias {
button = "modFdbk",
description = "Modulator Feedback",
branch = branches.mfdbk,
gainbias = objects.mfdbk,
biasMap = fdbkMap,
range = objects.mfdbkRange,
initialBias = 0.0,
}
controls.wet = GainBias {
button = "wet",
description = "0 car 1 ringmod",
branch = branches.wet,
gainbias = objects.wet,
biasMap = wetMap,
range = objects.wetRange,
initialBias = 0.5,
}
controls.level = GainBias {
button = "level",
description = "Level",
branch = branches.level,
gainbias = objects.level,
range = objects.levelRange,
initialBias = 0.5,
}
return controls, views
end
return Amie