@grame/faustwasm 0.1.7 → 0.2.1

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 (35) hide show
  1. package/assets/standalone/faustwasm/index.d.ts +150 -101
  2. package/assets/standalone/faustwasm/index.js +939 -1230
  3. package/assets/standalone/faustwasm/index.js.map +4 -4
  4. package/dist/cjs/index.d.ts +150 -101
  5. package/dist/cjs/index.js +941 -1212
  6. package/dist/cjs/index.js.map +4 -4
  7. package/dist/cjs-bundle/index.d.ts +150 -101
  8. package/dist/cjs-bundle/index.js +1044 -1317
  9. package/dist/cjs-bundle/index.js.map +4 -4
  10. package/dist/esm/index.d.ts +150 -101
  11. package/dist/esm/index.js +939 -1230
  12. package/dist/esm/index.js.map +4 -4
  13. package/dist/esm-bundle/index.d.ts +150 -101
  14. package/dist/esm-bundle/index.js +1044 -1321
  15. package/dist/esm-bundle/index.js.map +4 -4
  16. package/libfaust-wasm/libfaust-wasm.js +1 -1
  17. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  18. package/package.json +15 -15
  19. package/src/FaustAudioWorkletProcessor.ts +3 -14
  20. package/src/FaustCmajor.ts +6 -6
  21. package/src/FaustCompiler.ts +2 -2
  22. package/src/FaustDspGenerator.ts +156 -78
  23. package/src/FaustDspInstance.ts +2 -2
  24. package/src/FaustFFTAudioWorkletProcessor.ts +3 -1
  25. package/src/FaustWebAudioDsp.ts +224 -449
  26. package/src/SoundfileReader.ts +117 -0
  27. package/src/exports.ts +1 -0
  28. package/src/faust2wasmFiles.js +1 -1
  29. package/src/types.ts +15 -7
  30. package/test/faustlive-wasm/faustwasm/index.d.ts +150 -101
  31. package/test/faustlive-wasm/faustwasm/index.js +939 -1230
  32. package/test/faustlive-wasm/faustwasm/index.js.map +4 -4
  33. package/test/soundfile.dsp +15 -0
  34. package/test/soundfile1.dsp +23 -0
  35. package/test/web/soundfile.html +69 -0
@@ -0,0 +1,15 @@
1
+ declare name "DroneLAN";
2
+ declare author "Developpement Grame - CNCM par Elodie Rabibisoa et Romain Constant.";
3
+ declare soundfiles "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/drone/";
4
+
5
+ import ("stdfaust.lib");
6
+
7
+ // 2 drones :
8
+ process = par(i, 1, (multi(i) :> _));
9
+
10
+ // 4 sounds per drone :
11
+ multi(N) = par(i, 2, so.loop(drone(N), i) *(0.25) * volume(i));
12
+ drone(0) = soundfile("Drone_1 [url:{'Alonepad_reverb_stereo_instru1.flac'; 'Dronepad_test_stereo_instru1.flac'}]", 1);
13
+
14
+ volume(0) = hslider("Volume 0 [acc:0 0 0 0 10][hidden:1]", 1, 0, 1, 0.001) : fi.lowpass(1, 1);
15
+ volume(1) = hslider("Volume 1 [acc:0 1 -10 0 0][hidden:1]", 0, 0, 1, 0.001) : fi.lowpass(1, 1);
@@ -0,0 +1,23 @@
1
+ import ("stdfaust.lib");
2
+
3
+ declare name "DroneLAN";
4
+ declare author "Developpement Grame - CNCM par Elodie Rabibisoa et Romain Constant.";
5
+ declare soundfiles "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/drone";
6
+
7
+ // 2 drones :
8
+ process = par(i, 2, (multi(i) :> _* (select_drone == i))) :>_ * on_off <:_,_;
9
+
10
+ select_drone = hslider("[1]Drones[style:radio{'1':0;'2':1}]", 0, 0, 1, 1);
11
+
12
+ on_off = checkbox("[0]ON / OFF");
13
+
14
+ // 4 sounds per drone :
15
+ multi(N) = par(i, 4, so.loop(drone(N), i) *(0.25) * volume(i));
16
+
17
+ drone(0) = soundfile("Drone_1 [url:{'Alonepad_reverb_stereo_instru1.flac'; 'Dronepad_test_stereo_instru1.flac'; 'Rain_full_stereo_instru1.flac'; 'Gouttes_eau_mono_instru1.flac'}]", 1);
18
+ drone(1) = soundfile("Drone_2 [url:{'Drone_C_filter_stereo_instru2.flac'; 'Pad_C_tremolo_stereo_instru2.flac'; 'Pedale_C_filter_stereo_instru2.flac'; 'String_freeze_stereo_instru2.flac'}]", 1);
19
+
20
+ volume(0) = hslider("Volume 0 [acc:0 0 0 0 10][hidden:1]", 0, 0, 1, 0.001) : fi.lowpass(1, 1);
21
+ volume(1) = hslider("Volume 1 [acc:0 1 -10 0 0][hidden:1]", 0, 0, 1, 0.001) : fi.lowpass(1, 1);
22
+ volume(2) = hslider("Volume 2 [acc:1 0 0 0 10][hidden:1]", 0, 0, 1, 0.001) : fi.lowpass(1, 1);
23
+ volume(3) = hslider("Volume 3 [acc:1 1 -10 0 0][hidden:1]", 0, 0, 1, 0.001) : fi.lowpass(1, 1);
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <script src="../../dist/cjs-bundle/index.js"></script>
6
+ </head>
7
+ <body style="position: absolute; width: 100%; height: 100%; margin: 0px">
8
+ <button id="start">Start</button>
9
+ </body>
10
+ <script>
11
+ code = `\
12
+ declare name "DroneLAN";
13
+ declare author "Developpement Grame - CNCM par Elodie Rabibisoa et Romain Constant.";
14
+
15
+ import ("stdfaust.lib");
16
+
17
+ declare soundfiles "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/drone/";
18
+ // 2 drones :
19
+ process = par(i, 1, (multi(i) :> _* 1)) :>_ <:_,_;
20
+
21
+ // select_drone = hslider("[1]Drones[style:radio{'1':0;'2':1}]", 0, 0, 1, 1);
22
+
23
+ // 4 sounds per drone :
24
+ multi(N) = par(i, 2, so.loop(drone(N), i) *(0.25) * volume(i));
25
+ drone(0) = soundfile("Drone_1 [url:{'Alonepad_reverb_stereo_instru1.flac'; 'something_new'}]", 1);
26
+
27
+ volume(0) = hslider("Volume 0 [acc:0 0 0 0 10][hidden:1]", 1, 0, 1, 0.001) : fi.lowpass(1, 1);
28
+ volume(1) = hslider("Volume 1 [acc:0 1 -10 0 0][hidden:1]", 0.2, 0, 1, 0.001) : fi.lowpass(1, 1);
29
+ `;
30
+ let t0 = performance.now();
31
+ const time = (str) => {
32
+ const t = performance.now();
33
+ if (str) console.log(str, t - t0);
34
+ t0 = t;
35
+ }
36
+ const { instantiateFaustModule, LibFaust, FaustCompiler, FaustMonoDspGenerator } = faustwasm;
37
+ document.getElementById("start").onclick = async () => {
38
+ audioCtx = new (window.AudioContext || window.webkitAudioContext)();
39
+ await audioCtx.resume();
40
+ time();
41
+ faustModule = await instantiateFaustModule();
42
+ time("Faust WASM Module ready");
43
+ libFaust = new LibFaust(faustModule);
44
+ compiler = new FaustCompiler(libFaust);
45
+ generator = new FaustMonoDspGenerator();
46
+ time("Faust DSP Generator ready");
47
+ await generator.compile(compiler, "dsp", code, "");
48
+ time("Faust DSP compiled");
49
+ const buffer = new Float32Array(audioCtx.sampleRate * 5).fill(0);
50
+ for (let i = 0; i < buffer.length; i++) {
51
+ buffer[i] = Math.sin(i * 100 / audioCtx.sampleRate * 2 * Math.PI) * (buffer.length - i) / buffer.length;
52
+ }
53
+ generator.addSoundfiles({ "something_new": { audioBuffer: [buffer], sampleRate: audioCtx.sampleRate } });
54
+ node = await generator.createNode(audioCtx);
55
+ time("Faust AW Node generated");
56
+ node.connect(audioCtx.destination);
57
+ /*
58
+ setTimeout(async () => {
59
+ node.disconnect();
60
+ time();
61
+ node1 = await generator.createNode(audioCtx, undefined, undefined, true);
62
+ time("Faust SP Node generated");
63
+ node1.connect(audioCtx.destination);
64
+ setTimeout(() => node1.disconnect(), 6000);
65
+ }, 6000);
66
+ */
67
+ };
68
+ </script>
69
+ </html>