@toneflix/studio-wams 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -2
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/catalog.d.ts +22 -0
- package/dist/catalog.js +149 -0
- package/dist/community.d.ts +47 -0
- package/dist/community.js +180 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +68 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +49 -3
- package/plugins/plugins.json +194 -0
- package/plugins/toneflix/base.js +194 -0
- package/plugins/toneflix/chorus.js +48 -0
- package/plugins/toneflix/chorus.png +0 -0
- package/plugins/toneflix/compressor.js +35 -0
- package/plugins/toneflix/compressor.png +0 -0
- package/plugins/toneflix/drive.js +44 -0
- package/plugins/toneflix/drive.png +0 -0
- package/plugins/toneflix/echo.js +35 -0
- package/plugins/toneflix/echo.png +0 -0
- package/plugins/toneflix/eq.js +36 -0
- package/plugins/toneflix/eq.png +0 -0
- package/plugins/toneflix/gate.js +79 -0
- package/plugins/toneflix/gate.png +0 -0
- package/plugins/toneflix/kbverb.js +153 -0
- package/plugins/toneflix/kbverb.png +0 -0
- package/plugins/toneflix/limiter.js +47 -0
- package/plugins/toneflix/limiter.png +0 -0
- package/plugins/toneflix/phaser.js +47 -0
- package/plugins/toneflix/phaser.png +0 -0
- package/plugins/toneflix/reverb.js +58 -0
- package/plugins/toneflix/reverb.png +0 -0
- package/plugins/toneflix/stone-phaser.js +142 -0
- package/plugins/toneflix/stone-phaser.png +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toneflix/studio-wams",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Reviewed Web Audio Module effects for Toneflix Studio, pinned and served from jsDelivr, with a browser tab and mixer catalog for them.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Toneflix <code@toneflix.com.ng>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/toneflix/studio.git",
|
|
10
|
+
"directory": "packages/wams"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://toneflix.github.io/studio/",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/toneflix/studio/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"wam",
|
|
18
|
+
"web-audio-module",
|
|
19
|
+
"plugins",
|
|
20
|
+
"effects",
|
|
21
|
+
"daw"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"@toneflix/source": "./src/index.ts",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./plugins/*": "./plugins/*"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"plugins",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"THIRD_PARTY_NOTICES.md"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.18"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"provenance": true
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.build.json"
|
|
51
|
+
}
|
|
6
52
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"identifier": "net.toneflix.studio.echo",
|
|
4
|
+
"name": "Echo",
|
|
5
|
+
"vendor": "Toneflix",
|
|
6
|
+
"description": "Tempo-synced echo with feedback and tone",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"effect",
|
|
9
|
+
"delay",
|
|
10
|
+
"echo"
|
|
11
|
+
],
|
|
12
|
+
"path": "toneflix/echo.js",
|
|
13
|
+
"thumbnail": "toneflix/echo.png",
|
|
14
|
+
"version": "1.0.0",
|
|
15
|
+
"isInstrument": false,
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"identifier": "net.toneflix.studio.drive",
|
|
21
|
+
"name": "Drive",
|
|
22
|
+
"vendor": "Toneflix",
|
|
23
|
+
"description": "Warm saturation with tone and level",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"effect",
|
|
26
|
+
"distortion",
|
|
27
|
+
"saturation"
|
|
28
|
+
],
|
|
29
|
+
"path": "toneflix/drive.js",
|
|
30
|
+
"thumbnail": "toneflix/drive.png",
|
|
31
|
+
"version": "1.0.0",
|
|
32
|
+
"isInstrument": false,
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"identifier": "net.toneflix.studio.reverb",
|
|
38
|
+
"name": "Reverb",
|
|
39
|
+
"vendor": "Toneflix",
|
|
40
|
+
"description": "Room-to-hall reverb with decay, pre-delay and tone",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"effect",
|
|
43
|
+
"reverb",
|
|
44
|
+
"space"
|
|
45
|
+
],
|
|
46
|
+
"path": "toneflix/reverb.js",
|
|
47
|
+
"thumbnail": "toneflix/reverb.png",
|
|
48
|
+
"version": "1.0.0",
|
|
49
|
+
"isInstrument": false,
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"identifier": "net.toneflix.studio.compressor",
|
|
55
|
+
"name": "Compressor",
|
|
56
|
+
"vendor": "Toneflix",
|
|
57
|
+
"description": "Compressor with threshold, ratio, attack, release, knee and make-up gain",
|
|
58
|
+
"keywords": [
|
|
59
|
+
"effect",
|
|
60
|
+
"dynamics",
|
|
61
|
+
"compressor"
|
|
62
|
+
],
|
|
63
|
+
"path": "toneflix/compressor.js",
|
|
64
|
+
"thumbnail": "toneflix/compressor.png",
|
|
65
|
+
"version": "1.0.0",
|
|
66
|
+
"isInstrument": false,
|
|
67
|
+
"license": "MIT",
|
|
68
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"identifier": "net.toneflix.studio.limiter",
|
|
72
|
+
"name": "Limiter",
|
|
73
|
+
"vendor": "Toneflix",
|
|
74
|
+
"description": "Peak limiter with gain and a hard ceiling",
|
|
75
|
+
"keywords": [
|
|
76
|
+
"effect",
|
|
77
|
+
"dynamics",
|
|
78
|
+
"limiter",
|
|
79
|
+
"master"
|
|
80
|
+
],
|
|
81
|
+
"path": "toneflix/limiter.js",
|
|
82
|
+
"thumbnail": "toneflix/limiter.png",
|
|
83
|
+
"version": "1.0.0",
|
|
84
|
+
"isInstrument": false,
|
|
85
|
+
"license": "MIT",
|
|
86
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"identifier": "net.toneflix.studio.gate",
|
|
90
|
+
"name": "Gate",
|
|
91
|
+
"vendor": "Toneflix",
|
|
92
|
+
"description": "Noise gate with threshold, hold and range",
|
|
93
|
+
"keywords": [
|
|
94
|
+
"effect",
|
|
95
|
+
"dynamics",
|
|
96
|
+
"gate",
|
|
97
|
+
"noise"
|
|
98
|
+
],
|
|
99
|
+
"path": "toneflix/gate.js",
|
|
100
|
+
"thumbnail": "toneflix/gate.png",
|
|
101
|
+
"version": "1.0.0",
|
|
102
|
+
"isInstrument": false,
|
|
103
|
+
"license": "MIT",
|
|
104
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"identifier": "net.toneflix.studio.eq",
|
|
108
|
+
"name": "EQ",
|
|
109
|
+
"vendor": "Toneflix",
|
|
110
|
+
"description": "Three-band equalizer with a sweepable mid",
|
|
111
|
+
"keywords": [
|
|
112
|
+
"effect",
|
|
113
|
+
"eq",
|
|
114
|
+
"equalizer",
|
|
115
|
+
"filter"
|
|
116
|
+
],
|
|
117
|
+
"path": "toneflix/eq.js",
|
|
118
|
+
"thumbnail": "toneflix/eq.png",
|
|
119
|
+
"version": "1.0.0",
|
|
120
|
+
"isInstrument": false,
|
|
121
|
+
"license": "MIT",
|
|
122
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"identifier": "net.toneflix.studio.chorus",
|
|
126
|
+
"name": "Chorus",
|
|
127
|
+
"vendor": "Toneflix",
|
|
128
|
+
"description": "Stereo chorus with rate, depth and delay",
|
|
129
|
+
"keywords": [
|
|
130
|
+
"effect",
|
|
131
|
+
"modulation",
|
|
132
|
+
"chorus"
|
|
133
|
+
],
|
|
134
|
+
"path": "toneflix/chorus.js",
|
|
135
|
+
"thumbnail": "toneflix/chorus.png",
|
|
136
|
+
"version": "1.0.0",
|
|
137
|
+
"isInstrument": false,
|
|
138
|
+
"license": "MIT",
|
|
139
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"identifier": "net.toneflix.studio.phaser",
|
|
143
|
+
"name": "Phaser",
|
|
144
|
+
"vendor": "Toneflix",
|
|
145
|
+
"description": "Six-stage phaser with feedback",
|
|
146
|
+
"keywords": [
|
|
147
|
+
"effect",
|
|
148
|
+
"modulation",
|
|
149
|
+
"phaser"
|
|
150
|
+
],
|
|
151
|
+
"path": "toneflix/phaser.js",
|
|
152
|
+
"thumbnail": "toneflix/phaser.png",
|
|
153
|
+
"version": "1.0.0",
|
|
154
|
+
"isInstrument": false,
|
|
155
|
+
"license": "MIT",
|
|
156
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"identifier": "net.toneflix.studio.kbverb",
|
|
160
|
+
"name": "KB Verb",
|
|
161
|
+
"vendor": "Toneflix",
|
|
162
|
+
"description": "Lush allpass-loop reverb, a port of KBVerb by Corey Kereliuk",
|
|
163
|
+
"keywords": [
|
|
164
|
+
"effect",
|
|
165
|
+
"reverb",
|
|
166
|
+
"space",
|
|
167
|
+
"ambient"
|
|
168
|
+
],
|
|
169
|
+
"path": "toneflix/kbverb.js",
|
|
170
|
+
"thumbnail": "toneflix/kbverb.png",
|
|
171
|
+
"version": "1.0.0",
|
|
172
|
+
"isInstrument": false,
|
|
173
|
+
"license": "MIT",
|
|
174
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"identifier": "net.toneflix.studio.stone-phaser",
|
|
178
|
+
"name": "Stone Phaser",
|
|
179
|
+
"vendor": "Toneflix",
|
|
180
|
+
"description": "Four-stage analog phaser model, a port of Stone Phaser by Jean Pierre Cimalando",
|
|
181
|
+
"keywords": [
|
|
182
|
+
"effect",
|
|
183
|
+
"modulation",
|
|
184
|
+
"phaser",
|
|
185
|
+
"analog"
|
|
186
|
+
],
|
|
187
|
+
"path": "toneflix/stone-phaser.js",
|
|
188
|
+
"thumbnail": "toneflix/stone-phaser.png",
|
|
189
|
+
"version": "1.0.0",
|
|
190
|
+
"isInstrument": false,
|
|
191
|
+
"license": "MIT",
|
|
192
|
+
"homepage": "https://github.com/toneflix/studio"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny base for the Toneflix plugins: a Web Audio Module (WAM 2) made of plain
|
|
3
|
+
* Web Audio nodes, with parameters, state, transport events and a slider editor.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** One AudioNode outside, a graph inside: input is this node, output is `this.output`. */
|
|
7
|
+
class CompositeNode extends GainNode {
|
|
8
|
+
constructor(context) {
|
|
9
|
+
super(context);
|
|
10
|
+
this.output = new GainNode(context);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
connect(...args) {
|
|
14
|
+
return this.output.connect(...args);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
disconnect(...args) {
|
|
18
|
+
return this.output.disconnect(...args);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Connect the input itself, not the output. */
|
|
22
|
+
connectInput(target) {
|
|
23
|
+
return GainNode.prototype.connect.call(this, target);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** AudioWorklet modules already added, per context. */
|
|
28
|
+
const worklets = new WeakMap();
|
|
29
|
+
|
|
30
|
+
/** Add a worklet's processor code to a context once. */
|
|
31
|
+
const loadWorklet = (context, code) => {
|
|
32
|
+
let loaded = worklets.get(context);
|
|
33
|
+
|
|
34
|
+
if (!loaded) {
|
|
35
|
+
loaded = new Map();
|
|
36
|
+
worklets.set(context, loaded);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!loaded.has(code)) {
|
|
40
|
+
const url = URL.createObjectURL(new Blob([code], { type: 'text/javascript' }));
|
|
41
|
+
|
|
42
|
+
loaded.set(
|
|
43
|
+
code,
|
|
44
|
+
context.audioWorklet.addModule(url).finally(() => URL.revokeObjectURL(url)),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return loaded.get(code);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** A value as 0 to 1 of a parameter's range, and back. */
|
|
52
|
+
const toNormal = (p, value) => (p.maxValue === p.minValue ? 0 : (value - p.minValue) / (p.maxValue - p.minValue));
|
|
53
|
+
const fromNormal = (p, value) => p.minValue + value * (p.maxValue - p.minValue);
|
|
54
|
+
const clampTo = (p, value) => Math.min(p.maxValue, Math.max(p.minValue, Number(value)));
|
|
55
|
+
|
|
56
|
+
/** Decimals to show for a parameter's step. */
|
|
57
|
+
const decimals = (step) => Math.min(2, String(step).split('.')[1]?.length ?? 0);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `params` are the sliders, `build` makes the graph, `apply` sets it from the values.
|
|
61
|
+
* A `stop` function in the parts `build` returns runs when the plugin is destroyed.
|
|
62
|
+
* `worklet` is AudioWorklet processor code the graph needs, added before `build` runs.
|
|
63
|
+
*/
|
|
64
|
+
export const makePlugin = ({ identifier, name, params, build, apply, worklet }) => {
|
|
65
|
+
class Node extends CompositeNode {
|
|
66
|
+
constructor(context) {
|
|
67
|
+
super(context);
|
|
68
|
+
this.values = Object.fromEntries(Object.entries(params).map(([id, p]) => [id, p.defaultValue]));
|
|
69
|
+
this.transport = { tempo: 120, playing: false };
|
|
70
|
+
this.parts = build(context, this);
|
|
71
|
+
this.update();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
update() {
|
|
75
|
+
apply(this.parts, this.values, this.transport, this.context);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getState() {
|
|
79
|
+
return { ...this.values };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async setState(state) {
|
|
83
|
+
Object.assign(this.values, state);
|
|
84
|
+
this.update();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async getParameterInfo(...ids) {
|
|
88
|
+
return Object.fromEntries(Object.entries(params).filter(([id]) => !ids.length || ids.includes(id)).map(([id, p]) => [id, { id, type: 'float', ...p }]));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async getParameterValues(normalized = false, ...ids) {
|
|
92
|
+
return Object.fromEntries(
|
|
93
|
+
Object.entries(this.values)
|
|
94
|
+
.filter(([id]) => !ids.length || ids.includes(id))
|
|
95
|
+
.map(([id, value]) => [id, { id, value: normalized ? toNormal(params[id], value) : value, normalized }]),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async setParameterValues(values) {
|
|
100
|
+
for (const { id, value, normalized } of Object.values(values)) {
|
|
101
|
+
if (params[id]) this.values[id] = clampTo(params[id], normalized ? fromNormal(params[id], value) : value);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.update();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
scheduleEvents(...events) {
|
|
108
|
+
for (const event of events) {
|
|
109
|
+
if (event.type === 'wam-transport') this.transport = event.data;
|
|
110
|
+
if (event.type === 'wam-automation') this.values[event.data.id] = event.data.value;
|
|
111
|
+
}
|
|
112
|
+
this.update();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
clearEvents() {}
|
|
116
|
+
|
|
117
|
+
destroy() {
|
|
118
|
+
this.parts.stop?.();
|
|
119
|
+
this.disconnect();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return class Plugin {
|
|
124
|
+
static async createInstance(groupId, audioContext, initialState) {
|
|
125
|
+
if (worklet) await loadWorklet(audioContext, worklet);
|
|
126
|
+
|
|
127
|
+
const plugin = new Plugin(groupId, audioContext);
|
|
128
|
+
if (initialState) await plugin.audioNode.setState(initialState);
|
|
129
|
+
return plugin;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
constructor(groupId, audioContext) {
|
|
133
|
+
this.groupId = groupId;
|
|
134
|
+
this.audioContext = audioContext;
|
|
135
|
+
this.audioNode = new Node(audioContext);
|
|
136
|
+
this.descriptor = { identifier, name, vendor: 'Toneflix', version: '1.0.0', apiVersion: '2.0.0', hasAudioInput: true, hasAudioOutput: true };
|
|
137
|
+
this.instanceId = `${identifier}-${Math.random().toString(36).slice(2)}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get isWebAudioModule() {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get moduleId() {
|
|
145
|
+
return identifier;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get name() {
|
|
149
|
+
return name;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get vendor() {
|
|
153
|
+
return this.descriptor.vendor;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async createGui() {
|
|
157
|
+
const node = this.audioNode;
|
|
158
|
+
const root = document.createElement('div');
|
|
159
|
+
|
|
160
|
+
root.style.cssText = 'display:grid;gap:10px;padding:14px 16px;min-width:220px;font:12px system-ui,sans-serif;color:#e8e8ea';
|
|
161
|
+
|
|
162
|
+
for (const [id, p] of Object.entries(params)) {
|
|
163
|
+
const row = document.createElement('label');
|
|
164
|
+
const top = document.createElement('div');
|
|
165
|
+
const value = document.createElement('span');
|
|
166
|
+
const input = document.createElement('input');
|
|
167
|
+
const show = () => (value.textContent = `${(+node.values[id]).toFixed(decimals(p.step ?? 0.01))}${p.units ? ` ${p.units}` : ''}`);
|
|
168
|
+
|
|
169
|
+
top.style.cssText = 'display:flex;justify-content:space-between;margin-bottom:4px';
|
|
170
|
+
top.append(p.label, value);
|
|
171
|
+
input.type = 'range';
|
|
172
|
+
input.min = p.minValue;
|
|
173
|
+
input.max = p.maxValue;
|
|
174
|
+
input.step = p.step ?? 0.01;
|
|
175
|
+
input.value = node.values[id];
|
|
176
|
+
input.style.cssText = 'width:100%;accent-color:#03bfff';
|
|
177
|
+
input.addEventListener('input', () => {
|
|
178
|
+
node.values[id] = +input.value;
|
|
179
|
+
node.update();
|
|
180
|
+
show();
|
|
181
|
+
});
|
|
182
|
+
show();
|
|
183
|
+
row.append(top, input);
|
|
184
|
+
root.append(row);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return root;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
destroyGui(gui) {
|
|
191
|
+
gui.remove();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { makePlugin } from './base.js';
|
|
2
|
+
|
|
3
|
+
/** A stereo chorus: two short delays swept in opposite directions by one LFO. */
|
|
4
|
+
export default makePlugin({
|
|
5
|
+
identifier: 'net.toneflix.studio.chorus',
|
|
6
|
+
name: 'Chorus',
|
|
7
|
+
params: {
|
|
8
|
+
rate: { label: 'Rate', defaultValue: 0.8, minValue: 0.05, maxValue: 5, step: 0.05, units: 'Hz' },
|
|
9
|
+
depth: { label: 'Depth', defaultValue: 3, minValue: 0, maxValue: 10, step: 0.1, units: 'ms' },
|
|
10
|
+
delay: { label: 'Delay', defaultValue: 15, minValue: 5, maxValue: 40, step: 1, units: 'ms' },
|
|
11
|
+
mix: { label: 'Mix', defaultValue: 0.5, minValue: 0, maxValue: 1 },
|
|
12
|
+
},
|
|
13
|
+
build(context, node) {
|
|
14
|
+
const lfo = new OscillatorNode(context, { type: 'sine' });
|
|
15
|
+
const dry = new GainNode(context);
|
|
16
|
+
const wet = new GainNode(context);
|
|
17
|
+
const voices = [-1, 1].map((side) => {
|
|
18
|
+
const delay = new DelayNode(context, { maxDelayTime: 0.06 });
|
|
19
|
+
const depth = new GainNode(context);
|
|
20
|
+
const pan = new StereoPannerNode(context, { pan: side * 0.8 });
|
|
21
|
+
|
|
22
|
+
lfo.connect(depth).connect(delay.delayTime);
|
|
23
|
+
node.connectInput(delay).connect(pan).connect(wet);
|
|
24
|
+
|
|
25
|
+
return { delay, depth, side };
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
node.connectInput(dry).connect(node.output);
|
|
29
|
+
wet.connect(node.output);
|
|
30
|
+
lfo.start();
|
|
31
|
+
|
|
32
|
+
return { lfo, dry, wet, voices, stop: () => lfo.stop() };
|
|
33
|
+
},
|
|
34
|
+
apply({ lfo, dry, wet, voices }, v, _transport, context) {
|
|
35
|
+
const now = context.currentTime;
|
|
36
|
+
|
|
37
|
+
lfo.frequency.setTargetAtTime(v.rate, now, 0.02);
|
|
38
|
+
|
|
39
|
+
for (const voice of voices) {
|
|
40
|
+
voice.delay.delayTime.setTargetAtTime(v.delay / 1000, now, 0.02);
|
|
41
|
+
voice.depth.gain.setTargetAtTime((voice.side * v.depth) / 1000 / 2, now, 0.02);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Two voices: each at half level
|
|
45
|
+
wet.gain.setTargetAtTime(v.mix * 0.5, now, 0.02);
|
|
46
|
+
dry.gain.setTargetAtTime(1 - v.mix * 0.5, now, 0.02);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { makePlugin } from './base.js';
|
|
2
|
+
|
|
3
|
+
const gain = (db) => 10 ** (db / 20);
|
|
4
|
+
|
|
5
|
+
/** A compressor with threshold, ratio, timing and make-up gain. */
|
|
6
|
+
export default makePlugin({
|
|
7
|
+
identifier: 'net.toneflix.studio.compressor',
|
|
8
|
+
name: 'Compressor',
|
|
9
|
+
params: {
|
|
10
|
+
threshold: { label: 'Threshold', defaultValue: -18, minValue: -60, maxValue: 0, step: 0.5, units: 'dB' },
|
|
11
|
+
ratio: { label: 'Ratio', defaultValue: 4, minValue: 1, maxValue: 20, step: 0.5, units: ':1' },
|
|
12
|
+
attack: { label: 'Attack', defaultValue: 10, minValue: 0, maxValue: 200, step: 1, units: 'ms' },
|
|
13
|
+
release: { label: 'Release', defaultValue: 150, minValue: 10, maxValue: 1000, step: 5, units: 'ms' },
|
|
14
|
+
knee: { label: 'Knee', defaultValue: 6, minValue: 0, maxValue: 40, step: 1, units: 'dB' },
|
|
15
|
+
makeup: { label: 'Make-up', defaultValue: 0, minValue: -12, maxValue: 24, step: 0.5, units: 'dB' },
|
|
16
|
+
},
|
|
17
|
+
build(context, node) {
|
|
18
|
+
const compressor = new DynamicsCompressorNode(context);
|
|
19
|
+
const makeup = new GainNode(context);
|
|
20
|
+
|
|
21
|
+
node.connectInput(compressor).connect(makeup).connect(node.output);
|
|
22
|
+
|
|
23
|
+
return { compressor, makeup };
|
|
24
|
+
},
|
|
25
|
+
apply({ compressor, makeup }, v, _transport, context) {
|
|
26
|
+
const now = context.currentTime;
|
|
27
|
+
|
|
28
|
+
compressor.threshold.setValueAtTime(v.threshold, now);
|
|
29
|
+
compressor.ratio.setValueAtTime(v.ratio, now);
|
|
30
|
+
compressor.attack.setValueAtTime(v.attack / 1000, now);
|
|
31
|
+
compressor.release.setValueAtTime(v.release / 1000, now);
|
|
32
|
+
compressor.knee.setValueAtTime(v.knee, now);
|
|
33
|
+
makeup.gain.setTargetAtTime(gain(v.makeup), now, 0.02);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { makePlugin } from './base.js';
|
|
2
|
+
|
|
3
|
+
const curve = (amount) => {
|
|
4
|
+
const k = amount * 50;
|
|
5
|
+
const data = new Float32Array(1024);
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < data.length; i++) {
|
|
8
|
+
const x = (i / (data.length - 1)) * 2 - 1;
|
|
9
|
+
data[i] = ((1 + k) * x) / (1 + k * Math.abs(x));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Warm saturation with a tone control. */
|
|
16
|
+
export default makePlugin({
|
|
17
|
+
identifier: 'net.toneflix.studio.drive',
|
|
18
|
+
name: 'Drive',
|
|
19
|
+
params: {
|
|
20
|
+
drive: { label: 'Drive', defaultValue: 0.3, minValue: 0, maxValue: 1 },
|
|
21
|
+
tone: { label: 'Tone', defaultValue: 6000, minValue: 800, maxValue: 16000, step: 50, units: 'Hz' },
|
|
22
|
+
level: { label: 'Level', defaultValue: 0.8, minValue: 0, maxValue: 1.5 },
|
|
23
|
+
},
|
|
24
|
+
build(context, node) {
|
|
25
|
+
const shaper = new WaveShaperNode(context, { oversample: '4x' });
|
|
26
|
+
const tone = new BiquadFilterNode(context, { type: 'lowpass' });
|
|
27
|
+
const level = new GainNode(context);
|
|
28
|
+
|
|
29
|
+
node.connectInput(shaper).connect(tone).connect(level).connect(node.output);
|
|
30
|
+
|
|
31
|
+
return { shaper, tone, level, amount: -1 };
|
|
32
|
+
},
|
|
33
|
+
apply(parts, v, _transport, context) {
|
|
34
|
+
const now = context.currentTime;
|
|
35
|
+
|
|
36
|
+
if (parts.amount !== v.drive) {
|
|
37
|
+
parts.shaper.curve = curve(v.drive);
|
|
38
|
+
parts.amount = v.drive;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
parts.tone.frequency.setTargetAtTime(v.tone, now, 0.02);
|
|
42
|
+
parts.level.gain.setTargetAtTime(v.level, now, 0.02);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { makePlugin } from './base.js';
|
|
2
|
+
|
|
3
|
+
/** A tempo-synced echo: repeats every `beats` beats of the host's tempo. */
|
|
4
|
+
export default makePlugin({
|
|
5
|
+
identifier: 'net.toneflix.studio.echo',
|
|
6
|
+
name: 'Echo',
|
|
7
|
+
params: {
|
|
8
|
+
beats: { label: 'Beats', defaultValue: 0.75, minValue: 0.25, maxValue: 2, step: 0.25 },
|
|
9
|
+
feedback: { label: 'Feedback', defaultValue: 0.35, minValue: 0, maxValue: 0.9 },
|
|
10
|
+
tone: { label: 'Tone', defaultValue: 3500, minValue: 500, maxValue: 12000, step: 50, units: 'Hz' },
|
|
11
|
+
mix: { label: 'Mix', defaultValue: 0.3, minValue: 0, maxValue: 1 },
|
|
12
|
+
},
|
|
13
|
+
build(context, node) {
|
|
14
|
+
const delay = new DelayNode(context, { maxDelayTime: 4 });
|
|
15
|
+
const feedback = new GainNode(context);
|
|
16
|
+
const tone = new BiquadFilterNode(context, { type: 'lowpass' });
|
|
17
|
+
const wet = new GainNode(context);
|
|
18
|
+
const dry = new GainNode(context);
|
|
19
|
+
|
|
20
|
+
node.connectInput(dry).connect(node.output);
|
|
21
|
+
node.connectInput(delay).connect(tone).connect(feedback).connect(delay);
|
|
22
|
+
tone.connect(wet).connect(node.output);
|
|
23
|
+
|
|
24
|
+
return { delay, feedback, tone, wet, dry };
|
|
25
|
+
},
|
|
26
|
+
apply({ delay, feedback, tone, wet, dry }, v, transport, context) {
|
|
27
|
+
const now = context.currentTime;
|
|
28
|
+
|
|
29
|
+
delay.delayTime.setTargetAtTime(Math.min(4, v.beats * (60 / (transport.tempo || 120))), now, 0.02);
|
|
30
|
+
feedback.gain.setTargetAtTime(v.feedback, now, 0.02);
|
|
31
|
+
tone.frequency.setTargetAtTime(v.tone, now, 0.02);
|
|
32
|
+
wet.gain.setTargetAtTime(v.mix, now, 0.02);
|
|
33
|
+
dry.gain.setTargetAtTime(1 - v.mix * 0.5, now, 0.02);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { makePlugin } from './base.js';
|
|
2
|
+
|
|
3
|
+
/** A three-band EQ: low shelf, a sweepable mid and a high shelf. */
|
|
4
|
+
export default makePlugin({
|
|
5
|
+
identifier: 'net.toneflix.studio.eq',
|
|
6
|
+
name: 'EQ',
|
|
7
|
+
params: {
|
|
8
|
+
low: { label: 'Low', defaultValue: 0, minValue: -18, maxValue: 18, step: 0.5, units: 'dB' },
|
|
9
|
+
lowFreq: { label: 'Low freq', defaultValue: 120, minValue: 40, maxValue: 500, step: 5, units: 'Hz' },
|
|
10
|
+
mid: { label: 'Mid', defaultValue: 0, minValue: -18, maxValue: 18, step: 0.5, units: 'dB' },
|
|
11
|
+
midFreq: { label: 'Mid freq', defaultValue: 1000, minValue: 200, maxValue: 8000, step: 10, units: 'Hz' },
|
|
12
|
+
midQ: { label: 'Mid width', defaultValue: 1, minValue: 0.3, maxValue: 8, step: 0.1, units: 'Q' },
|
|
13
|
+
high: { label: 'High', defaultValue: 0, minValue: -18, maxValue: 18, step: 0.5, units: 'dB' },
|
|
14
|
+
highFreq: { label: 'High freq', defaultValue: 8000, minValue: 2000, maxValue: 16000, step: 50, units: 'Hz' },
|
|
15
|
+
},
|
|
16
|
+
build(context, node) {
|
|
17
|
+
const low = new BiquadFilterNode(context, { type: 'lowshelf' });
|
|
18
|
+
const mid = new BiquadFilterNode(context, { type: 'peaking' });
|
|
19
|
+
const high = new BiquadFilterNode(context, { type: 'highshelf' });
|
|
20
|
+
|
|
21
|
+
node.connectInput(low).connect(mid).connect(high).connect(node.output);
|
|
22
|
+
|
|
23
|
+
return { low, mid, high };
|
|
24
|
+
},
|
|
25
|
+
apply({ low, mid, high }, v, _transport, context) {
|
|
26
|
+
const now = context.currentTime;
|
|
27
|
+
|
|
28
|
+
low.gain.setTargetAtTime(v.low, now, 0.02);
|
|
29
|
+
low.frequency.setTargetAtTime(v.lowFreq, now, 0.02);
|
|
30
|
+
mid.gain.setTargetAtTime(v.mid, now, 0.02);
|
|
31
|
+
mid.frequency.setTargetAtTime(v.midFreq, now, 0.02);
|
|
32
|
+
mid.Q.setTargetAtTime(v.midQ, now, 0.02);
|
|
33
|
+
high.gain.setTargetAtTime(v.high, now, 0.02);
|
|
34
|
+
high.frequency.setTargetAtTime(v.highFreq, now, 0.02);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
Binary file
|