@toneflix/studio-wams 0.0.0-stage → 0.5.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -2
  3. package/THIRD_PARTY_NOTICES.md +43 -0
  4. package/dist/catalog.d.ts +22 -0
  5. package/dist/catalog.js +272 -0
  6. package/dist/index.d.ts +45 -0
  7. package/dist/index.js +38 -0
  8. package/dist/version.d.ts +2 -0
  9. package/dist/version.js +2 -0
  10. package/licenses/MPL-2.0.txt +373 -0
  11. package/package.json +50 -3
  12. package/plugins/plugins.json +357 -0
  13. package/plugins/sequencer-party/delay/descriptor.json +16 -0
  14. package/plugins/sequencer-party/delay/index.js +247 -0
  15. package/plugins/sequencer-party/delay/screenshot.png +0 -0
  16. package/plugins/sequencer-party/distortion/descriptor.json +16 -0
  17. package/plugins/sequencer-party/distortion/index.js +257 -0
  18. package/plugins/sequencer-party/distortion/screenshot.png +0 -0
  19. package/plugins/sequencer-party/simple-eq/descriptor.json +16 -0
  20. package/plugins/sequencer-party/simple-eq/index.js +237 -0
  21. package/plugins/sequencer-party/simple-eq/screenshot.png +0 -0
  22. package/plugins/toneflix/base.js +182 -0
  23. package/plugins/toneflix/chorus.js +48 -0
  24. package/plugins/toneflix/chorus.png +0 -0
  25. package/plugins/toneflix/compressor.js +35 -0
  26. package/plugins/toneflix/compressor.png +0 -0
  27. package/plugins/toneflix/drive.js +44 -0
  28. package/plugins/toneflix/drive.png +0 -0
  29. package/plugins/toneflix/echo.js +35 -0
  30. package/plugins/toneflix/echo.png +0 -0
  31. package/plugins/toneflix/eq.js +36 -0
  32. package/plugins/toneflix/eq.png +0 -0
  33. package/plugins/toneflix/gate.js +79 -0
  34. package/plugins/toneflix/gate.png +0 -0
  35. package/plugins/toneflix/kbverb.js +153 -0
  36. package/plugins/toneflix/kbverb.png +0 -0
  37. package/plugins/toneflix/limiter.js +47 -0
  38. package/plugins/toneflix/limiter.png +0 -0
  39. package/plugins/toneflix/phaser.js +47 -0
  40. package/plugins/toneflix/phaser.png +0 -0
  41. package/plugins/toneflix/reverb.js +58 -0
  42. package/plugins/toneflix/reverb.png +0 -0
  43. package/plugins/toneflix/stone-phaser.js +142 -0
  44. package/plugins/toneflix/stone-phaser.png +0 -0
@@ -0,0 +1,47 @@
1
+ import { makePlugin } from './base.js';
2
+
3
+ const STAGES = 6;
4
+
5
+ /** A six-stage phaser with an LFO-swept centre and feedback. */
6
+ export default makePlugin({
7
+ identifier: 'net.toneflix.studio.phaser',
8
+ name: 'Phaser',
9
+ params: {
10
+ rate: { label: 'Rate', defaultValue: 0.4, minValue: 0.05, maxValue: 5, step: 0.05, units: 'Hz' },
11
+ centre: { label: 'Centre', defaultValue: 900, minValue: 200, maxValue: 4000, step: 10, units: 'Hz' },
12
+ depth: { label: 'Depth', defaultValue: 0.7, minValue: 0, maxValue: 1 },
13
+ feedback: { label: 'Feedback', defaultValue: 0.4, minValue: 0, maxValue: 0.9 },
14
+ mix: { label: 'Mix', defaultValue: 0.5, minValue: 0, maxValue: 1 },
15
+ },
16
+ build(context, node) {
17
+ const lfo = new OscillatorNode(context, { type: 'sine' });
18
+ const sweep = new GainNode(context);
19
+ const stages = Array.from({ length: STAGES }, () => new BiquadFilterNode(context, { type: 'allpass', Q: 0.5 }));
20
+ const feedback = new GainNode(context);
21
+ // A loop needs a delay; this one is a single render block
22
+ const loop = new DelayNode(context, { delayTime: 128 / context.sampleRate, maxDelayTime: 0.01 });
23
+ const wet = new GainNode(context);
24
+ const dry = new GainNode(context);
25
+
26
+ lfo.connect(sweep);
27
+ node.connectInput(stages[0]);
28
+ for (let i = 1; i < STAGES; i++) stages[i - 1].connect(stages[i]);
29
+ for (const stage of stages) sweep.connect(stage.frequency);
30
+ stages[STAGES - 1].connect(feedback).connect(loop).connect(stages[0]);
31
+ stages[STAGES - 1].connect(wet).connect(node.output);
32
+ node.connectInput(dry).connect(node.output);
33
+ lfo.start();
34
+
35
+ return { lfo, sweep, stages, feedback, wet, dry, stop: () => lfo.stop() };
36
+ },
37
+ apply({ lfo, sweep, stages, feedback, wet, dry }, v, _transport, context) {
38
+ const now = context.currentTime;
39
+
40
+ lfo.frequency.setTargetAtTime(v.rate, now, 0.02);
41
+ sweep.gain.setTargetAtTime(v.centre * v.depth * 0.9, now, 0.02);
42
+ for (const stage of stages) stage.frequency.setTargetAtTime(v.centre, now, 0.02);
43
+ feedback.gain.setTargetAtTime(v.feedback, now, 0.02);
44
+ wet.gain.setTargetAtTime(v.mix, now, 0.02);
45
+ dry.gain.setTargetAtTime(1 - v.mix * 0.5, now, 0.02);
46
+ },
47
+ });
Binary file
@@ -0,0 +1,58 @@
1
+ import { makePlugin } from './base.js';
2
+
3
+ /** A stereo impulse response of decaying noise, the same every time for a given length. */
4
+ const impulse = (context, seconds) => {
5
+ const length = Math.max(1, Math.floor(context.sampleRate * seconds));
6
+ const buffer = context.createBuffer(2, length, context.sampleRate);
7
+ let seed = 1;
8
+ const random = () => {
9
+ seed = (seed * 1664525 + 1013904223) >>> 0;
10
+ return seed / 2 ** 31 - 1;
11
+ };
12
+
13
+ for (let channel = 0; channel < 2; channel++) {
14
+ const data = buffer.getChannelData(channel);
15
+
16
+ // Falls 60 dB over the length
17
+ for (let i = 0; i < length; i++) data[i] = random() * Math.exp((-6.9 * i) / length);
18
+ }
19
+
20
+ return buffer;
21
+ };
22
+
23
+ /** A room-to-hall reverb with decay, pre-delay and tone. */
24
+ export default makePlugin({
25
+ identifier: 'net.toneflix.studio.reverb',
26
+ name: 'Reverb',
27
+ params: {
28
+ decay: { label: 'Decay', defaultValue: 2, minValue: 0.2, maxValue: 8, step: 0.1, units: 's' },
29
+ predelay: { label: 'Pre-delay', defaultValue: 20, minValue: 0, maxValue: 200, step: 1, units: 'ms' },
30
+ tone: { label: 'Tone', defaultValue: 7000, minValue: 1000, maxValue: 16000, step: 50, units: 'Hz' },
31
+ mix: { label: 'Mix', defaultValue: 0.25, minValue: 0, maxValue: 1 },
32
+ },
33
+ build(context, node) {
34
+ const predelay = new DelayNode(context, { maxDelayTime: 0.2 });
35
+ const convolver = new ConvolverNode(context);
36
+ const tone = new BiquadFilterNode(context, { type: 'lowpass' });
37
+ const wet = new GainNode(context);
38
+ const dry = new GainNode(context);
39
+
40
+ node.connectInput(dry).connect(node.output);
41
+ node.connectInput(predelay).connect(convolver).connect(tone).connect(wet).connect(node.output);
42
+
43
+ return { predelay, convolver, tone, wet, dry, decay: -1 };
44
+ },
45
+ apply(parts, v, _transport, context) {
46
+ const now = context.currentTime;
47
+
48
+ if (parts.decay !== v.decay) {
49
+ parts.convolver.buffer = impulse(context, v.decay);
50
+ parts.decay = v.decay;
51
+ }
52
+
53
+ parts.predelay.delayTime.setTargetAtTime(v.predelay / 1000, now, 0.02);
54
+ parts.tone.frequency.setTargetAtTime(v.tone, now, 0.02);
55
+ parts.wet.gain.setTargetAtTime(v.mix, now, 0.02);
56
+ parts.dry.gain.setTargetAtTime(1 - v.mix * 0.5, now, 0.02);
57
+ },
58
+ });
Binary file
@@ -0,0 +1,142 @@
1
+ import { makePlugin } from './base.js';
2
+
3
+ /**
4
+ * A port of Stone Phaser by Jean Pierre Cimalando (CC0-1.0), a model of a four-stage
5
+ * analog phaser pedal after Kiiski, Esqueda and Välimäki, "Time-variant gray-box
6
+ * modeling of a phaser pedal" (DAFx-16).
7
+ */
8
+ const processor = `
9
+ const smoothing = Math.exp(-1 / (0.1 * sampleRate));
10
+ const key = (hz) => 69 + 12 * Math.log2(hz / 440);
11
+ const hz = (k) => 440 * 2 ** ((k - 69) / 12);
12
+
13
+ /** The rounded triangle the pedal's LFO makes, from 0 to 1 over a cycle. */
14
+ const roundness = 0.975;
15
+ const shape = (pos) => 1 - Math.sin(2 * (pos < 0.5 ? pos : 1 - pos) * Math.asin(roundness)) / roundness;
16
+
17
+ class Smooth {
18
+ constructor(value) {
19
+ this.value = value;
20
+ }
21
+
22
+ step(target) {
23
+ return (this.value = (1 - smoothing) * target + smoothing * this.value);
24
+ }
25
+ }
26
+
27
+ /** One-pole highpass. */
28
+ class Highpass {
29
+ x1 = 0;
30
+ y1 = 0;
31
+
32
+ step(x, f) {
33
+ const p = Math.exp((-2 * Math.PI * f) / sampleRate);
34
+ const y = 0.5 * (1 + p) * (x - this.x1) + p * this.y1;
35
+
36
+ this.x1 = x;
37
+ this.y1 = y;
38
+
39
+ return y;
40
+ }
41
+ }
42
+
43
+ /** One-pole allpass. */
44
+ class Allpass {
45
+ x1 = 0;
46
+ y1 = 0;
47
+
48
+ step(x, a) {
49
+ const y = a * x + this.x1 - a * this.y1;
50
+
51
+ this.x1 = x;
52
+ this.y1 = y;
53
+
54
+ return y;
55
+ }
56
+ }
57
+
58
+ class Channel {
59
+ input = new Highpass();
60
+ loop = new Highpass();
61
+ stages = [new Allpass(), new Allpass(), new Allpass(), new Allpass()];
62
+ last = 0;
63
+
64
+ step(x, a, feedback, cut) {
65
+ let y = this.input.step(x, 33) + this.loop.step(this.last, cut) * feedback;
66
+
67
+ for (const stage of this.stages) y = stage.step(y, a);
68
+
69
+ return (this.last = y);
70
+ }
71
+ }
72
+
73
+ class ToneflixStonePhaser extends AudioWorkletProcessor {
74
+ static get parameterDescriptors() {
75
+ return ['color', 'rate', 'feedback', 'cut', 'mix', 'phase'].map((name) => ({ name, defaultValue: 0, automationRate: 'k-rate' }));
76
+ }
77
+
78
+ constructor() {
79
+ super();
80
+ this.channels = [new Channel(), new Channel()];
81
+ this.pos = 0;
82
+ this.s = { rate: new Smooth(0.2), feedback: new Smooth(0.75), cut: new Smooth(500), wet: new Smooth(0.7), dry: new Smooth(0.7), phase: new Smooth(1), low: new Smooth(key(80)), high: new Smooth(key(2200)), colorFeedback: new Smooth(0.75) };
83
+ }
84
+
85
+ process([input], [output], p) {
86
+ const color = p.color[0] >= 0.5;
87
+ const mix = p.mix[0] / 100;
88
+ const s = this.s;
89
+
90
+ for (let i = 0; i < output[0].length; i++) {
91
+ const rate = s.rate.step(p.rate[0]);
92
+ const feedback = s.feedback.step(p.feedback[0] / 100);
93
+ const cut = s.cut.step(p.cut[0]);
94
+ const wet = s.wet.step(Math.sin((mix * Math.PI) / 2));
95
+ const dry = s.dry.step(Math.cos((mix * Math.PI) / 2));
96
+ const phase = s.phase.step(p.phase[0] / 360 + 1);
97
+ const low = s.low.step(key(color ? 80 : 300));
98
+ const high = s.high.step(key(color ? 2200 : 6000));
99
+ const loop = s.colorFeedback.step(color ? feedback : 0.1 * feedback);
100
+
101
+ this.pos = (this.pos + rate / sampleRate) % 1;
102
+
103
+ for (let c = 0; c < output.length; c++) {
104
+ const pos = c ? (this.pos + phase) % 1 : this.pos;
105
+ const f = hz(low + shape(pos) * (high - low));
106
+ const a = -1 + (2 * Math.PI * f) / sampleRate;
107
+ const x = (input[c] ?? input[0])?.[i] ?? 0;
108
+
109
+ output[c][i] = x * dry + this.channels[c].step(x, a, loop, cut) * wet;
110
+ }
111
+ }
112
+
113
+ return true;
114
+ }
115
+ }
116
+
117
+ registerProcessor('toneflix-stone-phaser', ToneflixStonePhaser);
118
+ `;
119
+
120
+ export default makePlugin({
121
+ identifier: 'net.toneflix.studio.stone-phaser',
122
+ name: 'Stone Phaser',
123
+ worklet: processor,
124
+ params: {
125
+ rate: { label: 'Rate', defaultValue: 0.2, minValue: 0.01, maxValue: 5, step: 0.01, units: 'Hz' },
126
+ feedback: { label: 'Feedback', defaultValue: 75, minValue: 0, maxValue: 99, step: 1, units: '%' },
127
+ cut: { label: 'Feedback bass cut', defaultValue: 500, minValue: 10, maxValue: 5000, step: 10, units: 'Hz' },
128
+ color: { label: 'Color', defaultValue: 1, minValue: 0, maxValue: 1, step: 1 },
129
+ phase: { label: 'Stereo phase', defaultValue: 0, minValue: -180, maxValue: 180, step: 1, units: '°' },
130
+ mix: { label: 'Mix', defaultValue: 50, minValue: 0, maxValue: 100, step: 1, units: '%' },
131
+ },
132
+ build(context, node) {
133
+ const phaser = new AudioWorkletNode(context, 'toneflix-stone-phaser', { outputChannelCount: [2] });
134
+
135
+ node.connectInput(phaser).connect(node.output);
136
+
137
+ return { phaser };
138
+ },
139
+ apply({ phaser }, v, _transport, context) {
140
+ for (const id of ['color', 'rate', 'feedback', 'cut', 'mix', 'phase']) phaser.parameters.get(id).setValueAtTime(v[id], context.currentTime);
141
+ },
142
+ });