@fluex/fluexgl-dsp 0.1.3 → 0.2.2
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.
- package/README.md +86 -86
- package/lib/dist/console-codes.d.ts +13 -13
- package/lib/dist/console-codes.js +16 -16
- package/lib/dist/core/classes/AudioClip.d.ts +67 -62
- package/lib/dist/core/classes/AudioClip.d.ts.map +1 -1
- package/lib/dist/core/classes/AudioClip.js +406 -386
- package/lib/dist/core/classes/AudioDevice.d.ts +12 -12
- package/lib/dist/core/classes/AudioDevice.js +30 -30
- package/lib/dist/core/classes/Channel.d.ts +41 -29
- package/lib/dist/core/classes/Channel.d.ts.map +1 -1
- package/lib/dist/core/classes/Channel.js +210 -144
- package/lib/dist/core/classes/DpsPipeline.d.ts +59 -59
- package/lib/dist/core/classes/DpsPipeline.js +115 -115
- package/lib/dist/core/classes/Effector.d.ts +8 -11
- package/lib/dist/core/classes/Effector.d.ts.map +1 -1
- package/lib/dist/core/classes/Effector.js +8 -20
- package/lib/dist/core/classes/Master.d.ts +11 -11
- package/lib/dist/core/classes/Master.js +35 -35
- package/lib/dist/core/exports.d.ts +6 -6
- package/lib/dist/core/exports.js +6 -6
- package/lib/dist/effects/classes/Chorus.d.ts +19 -2
- package/lib/dist/effects/classes/Chorus.d.ts.map +1 -1
- package/lib/dist/effects/classes/Chorus.js +53 -2
- package/lib/dist/effects/classes/Distortion.d.ts +6 -2
- package/lib/dist/effects/classes/Distortion.d.ts.map +1 -1
- package/lib/dist/effects/classes/Distortion.js +9 -2
- package/lib/dist/effects/classes/Equalizer.d.ts +2 -2
- package/lib/dist/effects/classes/Equalizer.js +2 -2
- package/lib/dist/effects/classes/Limiter.d.ts +2 -2
- package/lib/dist/effects/classes/Limiter.js +2 -2
- package/lib/dist/effects/classes/Saturation.d.ts +2 -2
- package/lib/dist/effects/classes/Saturation.d.ts.map +1 -1
- package/lib/dist/effects/classes/Saturation.js +2 -2
- package/lib/dist/effects/classes/SoftClip.d.ts +12 -7
- package/lib/dist/effects/classes/SoftClip.d.ts.map +1 -1
- package/lib/dist/effects/classes/SoftClip.js +54 -38
- package/lib/dist/effects/classes/StereoPanner.d.ts +3 -2
- package/lib/dist/effects/classes/StereoPanner.d.ts.map +1 -1
- package/lib/dist/effects/classes/StereoPanner.js +3 -2
- package/lib/dist/effects/classes/compressors/Compressor.d.ts +2 -2
- package/lib/dist/effects/classes/compressors/Compressor.js +2 -2
- package/lib/dist/effects/classes/compressors/MultibandCompressor.d.ts +2 -2
- package/lib/dist/effects/classes/compressors/MultibandCompressor.js +2 -2
- package/lib/dist/effects/classes/delays/AdvancedDelay.d.ts +2 -2
- package/lib/dist/effects/classes/delays/AdvancedDelay.js +2 -2
- package/lib/dist/effects/classes/delays/MonoDelay.d.ts +2 -2
- package/lib/dist/effects/classes/delays/MonoDelay.js +2 -2
- package/lib/dist/effects/classes/delays/PingPongDelay.d.ts +2 -2
- package/lib/dist/effects/classes/delays/PingPongDelay.js +2 -2
- package/lib/dist/effects/classes/delays/StereoDelay.d.ts +2 -2
- package/lib/dist/effects/classes/delays/StereoDelay.js +2 -2
- package/lib/dist/effects/classes/filters/LowPassFilter.d.ts +14 -0
- package/lib/dist/effects/classes/filters/LowPassFilter.d.ts.map +1 -0
- package/lib/dist/effects/classes/filters/LowPassFilter.js +38 -0
- package/lib/dist/effects/classes/reverbs/ChamberReverb.d.ts +2 -2
- package/lib/dist/effects/classes/reverbs/ChamberReverb.js +2 -2
- package/lib/dist/effects/classes/reverbs/ConvolverReverb.d.ts +2 -2
- package/lib/dist/effects/classes/reverbs/ConvolverReverb.js +2 -2
- package/lib/dist/effects/classes/reverbs/GenericReverb.d.ts +2 -2
- package/lib/dist/effects/classes/reverbs/GenericReverb.js +2 -2
- package/lib/dist/effects/classes/reverbs/HallReverb.d.ts +2 -2
- package/lib/dist/effects/classes/reverbs/HallReverb.js +2 -2
- package/lib/dist/effects/classes/reverbs/RoomReverb.d.ts +2 -2
- package/lib/dist/effects/classes/reverbs/RoomReverb.js +2 -2
- package/lib/dist/effects/exports.d.ts +19 -19
- package/lib/dist/effects/exports.d.ts.map +1 -1
- package/lib/dist/effects/exports.js +19 -19
- package/lib/dist/index.d.ts +12 -12
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +28 -28
- package/lib/dist/typings.d.ts +97 -59
- package/lib/dist/typings.d.ts.map +1 -1
- package/lib/dist/typings.js +30 -1
- package/lib/dist/utilities/constants.d.ts +1 -1
- package/lib/dist/utilities/constants.js +9 -9
- package/lib/dist/utilities/debugger.d.ts +7 -7
- package/lib/dist/utilities/debugger.js +49 -49
- package/lib/dist/utilities/helpers.d.ts +46 -40
- package/lib/dist/utilities/helpers.d.ts.map +1 -1
- package/lib/dist/utilities/helpers.js +186 -143
- package/lib/dist/utilities/web-assembly.d.ts +3 -3
- package/lib/dist/utilities/web-assembly.d.ts.map +1 -1
- package/lib/dist/utilities/web-assembly.js +12 -12
- package/lib/src/console-codes.ts +15 -15
- package/lib/src/core/classes/AudioClip.ts +539 -539
- package/lib/src/core/classes/AudioDevice.ts +38 -38
- package/lib/src/core/classes/Channel.ts +288 -288
- package/lib/src/core/classes/DpsPipeline.ts +152 -152
- package/lib/src/core/classes/Effector.ts +11 -12
- package/lib/src/core/classes/Master.ts +49 -49
- package/lib/src/core/exports.ts +5 -5
- package/lib/src/effects/classes/Chorus.ts +65 -111
- package/lib/src/effects/classes/Distortion.ts +13 -13
- package/lib/src/effects/classes/Saturation.ts +2 -2
- package/lib/src/effects/classes/SoftClip.ts +60 -44
- package/lib/src/effects/classes/StereoPanner.ts +2 -2
- package/lib/src/effects/classes/filters/LowPassFilter.ts +54 -0
- package/lib/src/effects/exports.ts +23 -22
- package/lib/src/index.ts +98 -93
- package/lib/src/typings.ts +113 -78
- package/lib/src/utilities/constants.ts +8 -8
- package/lib/src/utilities/debugger.ts +65 -65
- package/lib/src/utilities/helpers.ts +265 -237
- package/lib/src/utilities/web-assembly.ts +12 -12
- package/package.json +51 -50
- package/lib/dist/effects/classes/Filter.d.ts +0 -3
- package/lib/dist/effects/classes/Filter.d.ts.map +0 -1
- package/lib/dist/effects/classes/Filter.js +0 -2
- package/lib/src/effects/classes/Filter.ts +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Master } from "./Master";
|
|
2
|
-
export declare class AudioDevice {
|
|
3
|
-
deviceInfo: MediaDeviceInfo;
|
|
4
|
-
id: string;
|
|
5
|
-
timestamp: number;
|
|
6
|
-
masterChannel: Master;
|
|
7
|
-
masterChannels: Master[];
|
|
8
|
-
constructor(deviceInfo: MediaDeviceInfo);
|
|
9
|
-
GetMasterChannel(): Master;
|
|
10
|
-
SetMasterChannel(channel: Master): void;
|
|
11
|
-
CreateMasterChannel(): Master;
|
|
12
|
-
}
|
|
1
|
+
import { Master } from "./Master";
|
|
2
|
+
export declare class AudioDevice {
|
|
3
|
+
deviceInfo: MediaDeviceInfo;
|
|
4
|
+
id: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
masterChannel: Master;
|
|
7
|
+
masterChannels: Master[];
|
|
8
|
+
constructor(deviceInfo: MediaDeviceInfo);
|
|
9
|
+
GetMasterChannel(): Master;
|
|
10
|
+
SetMasterChannel(channel: Master): void;
|
|
11
|
+
CreateMasterChannel(): Master;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=AudioDevice.d.ts.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { v4 } from "uuid";
|
|
2
|
-
import { Master } from "./Master";
|
|
3
|
-
import { ErrorCodes } from "../../console-codes";
|
|
4
|
-
import { Debug } from "../../utilities/debugger";
|
|
5
|
-
export class AudioDevice {
|
|
6
|
-
deviceInfo;
|
|
7
|
-
id = v4();
|
|
8
|
-
timestamp = Date.now();
|
|
9
|
-
masterChannel = new Master();
|
|
10
|
-
masterChannels = [];
|
|
11
|
-
constructor(deviceInfo) {
|
|
12
|
-
this.deviceInfo = deviceInfo;
|
|
13
|
-
}
|
|
14
|
-
GetMasterChannel() {
|
|
15
|
-
return this.masterChannel;
|
|
16
|
-
}
|
|
17
|
-
SetMasterChannel(channel) {
|
|
18
|
-
if (channel.id === this.masterChannel.id)
|
|
19
|
-
return Debug.Error("The provided master channel is the same as the current channel.", [
|
|
20
|
-
"Provide this method with a different master channel.",
|
|
21
|
-
`Received master channel ID ${channel.id}.`
|
|
22
|
-
], ErrorCodes.SAME_MASTER_CHANNEL);
|
|
23
|
-
this.masterChannel = channel;
|
|
24
|
-
}
|
|
25
|
-
CreateMasterChannel() {
|
|
26
|
-
const master = new Master();
|
|
27
|
-
this.masterChannels.push(master);
|
|
28
|
-
return master;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
import { Master } from "./Master";
|
|
3
|
+
import { ErrorCodes } from "../../console-codes";
|
|
4
|
+
import { Debug } from "../../utilities/debugger";
|
|
5
|
+
export class AudioDevice {
|
|
6
|
+
deviceInfo;
|
|
7
|
+
id = v4();
|
|
8
|
+
timestamp = Date.now();
|
|
9
|
+
masterChannel = new Master();
|
|
10
|
+
masterChannels = [];
|
|
11
|
+
constructor(deviceInfo) {
|
|
12
|
+
this.deviceInfo = deviceInfo;
|
|
13
|
+
}
|
|
14
|
+
GetMasterChannel() {
|
|
15
|
+
return this.masterChannel;
|
|
16
|
+
}
|
|
17
|
+
SetMasterChannel(channel) {
|
|
18
|
+
if (channel.id === this.masterChannel.id)
|
|
19
|
+
return Debug.Error("The provided master channel is the same as the current channel.", [
|
|
20
|
+
"Provide this method with a different master channel.",
|
|
21
|
+
`Received master channel ID ${channel.id}.`
|
|
22
|
+
], ErrorCodes.SAME_MASTER_CHANNEL);
|
|
23
|
+
this.masterChannel = channel;
|
|
24
|
+
}
|
|
25
|
+
CreateMasterChannel() {
|
|
26
|
+
const master = new Master();
|
|
27
|
+
this.masterChannels.push(master);
|
|
28
|
+
return master;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,30 +1,42 @@
|
|
|
1
|
-
import { Effector } from "./Effector";
|
|
2
|
-
import { AudioClip } from "./AudioClip";
|
|
3
|
-
import { Master } from "./Master";
|
|
4
|
-
import { ChannelOptions } from "../../typings";
|
|
5
|
-
export declare class Channel {
|
|
6
|
-
options: Partial<ChannelOptions>;
|
|
7
|
-
id: string;
|
|
8
|
-
effects: Effector[];
|
|
9
|
-
label: string | null;
|
|
10
|
-
parentialContext: AudioContext | null;
|
|
11
|
-
parentialMasterChannel: Master | null;
|
|
12
|
-
audioClips: AudioClip[];
|
|
13
|
-
gainNode: GainNode | null;
|
|
14
|
-
stereoPannerNode: StereoPannerNode | null;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { Effector } from "./Effector";
|
|
2
|
+
import { AudioClip } from "./AudioClip";
|
|
3
|
+
import { Master } from "./Master";
|
|
4
|
+
import { ChannelOptions } from "../../typings";
|
|
5
|
+
export declare class Channel {
|
|
6
|
+
options: Partial<ChannelOptions>;
|
|
7
|
+
id: string;
|
|
8
|
+
effects: Effector[];
|
|
9
|
+
label: string | null;
|
|
10
|
+
parentialContext: AudioContext | null;
|
|
11
|
+
parentialMasterChannel: Master | null;
|
|
12
|
+
audioClips: AudioClip[];
|
|
13
|
+
gainNode: GainNode | null;
|
|
14
|
+
stereoPannerNode: StereoPannerNode | null;
|
|
15
|
+
analyserNode: AnalyserNode | null;
|
|
16
|
+
channelSplitterNode: ChannelSplitterNode | null;
|
|
17
|
+
analyserFloatArrayBuffer: Float32Array<ArrayBuffer>;
|
|
18
|
+
analyserByteArrayBuffer: Uint8Array<ArrayBuffer>;
|
|
19
|
+
audioClipsInputGainNode: GainNode | null;
|
|
20
|
+
analyserOptions: AnalyserOptions;
|
|
21
|
+
constructor(options?: Partial<ChannelOptions>);
|
|
22
|
+
private rebuildEffectChain;
|
|
23
|
+
InitializeChannelOnMasterAttachment(master: Master): void;
|
|
24
|
+
SetLabel(label: string): void;
|
|
25
|
+
ClearLabel(): void;
|
|
26
|
+
AttachAudioClip(clip: AudioClip): void;
|
|
27
|
+
DetachAudioClip(clip: AudioClip): void;
|
|
28
|
+
HasAudioClip(clip: AudioClip): boolean;
|
|
29
|
+
SetVolume(volume: number): void;
|
|
30
|
+
SetPanLevel(pan: number): void;
|
|
31
|
+
AddEffect(effect: Effector): void;
|
|
32
|
+
AttachEffect(effect: Effector): void;
|
|
33
|
+
RemoveEffect(effect: Effector): void;
|
|
34
|
+
DetachEffect(effect: Effector): void;
|
|
35
|
+
SetAnalyserFftSize(value: number): number | null;
|
|
36
|
+
GetWaveformFloatData(): Float32Array | null;
|
|
37
|
+
GetWaveformByteData(): Uint8Array | null;
|
|
38
|
+
SetAnalyserOptions(options: AnalyserOptions): Channel | null;
|
|
39
|
+
get volume(): number | null;
|
|
40
|
+
get panLevel(): number | null;
|
|
41
|
+
}
|
|
30
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,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,qBAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Channel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,qBAAa,OAAO;IAuBG,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC;IArB5C,EAAE,EAAE,MAAM,CAAQ;IAClB,OAAO,EAAE,QAAQ,EAAE,CAAM;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,gBAAgB,EAAE,YAAY,GAAG,IAAI,CAAQ;IAC7C,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE7C,UAAU,EAAE,SAAS,EAAE,CAAM;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACjC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACjD,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IACzC,mBAAmB,EAAE,mBAAmB,GAAG,IAAI,CAAQ;IAEvD,wBAAwB,4BAAsB;IAC9C,uBAAuB,0BAAoB;IAE3C,uBAAuB,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAEhD,eAAe,EAAE,eAAe,CAAmB;gBAEvC,OAAO,GAAE,OAAO,CAAC,cAAc,CAAuC;IAIzF,OAAO,CAAC,kBAAkB;IA2CnB,mCAAmC,CAAC,MAAM,EAAE,MAAM;IAoBlD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,UAAU,IAAI,IAAI;IAMlB,eAAe,CAAC,IAAI,EAAE,SAAS;IAU/B,eAAe,CAAC,IAAI,EAAE,SAAS;IAuB/B,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAStC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAS/B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAS9B,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAkBjC,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAIpC,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAgBpC,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAIpC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAehD,oBAAoB,IAAI,YAAY,GAAG,IAAI;IAe3C,mBAAmB,IAAI,UAAU,GAAG,IAAI;IAexC,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,GAAG,IAAI;IAmBnE,IAAW,MAAM,IAAI,MAAM,GAAG,IAAI,CAIjC;IAED,IAAW,QAAQ,IAAI,MAAM,GAAG,IAAI,CAInC;CACJ"}
|
|
@@ -1,144 +1,210 @@
|
|
|
1
|
-
import { v4 } from "uuid";
|
|
2
|
-
import { Debug } from "../../utilities/debugger";
|
|
3
|
-
export class Channel {
|
|
4
|
-
options;
|
|
5
|
-
id = v4();
|
|
6
|
-
effects = [];
|
|
7
|
-
label;
|
|
8
|
-
parentialContext = null;
|
|
9
|
-
parentialMasterChannel = null;
|
|
10
|
-
audioClips = [];
|
|
11
|
-
gainNode = null;
|
|
12
|
-
stereoPannerNode = null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.audioClipsInputGainNode.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.gainNode
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
clip.
|
|
82
|
-
clip
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
import { Debug } from "../../utilities/debugger";
|
|
3
|
+
export class Channel {
|
|
4
|
+
options;
|
|
5
|
+
id = v4();
|
|
6
|
+
effects = [];
|
|
7
|
+
label;
|
|
8
|
+
parentialContext = null;
|
|
9
|
+
parentialMasterChannel = null;
|
|
10
|
+
audioClips = [];
|
|
11
|
+
gainNode = null;
|
|
12
|
+
stereoPannerNode = null;
|
|
13
|
+
analyserNode = null;
|
|
14
|
+
channelSplitterNode = null;
|
|
15
|
+
analyserFloatArrayBuffer = new Float32Array();
|
|
16
|
+
analyserByteArrayBuffer = new Uint8Array();
|
|
17
|
+
audioClipsInputGainNode = null;
|
|
18
|
+
analyserOptions = { fftSize: 32 };
|
|
19
|
+
constructor(options = { maxAudioNodes: 8, maxEffects: 8 }) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.label = options.label ?? null;
|
|
22
|
+
}
|
|
23
|
+
rebuildEffectChain() {
|
|
24
|
+
Debug.Log("Attempting to rebuild effect chain.");
|
|
25
|
+
if (!this.audioClipsInputGainNode || !this.gainNode)
|
|
26
|
+
return Debug.Error("Could not rebuild effect chain, because one or more gain nodes on this channel are undefined.", [
|
|
27
|
+
`Channel id: ${this.id}.`,
|
|
28
|
+
`Current amount of effects: ${this.effects.length}.`
|
|
29
|
+
]);
|
|
30
|
+
this.audioClipsInputGainNode.disconnect();
|
|
31
|
+
for (const effect of this.effects) {
|
|
32
|
+
effect.audioWorkletNode?.disconnect();
|
|
33
|
+
}
|
|
34
|
+
const activeEffects = this.effects.filter(e => !!e.audioWorkletNode);
|
|
35
|
+
if (activeEffects.length === 0) {
|
|
36
|
+
this.audioClipsInputGainNode.connect(this.gainNode);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const firstEffectGain = activeEffects[0].audioWorkletNode;
|
|
40
|
+
this.audioClipsInputGainNode.connect(firstEffectGain);
|
|
41
|
+
for (let i = 0; i < activeEffects.length - 1; i++) {
|
|
42
|
+
const current = activeEffects[i].audioWorkletNode;
|
|
43
|
+
const next = activeEffects[i + 1].audioWorkletNode;
|
|
44
|
+
current.connect(next);
|
|
45
|
+
}
|
|
46
|
+
const lastEffectGain = activeEffects[activeEffects.length - 1].audioWorkletNode;
|
|
47
|
+
lastEffectGain.connect(this.gainNode);
|
|
48
|
+
}
|
|
49
|
+
Debug.Success("Successfully rebuilt effect chain.", [
|
|
50
|
+
`Channel id: ${this.id}.`,
|
|
51
|
+
`Current amount of effects: ${this.effects.length}`
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
InitializeChannelOnMasterAttachment(master) {
|
|
55
|
+
this.parentialMasterChannel = master;
|
|
56
|
+
this.parentialContext = master.context;
|
|
57
|
+
this.gainNode = new GainNode(this.parentialContext);
|
|
58
|
+
this.stereoPannerNode = new StereoPannerNode(this.parentialContext);
|
|
59
|
+
this.analyserNode = new AnalyserNode(this.parentialContext, this.analyserOptions);
|
|
60
|
+
this.analyserFloatArrayBuffer = new Float32Array(this.analyserNode.fftSize);
|
|
61
|
+
this.analyserByteArrayBuffer = new Uint8Array(this.analyserNode.fftSize);
|
|
62
|
+
this.audioClipsInputGainNode = new GainNode(this.parentialContext);
|
|
63
|
+
this.audioClipsInputGainNode.connect(this.stereoPannerNode);
|
|
64
|
+
this.stereoPannerNode.connect(this.gainNode);
|
|
65
|
+
this.gainNode.connect(this.analyserNode);
|
|
66
|
+
this.analyserNode.connect(this.parentialMasterChannel.gainNode);
|
|
67
|
+
}
|
|
68
|
+
SetLabel(label) {
|
|
69
|
+
this.options.label = label;
|
|
70
|
+
this.label = label;
|
|
71
|
+
}
|
|
72
|
+
ClearLabel() {
|
|
73
|
+
this.options.label = "";
|
|
74
|
+
this.label = null;
|
|
75
|
+
}
|
|
76
|
+
AttachAudioClip(clip) {
|
|
77
|
+
if (this.audioClips.includes(clip))
|
|
78
|
+
return Debug.Error("Could not attach audio clip because it is already part of this channel", [
|
|
79
|
+
"Call .DetachAudioClip([clip AudioClip]) before attaching audio clip."
|
|
80
|
+
]);
|
|
81
|
+
clip.InitializeAudioClipOnAttaching(this);
|
|
82
|
+
this.audioClips.push(clip);
|
|
83
|
+
}
|
|
84
|
+
DetachAudioClip(clip) {
|
|
85
|
+
if (!this.audioClips.includes(clip))
|
|
86
|
+
return Debug.Error("Could not detach audio clip, because it is not part of this channel.", [
|
|
87
|
+
"Call .AttachAudioClip([clip AudioClip]) before deattaching audio clip."
|
|
88
|
+
]);
|
|
89
|
+
const self = this;
|
|
90
|
+
clip.parentialAudioContext = null;
|
|
91
|
+
clip.parentialChannel = null;
|
|
92
|
+
clip.hasAttachedToChannel = false;
|
|
93
|
+
clip.stereoPannerNode?.disconnect();
|
|
94
|
+
clip.gainNode?.disconnect();
|
|
95
|
+
clip.DisconnectAllAudioBufferSourceNodes();
|
|
96
|
+
this.audioClips.forEach(function (_clip, index) {
|
|
97
|
+
if (clip.id === _clip.id)
|
|
98
|
+
return self.audioClips.splice(index, 1);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
HasAudioClip(clip) {
|
|
102
|
+
for (let _clip of this.audioClips) {
|
|
103
|
+
if (_clip.id === clip.id)
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
SetVolume(volume) {
|
|
109
|
+
if (!this.gainNode)
|
|
110
|
+
return Debug.Error("Could not set channel volume because the channel is not attached to a master channel.", [
|
|
111
|
+
"Attach the channel to a master channel before setting the volume."
|
|
112
|
+
]);
|
|
113
|
+
this.gainNode.gain.setValueAtTime(volume, this.parentialContext.currentTime);
|
|
114
|
+
}
|
|
115
|
+
SetPanLevel(pan) {
|
|
116
|
+
if (!this.stereoPannerNode)
|
|
117
|
+
return Debug.Error("Could not set channel pan level because the channel is not attached to a master channel.", [
|
|
118
|
+
"Attach the channel to a master channel before setting the pan level."
|
|
119
|
+
]);
|
|
120
|
+
this.stereoPannerNode.pan.setValueAtTime(pan, this.parentialContext.currentTime);
|
|
121
|
+
}
|
|
122
|
+
AddEffect(effect) {
|
|
123
|
+
if (!this.parentialContext)
|
|
124
|
+
return Debug.Error("Could not add effect on channel, because the parential context is undefined.", [
|
|
125
|
+
`Channel ID: ${this.id}`,
|
|
126
|
+
`Effect ID: ${effect.id}`,
|
|
127
|
+
`Effect name: ${effect.constructor.name}`
|
|
128
|
+
]);
|
|
129
|
+
if (this.effects.includes(effect))
|
|
130
|
+
return Debug.Error("Could not add effect because it is already part of this channel", [
|
|
131
|
+
"Call .RemoveEffect([effect Effector]) before adding effect."
|
|
132
|
+
]);
|
|
133
|
+
effect.InitializeOnAttachment(this.parentialContext);
|
|
134
|
+
this.effects.push(effect);
|
|
135
|
+
this.rebuildEffectChain();
|
|
136
|
+
}
|
|
137
|
+
AttachEffect(effect) {
|
|
138
|
+
return this.AddEffect(effect);
|
|
139
|
+
}
|
|
140
|
+
RemoveEffect(effect) {
|
|
141
|
+
if (!this.effects.includes(effect))
|
|
142
|
+
return Debug.Error("Could not remove effect, because it is not part of this channel.", [
|
|
143
|
+
"Call .AddEffect([effect Effector]) before removing effect."
|
|
144
|
+
]);
|
|
145
|
+
const self = this;
|
|
146
|
+
this.effects.forEach(function (_effect, index) {
|
|
147
|
+
if (effect.id === _effect.id)
|
|
148
|
+
return self.effects.splice(index, 1);
|
|
149
|
+
});
|
|
150
|
+
this.rebuildEffectChain();
|
|
151
|
+
}
|
|
152
|
+
DetachEffect(effect) {
|
|
153
|
+
return this.RemoveEffect(effect);
|
|
154
|
+
}
|
|
155
|
+
SetAnalyserFftSize(value) {
|
|
156
|
+
if (!this.analyserNode) {
|
|
157
|
+
Debug.Error("Could not set FFT size on analyser because the analyser has not been defined.");
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
this.analyserNode.fftSize = value;
|
|
161
|
+
this.analyserFloatArrayBuffer = new Float32Array(this.analyserNode.fftSize);
|
|
162
|
+
this.analyserByteArrayBuffer = new Uint8Array(this.analyserNode.fftSize);
|
|
163
|
+
return this.analyserNode.fftSize;
|
|
164
|
+
}
|
|
165
|
+
GetWaveformFloatData() {
|
|
166
|
+
if (!this.analyserNode) {
|
|
167
|
+
Debug.Error("Could not get waveform float data, because the analyser has not been defined.");
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
if (this.analyserFloatArrayBuffer.length !== this.analyserNode.fftSize) {
|
|
171
|
+
this.analyserFloatArrayBuffer = new Float32Array(this.analyserNode.fftSize);
|
|
172
|
+
}
|
|
173
|
+
this.analyserNode.getFloatTimeDomainData(this.analyserFloatArrayBuffer);
|
|
174
|
+
return this.analyserFloatArrayBuffer;
|
|
175
|
+
}
|
|
176
|
+
GetWaveformByteData() {
|
|
177
|
+
if (!this.analyserNode) {
|
|
178
|
+
Debug.Error("Could not get waveform byte data, because the analyser has not been defined.");
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
if (this.analyserByteArrayBuffer.length !== this.analyserNode.fftSize) {
|
|
182
|
+
this.analyserByteArrayBuffer = new Uint8Array(this.analyserNode.fftSize);
|
|
183
|
+
}
|
|
184
|
+
this.analyserNode.getByteTimeDomainData(this.analyserByteArrayBuffer);
|
|
185
|
+
return this.analyserByteArrayBuffer;
|
|
186
|
+
}
|
|
187
|
+
SetAnalyserOptions(options) {
|
|
188
|
+
this.analyserOptions = { ...options };
|
|
189
|
+
if (!this.analyserNode)
|
|
190
|
+
return null;
|
|
191
|
+
this.analyserNode.minDecibels = options.minDecibels ?? this.analyserNode.minDecibels;
|
|
192
|
+
this.analyserNode.maxDecibels = options.maxDecibels ?? this.analyserNode.maxDecibels;
|
|
193
|
+
this.analyserNode.fftSize = options.fftSize ?? 32;
|
|
194
|
+
this.analyserNode.smoothingTimeConstant = options.smoothingTimeConstant ?? this.analyserNode.smoothingTimeConstant;
|
|
195
|
+
this.analyserByteArrayBuffer = new Uint8Array(this.analyserNode.fftSize);
|
|
196
|
+
this.analyserFloatArrayBuffer = new Float32Array(this.analyserNode.fftSize);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
// Public getters and setters
|
|
200
|
+
get volume() {
|
|
201
|
+
if (!this.gainNode)
|
|
202
|
+
return null;
|
|
203
|
+
return this.gainNode.gain.value;
|
|
204
|
+
}
|
|
205
|
+
get panLevel() {
|
|
206
|
+
if (!this.stereoPannerNode)
|
|
207
|
+
return null;
|
|
208
|
+
return this.stereoPannerNode.pan.value;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { AudioDevice } from "./AudioDevice";
|
|
2
|
-
import { DspPipelineInitializationOptions } from "../../typings";
|
|
3
|
-
/**
|
|
4
|
-
* Represents the digital signal processing (DSP) pipeline responsible for initializing
|
|
5
|
-
* WebAssembly modules, AudioWorklet processors, and resolving audio output devices.
|
|
6
|
-
*/
|
|
7
|
-
export declare class DspPipeline {
|
|
8
|
-
/**
|
|
9
|
-
* The path to the WebAssembly module file.
|
|
10
|
-
*/
|
|
11
|
-
pathToWasm: string | null;
|
|
12
|
-
/**
|
|
13
|
-
* The path to the AudioWorklet processor script.
|
|
14
|
-
*/
|
|
15
|
-
pathToWorklet: string | null;
|
|
16
|
-
/**
|
|
17
|
-
* Unique identifier of this DSP pipeline instance.
|
|
18
|
-
*/
|
|
19
|
-
id: string;
|
|
20
|
-
/**
|
|
21
|
-
* Indicates whether the DSP pipeline has been successfully initialized.
|
|
22
|
-
*/
|
|
23
|
-
hasInitialized: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* The generated blob URL containing the AudioWorklet processor code.
|
|
26
|
-
*/
|
|
27
|
-
private blobUrl;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new instance of the {@link DspPipeline} class.
|
|
30
|
-
*
|
|
31
|
-
* @param options - Initialization options for the DSP pipeline.
|
|
32
|
-
* Must include valid paths to the WebAssembly and AudioWorklet files.
|
|
33
|
-
*/
|
|
34
|
-
constructor(options: DspPipelineInitializationOptions);
|
|
35
|
-
/**
|
|
36
|
-
* Initializes the DSP pipeline.
|
|
37
|
-
* This is a convenience wrapper around {@link InitializeDpsPipeline}.
|
|
38
|
-
*
|
|
39
|
-
* @returns A promise resolving to `true` if the initialization succeeded, otherwise `false`.
|
|
40
|
-
*/
|
|
41
|
-
Init(): Promise<boolean>;
|
|
42
|
-
/**
|
|
43
|
-
* Performs the full initialization of the DSP pipeline.
|
|
44
|
-
* Loads the WebAssembly module, constructs the AudioWorklet blob URL,
|
|
45
|
-
* and ensures audio access permissions are granted.
|
|
46
|
-
*
|
|
47
|
-
* @returns A promise resolving to `true` when initialization completes successfully, otherwise `false`.
|
|
48
|
-
*/
|
|
49
|
-
InitializeDpsPipeline(): Promise<boolean>;
|
|
50
|
-
/**
|
|
51
|
-
* Resolves and initializes the system’s default audio output device.
|
|
52
|
-
* This method can only be called after the DSP pipeline has been initialized.
|
|
53
|
-
*
|
|
54
|
-
* @returns A promise that resolves with the default {@link AudioDevice} instance,
|
|
55
|
-
* or `null` if no default device was found or initialization failed.
|
|
56
|
-
*/
|
|
57
|
-
ResolveDefaultAudioOutputDevice(): Promise<AudioDevice | null>;
|
|
58
|
-
TellMeWhatTheFuckThisWholeLibraryActuallyDoes(): string;
|
|
59
|
-
}
|
|
1
|
+
import { AudioDevice } from "./AudioDevice";
|
|
2
|
+
import { DspPipelineInitializationOptions } from "../../typings";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the digital signal processing (DSP) pipeline responsible for initializing
|
|
5
|
+
* WebAssembly modules, AudioWorklet processors, and resolving audio output devices.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DspPipeline {
|
|
8
|
+
/**
|
|
9
|
+
* The path to the WebAssembly module file.
|
|
10
|
+
*/
|
|
11
|
+
pathToWasm: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* The path to the AudioWorklet processor script.
|
|
14
|
+
*/
|
|
15
|
+
pathToWorklet: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Unique identifier of this DSP pipeline instance.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether the DSP pipeline has been successfully initialized.
|
|
22
|
+
*/
|
|
23
|
+
hasInitialized: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The generated blob URL containing the AudioWorklet processor code.
|
|
26
|
+
*/
|
|
27
|
+
private blobUrl;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of the {@link DspPipeline} class.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Initialization options for the DSP pipeline.
|
|
32
|
+
* Must include valid paths to the WebAssembly and AudioWorklet files.
|
|
33
|
+
*/
|
|
34
|
+
constructor(options: DspPipelineInitializationOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Initializes the DSP pipeline.
|
|
37
|
+
* This is a convenience wrapper around {@link InitializeDpsPipeline}.
|
|
38
|
+
*
|
|
39
|
+
* @returns A promise resolving to `true` if the initialization succeeded, otherwise `false`.
|
|
40
|
+
*/
|
|
41
|
+
Init(): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Performs the full initialization of the DSP pipeline.
|
|
44
|
+
* Loads the WebAssembly module, constructs the AudioWorklet blob URL,
|
|
45
|
+
* and ensures audio access permissions are granted.
|
|
46
|
+
*
|
|
47
|
+
* @returns A promise resolving to `true` when initialization completes successfully, otherwise `false`.
|
|
48
|
+
*/
|
|
49
|
+
InitializeDpsPipeline(): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves and initializes the system’s default audio output device.
|
|
52
|
+
* This method can only be called after the DSP pipeline has been initialized.
|
|
53
|
+
*
|
|
54
|
+
* @returns A promise that resolves with the default {@link AudioDevice} instance,
|
|
55
|
+
* or `null` if no default device was found or initialization failed.
|
|
56
|
+
*/
|
|
57
|
+
ResolveDefaultAudioOutputDevice(): Promise<AudioDevice | null>;
|
|
58
|
+
TellMeWhatTheFuckThisWholeLibraryActuallyDoes(): string;
|
|
59
|
+
}
|
|
60
60
|
//# sourceMappingURL=DpsPipeline.d.ts.map
|