-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManualGrowl.lua
More file actions
executable file
·239 lines (218 loc) · 7.66 KB
/
Copy pathManualGrowl.lua
File metadata and controls
executable file
·239 lines (218 loc) · 7.66 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
function getClientInfo()
return {
name = "2 - Manual Growl",
category = "Utilities",
author = "Turbo49",
versionNumber = 1,
minEditorVersion = 131330,
type = "SidePanelSection"
}
end
-- initialize vars
parameters = {
growlType = SV:create("WidgetValue"),
growlCoverage = SV:create("WidgetValue"),
growlAmplitudeMod = SV:create("WidgetValue"),
applyButton = SV:create("WidgetValue"),
resetButton = SV:create("WidgetValue"),
}
-- set defaults
parameters.growlType:setValue(0)
parameters.growlCoverage:setValue(50)
parameters.growlAmplitudeMod:setValue(0)
-- functions that do the thing
function clearAutomation(group,notes)
local startPosition = notes[1]:getOnset()
local endPosition = notes[#notes]:getEnd()
local pitch = group:getParameter("pitchDelta")
local breath = group:getParameter("breathiness")
local voice = group:getParameter("voicing")
-- reset pitch to 0
pitch:remove(startPosition,endPosition)
pitch:add(startPosition,0)
pitch:add(endPosition,0)
-- remove points in others, keep default value
breath:remove(startPosition,endPosition)
voice:remove(startPosition,endPosition)
end
function createAutomation(group,notes)
local pitch = group:getParameter("pitchDelta")
local breath = group:getParameter("breathiness")
local voice = group:getParameter("voicing")
-- initialize position vars
local startPosition = 0
local endPosition = 0
local noteLength = 0
for _,note in ipairs(notes) do
startPosition = note:getOnset()
endPosition = note:getEnd()
noteLength = endPosition - startPosition
if parameters.growlType:getValue() == 4 then
local pointAmplitude = 1000 + parameters.growlAmplitudeMod:getValue()
pitch:add(startPosition + 1, -pointAmplitude)
pitch:add(startPosition + noteLength * parameters.growlCoverage:getValue() / 320, -pointAmplitude * .8)
pitch:add(startPosition + noteLength * parameters.growlCoverage:getValue() / 300, 0)
elseif parameters.growlType:getValue() == 5 then
local pointAmplitude = 1000 + parameters.growlAmplitudeMod:getValue()
pitch:add(endPosition - 1, -pointAmplitude)
pitch:add(endPosition - noteLength * parameters.growlCoverage:getValue() / 320, -pointAmplitude * .8)
pitch:add(endPosition - noteLength * parameters.growlCoverage:getValue() / 300, 0)
elseif parameters.growlType:getValue() == 0 then
local pointBoundaries = math.floor(50 + (parameters.growlAmplitudeMod:getValue() / 2))
local pointSpacing = .02 * SV.QUARTER
local pointAmount = math.floor(noteLength * parameters.growlCoverage:getValue() / 100 / pointSpacing)
-- use a boolean to make sure the average pitch doesn't offset too much from 0
local isUp = true
for i = 1,pointAmount do
if isUp then
pitch:add(startPosition + i * pointSpacing, math.random(0, pointBoundaries))
else
pitch:add(startPosition + i * pointSpacing, math.random(-pointBoundaries, 0))
end
isUp = not isUp
end
-- add a final point at 0 to stop the pitch from being modified outside of bounds
pitch:add(startPosition + noteLength * parameters.growlCoverage:getValue() / 100, 0)
elseif parameters.growlType:getValue() == 1 then
local pointBoundaries = math.floor(50 + (parameters.growlAmplitudeMod:getValue() / 2))
local pointSpacing = .02 * SV.QUARTER
local pointAmount = math.floor(noteLength * parameters.growlCoverage:getValue() / 100 / pointSpacing)
-- use a boolean to make sure the average pitch doesn't offset too much from 0
local isUp = true
for i = 1,pointAmount do
if isUp then
pitch:add(endPosition - i * pointSpacing, math.random(0, pointBoundaries))
else
pitch:add(endPosition - i * pointSpacing, math.random(-pointBoundaries, 0))
end
isUp = not isUp
end
-- add a final point at 0 to stop the pitch from being modified outside of bounds
pitch:add(endPosition - noteLength * parameters.growlCoverage:getValue() / 100, 0)
elseif parameters.growlType:getValue() == 2 then
local pointBoundaries = 0
local pointAmplitude = 0
local pointSpacing = .01 * SV.QUARTER
local pointAmount = noteLength * parameters.growlCoverage:getValue() / 100 / pointSpacing
for i = 1,pointAmount do
pointAmplitude = 75 + parameters.growlAmplitudeMod:getValue() / 2
pointBoundaries = math.floor(pointAmplitude - (i / pointAmount) * pointAmplitude)
pitch:add(startPosition + i * pointSpacing, math.random(-pointBoundaries,pointBoundaries))
end
elseif parameters.growlType:getValue() == 3 then
local pointBoundaries = 0
local pointAmplitude = 0
local pointSpacing = .01 * SV.QUARTER
local pointAmount = noteLength * parameters.growlCoverage:getValue() / 100 / pointSpacing
for i = 1,pointAmount do
pointAmplitude = 75 + parameters.growlAmplitudeMod:getValue() / 2
pointBoundaries = math.floor(pointAmplitude - (i / pointAmount) * pointAmplitude)
pitch:add(endPosition - i * pointSpacing, math.random(-pointBoundaries,pointBoundaries))
end
elseif parameters.growlType:getValue() == 6 then
-- add points at note boundaries at current values
breath:add(startPosition, breath:get(startPosition))
breath:add(endPosition, breath:get(endPosition))
voice:add(startPosition, voice:get(startPosition))
voice:add(endPosition, voice:get(endPosition))
-- add the points offset from note boundaries to keep others untouched
breath:add(startPosition + 1, 1)
breath:add(endPosition - 1, 1)
voice:add(startPosition + 1, 0)
voice:add(endPosition - 1, 0)
end
end
end
--update selection on change
selectedGroup = nil
selectedNotes = nil
SV:getMainEditor():getSelection():registerSelectionCallback(function()
selectedGroup = SV:getMainEditor():getCurrentGroup():getTarget()
selectedNotes = SV:getMainEditor():getSelection():getSelectedNotes()
end)
SV:getMainEditor():getSelection():registerClearCallback(function()
selectedGroup = nil
selectedNotes = nil
end)
--on button press
parameters.applyButton:setValueChangeCallback(function()
if selectedNotes == nil then
SV:showMessageBox("Error","No notes were selected")
else
clearAutomation(selectedGroup,selectedNotes)
createAutomation(selectedGroup,selectedNotes)
end
end)
parameters.resetButton:setValueChangeCallback(function()
if selectedNotes == nil then
SV:showMessageBox("Error","No notes were selected")
else
clearAutomation(selectedGroup,selectedNotes)
end
end)
function getSidePanelSectionState()
return {
title = "Manual Growl",
rows = {
--options
{
type = "Container",
columns = {
{
type = "ComboBox",
choices = {"Growl (Start)", "Growl (End)", "Fading Growl (Start)", "Fading Growl (End)", "Vocal Fry (Start)", "Vocal Fry (End)", "Guttural"},
value = parameters.growlType
}
}
},
{
type = "Container",
columns = {
{
type = "Slider",
text = "Amplitude Modifier",
format = "%+3.0f cents",
minValue = -100,
maxValue = 100,
interval = 1,
value = parameters.growlAmplitudeMod
}
}
},
{
type = "Container",
columns = {
{
type = "Slider",
text = "Coverage",
format = "%3.0f %%",
minValue = 0,
maxValue = 100,
interval = 5,
value = parameters.growlCoverage
}
}
},
{
type = "Container",
columns = {
{
type = "Button",
text = "Apply to Selected",
value = parameters.applyButton
}
}
},
{
type = "Container",
columns = {
{
type = "Button",
text = "Reset Selected",
value = parameters.resetButton
}
}
}
}
}
end