-
Notifications
You must be signed in to change notification settings - Fork 3
/
Ringmod.lua
82 lines (67 loc) · 2.01 KB
/
Ringmod.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
-- GLOBALS: app, connect
local Class = require "Base.Class"
local Unit = require "Unit"
local Pitch = require "Unit.ViewControl.Pitch"
local GainBias = require "Unit.ViewControl.GainBias"
local Gate = require "Unit.ViewControl.Gate"
local Fader = require "Unit.ViewControl.Fader"
local Encoder = require "Encoder"
local ply = app.SECTION_PLY
local Ringmod = Class{}
Ringmod:include(Unit)
function Ringmod:init(args)
args.title = "Ring Mod"
args.mnemonic = "RM"
args.version = 1
Unit.init(self,args)
end
function Ringmod:onLoadGraph(channelCount)
-- input, vca, sine osc
-- create sine osc
local modulator = self:createObject("SineOscillator","modulator")
-- create multipliers
local mult1 = self:createObject("Multiply","mult1")
local mult2 = self:createObject("Multiply","mult2")
-- create f0 gainbias & minmax
local f0 = self:createObject("GainBias","f0")
local f0Range = self:createObject("MinMax","f0Range")
-- connect unit input to vca/multipler
connect(self,"In1",mult1,"Left")
if channelCount > 1 then
connect(self,"In2",mult2,"Left")
end
-- connect vca/multiplier to unit output
connect(mult1,"Out",self,"Out1")
if channelCount > 1 then
connect(mult2,"Out",self,"Out2")
end
-- connect sine osc to right Inlet of vca/multiplier
connect(modulator,"Out",mult1,"Right")
if channelCount > 1 then
connect(modulator,"Out",mult2,"Right")
end
connect(f0,"Out",modulator,"Fundamental")
connect(f0,"Out",f0Range,"In")
self:createMonoBranch("f0",f0,"In",f0,"Out")
end
local views = {
expanded = {"freq"},
collapsed = {},
}
function Ringmod:onLoadViews(objects,branches)
local controls = {}
controls.freq = GainBias {
button = "f0",
description = "Fundamental",
branch = branches.f0,
gainbias = objects.f0,
range = objects.f0Range,
biasMap = Encoder.getMap("oscFreq"),
biasUnits = app.unitHertz,
initialBias = 200.0,
gainMap = Encoder.getMap("freqGain"),
scaling = app.octaveScaling
}
return controls, views
end
return Ringmod