-
Notifications
You must be signed in to change notification settings - Fork 3
/
BespokeAliasingPulse.lua
157 lines (132 loc) · 4.28 KB
/
BespokeAliasingPulse.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
-- 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 AliasingPulse = Class{}
AliasingPulse:include(Unit)
function AliasingPulse:init(args)
args.title = "Aliasing Pulse"
args.mnemonic = "AP"
Unit.init(self,args)
end
function AliasingPulse:onLoadGraph(channelCount)
if channelCount==2 then
self:loadStereoGraph()
else
self:loadMonoGraph()
end
end
function AliasingPulse:loadMonoGraph()
-- create objects
local osc = self:addObject("osc",libcore.SineOscillator())
local tune = self:addObject("tune",app.ConstantOffset())
local tuneRange = self:addObject("tuneRange",app.MinMax())
local f0 = self:addObject("f0",app.GainBias())
local f0Range = self:addObject("f0Range",app.MinMax())
local vca = self:addObject("vca",app.Multiply())
local level = self:addObject("level",app.GainBias())
local levelRange = self:addObject("levelRange",app.MinMax())
local bump = self:addObject("bump",libcore.BumpMap())
local width = self:addObject("width",app.ParameterAdapter())
local oscVca = self:addObject("oscVca",app.Multiply())
local oscVcaMult = self:addObject("oscVcaMult",app.Constant())
local compVca = self:addObject("compVca",app.Multiply())
local compVcaMult = self:addObject("compVcaMult",app.Constant())
local offset = self:addObject("offset",app.ConstantOffset())
local sync = self:addObject("sync",app.Comparator())
sync:setTriggerMode()
tie(bump,"Width",width,"Out")
bump:hardSet("Height",1.0)
bump:hardSet("Fade",0.0)
oscVcaMult:hardSet("Value",0.5)
offset:hardSet("Offset",-0.5)
compVcaMult:hardSet("Value",2.0)
connect(tune,"Out",tuneRange,"In")
connect(tune,"Out",osc,"V/Oct")
connect(f0,"Out",osc,"Fundamental")
connect(f0,"Out",f0Range,"In")
connect(level,"Out",levelRange,"In")
connect(level,"Out",vca,"Left")
connect(osc,"Out",oscVca,"Left")
connect(sync,"Out",osc,"Sync")
connect(oscVcaMult,"Out",oscVca,"Right")
connect(oscVca,"Out",bump,"In")
connect(bump,"Out",offset,"In")
connect(offset,"Out",compVca,"Left")
connect(compVcaMult,"Out",compVca,"Right")
connect(compVca,"Out",vca,"Right")
connect(vca,"Out",self,"Out1")
self:addMonoBranch("level",level,"In",level,"Out")
self:addMonoBranch("tune",tune,"In",tune,"Out")
self:addMonoBranch("f0",f0,"In",f0,"Out")
self:addMonoBranch("width",width,"In",width,"Out")
self:addMonoBranch("sync",sync,"In",sync,"Out")
end
function AliasingPulse:loadStereoGraph()
self:loadMonoGraph()
connect(self.objects.vca,"Out",self,"Out2")
end
local views = {
expanded = {"tune","freq","width","sync","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 widthMap = linMap(0,1,0.1,0.01,0.001,0.001)
function AliasingPulse:onLoadViews(objects,branches)
local controls = {}
controls.tune = Pitch {
button = "V/oct",
branch = branches.tune,
description = "V/oct",
offset = objects.tune,
range = objects.tuneRange
}
controls.freq = GainBias {
button = "f0",
description = "Fundamental",
branch = branches.f0,
gainbias = objects.f0,
range = objects.f0Range,
biasMap = Encoder.getMap("oscFreq"),
biasUnits = app.unitHertz,
initialBias = 27.5,
gainMap = Encoder.getMap("freqGain"),
scaling = app.octaveScaling
}
controls.level = GainBias {
button = "level",
description = "Level",
branch = branches.level,
gainbias = objects.level,
range = objects.levelRange,
initialBias = 0.5,
}
controls.width = GainBias {
button = "width",
description = "Pulse Width",
branch = branches.width,
gainbias = objects.width,
range = objects.width,
biasMap = widthMap,
initialBias = 0.5,
}
controls.sync = Gate {
button = "sync",
description = "Sync",
branch = branches.sync,
comparator = objects.sync,
}
return controls, views
end
return AliasingPulse