@fluex/fluexgl-dsp 0.2.1 → 0.3.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 (35) hide show
  1. package/lib/dist/effects/classes/Chorus.d.ts +7 -8
  2. package/lib/dist/effects/classes/Chorus.d.ts.map +1 -1
  3. package/lib/dist/effects/classes/Chorus.js +21 -53
  4. package/lib/dist/effects/classes/clips/HardClip.d.ts +14 -0
  5. package/lib/dist/effects/classes/clips/HardClip.d.ts.map +1 -0
  6. package/lib/dist/effects/classes/clips/HardClip.js +32 -0
  7. package/lib/dist/effects/classes/clips/SoftClip.d.ts +14 -0
  8. package/lib/dist/effects/classes/clips/SoftClip.d.ts.map +1 -0
  9. package/lib/dist/effects/classes/clips/SoftClip.js +32 -0
  10. package/lib/dist/effects/classes/filters/LowPassFilter.d.ts +14 -0
  11. package/lib/dist/effects/classes/filters/LowPassFilter.d.ts.map +1 -0
  12. package/lib/dist/effects/classes/filters/LowPassFilter.js +38 -0
  13. package/lib/dist/effects/exports.d.ts +2 -2
  14. package/lib/dist/effects/exports.d.ts.map +1 -1
  15. package/lib/dist/effects/exports.js +2 -2
  16. package/lib/dist/index.d.ts +3 -3
  17. package/lib/dist/index.d.ts.map +1 -1
  18. package/lib/dist/index.js +2 -2
  19. package/lib/dist/typings.d.ts +54 -5
  20. package/lib/dist/typings.d.ts.map +1 -1
  21. package/lib/dist/typings.js +43 -1
  22. package/lib/dist/utilities/helpers.d.ts +3 -1
  23. package/lib/dist/utilities/helpers.d.ts.map +1 -1
  24. package/lib/dist/utilities/helpers.js +27 -1
  25. package/lib/src/effects/classes/Chorus.ts +24 -70
  26. package/lib/src/effects/classes/clips/HardClip.ts +41 -0
  27. package/lib/src/effects/classes/clips/SoftClip.ts +41 -0
  28. package/lib/src/effects/classes/filters/LowPassFilter.ts +55 -0
  29. package/lib/src/effects/exports.ts +3 -2
  30. package/lib/src/index.ts +12 -3
  31. package/lib/src/typings.ts +66 -5
  32. package/lib/src/utilities/helpers.ts +35 -7
  33. package/package.json +1 -1
  34. package/lib/src/effects/classes/Filter.ts +0 -1
  35. package/lib/src/effects/classes/SoftClip.ts +0 -45
@@ -8,14 +8,13 @@ export declare class Chorus extends Effector {
8
8
  rateHz: number;
9
9
  mix: number;
10
10
  feedback: number;
11
- options: ChorusEffectOptions;
12
- private sampleRate;
13
- constructor(options?: ChorusEffectOptions);
11
+ constructor({ baseDelayMs, depthMs, rateHz, mix, feedback }: Partial<ChorusEffectOptions>);
14
12
  InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
15
- SetBaseDelayMs(value: number): void;
16
- SetDepthMs(value: number): void;
17
- SetRateHz(value: number): void;
18
- SetMix(value: number): void;
19
- SetFeedback(value: number): void;
13
+ ReturnOptionsAsObject(): ChorusEffectOptions;
14
+ SetBaseDelayMs(value: number): boolean;
15
+ SetDepthMs(value: number): boolean;
16
+ SetRateHz(value: number): boolean;
17
+ SetMix(value: number): boolean;
18
+ SetFeedback(value: number): boolean;
20
19
  }
21
20
  //# sourceMappingURL=Chorus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chorus.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Chorus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAY;IAChC,IAAI,EAAE,MAAM,CAAY;IAExB,WAAW,EAAE,MAAM,CAAM;IACzB,OAAO,EAAE,MAAM,CAAK;IACpB,MAAM,EAAE,MAAM,CAAO;IACrB,GAAG,EAAE,MAAM,CAAO;IAClB,QAAQ,EAAE,MAAM,CAAO;IAEvB,OAAO,EAAE,mBAAmB,CAAM;IAEzC,OAAO,CAAC,UAAU,CAAa;gBAEnB,OAAO,CAAC,EAAE,mBAAmB;IAa5B,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3E,cAAc,CAAC,KAAK,EAAE,MAAM;IAW5B,UAAU,CAAC,KAAK,EAAE,MAAM;IAWxB,SAAS,CAAC,KAAK,EAAE,MAAM;IAWvB,MAAM,CAAC,KAAK,EAAE,MAAM;IAWpB,WAAW,CAAC,KAAK,EAAE,MAAM;CAUnC"}
1
+ {"version":3,"file":"Chorus.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Chorus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAsD,MAAM,eAAe,CAAC;AAExG,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAY;IAChC,IAAI,EAAE,MAAM,CAAY;IAExB,WAAW,EAAE,MAAM,CAAM;IACzB,OAAO,EAAE,MAAM,CAAK;IACpB,MAAM,EAAE,MAAM,CAAO;IACrB,GAAG,EAAE,MAAM,CAAO;IAClB,QAAQ,EAAE,MAAM,CAAO;gBAElB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAU5E,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3E,qBAAqB,IAAI,mBAAmB;IAU5C,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKtC,UAAU,CAAC,KAAK,EAAE,MAAM;IAKxB,SAAS,CAAC,KAAK,EAAE,MAAM;IAKvB,MAAM,CAAC,KAAK,EAAE,MAAM;IAKpB,WAAW,CAAC,KAAK,EAAE,MAAM;CAInC"}
@@ -1,6 +1,6 @@
1
- import { compiledWebAssemblyModule } from "../../utilities/web-assembly";
1
+ import { SendMessageToWorklet, CreateAudioWorkletNode } from "../../utilities/helpers";
2
2
  import { Effector } from "../../core/classes/Effector";
3
- import { Debug } from "../../utilities/debugger";
3
+ import { ChorusMessageCommandId, AudioWorkletProcessorNames } from "../../typings";
4
4
  export class Chorus extends Effector {
5
5
  label = "Chorus";
6
6
  name = "Chorus";
@@ -9,77 +9,45 @@ export class Chorus extends Effector {
9
9
  rateHz = 1.5;
10
10
  mix = 0.5;
11
11
  feedback = 0.2;
12
- options = {};
13
- sampleRate = 0;
14
- constructor(options) {
12
+ constructor({ baseDelayMs, depthMs, rateHz, mix, feedback }) {
15
13
  super();
16
- this.options = {
14
+ this.baseDelayMs = baseDelayMs ?? this.baseDelayMs;
15
+ this.depthMs = depthMs ?? this.depthMs;
16
+ this.rateHz = rateHz ?? this.rateHz;
17
+ this.mix = mix ?? this.mix;
18
+ this.feedback = feedback ?? this.feedback;
19
+ }
20
+ async InitializeOnAttachment(parentialContext) {
21
+ this.parentialContext = parentialContext;
22
+ this.audioWorkletNode = CreateAudioWorkletNode(parentialContext, AudioWorkletProcessorNames.Chorus, this.ReturnOptionsAsObject());
23
+ }
24
+ ReturnOptionsAsObject() {
25
+ return {
17
26
  baseDelayMs: this.baseDelayMs,
18
27
  depthMs: this.depthMs,
19
28
  rateHz: this.rateHz,
20
29
  mix: this.mix,
21
- feedback: this.mix,
22
- ...options
30
+ feedback: this.feedback,
23
31
  };
24
32
  }
25
- async InitializeOnAttachment(parentialContext) {
26
- if (!compiledWebAssemblyModule)
27
- return Debug.Error("Could not initialize effector because the nessecary WASM file has not been specified.", [
28
- `Effector type: Chorus`
29
- ]);
30
- this.sampleRate = parentialContext.sampleRate;
31
- this.audioWorkletNode = new AudioWorkletNode(parentialContext, "ChorusProcessor", {
32
- numberOfInputs: 1,
33
- numberOfOutputs: 1,
34
- outputChannelCount: [2],
35
- parameterData: {
36
- ...this.options,
37
- sampleRate: this.sampleRate
38
- },
39
- processorOptions: {
40
- module: compiledWebAssemblyModule
41
- }
42
- });
43
- this.parentialContext = parentialContext;
44
- }
45
33
  SetBaseDelayMs(value) {
46
34
  this.baseDelayMs = value;
47
- this.options.baseDelayMs = value;
48
- this.audioWorkletNode?.port.postMessage({
49
- type: "set-base-delay-ms",
50
- value
51
- });
35
+ return SendMessageToWorklet(this.audioWorkletNode, ChorusMessageCommandId.SetBaseDelayMs, value);
52
36
  }
53
37
  SetDepthMs(value) {
54
38
  this.depthMs = value;
55
- this.options.depthMs = value;
56
- this.audioWorkletNode?.port.postMessage({
57
- type: "set-depth-ms",
58
- value
59
- });
39
+ return SendMessageToWorklet(this.audioWorkletNode, ChorusMessageCommandId.SetDepthMs, value);
60
40
  }
61
41
  SetRateHz(value) {
62
42
  this.rateHz = value;
63
- this.options.rateHz = value;
64
- this.audioWorkletNode?.port.postMessage({
65
- type: "set-rate-hz",
66
- value
67
- });
43
+ return SendMessageToWorklet(this.audioWorkletNode, ChorusMessageCommandId.SetRateHz, value);
68
44
  }
69
45
  SetMix(value) {
70
46
  this.mix = value;
71
- this.options.mix = value;
72
- this.audioWorkletNode?.port.postMessage({
73
- type: "set-mix",
74
- value
75
- });
47
+ return SendMessageToWorklet(this.audioWorkletNode, ChorusMessageCommandId.SetMix, value);
76
48
  }
77
49
  SetFeedback(value) {
78
50
  this.feedback = value;
79
- this.options.feedback = value;
80
- this.audioWorkletNode?.port.postMessage({
81
- type: "set-mix",
82
- value
83
- });
51
+ return SendMessageToWorklet(this.audioWorkletNode, ChorusMessageCommandId.SetFeedback, value);
84
52
  }
85
53
  }
@@ -0,0 +1,14 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { HardClipOptions } from "../../../typings";
3
+ export declare class HardClip extends Effector {
4
+ label: string | null;
5
+ name: string;
6
+ drive: number;
7
+ gain: number;
8
+ constructor({ drive, gain }: Partial<HardClipOptions>);
9
+ InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
10
+ ReturnOptionsAsObject(): HardClipOptions;
11
+ SetDrive(drive: number): boolean;
12
+ SetGain(gain: number): boolean;
13
+ }
14
+ //# sourceMappingURL=HardClip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HardClip.d.ts","sourceRoot":"","sources":["../../../../src/effects/classes/clips/HardClip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE1D,OAAO,EAAwD,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEzG,qBAAa,QAAS,SAAQ,QAAQ;IAE3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAc;IAClC,IAAI,EAAE,MAAM,CAAc;IAE1B,KAAK,EAAE,MAAM,CAAK;IAClB,IAAI,EAAE,MAAM,CAAK;gBAEZ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,eAAe,CAAC;IAOxC,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3E,qBAAqB,IAAI,eAAe;IAOvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKjC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAIxC"}
@@ -0,0 +1,32 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { CreateAudioWorkletNode, SendMessageToWorklet } from "../../../utilities/helpers";
3
+ import { HardClipMessageCommandId, AudioWorkletProcessorNames } from "../../../typings";
4
+ export class HardClip extends Effector {
5
+ label = "HardClip";
6
+ name = "HardClip";
7
+ drive = 1;
8
+ gain = 1;
9
+ constructor({ drive, gain }) {
10
+ super();
11
+ this.drive = drive ?? this.drive;
12
+ this.gain = gain ?? this.gain;
13
+ }
14
+ async InitializeOnAttachment(parentialContext) {
15
+ this.parentialContext = parentialContext;
16
+ this.audioWorkletNode = CreateAudioWorkletNode(parentialContext, AudioWorkletProcessorNames.HardClip, this.ReturnOptionsAsObject());
17
+ }
18
+ ReturnOptionsAsObject() {
19
+ return {
20
+ drive: this.drive,
21
+ gain: this.gain
22
+ };
23
+ }
24
+ SetDrive(drive) {
25
+ this.drive = drive;
26
+ return SendMessageToWorklet(this.audioWorkletNode, HardClipMessageCommandId.SetDrive, drive);
27
+ }
28
+ SetGain(gain) {
29
+ this.gain = gain;
30
+ return SendMessageToWorklet(this.audioWorkletNode, HardClipMessageCommandId.SetGain, gain);
31
+ }
32
+ }
@@ -0,0 +1,14 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { SoftClipOptions } from "../../../typings";
3
+ export declare class SoftClip extends Effector {
4
+ label: string | null;
5
+ name: string;
6
+ drive: number;
7
+ gain: number;
8
+ constructor({ drive, gain }: Partial<SoftClipOptions>);
9
+ InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
10
+ ReturnOptionsAsObject(): SoftClipOptions;
11
+ SetDrive(drive: number): boolean;
12
+ SetGain(gain: number): boolean;
13
+ }
14
+ //# sourceMappingURL=SoftClip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SoftClip.d.ts","sourceRoot":"","sources":["../../../../src/effects/classes/clips/SoftClip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAwD,MAAM,kBAAkB,CAAC;AAEzG,qBAAa,QAAS,SAAQ,QAAQ;IAE3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAc;IAClC,IAAI,EAAE,MAAM,CAAc;IAE1B,KAAK,EAAE,MAAM,CAAK;IAClB,IAAI,EAAE,MAAM,CAAK;gBAEZ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,eAAe,CAAC;IAOxC,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3E,qBAAqB,IAAI,eAAe;IAOxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKhC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAIxC"}
@@ -0,0 +1,32 @@
1
+ import { CreateAudioWorkletNode, SendMessageToWorklet } from "../../../utilities/helpers";
2
+ import { Effector } from "../../../core/classes/Effector";
3
+ import { AudioWorkletProcessorNames, SoftClipMessageCommandId } from "../../../typings";
4
+ export class SoftClip extends Effector {
5
+ label = "SoftClip";
6
+ name = "SoftClip";
7
+ drive = 1;
8
+ gain = 1;
9
+ constructor({ drive, gain }) {
10
+ super();
11
+ this.drive = drive ?? this.drive;
12
+ this.gain = gain ?? this.gain;
13
+ }
14
+ async InitializeOnAttachment(parentialContext) {
15
+ this.parentialContext = parentialContext;
16
+ this.audioWorkletNode = CreateAudioWorkletNode(parentialContext, AudioWorkletProcessorNames.SoftClip, this.ReturnOptionsAsObject());
17
+ }
18
+ ReturnOptionsAsObject() {
19
+ return {
20
+ drive: this.drive,
21
+ gain: this.gain
22
+ };
23
+ }
24
+ SetDrive(drive) {
25
+ this.drive = drive;
26
+ return SendMessageToWorklet(this.audioWorkletNode, SoftClipMessageCommandId.SetDrive, drive);
27
+ }
28
+ SetGain(gain) {
29
+ this.gain = gain;
30
+ return SendMessageToWorklet(this.audioWorkletNode, SoftClipMessageCommandId.SetGain, gain);
31
+ }
32
+ }
@@ -0,0 +1,14 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { LowPassFilterOptions } from "../../../typings";
3
+ export declare class LowPassFilter extends Effector {
4
+ name: string;
5
+ label: string | null;
6
+ cutoff: number;
7
+ minFrequency: number;
8
+ constructor({ cutoff, minFrequency }: Partial<LowPassFilterOptions>);
9
+ InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
10
+ ReturnOptionsAsObject(): LowPassFilterOptions;
11
+ SetCutoff(cutoff?: number): boolean;
12
+ SetMinFrequency(minFrequency?: number): boolean;
13
+ }
14
+ //# sourceMappingURL=LowPassFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LowPassFilter.d.ts","sourceRoot":"","sources":["../../../../src/effects/classes/filters/LowPassFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAI1D,OAAO,EAAE,oBAAoB,EAA6D,MAAM,kBAAkB,CAAC;AAEnH,qBAAa,aAAc,SAAQ,QAAQ;IAEhC,IAAI,EAAE,MAAM,CAAmB;IAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAmB;IAEvC,MAAM,EAAE,MAAM,CAAQ;IACtB,YAAY,EAAE,MAAM,CAAM;gBAErB,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAOtD,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3E,qBAAqB,IAAI,oBAAoB;IAO7C,SAAS,CAAC,MAAM,GAAE,MAAa,GAAG,OAAO;IAWzC,eAAe,CAAC,YAAY,GAAE,MAAW,GAAG,OAAO;CAS7D"}
@@ -0,0 +1,38 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { SendMessageToWorklet, CreateAudioWorkletNode } from "../../../utilities/helpers";
3
+ import { LowPassFilterMessageCommandId, AudioWorkletProcessorNames } from "../../../typings";
4
+ export class LowPassFilter extends Effector {
5
+ name = "LowPassFilter";
6
+ label = "LowPassFilter";
7
+ cutoff = 4000;
8
+ minFrequency = 10;
9
+ constructor({ cutoff, minFrequency }) {
10
+ super();
11
+ this.cutoff = cutoff ?? this.cutoff;
12
+ this.minFrequency = minFrequency ?? this.minFrequency;
13
+ }
14
+ async InitializeOnAttachment(parentialContext) {
15
+ this.parentialContext = parentialContext;
16
+ this.audioWorkletNode = CreateAudioWorkletNode(parentialContext, AudioWorkletProcessorNames.LowPassFilter, this.ReturnOptionsAsObject());
17
+ }
18
+ ReturnOptionsAsObject() {
19
+ return {
20
+ cutoff: this.cutoff,
21
+ minFrequency: this.minFrequency
22
+ };
23
+ }
24
+ SetCutoff(cutoff = 4000) {
25
+ if (!this.parentialContext)
26
+ return false;
27
+ if (cutoff >= this.parentialContext.sampleRate)
28
+ cutoff = this.parentialContext.sampleRate;
29
+ this.cutoff = cutoff;
30
+ return SendMessageToWorklet(this.audioWorkletNode, LowPassFilterMessageCommandId.SetCutoff, cutoff);
31
+ }
32
+ SetMinFrequency(minFrequency = 10) {
33
+ if (minFrequency < 10)
34
+ minFrequency = 10;
35
+ this.minFrequency = minFrequency;
36
+ return SendMessageToWorklet(this.audioWorkletNode, LowPassFilterMessageCommandId.SetMinFrequency, minFrequency);
37
+ }
38
+ }
@@ -1,11 +1,10 @@
1
1
  export { Chorus } from "./classes/Chorus";
2
2
  export { Distortion } from "./classes/Distortion";
3
3
  export { Equalizer } from "./classes/Equalizer";
4
- export { Filter } from "./classes/Filter";
5
4
  export { Limiter } from "./classes/Limiter";
6
5
  export { Saturation } from "./classes/Saturation";
7
6
  export { StereoPanner } from "./classes/StereoPanner";
8
- export { SoftClip } from "./classes/SoftClip";
7
+ export { SoftClip } from "./classes/clips/SoftClip";
9
8
  export { Compressor } from "./classes/compressors/Compressor";
10
9
  export { MultibandCompressor } from "./classes/compressors/MultibandCompressor";
11
10
  export { AdvancedDelay } from "./classes/delays/AdvancedDelay";
@@ -17,4 +16,5 @@ export { ConvolverReverb } from "./classes/reverbs/ConvolverReverb";
17
16
  export { GenericReverb } from "./classes/reverbs/GenericReverb";
18
17
  export { HallReverb } from "./classes/reverbs/HallReverb";
19
18
  export { RoomReverb } from "./classes/reverbs/RoomReverb";
19
+ export { LowPassFilter } from "./classes/filters/LowPassFilter";
20
20
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/effects/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OA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kCAAkC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,11 +1,10 @@
1
1
  export { Chorus } from "./classes/Chorus";
2
2
  export { Distortion } from "./classes/Distortion";
3
3
  export { Equalizer } from "./classes/Equalizer";
4
- export { Filter } from "./classes/Filter";
5
4
  export { Limiter } from "./classes/Limiter";
6
5
  export { Saturation } from "./classes/Saturation";
7
6
  export { StereoPanner } from "./classes/StereoPanner";
8
- export { SoftClip } from "./classes/SoftClip";
7
+ export { SoftClip } from "./classes/clips/SoftClip";
9
8
  export { Compressor } from "./classes/compressors/Compressor";
10
9
  export { MultibandCompressor } from "./classes/compressors/MultibandCompressor";
11
10
  export { AdvancedDelay } from "./classes/delays/AdvancedDelay";
@@ -17,3 +16,4 @@ export { ConvolverReverb } from "./classes/reverbs/ConvolverReverb";
17
16
  export { GenericReverb } from "./classes/reverbs/GenericReverb";
18
17
  export { HallReverb } from "./classes/reverbs/HallReverb";
19
18
  export { RoomReverb } from "./classes/reverbs/RoomReverb";
19
+ export { LowPassFilter } from "./classes/filters/LowPassFilter";
@@ -4,10 +4,10 @@
4
4
  */
5
5
  import { FluexGLAudioDescriptor } from "./typings";
6
6
  export declare const FluexGLAudio: FluexGLAudioDescriptor;
7
- export { Chorus, Distortion, Equalizer, Filter, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip } from "./effects/exports";
7
+ export { Chorus, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter } from "./effects/exports";
8
8
  export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline } from "./core/exports";
9
- export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
9
+ export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, SendMessageToWorklet } from "./utilities/helpers";
10
10
  export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
11
11
  export { hasInitializedWasm, } from "./utilities/web-assembly";
12
- export type { FluexGLAudioDescriptor, FluexGLAudioDebuggerOptions, FluexGLAudioOptions, LoadAudioSourceOptions, AudioSourceData, ChannelOptions, ChannelSpatialization, AudioClipEventMap, AudioClipEvents, AudioClipOnProgressEvent, AudioClipAnalyserProperty, AudioClipAnalyserType, DspPipelineInitializationOptions, DspPipelineInitializationState, ChorusEffectOptions } from "./typings";
12
+ export type { FluexGLAudioDescriptor, FluexGLAudioDebuggerOptions, FluexGLAudioOptions, LoadAudioSourceOptions, AudioSourceData, ChannelOptions, ChannelSpatialization, AudioClipEventMap, AudioClipEvents, AudioClipOnProgressEvent, AudioClipAnalyserProperty, AudioClipAnalyserType, DspPipelineInitializationOptions, DspPipelineInitializationState, ChorusEffectOptions, LowPassFilterOptions, LowPassFilterMessageCommandId, ChorusMessageCommandId, AudioWorkletProcessorNames, SoftClipMessageCommandId, SoftClipOptions, HardClipMessageCommandId, HardClipOptions } from "./typings";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,YAAY,EAAE,sBAkB1B,CAAA;AAED,OAAO,EACH,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACR,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAC9B,mBAAmB,EACtB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,YAAY,EAAE,sBAkB1B,CAAA;AAED,OAAO,EACH,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACR,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,eAAe,EACf,wBAAwB,EACxB,eAAe,EAClB,MAAM,WAAW,CAAC"}
package/lib/dist/index.js CHANGED
@@ -21,8 +21,8 @@ export const FluexGLAudio = {
21
21
  }
22
22
  }
23
23
  };
24
- export { Chorus, Distortion, Equalizer, Filter, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip } from "./effects/exports";
24
+ export { Chorus, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter } from "./effects/exports";
25
25
  export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline } from "./core/exports";
26
- export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
26
+ export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, SendMessageToWorklet } from "./utilities/helpers";
27
27
  export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
28
28
  export { hasInitializedWasm, } from "./utilities/web-assembly";
@@ -4,6 +4,43 @@ export type AudioClipAnalyserProperty = "fftSize" | "minDecibels" | "maxDecibels
4
4
  export type AudioClipEvents = {
5
5
  [K in keyof AudioClipEventMap]: AudioClipEventMap[K][];
6
6
  };
7
+ export declare enum LowPassFilterMessageCommandId {
8
+ SetCutoff = 0,
9
+ SetMinFrequency = 1
10
+ }
11
+ export declare enum ChorusMessageCommandId {
12
+ SetBaseDelayMs = 0,
13
+ SetDepthMs = 1,
14
+ SetRateHz = 2,
15
+ SetMix = 3,
16
+ SetFeedback = 4
17
+ }
18
+ export declare enum SoftClipMessageCommandId {
19
+ SetDrive = 0,
20
+ SetGain = 1
21
+ }
22
+ export declare enum HardClipMessageCommandId {
23
+ SetDrive = 0,
24
+ SetGain = 1
25
+ }
26
+ export declare enum AudioWorkletProcessorNames {
27
+ Compressor = "CompressorProcessor",
28
+ MultibandCompressor = "MultibandCompressorProcessor",
29
+ AdvancedDelay = "AdvancedDelayProcessor",
30
+ MonoDelay = "MonoDelayProcessor",
31
+ PingPongDelay = "PingPongDelayProcessor",
32
+ StereoDelay = "StereoDelayProcessor",
33
+ LowPassFilter = "LowPassFilterProcessor",
34
+ HighPassFilter = "HighPassFilterProcessor",
35
+ BandPassFilter = "BandPassFilterProcessor",
36
+ NotchFilter = "NotchFilterProcessor",
37
+ Chorus = "ChorusProcessor",
38
+ Flanger = "FlangerProcessor",
39
+ Phaser = "PhaserProcessor",
40
+ Reverb = "ReverbProcessor",
41
+ SoftClip = "SoftClipProcessor",
42
+ HardClip = "HardClipProcessor"
43
+ }
7
44
  export interface FluexGLAudioDebuggerOptions {
8
45
  breakOnError: boolean;
9
46
  showInfo: boolean;
@@ -58,10 +95,22 @@ export interface DspPipelineInitializationState {
58
95
  workletBlobUrl: string;
59
96
  }
60
97
  export interface ChorusEffectOptions {
61
- baseDelayMs?: number;
62
- depthMs?: number;
63
- rateHz?: number;
64
- mix?: number;
65
- feedback?: number;
98
+ baseDelayMs: number;
99
+ depthMs: number;
100
+ rateHz: number;
101
+ mix: number;
102
+ feedback: number;
103
+ }
104
+ export interface LowPassFilterOptions {
105
+ cutoff: number;
106
+ minFrequency: number;
107
+ }
108
+ export interface SoftClipOptions {
109
+ drive: number;
110
+ gain: number;
111
+ }
112
+ export interface HardClipOptions {
113
+ drive: number;
114
+ gain: number;
66
115
  }
67
116
  //# sourceMappingURL=typings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../src/typings.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,MA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ACrB;AAED,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B,UAAU,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,gCAAgC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAID,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB"}
@@ -1 +1,43 @@
1
- export {};
1
+ // ======== Audio worklet command id's ========
2
+ export var LowPassFilterMessageCommandId;
3
+ (function (LowPassFilterMessageCommandId) {
4
+ LowPassFilterMessageCommandId[LowPassFilterMessageCommandId["SetCutoff"] = 0] = "SetCutoff";
5
+ LowPassFilterMessageCommandId[LowPassFilterMessageCommandId["SetMinFrequency"] = 1] = "SetMinFrequency";
6
+ })(LowPassFilterMessageCommandId || (LowPassFilterMessageCommandId = {}));
7
+ export var ChorusMessageCommandId;
8
+ (function (ChorusMessageCommandId) {
9
+ ChorusMessageCommandId[ChorusMessageCommandId["SetBaseDelayMs"] = 0] = "SetBaseDelayMs";
10
+ ChorusMessageCommandId[ChorusMessageCommandId["SetDepthMs"] = 1] = "SetDepthMs";
11
+ ChorusMessageCommandId[ChorusMessageCommandId["SetRateHz"] = 2] = "SetRateHz";
12
+ ChorusMessageCommandId[ChorusMessageCommandId["SetMix"] = 3] = "SetMix";
13
+ ChorusMessageCommandId[ChorusMessageCommandId["SetFeedback"] = 4] = "SetFeedback";
14
+ })(ChorusMessageCommandId || (ChorusMessageCommandId = {}));
15
+ export var SoftClipMessageCommandId;
16
+ (function (SoftClipMessageCommandId) {
17
+ SoftClipMessageCommandId[SoftClipMessageCommandId["SetDrive"] = 0] = "SetDrive";
18
+ SoftClipMessageCommandId[SoftClipMessageCommandId["SetGain"] = 1] = "SetGain";
19
+ })(SoftClipMessageCommandId || (SoftClipMessageCommandId = {}));
20
+ export var HardClipMessageCommandId;
21
+ (function (HardClipMessageCommandId) {
22
+ HardClipMessageCommandId[HardClipMessageCommandId["SetDrive"] = 0] = "SetDrive";
23
+ HardClipMessageCommandId[HardClipMessageCommandId["SetGain"] = 1] = "SetGain";
24
+ })(HardClipMessageCommandId || (HardClipMessageCommandId = {}));
25
+ export var AudioWorkletProcessorNames;
26
+ (function (AudioWorkletProcessorNames) {
27
+ AudioWorkletProcessorNames["Compressor"] = "CompressorProcessor";
28
+ AudioWorkletProcessorNames["MultibandCompressor"] = "MultibandCompressorProcessor";
29
+ AudioWorkletProcessorNames["AdvancedDelay"] = "AdvancedDelayProcessor";
30
+ AudioWorkletProcessorNames["MonoDelay"] = "MonoDelayProcessor";
31
+ AudioWorkletProcessorNames["PingPongDelay"] = "PingPongDelayProcessor";
32
+ AudioWorkletProcessorNames["StereoDelay"] = "StereoDelayProcessor";
33
+ AudioWorkletProcessorNames["LowPassFilter"] = "LowPassFilterProcessor";
34
+ AudioWorkletProcessorNames["HighPassFilter"] = "HighPassFilterProcessor";
35
+ AudioWorkletProcessorNames["BandPassFilter"] = "BandPassFilterProcessor";
36
+ AudioWorkletProcessorNames["NotchFilter"] = "NotchFilterProcessor";
37
+ AudioWorkletProcessorNames["Chorus"] = "ChorusProcessor";
38
+ AudioWorkletProcessorNames["Flanger"] = "FlangerProcessor";
39
+ AudioWorkletProcessorNames["Phaser"] = "PhaserProcessor";
40
+ AudioWorkletProcessorNames["Reverb"] = "ReverbProcessor";
41
+ AudioWorkletProcessorNames["SoftClip"] = "SoftClipProcessor";
42
+ AudioWorkletProcessorNames["HardClip"] = "HardClipProcessor";
43
+ })(AudioWorkletProcessorNames || (AudioWorkletProcessorNames = {}));
@@ -1,6 +1,6 @@
1
1
  import { AudioDevice } from "../core/classes/AudioDevice";
2
2
  import { Master } from "../core/classes/Master";
3
- import { LoadAudioSourceOptions, AudioSourceData, DspPipelineInitializationOptions, DspPipelineInitializationState } from "../typings";
3
+ import { LoadAudioSourceOptions, AudioSourceData, DspPipelineInitializationOptions, DspPipelineInitializationState, AudioWorkletProcessorNames } from "../typings";
4
4
  /**
5
5
  * Initializes the DSP pipeline by requesting audio permissions and initializing the WASM module.
6
6
  * Very important to call this function and wait for it to complete before using any audio features.
@@ -42,4 +42,6 @@ export declare function LoadAudioSource(path: string, options?: Partial<LoadAudi
42
42
  export declare function LoadAudioSourceFromBlob(blob: Blob): Promise<AudioSourceData | null>;
43
43
  export declare function ConstructProcessorWorklet(code: string): string;
44
44
  export declare function LoadWorkletOnMasterChannel(master: Master, workletBlobUrl: string): Promise<boolean>;
45
+ export declare function SendMessageToWorklet<T, K = any>(node: AudioWorkletNode | null, commandId: T, data: K): boolean;
46
+ export declare function CreateAudioWorkletNode<T = any>(context: AudioContext, name: AudioWorkletProcessorNames | string, data: T): AudioWorkletNode | null;
45
47
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utilities/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAahD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAEvI;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAwCrI;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAUxE;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAUvE;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAmBvH;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAmBtH;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAoC,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoChK;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAYzF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9D;AAED,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAgB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AAE,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,WAOpG;AAED,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,0BAA0B,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,2BAsBxH"}
@@ -3,7 +3,7 @@ import { v4 } from "uuid";
3
3
  import { AudioDevice } from "../core/classes/AudioDevice";
4
4
  import { Debug } from "./debugger";
5
5
  import { SUPPORTED_FILE_TYPES } from "./constants";
6
- import { LoadWebAssemblyModule } from "./web-assembly";
6
+ import { compiledWebAssemblyModule, LoadWebAssemblyModule } from "./web-assembly";
7
7
  import { ErrorCodes, WarningCodes } from "../console-codes";
8
8
  /**
9
9
  * Initializes the DSP pipeline by requesting audio permissions and initializing the WASM module.
@@ -158,3 +158,29 @@ export async function LoadWorkletOnMasterChannel(master, workletBlobUrl) {
158
158
  ]);
159
159
  return true;
160
160
  }
161
+ export function SendMessageToWorklet(node, commandId, data) {
162
+ if (!node)
163
+ return false;
164
+ node.port.postMessage({ commandId, data });
165
+ return true;
166
+ }
167
+ export function CreateAudioWorkletNode(context, name, data) {
168
+ if (!compiledWebAssemblyModule) {
169
+ Debug.Error("Failed to create audio worklet node, because the web assembly module has not been compiled properly.", [
170
+ `Request audio worklet node: ${name}.`
171
+ ]);
172
+ return null;
173
+ }
174
+ return new AudioWorkletNode(context, name, {
175
+ numberOfInputs: 1,
176
+ numberOfOutputs: 1,
177
+ outputChannelCount: [2],
178
+ parameterData: {
179
+ ...data,
180
+ sampleRate: context.sampleRate
181
+ },
182
+ processorOptions: {
183
+ module: compiledWebAssemblyModule
184
+ }
185
+ });
186
+ }
@@ -1,7 +1,6 @@
1
- import { compiledWebAssemblyModule } from "../../utilities/web-assembly";
1
+ import { SendMessageToWorklet, CreateAudioWorkletNode } from "../../utilities/helpers";
2
2
  import { Effector } from "../../core/classes/Effector";
3
- import { Debug } from "../../utilities/debugger";
4
- import { ChorusEffectOptions } from "../../typings";
3
+ import { ChorusEffectOptions, ChorusMessageCommandId, AudioWorkletProcessorNames } from "../../typings";
5
4
 
6
5
  export class Chorus extends Effector {
7
6
 
@@ -14,99 +13,54 @@ export class Chorus extends Effector {
14
13
  public mix: number = 0.5;
15
14
  public feedback: number = 0.2;
16
15
 
17
- public options: ChorusEffectOptions = {};
18
-
19
- private sampleRate: number = 0;
20
-
21
- constructor(options?: ChorusEffectOptions) {
16
+ constructor({ baseDelayMs, depthMs, rateHz, mix, feedback }: Partial<ChorusEffectOptions>) {
22
17
  super();
23
18
 
24
- this.options = {
25
- baseDelayMs: this.baseDelayMs,
26
- depthMs: this.depthMs,
27
- rateHz: this.rateHz,
28
- mix: this.mix,
29
- feedback: this.mix,
30
- ...options
31
- }
19
+ this.baseDelayMs = baseDelayMs ?? this.baseDelayMs;
20
+ this.depthMs = depthMs ?? this.depthMs;
21
+ this.rateHz = rateHz ?? this.rateHz;
22
+ this.mix = mix ?? this.mix;
23
+ this.feedback = feedback ?? this.feedback;
32
24
  }
33
25
 
34
26
  public async InitializeOnAttachment(parentialContext: AudioContext): Promise<void> {
35
27
 
36
- if (!compiledWebAssemblyModule) return Debug.Error("Could not initialize effector because the nessecary WASM file has not been specified.", [
37
- `Effector type: Chorus`
38
- ]);
39
-
40
- this.sampleRate = parentialContext.sampleRate;
41
-
42
- this.audioWorkletNode = new AudioWorkletNode(parentialContext, "ChorusProcessor", {
43
- numberOfInputs: 1,
44
- numberOfOutputs: 1,
45
- outputChannelCount: [2],
46
- parameterData: {
47
- ...this.options,
48
- sampleRate: this.sampleRate
49
- },
50
- processorOptions: {
51
- module: compiledWebAssemblyModule
52
- }
53
- });
54
-
55
28
  this.parentialContext = parentialContext;
29
+ this.audioWorkletNode = CreateAudioWorkletNode<ChorusEffectOptions>(parentialContext, AudioWorkletProcessorNames.Chorus, this.ReturnOptionsAsObject());
56
30
  }
57
31
 
58
- public SetBaseDelayMs(value: number) {
32
+ public ReturnOptionsAsObject(): ChorusEffectOptions {
33
+ return {
34
+ baseDelayMs: this.baseDelayMs,
35
+ depthMs: this.depthMs,
36
+ rateHz: this.rateHz,
37
+ mix: this.mix,
38
+ feedback: this.feedback,
39
+ }
40
+ }
59
41
 
42
+ public SetBaseDelayMs(value: number): boolean {
60
43
  this.baseDelayMs = value;
61
- this.options.baseDelayMs = value;
62
-
63
- this.audioWorkletNode?.port.postMessage({
64
- type: "set-base-delay-ms",
65
- value
66
- });
44
+ return SendMessageToWorklet<ChorusMessageCommandId, number>(this.audioWorkletNode, ChorusMessageCommandId.SetBaseDelayMs, value);
67
45
  }
68
46
 
69
47
  public SetDepthMs(value: number) {
70
-
71
48
  this.depthMs = value;
72
- this.options.depthMs = value;
73
-
74
- this.audioWorkletNode?.port.postMessage({
75
- type: "set-depth-ms",
76
- value
77
- });
49
+ return SendMessageToWorklet<ChorusMessageCommandId, number>(this.audioWorkletNode, ChorusMessageCommandId.SetDepthMs, value);
78
50
  }
79
51
 
80
52
  public SetRateHz(value: number) {
81
-
82
53
  this.rateHz = value;
83
- this.options.rateHz = value;
84
-
85
- this.audioWorkletNode?.port.postMessage({
86
- type: "set-rate-hz",
87
- value
88
- });
54
+ return SendMessageToWorklet<ChorusMessageCommandId, number>(this.audioWorkletNode, ChorusMessageCommandId.SetRateHz, value);
89
55
  }
90
56
 
91
57
  public SetMix(value: number) {
92
-
93
58
  this.mix = value;
94
- this.options.mix = value;
95
-
96
- this.audioWorkletNode?.port.postMessage({
97
- type: "set-mix",
98
- value
99
- });
59
+ return SendMessageToWorklet<ChorusMessageCommandId, number>(this.audioWorkletNode, ChorusMessageCommandId.SetMix, value);
100
60
  }
101
61
 
102
62
  public SetFeedback(value: number) {
103
-
104
63
  this.feedback = value;
105
- this.options.feedback = value;
106
-
107
- this.audioWorkletNode?.port.postMessage({
108
- type: "set-mix",
109
- value
110
- });
64
+ return SendMessageToWorklet<ChorusMessageCommandId, number>(this.audioWorkletNode, ChorusMessageCommandId.SetFeedback, value);
111
65
  }
112
66
  }
@@ -0,0 +1,41 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+ import { CreateAudioWorkletNode, SendMessageToWorklet } from "../../../utilities/helpers";
3
+ import { HardClipMessageCommandId, AudioWorkletProcessorNames, HardClipOptions } from "../../../typings";
4
+
5
+ export class HardClip extends Effector {
6
+
7
+ public label: string | null = "HardClip";
8
+ public name: string = "HardClip";
9
+
10
+ public drive: number = 1;
11
+ public gain: number = 1;
12
+
13
+ constructor({ drive, gain }: Partial<HardClipOptions>) {
14
+ super();
15
+
16
+ this.drive = drive ?? this.drive;
17
+ this.gain = gain ?? this.gain;
18
+ }
19
+
20
+ public async InitializeOnAttachment(parentialContext: AudioContext): Promise<void> {
21
+ this.parentialContext = parentialContext;
22
+ this.audioWorkletNode = CreateAudioWorkletNode<HardClipOptions>(parentialContext, AudioWorkletProcessorNames.HardClip, this.ReturnOptionsAsObject());
23
+ }
24
+
25
+ public ReturnOptionsAsObject(): HardClipOptions {
26
+ return {
27
+ drive: this.drive,
28
+ gain: this.gain
29
+ }
30
+ }
31
+
32
+ public SetDrive(drive: number): boolean {
33
+ this.drive = drive;
34
+ return SendMessageToWorklet<HardClipMessageCommandId, number>(this.audioWorkletNode, HardClipMessageCommandId.SetDrive, drive);
35
+ }
36
+
37
+ public SetGain(gain: number): boolean{
38
+ this.gain = gain;
39
+ return SendMessageToWorklet<HardClipMessageCommandId, number>(this.audioWorkletNode, HardClipMessageCommandId.SetGain, gain);
40
+ }
41
+ }
@@ -0,0 +1,41 @@
1
+ import { CreateAudioWorkletNode, SendMessageToWorklet } from "../../../utilities/helpers";
2
+ import { Effector } from "../../../core/classes/Effector";
3
+ import { SoftClipOptions, AudioWorkletProcessorNames, SoftClipMessageCommandId } from "../../../typings";
4
+
5
+ export class SoftClip extends Effector {
6
+
7
+ public label: string | null = "SoftClip";
8
+ public name: string = "SoftClip";
9
+
10
+ public drive: number = 1;
11
+ public gain: number = 1;
12
+
13
+ constructor({ drive, gain }: Partial<SoftClipOptions>) {
14
+ super();
15
+
16
+ this.drive = drive ?? this.drive;
17
+ this.gain = gain ?? this.gain;
18
+ }
19
+
20
+ public async InitializeOnAttachment(parentialContext: AudioContext): Promise<void> {
21
+ this.parentialContext = parentialContext;
22
+ this.audioWorkletNode = CreateAudioWorkletNode<SoftClipOptions>(parentialContext, AudioWorkletProcessorNames.SoftClip, this.ReturnOptionsAsObject());
23
+ }
24
+
25
+ public ReturnOptionsAsObject(): SoftClipOptions {
26
+ return {
27
+ drive: this.drive,
28
+ gain: this.gain
29
+ }
30
+ }
31
+
32
+ public SetDrive(drive: number): boolean {
33
+ this.drive = drive;
34
+ return SendMessageToWorklet<SoftClipMessageCommandId, number>(this.audioWorkletNode, SoftClipMessageCommandId.SetDrive, drive);
35
+ }
36
+
37
+ public SetGain(gain: number): boolean{
38
+ this.gain = gain;
39
+ return SendMessageToWorklet<SoftClipMessageCommandId, number>(this.audioWorkletNode, SoftClipMessageCommandId.SetGain, gain);
40
+ }
41
+ }
@@ -0,0 +1,55 @@
1
+ import { Effector } from "../../../core/classes/Effector";
2
+
3
+ import { SendMessageToWorklet, CreateAudioWorkletNode } from "../../../utilities/helpers";
4
+
5
+ import { LowPassFilterOptions, LowPassFilterMessageCommandId, AudioWorkletProcessorNames } from "../../../typings";
6
+
7
+ export class LowPassFilter extends Effector {
8
+
9
+ public name: string = "LowPassFilter";
10
+ public label: string | null = "LowPassFilter";
11
+
12
+ public cutoff: number = 4000;
13
+ public minFrequency: number = 10;
14
+
15
+ constructor({ cutoff, minFrequency }: Partial<LowPassFilterOptions>) {
16
+ super();
17
+
18
+ this.cutoff = cutoff ?? this.cutoff;
19
+ this.minFrequency = minFrequency ?? this.minFrequency;
20
+ }
21
+
22
+ public async InitializeOnAttachment(parentialContext: AudioContext): Promise<void> {
23
+
24
+ this.parentialContext = parentialContext;
25
+ this.audioWorkletNode = CreateAudioWorkletNode(parentialContext, AudioWorkletProcessorNames.LowPassFilter, this.ReturnOptionsAsObject());
26
+ }
27
+
28
+ public ReturnOptionsAsObject(): LowPassFilterOptions {
29
+ return {
30
+ cutoff: this.cutoff,
31
+ minFrequency: this.minFrequency
32
+ }
33
+ }
34
+
35
+ public SetCutoff(cutoff: number = 4000): boolean {
36
+
37
+ if (!this.parentialContext) return false;
38
+
39
+ if (cutoff >= this.parentialContext.sampleRate)
40
+ cutoff = this.parentialContext.sampleRate;
41
+
42
+ this.cutoff = cutoff;
43
+ return SendMessageToWorklet<LowPassFilterMessageCommandId, number>(this.audioWorkletNode, LowPassFilterMessageCommandId.SetCutoff, cutoff);
44
+ }
45
+
46
+ public SetMinFrequency(minFrequency: number = 10): boolean {
47
+
48
+
49
+ if (minFrequency < 10)
50
+ minFrequency = 10;
51
+
52
+ this.minFrequency = minFrequency;
53
+ return SendMessageToWorklet<LowPassFilterMessageCommandId, number>(this.audioWorkletNode, LowPassFilterMessageCommandId.SetMinFrequency, minFrequency);
54
+ }
55
+ }
@@ -1,11 +1,10 @@
1
1
  export { Chorus } from "./classes/Chorus";
2
2
  export { Distortion } from "./classes/Distortion";
3
3
  export { Equalizer } from "./classes/Equalizer";
4
- export { Filter } from "./classes/Filter";
5
4
  export { Limiter } from "./classes/Limiter";
6
5
  export { Saturation } from "./classes/Saturation";
7
6
  export { StereoPanner } from "./classes/StereoPanner";
8
- export { SoftClip } from "./classes/SoftClip";
7
+ export { SoftClip } from "./classes/clips/SoftClip";
9
8
 
10
9
  export { Compressor } from "./classes/compressors/Compressor";
11
10
  export { MultibandCompressor } from "./classes/compressors/MultibandCompressor";
@@ -20,3 +19,5 @@ export { ConvolverReverb } from "./classes/reverbs/ConvolverReverb";
20
19
  export { GenericReverb } from "./classes/reverbs/GenericReverb";
21
20
  export { HallReverb } from "./classes/reverbs/HallReverb";
22
21
  export { RoomReverb } from "./classes/reverbs/RoomReverb";
22
+
23
+ export { LowPassFilter } from "./classes/filters/LowPassFilter";
package/lib/src/index.ts CHANGED
@@ -29,7 +29,6 @@ export {
29
29
  Chorus,
30
30
  Distortion,
31
31
  Equalizer,
32
- Filter,
33
32
  Limiter,
34
33
  Saturation,
35
34
  StereoPanner,
@@ -44,7 +43,8 @@ export {
44
43
  GenericReverb,
45
44
  HallReverb,
46
45
  RoomReverb,
47
- SoftClip
46
+ SoftClip,
47
+ LowPassFilter
48
48
  } from "./effects/exports";
49
49
 
50
50
  export {
@@ -65,6 +65,7 @@ export {
65
65
  LoadAudioSource,
66
66
  LoadAudioSourceFromBlob,
67
67
  LoadWorkletOnMasterChannel,
68
+ SendMessageToWorklet
68
69
  } from "./utilities/helpers";
69
70
 
70
71
  export {
@@ -90,5 +91,13 @@ export type {
90
91
  AudioClipAnalyserType,
91
92
  DspPipelineInitializationOptions,
92
93
  DspPipelineInitializationState,
93
- ChorusEffectOptions
94
+ ChorusEffectOptions,
95
+ LowPassFilterOptions,
96
+ LowPassFilterMessageCommandId,
97
+ ChorusMessageCommandId,
98
+ AudioWorkletProcessorNames,
99
+ SoftClipMessageCommandId,
100
+ SoftClipOptions,
101
+ HardClipMessageCommandId,
102
+ HardClipOptions
94
103
  } from "./typings";
@@ -7,6 +7,50 @@ export type AudioClipEvents = {
7
7
  [K in keyof AudioClipEventMap]: AudioClipEventMap[K][];
8
8
  }
9
9
 
10
+ // ======== Audio worklet command id's ========
11
+
12
+ export enum LowPassFilterMessageCommandId {
13
+ SetCutoff,
14
+ SetMinFrequency
15
+ }
16
+
17
+ export enum ChorusMessageCommandId {
18
+ SetBaseDelayMs,
19
+ SetDepthMs,
20
+ SetRateHz,
21
+ SetMix,
22
+ SetFeedback
23
+ }
24
+
25
+ export enum SoftClipMessageCommandId {
26
+ SetDrive,
27
+ SetGain
28
+ }
29
+
30
+ export enum HardClipMessageCommandId {
31
+ SetDrive,
32
+ SetGain
33
+ }
34
+
35
+ export enum AudioWorkletProcessorNames {
36
+ Compressor = "CompressorProcessor",
37
+ MultibandCompressor = "MultibandCompressorProcessor",
38
+ AdvancedDelay = "AdvancedDelayProcessor",
39
+ MonoDelay = "MonoDelayProcessor",
40
+ PingPongDelay = "PingPongDelayProcessor",
41
+ StereoDelay = "StereoDelayProcessor",
42
+ LowPassFilter = "LowPassFilterProcessor",
43
+ HighPassFilter = "HighPassFilterProcessor",
44
+ BandPassFilter = "BandPassFilterProcessor",
45
+ NotchFilter = "NotchFilterProcessor",
46
+ Chorus = "ChorusProcessor",
47
+ Flanger = "FlangerProcessor",
48
+ Phaser = "PhaserProcessor",
49
+ Reverb = "ReverbProcessor",
50
+ SoftClip = "SoftClipProcessor",
51
+ HardClip = "HardClipProcessor"
52
+ }
53
+
10
54
  export interface FluexGLAudioDebuggerOptions {
11
55
  breakOnError: boolean;
12
56
  showInfo: boolean;
@@ -70,10 +114,27 @@ export interface DspPipelineInitializationState {
70
114
  workletBlobUrl: string;
71
115
  }
72
116
 
117
+ // ======== Effect options ========
118
+
73
119
  export interface ChorusEffectOptions {
74
- baseDelayMs?: number;
75
- depthMs?: number;
76
- rateHz?: number;
77
- mix?: number;
78
- feedback?: number;
120
+ baseDelayMs: number;
121
+ depthMs: number;
122
+ rateHz: number;
123
+ mix: number;
124
+ feedback: number;
125
+ }
126
+
127
+ export interface LowPassFilterOptions {
128
+ cutoff: number;
129
+ minFrequency: number;
130
+ }
131
+
132
+ export interface SoftClipOptions {
133
+ drive: number;
134
+ gain: number;
135
+ }
136
+
137
+ export interface HardClipOptions {
138
+ drive: number;
139
+ gain: number;
79
140
  }
@@ -3,19 +3,14 @@ import { v4 } from "uuid";
3
3
 
4
4
  import { AudioDevice } from "../core/classes/AudioDevice";
5
5
  import { Master } from "../core/classes/Master";
6
- import { Effector } from "../core/classes/Effector";
7
6
 
8
7
  import { Debug } from "./debugger";
9
8
  import { SUPPORTED_FILE_TYPES } from "./constants";
10
9
 
11
- import { LoadWebAssemblyModule } from "./web-assembly";
10
+ import { compiledWebAssemblyModule, LoadWebAssemblyModule } from "./web-assembly";
12
11
  import { ErrorCodes, WarningCodes } from "../console-codes";
13
12
 
14
- import { Chorus, SoftClip } from "../effects/exports";
15
-
16
- import * as Effects from "../effects/exports";
17
-
18
- import { LoadAudioSourceOptions, AudioSourceData, DspPipelineInitializationOptions, DspPipelineInitializationState } from "../typings";
13
+ import { LoadAudioSourceOptions, AudioSourceData, DspPipelineInitializationOptions, DspPipelineInitializationState, AudioWorkletProcessorNames } from "../typings";
19
14
 
20
15
  /**
21
16
  * Initializes the DSP pipeline by requesting audio permissions and initializing the WASM module.
@@ -235,3 +230,36 @@ export async function LoadWorkletOnMasterChannel(master: Master, workletBlobUrl:
235
230
 
236
231
  return true;
237
232
  }
233
+
234
+ export function SendMessageToWorklet<T, K = any>(node: AudioWorkletNode | null, commandId: T, data: K) {
235
+
236
+ if (!node) return false;
237
+
238
+ node.port.postMessage({ commandId, data });
239
+
240
+ return true;
241
+ }
242
+
243
+ export function CreateAudioWorkletNode<T = any>(context: AudioContext, name: AudioWorkletProcessorNames | string, data: T) {
244
+
245
+ if (!compiledWebAssemblyModule) {
246
+
247
+ Debug.Error("Failed to create audio worklet node, because the web assembly module has not been compiled properly.", [
248
+ `Request audio worklet node: ${name}.`
249
+ ]);
250
+ return null;
251
+ }
252
+
253
+ return new AudioWorkletNode(context, name, {
254
+ numberOfInputs: 1,
255
+ numberOfOutputs: 1,
256
+ outputChannelCount: [2],
257
+ parameterData: {
258
+ ...data,
259
+ sampleRate: context.sampleRate
260
+ },
261
+ processorOptions: {
262
+ module: compiledWebAssemblyModule
263
+ }
264
+ })
265
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluex/fluexgl-dsp",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "An open-source, web-based DSP library developed alongside FluexGL, designed for creating and manipulating sounds in various contexts.",
5
5
  "main": "lib/dist/index.js",
6
6
  "types": "lib/dist/index.d.ts",
@@ -1 +0,0 @@
1
- export class Filter {}
@@ -1,45 +0,0 @@
1
- import { compiledWebAssemblyModule } from "../../utilities/web-assembly";
2
- import { Effector } from "../../core/classes/Effector";
3
- import { Debug } from "../../utilities/debugger";
4
-
5
- export class SoftClip extends Effector {
6
-
7
- public label: string | null = "SoftClip";
8
- public name: string = "SoftClip";
9
-
10
- constructor(public drive: number = 1) {
11
- super();
12
- }
13
-
14
- public async InitializeOnAttachment(parentialContext: AudioContext): Promise<void> {
15
-
16
- if(!compiledWebAssemblyModule) return Debug.Error("Could not initialize effector because the nessecary WASM file has not been specified.", [
17
- `Effector type: SoftClip`
18
- ]);
19
-
20
- this.audioWorkletNode = new AudioWorkletNode(parentialContext, "SoftClipProcessor", {
21
- numberOfInputs: 1,
22
- numberOfOutputs: 1,
23
- outputChannelCount: [2],
24
- parameterData: {
25
- drive: this.drive
26
- },
27
- processorOptions: {
28
- module: compiledWebAssemblyModule
29
- }
30
- });
31
-
32
- this.parentialContext = parentialContext;
33
- }
34
-
35
- public SetDrive(drive: number): SoftClip {
36
-
37
- if(this.audioWorkletNode) this.audioWorkletNode.port.postMessage({
38
- type: "set-drive",
39
- value: drive
40
- });
41
-
42
- this.drive = drive;
43
- return this;
44
- }
45
- }