@fluex/fluexgl-dsp 0.4.4 → 0.4.5

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.
@@ -2,6 +2,7 @@ import { AudioClipPlayer } from "./AudioClipPlayer";
2
2
  import { AudioClip } from "./AudioClip";
3
3
  import { Master } from "./Master";
4
4
  import { Effector } from "./Effector";
5
+ import { ArrayPosition } from "../../typings";
5
6
  export declare class Channel {
6
7
  id: string;
7
8
  label: string;
@@ -16,13 +17,15 @@ export declare class Channel {
16
17
  audioClipPlayer: AudioClipPlayer | null;
17
18
  constructor(context: AudioContext, label?: string);
18
19
  private rebuildEffectChain;
19
- AddEffect(effect: Effector): void;
20
- AttachEffect(effect: Effector): void;
21
- RemoveEffect(effect: Effector): void;
22
- DetachEffect(effect: Effector): void;
23
20
  private disconnectAudioNodes;
24
21
  private isInitialized;
25
22
  private isReachable;
23
+ AddEffect(effect: Effector): Channel;
24
+ AttachEffect(effect: Effector): Channel;
25
+ RemoveEffect(effect: Effector): void;
26
+ RemoveAllEffects(): void;
27
+ DetachEffect(effect: Effector): void;
28
+ DetachAllEffects(): void;
26
29
  Send(channel: Channel | Master): void;
27
30
  Unsend(channel: Channel | Master): void;
28
31
  HasAudioClipPlayer(): boolean;
@@ -30,5 +33,10 @@ export declare class Channel {
30
33
  AttachAudioClip(audioClip: AudioClip): Channel;
31
34
  Volume(volume?: number): number;
32
35
  Pan(pan?: number): number;
36
+ GetEffectsByLabel(label: string): Effector[];
37
+ GetFirstEffectByLabel(label: string): Effector | null;
38
+ GetEffectById(id: string): Effector[];
39
+ GetFirstEffectById(id: string): Effector | null;
40
+ MoveEffectToIndex(effect: Effector, index: number | ArrayPosition): void;
33
41
  }
34
42
  //# sourceMappingURL=Channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Channel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MA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,MAAM,EAAE,QAAQ,GAAG,IAAI;IAIpC,gBAAgB;IAIhB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAkC9B,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAehC,kBAAkB,IAAI,OAAO;IAI7B,mBAAmB;IAOnB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAQ9C,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAS/B,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;IASzB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE;IAI5C,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAMrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE;IAIrC,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAM/C,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CA+DlF"}
@@ -58,42 +58,6 @@ export class Channel {
58
58
  }
59
59
  activeEffects[activeEffects.length - 1].audioWorkletNode.connect(this.stereoPannerNode);
60
60
  }
61
- AddEffect(effect) {
62
- if (!this.context) {
63
- Debug.Error("Could not add effect because this channel has no AudioContext.");
64
- return;
65
- }
66
- if (this.effects.includes(effect)) {
67
- Debug.Error("Could not add effect because it is already part of this channel", [
68
- "Call .RemoveEffect([effect Effector]) before adding effect."
69
- ], ErrorCodes.EFFECT_ALREADY_ATTACHED);
70
- return;
71
- }
72
- this.effects.push(effect);
73
- effect.InitializeOnAttachment(this.context);
74
- this.rebuildEffectChain();
75
- }
76
- AttachEffect(effect) {
77
- return this.AddEffect(effect);
78
- }
79
- RemoveEffect(effect) {
80
- if (!this.effects.includes(effect)) {
81
- Debug.Error("Could not remove effect, because it is not part of this channel.", [
82
- "Call .AddEffect([effect Effector]) before removing effect."
83
- ], ErrorCodes.EFFECT_NOT_FOUND);
84
- return;
85
- }
86
- const self = this;
87
- this.effects.forEach(function (_effect, index) {
88
- if (effect.id === _effect.id)
89
- self.effects.splice(index, 1);
90
- });
91
- effect.audioWorkletNode?.disconnect();
92
- this.rebuildEffectChain();
93
- }
94
- DetachEffect(effect) {
95
- return this.RemoveEffect(effect);
96
- }
97
61
  disconnectAudioNodes(gc) {
98
62
  this.input?.disconnect();
99
63
  this.stereoPannerNode?.disconnect();
@@ -129,6 +93,45 @@ export class Channel {
129
93
  }
130
94
  return false;
131
95
  }
96
+ AddEffect(effect) {
97
+ if (!this.context)
98
+ throw new Error(`Could not add effect (${effect.id}), to channel (${this.id}), because the channel's AudioContext is undefined.`);
99
+ if (this.effects.includes(effect))
100
+ throw new Error(`Could not add effect (${effect.id}), to channel (${this.id}), because it has already been added to the channel.`);
101
+ this.effects.push(effect);
102
+ effect.InitializeOnAttachment(this.context);
103
+ this.rebuildEffectChain();
104
+ return this;
105
+ }
106
+ AttachEffect(effect) {
107
+ return this.AddEffect(effect);
108
+ }
109
+ RemoveEffect(effect) {
110
+ if (!this.effects.includes(effect)) {
111
+ Debug.Error("Could not remove effect, because it is not part of this channel.", [
112
+ "Call .AddEffect([effect Effector]) before removing effect."
113
+ ], ErrorCodes.EFFECT_NOT_FOUND);
114
+ return;
115
+ }
116
+ const self = this;
117
+ this.effects.forEach(function (_effect, index) {
118
+ if (effect.id === _effect.id)
119
+ self.effects.splice(index, 1);
120
+ });
121
+ effect.audioWorkletNode?.disconnect();
122
+ this.rebuildEffectChain();
123
+ }
124
+ RemoveAllEffects() {
125
+ for (const effect of this.effects) {
126
+ this.RemoveEffect(effect);
127
+ }
128
+ }
129
+ DetachEffect(effect) {
130
+ return this.RemoveEffect(effect);
131
+ }
132
+ DetachAllEffects() {
133
+ return this.RemoveAllEffects();
134
+ }
132
135
  Send(channel) {
133
136
  if (channel instanceof Master)
134
137
  return channel.AttachChannel(this);
@@ -200,4 +203,66 @@ export class Channel {
200
203
  pan && this.stereoPannerNode.pan.setValueAtTime(pan, this.context.currentTime);
201
204
  return pan ?? this.stereoPannerNode.pan.value;
202
205
  }
206
+ GetEffectsByLabel(label) {
207
+ return this.effects.filter(effect => effect.label === label);
208
+ }
209
+ GetFirstEffectByLabel(label) {
210
+ const filteredEffects = this.effects.filter(effect => effect.label === label);
211
+ return filteredEffects.length !== 0 ? filteredEffects[0] : null;
212
+ }
213
+ GetEffectById(id) {
214
+ return this.effects.filter(effect => effect.id === id);
215
+ }
216
+ GetFirstEffectById(id) {
217
+ const filteredEffects = this.effects.filter(effect => effect.id === id);
218
+ return filteredEffects.length !== 0 ? filteredEffects[0] : null;
219
+ }
220
+ MoveEffectToIndex(effect, index) {
221
+ let fromIndex = -1, matches = 0, i = 0;
222
+ for (i = 0; i < this.effects.length; i++) {
223
+ if (this.effects[i].id === effect.id) {
224
+ if (fromIndex === -1)
225
+ fromIndex = i;
226
+ matches++;
227
+ }
228
+ }
229
+ if (matches === 0)
230
+ throw new Error("Effect '" + effect.id + "' (" + effect.label + ") could not be found. " +
231
+ "The effect ID may have changed, or the effect is not attached to this channel.");
232
+ if (matches > 1)
233
+ throw new Error("Multiple effects with the ID '" + effect.id + "' are attached to this channel. " +
234
+ "Make sure every effect has a unique ID.");
235
+ let toIndex;
236
+ if (typeof index === "number") {
237
+ toIndex = index;
238
+ }
239
+ else {
240
+ switch (index) {
241
+ case "start":
242
+ toIndex = 0;
243
+ break;
244
+ case "end":
245
+ toIndex = this.effects.length - 1;
246
+ break;
247
+ case "one-after-start":
248
+ toIndex = 1;
249
+ break;
250
+ case "one-before-end":
251
+ toIndex = this.effects.length - 2;
252
+ break;
253
+ default:
254
+ throw new Error("Invalid ArrayPosition: " + String(index));
255
+ }
256
+ }
257
+ if (toIndex < 0)
258
+ toIndex = 0;
259
+ if (toIndex >= this.effects.length)
260
+ toIndex = this.effects.length - 1;
261
+ if (fromIndex === toIndex)
262
+ return;
263
+ const item = this.effects.splice(fromIndex, 1)[0];
264
+ if (fromIndex < toIndex)
265
+ toIndex = toIndex - 1;
266
+ this.effects.splice(toIndex, 0, item);
267
+ }
203
268
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Effector.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Effector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGhH,8BAAsB,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAQ;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,IAAI,EAAE,MAAM,CAAc;IAE1B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACjD,OAAO,EAAE,YAAY,GAAG,IAAI,CAAQ;IAE3C,OAAO,CAAC,iCAAiC,CAAkB;IAE3D,OAAO,CAAC,MAAM,CAMb;IAED,OAAO,CAAC,sBAAsB;IAgB9B,SAAS,CAAC,4BAA4B,CAAC,IAAI,EAAE,gBAAgB;IAOtD,gBAAgB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAOjG,IAAI,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAarF,mBAAmB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,QAAQ;IAalG,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,gBAAgB,GAAG,QAAQ;aAWpD,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAC/E"}
1
+ {"version":3,"file":"Effector.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Effector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiD,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGhG,8BAAsB,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAQ;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,IAAI,EAAE,MAAM,CAAc;IAE1B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACjD,OAAO,EAAE,YAAY,GAAG,IAAI,CAAQ;IAE3C,OAAO,CAAC,iCAAiC,CAAkB;IAE3D,OAAO,CAAC,MAAM,CAMb;IAED,OAAO,CAAC,sBAAsB;IAgB9B,SAAS,CAAC,4BAA4B,CAAC,IAAI,EAAE,gBAAgB;IAQtD,gBAAgB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAOjG,IAAI,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAarF,mBAAmB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,QAAQ;IAalG,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,gBAAgB,GAAG,QAAQ;aAWpD,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAC/E"}
@@ -30,6 +30,7 @@ export class Effector {
30
30
  registerMessageEventListener(node) {
31
31
  if (this.hasRegisteredMessageEventListener)
32
32
  return;
33
+ this.hasRegisteredMessageEventListener = true;
33
34
  node.port.onmessage = this.handleIncomingMessages.bind(this);
34
35
  Debug.Log(`Succesfully registered event listener on effector ${this.name} (${this.label}) [${this.id}]`);
35
36
  }
@@ -6,7 +6,7 @@ export declare class SoftClip extends Effector {
6
6
  drive: number;
7
7
  gain: number;
8
8
  strictMode: StrictMode;
9
- constructor({ drive, gain, strictMode }: Partial<SoftClipOptions>);
9
+ constructor({ drive, gain, strictMode }?: Partial<SoftClipOptions>);
10
10
  InitializeOnAttachment(context: AudioContext): Promise<void>;
11
11
  ReturnOptionsAsObject(): SoftClipOptions;
12
12
  SetDrive(drive: number): boolean;
@@ -1 +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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErH,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;IACjB,UAAU,EAAE,UAAU,CAAuB;gBAExC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,eAAe,CAAC;IAUpD,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlE,qBAAqB,IAAI,eAAe;IAQxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAMhC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAKxC"}
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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErH,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;IACjB,UAAU,EAAE,UAAU,CAAuB;gBAExC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAE,OAAO,CAAC,eAAe,CAAM;IAUzD,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlE,qBAAqB,IAAI,eAAe;IAQxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAMhC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAKxC"}
@@ -7,7 +7,7 @@ export class SoftClip extends Effector {
7
7
  drive = 1;
8
8
  gain = 1;
9
9
  strictMode = StrictMode.Disabled;
10
- constructor({ drive, gain, strictMode }) {
10
+ constructor({ drive, gain, strictMode } = {}) {
11
11
  super();
12
12
  this.drive = Math.max(0, CoerceFiniteNumber(drive, this.drive));
13
13
  this.gain = Math.max(0, CoerceFiniteNumber(gain, this.gain));
@@ -9,6 +9,6 @@ export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline, AudioCl
9
9
  export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnAudioDevice, SendMessageToWorklet } from "./utilities/helpers";
10
10
  export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
11
11
  export { hasInitializedWasm, } from "./utilities/web-assembly";
12
- export { StrictMode, ProcessorIdentificationCodes, HardClipMessageCommandId, SoftClipMessageCommandId, AudioWorkletProcessorNames, ChorusMessageCommandId, LowPassFilterMessageCommandId } from "./typings";
13
- export type { DspDebuggerOptions, DspOptions, LoadAudioSourceOptions, AudioSourceData, ChannelOptions, ChannelSpatialization, AudioClipEventMap, AudioClipEvents, AudioClipOnProgressEvent, AudioClipAnalyserProperty, AudioClipAnalyserType, DspPipelineInitializationOptions, DspPipelineInitializationState, ChorusEffectOptions, LowPassFilterOptions, SoftClipOptions, HardClipOptions, EffectorEventMap, IncomingMessageType, IncomingProcessorMessage, ProcessorData, EffectorEvents, } from "./typings";
12
+ export { StrictMode, ProcessorIdentificationCodes, HardClipMessageCommandId, SoftClipMessageCommandId, AudioWorkletProcessorNames, ChorusMessageCommandId, LowPassFilterMessageCommandId, } from "./typings";
13
+ export type { DspDebuggerOptions, DspOptions, LoadAudioSourceOptions, AudioSourceData, ChannelOptions, ChannelSpatialization, AudioClipEventMap, AudioClipEvents, AudioClipOnProgressEvent, AudioClipAnalyserProperty, AudioClipAnalyserType, DspPipelineInitializationOptions, DspPipelineInitializationState, ChorusEffectOptions, LowPassFilterOptions, SoftClipOptions, HardClipOptions, EffectorEventMap, IncomingMessageType, IncomingProcessorMessage, ProcessorData, EffectorEvents, ArrayPosition } from "./typings";
14
14
  //# 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,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,GAAG,EAAE,UAYjB,CAAA;AAED,OAAO,EACH,MAAM,EACN,QAAQ,EACR,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,EACb,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,eAAe,EAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACH,UAAU,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAChC,MAAM,WAAW,CAAC;AAEnB,YAAY,EACR,kBAAkB,EAClB,UAAU,EACV,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,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,cAAc,GACjB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,GAAG,EAAE,UAYjB,CAAA;AAED,OAAO,EACH,MAAM,EACN,QAAQ,EACR,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,EACb,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,eAAe,EAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACH,UAAU,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,GAChC,MAAM,WAAW,CAAC;AAEnB,YAAY,EACR,kBAAkB,EAClB,UAAU,EACV,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,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,aAAa,EAChB,MAAM,WAAW,CAAC"}
package/lib/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  export const DSP = {
6
6
  maxMasterChannels: 8,
7
7
  maxTotalChannels: 128,
8
- sampleRate: 44000,
8
+ sampleRate: 41000,
9
9
  spatialization: "stereo",
10
10
  overrideMaxAudioBufferNodes: false,
11
11
  debugger: {
@@ -20,4 +20,4 @@ export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline, AudioCl
20
20
  export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnAudioDevice, SendMessageToWorklet } from "./utilities/helpers";
21
21
  export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
22
22
  export { hasInitializedWasm, } from "./utilities/web-assembly";
23
- export { StrictMode, ProcessorIdentificationCodes, HardClipMessageCommandId, SoftClipMessageCommandId, AudioWorkletProcessorNames, ChorusMessageCommandId, LowPassFilterMessageCommandId } from "./typings";
23
+ export { StrictMode, ProcessorIdentificationCodes, HardClipMessageCommandId, SoftClipMessageCommandId, AudioWorkletProcessorNames, ChorusMessageCommandId, LowPassFilterMessageCommandId, } from "./typings";
@@ -2,6 +2,7 @@ export type ChannelSpatialization = "mono" | "stereo" | "surround";
2
2
  export type AudioClipAnalyserType = "pre" | "post";
3
3
  export type AudioClipAnalyserProperty = "fftSize" | "minDecibels" | "maxDecibels" | "smoothingTimeConstant";
4
4
  export type IncomingMessageType = "message" | "error" | "warning" | "wasm-instantiated";
5
+ export type ArrayPosition = "start" | "middle" | "end" | "one-after-start" | "one-before-end";
5
6
  export type AudioClipEvents = {
6
7
  [K in keyof AudioClipEventMap]: AudioClipEventMap[K][];
7
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../src/typings.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AACnE,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,uBAAuB,CAAC;AAC5G,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,mBAAmB,CAAC;AAExF,MAAM,MAAM,eAAe,GAAG;KACzB,CAAC,IAAI,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,CAAC,CAAC,EAAE;CACzD,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;KACxB,CAAC,IAAI,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE;CACvD,CAAA;AAED,oBAAY,6BAA6B;IACrC,SAAS,IAAA;IACT,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,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,SAAS,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,GAAG,CAAC;CACxB"}
@@ -1,10 +1,12 @@
1
1
  import { v4 } from "uuid";
2
+
2
3
  import { Debug } from "../../utilities/debugger";
3
4
  import { AudioClipPlayer } from "./AudioClipPlayer";
4
5
  import { AudioClip } from "./AudioClip";
5
6
  import { Master } from "./Master";
6
7
  import { Effector } from "./Effector";
7
8
  import { ErrorCodes } from "../../console-codes";
9
+ import { ArrayPosition } from "../../typings";
8
10
 
9
11
  export class Channel {
10
12
 
@@ -73,7 +75,7 @@ export class Channel {
73
75
  this.input.connect(activeEffects[0].audioWorkletNode as AudioNode);
74
76
 
75
77
  for (let i: number = 0; i < activeEffects.length - 1; i++) {
76
-
78
+
77
79
  const current = activeEffects[i].audioWorkletNode as AudioNode;
78
80
  const next = activeEffects[i + 1].audioWorkletNode as AudioNode;
79
81
 
@@ -83,54 +85,6 @@ export class Channel {
83
85
  (activeEffects[activeEffects.length - 1].audioWorkletNode as AudioNode).connect(this.stereoPannerNode);
84
86
  }
85
87
 
86
- public AddEffect(effect: Effector): void {
87
-
88
- if (!this.context) {
89
- Debug.Error("Could not add effect because this channel has no AudioContext.");
90
- return;
91
- }
92
-
93
- if (this.effects.includes(effect)) {
94
- Debug.Error("Could not add effect because it is already part of this channel", [
95
- "Call .RemoveEffect([effect Effector]) before adding effect."
96
- ], ErrorCodes.EFFECT_ALREADY_ATTACHED);
97
- return;
98
- }
99
-
100
- this.effects.push(effect);
101
- effect.InitializeOnAttachment(this.context);
102
- this.rebuildEffectChain();
103
- }
104
-
105
- public AttachEffect(effect: Effector): void {
106
- return this.AddEffect(effect);
107
- }
108
-
109
- public RemoveEffect(effect: Effector): void {
110
-
111
- if (!this.effects.includes(effect)) {
112
- Debug.Error("Could not remove effect, because it is not part of this channel.", [
113
- "Call .AddEffect([effect Effector]) before removing effect."
114
- ], ErrorCodes.EFFECT_NOT_FOUND);
115
- return;
116
- }
117
-
118
- const self: Channel = this;
119
-
120
- this.effects.forEach(function (_effect: Effector, index: number): void {
121
- if (effect.id === _effect.id)
122
- self.effects.splice(index, 1);
123
- });
124
-
125
- effect.audioWorkletNode?.disconnect();
126
-
127
- this.rebuildEffectChain();
128
- }
129
-
130
- public DetachEffect(effect: Effector): void {
131
- return this.RemoveEffect(effect);
132
- }
133
-
134
88
  private disconnectAudioNodes(gc?: boolean) {
135
89
 
136
90
  this.input?.disconnect();
@@ -180,6 +134,59 @@ export class Channel {
180
134
  return false;
181
135
  }
182
136
 
137
+ public AddEffect(effect: Effector): Channel {
138
+
139
+ if (!this.context)
140
+ throw new Error(`Could not add effect (${effect.id}), to channel (${this.id}), because the channel's AudioContext is undefined.`);
141
+
142
+ if (this.effects.includes(effect))
143
+ throw new Error(`Could not add effect (${effect.id}), to channel (${this.id}), because it has already been added to the channel.`);
144
+
145
+ this.effects.push(effect);
146
+ effect.InitializeOnAttachment(this.context);
147
+ this.rebuildEffectChain();
148
+ return this;
149
+ }
150
+
151
+ public AttachEffect(effect: Effector): Channel {
152
+ return this.AddEffect(effect);
153
+ }
154
+
155
+ public RemoveEffect(effect: Effector): void {
156
+
157
+ if (!this.effects.includes(effect)) {
158
+ Debug.Error("Could not remove effect, because it is not part of this channel.", [
159
+ "Call .AddEffect([effect Effector]) before removing effect."
160
+ ], ErrorCodes.EFFECT_NOT_FOUND);
161
+ return;
162
+ }
163
+
164
+ const self: Channel = this;
165
+
166
+ this.effects.forEach(function (_effect: Effector, index: number): void {
167
+ if (effect.id === _effect.id)
168
+ self.effects.splice(index, 1);
169
+ });
170
+
171
+ effect.audioWorkletNode?.disconnect();
172
+
173
+ this.rebuildEffectChain();
174
+ }
175
+
176
+ public RemoveAllEffects() {
177
+ for (const effect of this.effects) {
178
+ this.RemoveEffect(effect);
179
+ }
180
+ }
181
+
182
+ public DetachEffect(effect: Effector): void {
183
+ return this.RemoveEffect(effect);
184
+ }
185
+
186
+ public DetachAllEffects() {
187
+ return this.RemoveAllEffects();
188
+ }
189
+
183
190
  public Send(channel: Channel | Master) {
184
191
 
185
192
  if (channel instanceof Master)
@@ -234,7 +241,6 @@ export class Channel {
234
241
  }
235
242
 
236
243
  public UnsendToAllChannels() {
237
-
238
244
  for (var i: number = 0; i < this.sends.length; i++) {
239
245
  this.Unsend(this.sends[i]);
240
246
  i--;
@@ -251,19 +257,103 @@ export class Channel {
251
257
 
252
258
  public Volume(volume?: number): number {
253
259
 
254
- if(!this.context) throw new Error("Could not set volume on channel, because it's context is undefined.");
255
- if(!this.gainNode) throw new Error("Could not set volume on channel, because it's GainNode is undefined.")
260
+ if (!this.context) throw new Error("Could not set volume on channel, because it's context is undefined.");
261
+ if (!this.gainNode) throw new Error("Could not set volume on channel, because it's GainNode is undefined.")
256
262
 
257
263
  volume && this.gainNode.gain.setValueAtTime(volume, this.context.currentTime);
258
264
  return volume ?? this.gainNode.gain.value;
259
265
  }
260
266
 
261
267
  public Pan(pan?: number): number {
262
-
263
- if(!this.context) throw new Error("Could not set pan on channel, because it's context is undefined.");
264
- if(!this.stereoPannerNode) throw new Error("Cannot set pan on channel, because it's StereoPannerNode is undefined.");
268
+
269
+ if (!this.context) throw new Error("Could not set pan on channel, because it's context is undefined.");
270
+ if (!this.stereoPannerNode) throw new Error("Cannot set pan on channel, because it's StereoPannerNode is undefined.");
265
271
 
266
272
  pan && this.stereoPannerNode.pan.setValueAtTime(pan, this.context.currentTime);
267
273
  return pan ?? this.stereoPannerNode.pan.value;
268
274
  }
275
+
276
+ public GetEffectsByLabel(label: string): Effector[] {
277
+ return this.effects.filter(effect => effect.label === label);
278
+ }
279
+
280
+ public GetFirstEffectByLabel(label: string): Effector | null {
281
+
282
+ const filteredEffects: Effector[] = this.effects.filter(effect => effect.label === label);
283
+ return filteredEffects.length !== 0 ? filteredEffects[0] : null;
284
+ }
285
+
286
+ public GetEffectById(id: string): Effector[] {
287
+ return this.effects.filter(effect => effect.id === id);
288
+ }
289
+
290
+ public GetFirstEffectById(id: string): Effector | null {
291
+
292
+ const filteredEffects: Effector[] = this.effects.filter(effect => effect.id === id);
293
+ return filteredEffects.length !== 0 ? filteredEffects[0] : null;
294
+ }
295
+
296
+ public MoveEffectToIndex(effect: Effector, index: number | ArrayPosition): void {
297
+
298
+ let fromIndex: number = -1,
299
+ matches: number = 0,
300
+ i: number = 0;
301
+
302
+ for (i = 0; i < this.effects.length; i++) {
303
+ if (this.effects[i].id === effect.id) {
304
+ if (fromIndex === -1)
305
+ fromIndex = i;
306
+
307
+ matches++;
308
+ }
309
+ }
310
+
311
+ if (matches === 0) throw new Error(
312
+ "Effect '" + effect.id + "' (" + effect.label + ") could not be found. " +
313
+ "The effect ID may have changed, or the effect is not attached to this channel."
314
+ );
315
+
316
+ if (matches > 1) throw new Error(
317
+ "Multiple effects with the ID '" + effect.id + "' are attached to this channel. " +
318
+ "Make sure every effect has a unique ID."
319
+ );
320
+
321
+ let toIndex: number;
322
+
323
+ if (typeof index === "number") {
324
+ toIndex = index;
325
+ } else {
326
+ switch (index) {
327
+ case "start":
328
+ toIndex = 0;
329
+ break;
330
+ case "end":
331
+ toIndex = this.effects.length - 1;
332
+ break;
333
+ case "one-after-start":
334
+ toIndex = 1;
335
+ break;
336
+ case "one-before-end":
337
+ toIndex = this.effects.length - 2;
338
+ break;
339
+ default:
340
+ throw new Error("Invalid ArrayPosition: " + String(index));
341
+ }
342
+ }
343
+
344
+ if (toIndex < 0)
345
+ toIndex = 0;
346
+
347
+ if (toIndex >= this.effects.length)
348
+ toIndex = this.effects.length - 1;
349
+
350
+ if (fromIndex === toIndex) return;
351
+
352
+ const item: Effector = this.effects.splice(fromIndex, 1)[0];
353
+
354
+ if (fromIndex < toIndex)
355
+ toIndex = toIndex - 1;
356
+
357
+ this.effects.splice(toIndex, 0, item);
358
+ }
269
359
  }
@@ -1,6 +1,6 @@
1
1
  import { v4 } from "uuid";
2
2
 
3
- import { IncomingProcessorMessage, IncomingMessageType, EffectorEvents, EffectorEventMap } from "../../typings";
3
+ import { IncomingProcessorMessage, type EffectorEvents, EffectorEventMap } from "../../typings";
4
4
  import { Debug } from "../../utilities/debugger";
5
5
 
6
6
  export abstract class Effector {
@@ -41,6 +41,7 @@ export abstract class Effector {
41
41
  protected registerMessageEventListener(node: AudioWorkletNode) {
42
42
  if (this.hasRegisteredMessageEventListener) return;
43
43
 
44
+ this.hasRegisteredMessageEventListener = true;
44
45
  node.port.onmessage = this.handleIncomingMessages.bind(this);
45
46
  Debug.Log(`Succesfully registered event listener on effector ${this.name} (${this.label}) [${this.id}]`);
46
47
  }
@@ -11,7 +11,7 @@ export class SoftClip extends Effector {
11
11
  public gain: number = 1;
12
12
  public strictMode: StrictMode = StrictMode.Disabled;
13
13
 
14
- constructor({ drive, gain, strictMode }: Partial<SoftClipOptions>) {
14
+ constructor({ drive, gain, strictMode }: Partial<SoftClipOptions> = {}) {
15
15
  super();
16
16
 
17
17
  this.drive = Math.max(0, CoerceFiniteNumber(drive, this.drive));
package/lib/src/index.ts CHANGED
@@ -8,7 +8,7 @@ import { DspOptions } from "./typings";
8
8
  export const DSP: DspOptions = {
9
9
  maxMasterChannels: 8,
10
10
  maxTotalChannels: 128,
11
- sampleRate: 44000,
11
+ sampleRate: 41000,
12
12
  spatialization: "stereo",
13
13
  overrideMaxAudioBufferNodes: false,
14
14
  debugger: {
@@ -80,7 +80,7 @@ export {
80
80
  SoftClipMessageCommandId,
81
81
  AudioWorkletProcessorNames,
82
82
  ChorusMessageCommandId,
83
- LowPassFilterMessageCommandId
83
+ LowPassFilterMessageCommandId,
84
84
  } from "./typings";
85
85
 
86
86
  export type {
@@ -106,4 +106,5 @@ export type {
106
106
  IncomingProcessorMessage,
107
107
  ProcessorData,
108
108
  EffectorEvents,
109
- } from "./typings";
109
+ ArrayPosition
110
+ } from "./typings";
@@ -2,6 +2,8 @@ export type ChannelSpatialization = "mono" | "stereo" | "surround";
2
2
  export type AudioClipAnalyserType = "pre" | "post";
3
3
  export type AudioClipAnalyserProperty = "fftSize" | "minDecibels" | "maxDecibels" | "smoothingTimeConstant";
4
4
  export type IncomingMessageType = "message" | "error" | "warning" | "wasm-instantiated";
5
+ export type ArrayPosition = "start" | "middle" | "end" | "one-after-start" | "one-before-end";
6
+
5
7
 
6
8
  export type AudioClipEvents = {
7
9
  [K in keyof AudioClipEventMap]: AudioClipEventMap[K][];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluex/fluexgl-dsp",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
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",