-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgain-parameter-modulation.js
More file actions
95 lines (82 loc) · 2.71 KB
/
gain-parameter-modulation.js
File metadata and controls
95 lines (82 loc) · 2.71 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
function pitchVolumeExecutor() {
var event = studio.window.browserCurrent();
if (!event || !event.isOfType("Event")) {
return;
}
var parameterIndex = 0;
var reverse = false;
var closeButton = {
widgetType: studio.ui.widgetType.PushButton,
text: "Close",
onClicked: function () {
this.closeDialog();
},
};
var addButton = {
widgetType: studio.ui.widgetType.PushButton,
text: "Add",
onClicked: function () {
var track = event.masterTrack;
var editor = studio.window.editorCurrent();
if (editor && editor.isOfType("Track")) {
track = editor;
}
var effectChain = track.mixerGroup.effectChain;
var gain = effectChain.addEffect("GainEffect");
effectChain.relationships.effects.remove(gain);
effectChain.relationships.effects.insert(0, gain);
var auto = gain.addAutomator("gain");
var param = event.parameters[parameterIndex].preset;
var autoCurve = auto.addAutomationCurve(param);
autoCurve.addAutomationPoint(param.minimum, reverse ? 0 : -Infinity);
autoCurve.addAutomationPoint(param.maximum, reverse ? -Infinity : 0);
this.closeDialog();
},
};
var buttons;
if (event.parameters.length == 0) {
main = [{
widgetType: studio.ui.widgetType.Label,
text: "This event has no parameters",
}];
buttons = [closeButton];
} else {
main = [{
widgetType: studio.ui.widgetType.ComboBox,
items: event.parameters.map(function (p) {
return {
text: p.preset.presetOwner.name,
userData: p.preset.id,
};
}),
onCurrentIndexChanged: function () {
parameterIndex = this.currentIndex();
},
}, {
widgetType: studio.ui.widgetType.CheckBox,
text: "Reverse",
onToggled: function() {
reverse = this.isChecked();
},
}];
buttons = [addButton];
}
studio.ui.showModalDialog({
widgetType: studio.ui.widgetType.Layout,
layout: studio.ui.layoutType.VBoxLayout,
items: main.concat([
{
widgetType: studio.ui.widgetType.Layout,
layout: studio.ui.layoutType.HBoxLayout,
items: buttons,
},
]),
minimumHeight: 100,
minimumWidth: 100,
});
}
studio.menu.addMenuItem({
name: "Modulate gain from parameter...",
execute: pitchVolumeExecutor,
keySequence: "F9",
});