@grame/faustwasm 0.6.4 → 0.7.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/assets/standalone/faustwasm/index.d.ts +8 -2
- package/assets/standalone/faustwasm/index.js +61 -34
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +56 -7
- package/assets/standalone/index-template.js +3 -3
- package/assets/standalone/index.js +4 -4
- package/dist/cjs/index.d.ts +8 -2
- package/dist/cjs/index.js +61 -34
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +8 -2
- package/dist/cjs-bundle/index.js +61 -34
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +61 -34
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +8 -2
- package/dist/esm-bundle/index.js +61 -34
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +35 -16
- package/src/FaustScriptProcessorNode.ts +26 -14
- package/src/FaustWebAudioDsp.ts +0 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +8 -2
- package/test/faustlive-wasm/faustwasm/index.js +61 -34
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/faustlive-wasm/index.js +1 -1
- package/test/osc2.dsp +1 -1
- package/test/tables.dsp +71 -0
|
@@ -492,7 +492,7 @@ const activateMonoDSP = (dsp) => {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
// Setup UI
|
|
495
|
-
DSP.
|
|
495
|
+
DSP.startSensors();
|
|
496
496
|
faustUI = new FaustUI({ ui: DSP.getUI(), root: faustUIRoot });
|
|
497
497
|
faustUI.paramChangeByUI = (path, value) => DSP.setParamValue(path, value);
|
|
498
498
|
DSP.setOutputParamHandler(output_handler);
|
package/test/osc2.dsp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import("stdfaust.lib");
|
|
2
|
-
f = hslider("freq [midi:ctrl 7][acc:0 1 -10 0 10]",440,50,2000,0.01);
|
|
2
|
+
f = hslider("freq [midi:ctrl 7][acc:0 1 -10 0 10]",440,50,2000,0.01) : si.smoo;
|
|
3
3
|
phasor(freq) = (+(freq/ma.SR) ~ ma.decimal);
|
|
4
4
|
osc(freq) = sin(phasor(freq)*2*ma.PI);
|
|
5
5
|
process = osc(f);
|
package/test/tables.dsp
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import("stdfaust.lib");
|
|
2
|
+
|
|
3
|
+
wavetable(sf, pct) = it.lagrangeN(N, f_idx, par(i, N + 1, table(i_idx - int(N / 2) + i)))
|
|
4
|
+
with {
|
|
5
|
+
N = 3; // lagrange order
|
|
6
|
+
SFC = outputs(sf);
|
|
7
|
+
S = 0, 0 : sf : ba.selector(0, SFC); // table size
|
|
8
|
+
table(j) = int(ma.modulo(j, S)) : sf(0) : !, !, si.bus(SFC-2);
|
|
9
|
+
idx = S*pct;
|
|
10
|
+
f_idx = ma.frac(idx) + int(N / 2);
|
|
11
|
+
i_idx = int(idx);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
TABLE_SIZE = 2048;
|
|
15
|
+
NUM_LEVELS = 4;
|
|
16
|
+
|
|
17
|
+
aa_wavetable_level(sf, LEVEL, pct) = it.lagrangeN(N, f_idx, par(i, N + 1, table(i_idx - int(N / 2) + i)))
|
|
18
|
+
with {
|
|
19
|
+
S = TABLE_SIZE>>LEVEL;
|
|
20
|
+
r0 = int(0);
|
|
21
|
+
r1 = int(S-1);
|
|
22
|
+
|
|
23
|
+
mipped_table(x) = ba.tabulate(0, FX, S, r0, r1, x).val
|
|
24
|
+
with {
|
|
25
|
+
// require 1 channel out due to ba.tabulate
|
|
26
|
+
read_table(i) = sf(0, i) : !, !, _;
|
|
27
|
+
|
|
28
|
+
// simple average of me plus LEVEL neighbors to the right
|
|
29
|
+
FX(i) = sum(j, LEVEL+1, read_table(i*(LEVEL+1)+j))/(LEVEL+1);
|
|
30
|
+
};
|
|
31
|
+
table(j) = int(ma.modulo(j, S)) : mipped_table;
|
|
32
|
+
idx = S*pct;
|
|
33
|
+
N = 1; // lagrange order
|
|
34
|
+
f_idx = ma.frac(idx) + int(N / 2);
|
|
35
|
+
i_idx = int(idx);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
aa_wavetable(sf, freq, pct) = si.vecOp((tmp_wavetables, coeff), *) :> _
|
|
39
|
+
with {
|
|
40
|
+
// todo: fiddle with best remap values.
|
|
41
|
+
level_pos = ba.hz2midikey(freq) : it.remap(24, 36, 0, 1) : aa.clip(0, 1) / NUM_LEVELS;
|
|
42
|
+
tmp_wavetables = pct <: par(level, NUM_LEVELS, aa_wavetable_level(sf(level), level));
|
|
43
|
+
coeff = par(i, NUM_LEVELS, max(0, 1-abs(i-level_pos*(NUM_LEVELS-1))));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// mathematical hard-syncing phasor (see `phasor_imp` in `faustlibraries/oscillators.lib`)
|
|
47
|
+
m_hsp_phasor(freq, reset, phase) = (select2(hard_reset, +(freq/ma.SR), phase) : ma.decimal) ~ _
|
|
48
|
+
with {
|
|
49
|
+
hard_reset = (1-1')|reset; // To correctly start at `phase` at the first sample
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// This works:
|
|
53
|
+
/*
|
|
54
|
+
process = m_hsp_phasor(freq, 0, 0) : wavetable(sf)*en.adsr(.01, .01, 1, .1, gate)*gain
|
|
55
|
+
with {
|
|
56
|
+
sf = soundfile("Square[url:{'square.wav'}]",1);
|
|
57
|
+
freq = hslider("freq", 440, 20, 20000, .01);
|
|
58
|
+
gate = hslider("gate", 0, 0, 1, .01);
|
|
59
|
+
gain = hslider("gain", 0, 0, 1, .01);
|
|
60
|
+
};
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// This doesn't compile:
|
|
65
|
+
process = m_hsp_phasor(freq, 0, 0) : aa_wavetable(sf, freq)*en.adsr(.01, .01, 1, .1, gate)*gain
|
|
66
|
+
with {
|
|
67
|
+
sf(i) = soundfile("Square%i [url:{'square.wav'}]",1);
|
|
68
|
+
freq = hslider("freq", 440, 20, 2000, .01);
|
|
69
|
+
gate = hslider("gate", 0.5, 0, 1, .01);
|
|
70
|
+
gain = hslider("gain", 0.5, 0, 1, .01);
|
|
71
|
+
};
|