@grame/faustwasm 0.0.55 → 0.0.57

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -395,34 +395,25 @@ export class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
395
395
  async compile(
396
396
  compiler: IFaustCompiler,
397
397
  name: string,
398
- dspCodeAux: string,
398
+ dspCode: string,
399
399
  args: string,
400
- // The ${dspCodeAux} string has to be added with wrapping new lines to make it properly formatted and ready to compile
400
+ // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile
401
401
  effectCode = `
402
- dsp_code = environment{
403
- ${dspCodeAux}
404
- };
405
- process = dsp_code.effect;`
406
- ) {
407
- // Since the effect is going to process the voice outputs "in-place",
408
- // the voice output number has to be the same as the effect input number
409
- const dspCode = `
410
402
  adapt(1,1) = _;
411
403
  adapt(2,2) = _,_;
412
404
  adapt(1,2) = _ <: _,_;
413
405
  adapt(2,1) = _,_ :> _;
414
406
  adaptor(F,G) = adapt(outputs(F),inputs(G));
415
407
  dsp_code = environment{
416
- ${dspCodeAux}
408
+ ${dspCode}
417
409
  };
418
- process = dsp_code.process : adaptor(dsp_code.process, dsp_code.effect);`;
419
-
410
+ process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`
411
+ ) {
420
412
  this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
421
413
  if (!this.voiceFactory) return null;
422
414
  // Compile effect, possibly failing
423
415
  try {
424
- // Effect is processing same buffers for input and output, so has to use -inpl option
425
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
416
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
426
417
  } catch (e) {
427
418
  console.warn(e);
428
419
  }
@@ -0,0 +1,60 @@
1
+ declare name "Sinusoide";
2
+ declare author "Developpement Grame - CNCM par Elodie Rabibisoa et Romain Constant.";
3
+
4
+ import ("stdfaust.lib");
5
+
6
+ process = mode_switch : os.osc * 0.333 * volume <: sinus_reverb,_ : dry_wet <: limiter :>_ * on_off;
7
+
8
+ on_off = checkbox("[1]ON / OFF");
9
+ freq_slide = vslider("Slide [unit:Hz][acc:0 0 -10 0 10][hidden:1]", freq(5), freq(0), freq(10), 0.001) : si.smooth(0.998);
10
+ freq_scale = vslider("Radio [unit:Hz][acc:0 0 -10 0 10][hidden:1]", 1, 0, (N-1), 1);
11
+ volume = hslider("Volume [hidden:1][acc:1 0 -9 0 10]", 0.35, 0, 0.7, 0.001):si.smooth(0.991):min(1):max(0);
12
+
13
+ // Default mode = slide (0)
14
+ toggle_mode = checkbox("[0]SLIDE / SCALE");
15
+ mode_switch = select2(toggle_mode, freq_slide, scale);
16
+
17
+ //----------------- Frequencies --------------------//
18
+ N = 11;
19
+ scale = par(i, N, freq(i) * choice(i)) :>_;
20
+ choice(n) = abs(freq_scale - n) < 0.5;
21
+
22
+ freq(0) = 523.5;
23
+ freq(1) = 587.3;
24
+ freq(2) = 622.3;
25
+ freq(3) = 784;
26
+ freq(4) = 830.6;
27
+ freq(5) = 1046.5;
28
+ freq(6) = 1174.7;
29
+ freq(7) = 1244.5;
30
+ freq(8) = 1568;
31
+ freq(9) = 1661.2;
32
+ freq(10) = 2093;
33
+
34
+ //----------------- Limiter -----------------------//
35
+ limiter(x,y) = x*coeff,y*coeff
36
+ with {
37
+ epsilon = 1/(44100*1.0);
38
+ peak = max(abs(x),abs(y)) : max ~ -(epsilon);
39
+ coeff = 1.0/max(1.0,peak);
40
+ };
41
+
42
+ //------------------ Reverb ----------------------//
43
+ sinus_reverb = _<: instrReverb :>_;
44
+
45
+ instrReverb = _,_ <: *(reverbGain),*(reverbGain),*(1 - reverbGain),*(1 - reverbGain) :
46
+ re.zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax),_,_ <: _,!,_,!,!,_,!,_ : +,+
47
+ with {
48
+ reverbGain = 0.4;
49
+ roomSize = 2;
50
+ rdel = 20;
51
+ f1 = 200;
52
+ f2 = 6000;
53
+ t60dc = roomSize*3;
54
+ t60m = roomSize*2;
55
+ fsmax = 48000;
56
+ };
57
+
58
+ dry_wet(x,y) = (x*c) + (y*(1-c)) with {
59
+ c = vslider("[1] Dry/Wet Mix [hidden:1][style:knob]", 1,0,1.0,0.01) : si.smoo;
60
+ };
@@ -1278,7 +1278,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1278
1278
  mixerBuffer: Uint8Array;
1279
1279
  mixerModule: WebAssembly.Module;
1280
1280
  constructor();
1281
- compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCode?: string): Promise<this | null>;
1281
+ compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<this | null>;
1282
1282
  createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
1283
1283
  createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1284
1284
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
@@ -3636,26 +3636,21 @@ var _FaustPolyDspGenerator = class {
3636
3636
  this.voiceFactory = null;
3637
3637
  this.effectFactory = null;
3638
3638
  }
3639
- async compile(compiler, name, dspCodeAux, args, effectCode = `
3640
- dsp_code = environment{
3641
- ${dspCodeAux}
3642
- };
3643
- process = dsp_code.effect;`) {
3644
- const dspCode = `
3639
+ async compile(compiler, name, dspCode, args, effectCode = `
3645
3640
  adapt(1,1) = _;
3646
3641
  adapt(2,2) = _,_;
3647
3642
  adapt(1,2) = _ <: _,_;
3648
3643
  adapt(2,1) = _,_ :> _;
3649
3644
  adaptor(F,G) = adapt(outputs(F),inputs(G));
3650
3645
  dsp_code = environment{
3651
- ${dspCodeAux}
3646
+ ${dspCode}
3652
3647
  };
3653
- process = dsp_code.process : adaptor(dsp_code.process, dsp_code.effect);`;
3648
+ process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`) {
3654
3649
  this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
3655
3650
  if (!this.voiceFactory)
3656
3651
  return null;
3657
3652
  try {
3658
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
3653
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
3659
3654
  } catch (e) {
3660
3655
  console.warn(e);
3661
3656
  }