@grame/faustwasm 0.0.28 → 0.0.30

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.
@@ -0,0 +1,8 @@
1
+ declare name "greyhole";
2
+ declare version "0.1";
3
+ declare author "GRAME";
4
+ declare description "Greyhole demo application.";
5
+
6
+ import("stdfaust.lib");
7
+
8
+ process = dm.greyhole_demo;
package/test/jprev.dsp ADDED
@@ -0,0 +1,8 @@
1
+ declare name "jprev";
2
+ declare version "0.1";
3
+ declare author "GRAME";
4
+ declare description "Jprev demo application.";
5
+
6
+ import("stdfaust.lib");
7
+
8
+ process = dm.jprev_demo;
@@ -0,0 +1,52 @@
1
+ import("stdfaust.lib");
2
+
3
+ gain = hslider("gain",.41,0,1,0.01) : si.smoo;
4
+ oct = hslider("oct",.5,0,1,0.01) : si.smoo;
5
+ noteLength = hslider("noteLen",.5,0,1,0.01):si.smoo;
6
+ timbre = hslider("timbre",.5,0,1,0.01):si.smoo;
7
+ filterAmt = hslider("filter",.5,0,1,0.001):si.smoo;
8
+ freq = hslider("freq [unit:Hz][scale:log]", 110, 20, 24000, 1): si.smooth(ba.tau2pole(.30));
9
+ verbAmt= hslider("reverb",.5,0,1,0.01):si.smoo;
10
+ // verb = hslider("reverb",0,0,1,0.01):si.smooth;
11
+ gate = button("note on/off"); // Add this button
12
+
13
+ //oscillators
14
+ nOscs = 8;
15
+ offset = hslider("offset",.25,0,0.25,0.001):si.smoo * timbre;
16
+ // offset = 0.05;
17
+ saws = par(
18
+ i,
19
+ nOscs,
20
+ os.saw2f4(
21
+ freq/4 * ((i+1))
22
+ + offset*i*(-1*i%2)*timbre
23
+ )
24
+ ):> /(nOscs);
25
+
26
+ sinOsc = (os.osc(freq)+os.osc(freq*4-offset*2))/4;
27
+
28
+ sound = sinOsc,saws:si.interpolate(timbre):ve.oberheimLPF(filterAmt,2);
29
+ // ADSR envelope
30
+ envelope = gate : en.adsr(0.01, 0.1, 0.9, 0.5)*.75;
31
+
32
+ dry = sound * envelope * gain;
33
+ reverbApplied =
34
+ dry <: re.jpverb(
35
+ 1, //decay s
36
+ 0.45, //damp
37
+ 1, //size
38
+ 0.8, //early
39
+ 0.15, //modulation depth
40
+ .01, //mod freq
41
+ .8, //low
42
+ .6, //mid
43
+ 1, //high
44
+ 3000, //lowcut
45
+ 7000 //highcut
46
+ )<:
47
+ dry*(1-verbAmt)+_*verbAmt,
48
+ dry*(1-verbAmt)+_*verbAmt;
49
+
50
+ //mixer
51
+ process = reverbApplied;
52
+
package/test/t1.cjs ADDED
@@ -0,0 +1,46 @@
1
+ const FaustWasm = require("@grame/faustwasm");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ const {
6
+ instantiateFaustModuleFromFile,
7
+ LibFaust,
8
+ WavEncoder,
9
+ FaustMonoDspGenerator,
10
+ FaustCompiler,
11
+ FaustSvgDiagrams
12
+ } = FaustWasm;
13
+
14
+ (async () => {
15
+ const faustModulePath = path.join(__dirname, "../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
16
+
17
+ // initialize the libfaust wasm
18
+ const faustModule = await instantiateFaustModuleFromFile(faustModulePath);
19
+
20
+ // Get the Faust compiler
21
+ const libFaust = new LibFaust(faustModule);
22
+ console.log(libFaust.version());
23
+ const compiler = new FaustCompiler(libFaust);
24
+ const generator = new FaustMonoDspGenerator();
25
+ const sampleRate = 48000;
26
+ const name = "Djembe"
27
+ const argv = ["-I", "libraries/"];
28
+ const code = `
29
+ import("stdfaust.lib");
30
+ process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
31
+ `;
32
+ // Compile the DSP
33
+ await generator.compile(compiler, name, code, argv.join(" "));
34
+ const processor = await generator.createOfflineProcessor(sampleRate, 1024);
35
+
36
+ // Generate SVG diagrams.
37
+ const svgDiagrams = new FaustSvgDiagrams(compiler);
38
+ const svgs = svgDiagrams.from(name, code, argv.join(" "));
39
+ console.log(Object.keys(svgs));
40
+
41
+ const out = processor.render(null, 192000);
42
+ const wav = WavEncoder.encode(out, { sampleRate, bitDepth: 24 });
43
+
44
+ // The wav file is generated
45
+ fs.writeFileSync(`${__dirname}/out.wav`, new Uint8Array(wav));
46
+ })();
package/test/t1.js ADDED
@@ -0,0 +1,46 @@
1
+ const FaustWasm = require("@grame/faustwasm");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ const {
6
+ instantiateFaustModuleFromFile,
7
+ LibFaust,
8
+ WavEncoder,
9
+ FaustMonoDspGenerator,
10
+ FaustCompiler,
11
+ FaustSvgDiagrams
12
+ } = FaustWasm;
13
+
14
+ (async () => {
15
+ const faustModulePath = path.join(__dirname, "../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
16
+
17
+ // initialize the libfaust wasm
18
+ const faustModule = await instantiateFaustModuleFromFile(faustModulePath);
19
+
20
+ // Get the Faust compiler
21
+ const libFaust = new LibFaust(faustModule);
22
+ console.log(libFaust.version());
23
+ const compiler = new FaustCompiler(libFaust);
24
+ const generator = new FaustMonoDspGenerator();
25
+ const sampleRate = 48000;
26
+ const name = "Djembe"
27
+ const argv = ["-I", "libraries/"];
28
+ const code = `
29
+ import("stdfaust.lib");
30
+ process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
31
+ `;
32
+ // Compile the DSP
33
+ await generator.compile(compiler, name, code, argv.join(" "));
34
+ const processor = await generator.createOfflineProcessor(sampleRate, 1024);
35
+
36
+ // Generate SVG diagrams.
37
+ const svgDiagrams = new FaustSvgDiagrams(compiler);
38
+ const svgs = svgDiagrams.from(name, code, argv.join(" "));
39
+ console.log(Object.keys(svgs));
40
+
41
+ const out = processor.render(null, 192000);
42
+ const wav = WavEncoder.encode(out, { sampleRate, bitDepth: 24 });
43
+
44
+ // The wav file is generated
45
+ fs.writeFileSync(`${__dirname}/out.wav`, new Uint8Array(wav));
46
+ })();