@fluex/fluexgl-dsp 0.4.1 → 0.4.3
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 +16 -38
- package/lib/dist/console-codes.d.ts +22 -7
- package/lib/dist/console-codes.d.ts.map +1 -1
- package/lib/dist/console-codes.js +22 -7
- package/lib/dist/core/classes/AudioClip.d.ts +3 -1
- package/lib/dist/core/classes/AudioClip.d.ts.map +1 -1
- package/lib/dist/core/classes/AudioClip.js +23 -17
- package/lib/dist/core/classes/AudioClipPlayer.d.ts +10 -2
- package/lib/dist/core/classes/AudioClipPlayer.d.ts.map +1 -1
- package/lib/dist/core/classes/AudioClipPlayer.js +56 -2
- package/lib/dist/core/classes/AudioDevice.d.ts +2 -0
- package/lib/dist/core/classes/AudioDevice.d.ts.map +1 -1
- package/lib/dist/core/classes/AudioDevice.js +5 -0
- package/lib/dist/core/classes/Channel.d.ts +14 -4
- package/lib/dist/core/classes/Channel.d.ts.map +1 -1
- package/lib/dist/core/classes/Channel.js +93 -7
- package/lib/dist/core/classes/DpsPipeline.d.ts +1 -1
- package/lib/dist/core/classes/DpsPipeline.d.ts.map +1 -1
- package/lib/dist/core/classes/DpsPipeline.js +7 -3
- package/lib/dist/core/classes/Effector.d.ts +2 -2
- package/lib/dist/core/classes/Effector.d.ts.map +1 -1
- package/lib/dist/core/classes/Effector.js +1 -1
- package/lib/dist/core/classes/Master.d.ts +12 -0
- package/lib/dist/core/classes/Master.d.ts.map +1 -1
- package/lib/dist/core/classes/Master.js +80 -9
- package/lib/dist/effects/classes/Analyser.d.ts +16 -0
- package/lib/dist/effects/classes/Analyser.d.ts.map +1 -0
- package/lib/dist/effects/classes/Analyser.js +62 -0
- package/lib/dist/effects/classes/Chorus.d.ts +4 -3
- package/lib/dist/effects/classes/Chorus.d.ts.map +1 -1
- package/lib/dist/effects/classes/Chorus.js +21 -12
- package/lib/dist/effects/classes/clips/HardClip.d.ts +4 -3
- package/lib/dist/effects/classes/clips/HardClip.d.ts.map +1 -1
- package/lib/dist/effects/classes/clips/HardClip.js +15 -9
- package/lib/dist/effects/classes/clips/SoftClip.d.ts +4 -3
- package/lib/dist/effects/classes/clips/SoftClip.d.ts.map +1 -1
- package/lib/dist/effects/classes/clips/SoftClip.js +15 -9
- package/lib/dist/effects/classes/filters/LowPassFilter.d.ts +4 -3
- package/lib/dist/effects/classes/filters/LowPassFilter.d.ts.map +1 -1
- package/lib/dist/effects/classes/filters/LowPassFilter.js +23 -14
- package/lib/dist/effects/exports.d.ts +1 -0
- package/lib/dist/effects/exports.d.ts.map +1 -1
- package/lib/dist/effects/exports.js +1 -0
- package/lib/dist/index.d.ts +5 -4
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +13 -18
- package/lib/dist/typings.d.ts +13 -11
- package/lib/dist/typings.d.ts.map +1 -1
- package/lib/dist/typings.js +5 -0
- package/lib/dist/utilities/debugger.js +6 -6
- package/lib/dist/utilities/helpers.d.ts +2 -0
- package/lib/dist/utilities/helpers.d.ts.map +1 -1
- package/lib/dist/utilities/helpers.js +35 -12
- package/lib/dist/utilities/web-assembly.d.ts.map +1 -1
- package/lib/dist/utilities/web-assembly.js +6 -0
- package/lib/src/console-codes.ts +22 -7
- package/lib/src/core/classes/AudioClip.ts +28 -19
- package/lib/src/core/classes/AudioClipPlayer.ts +77 -8
- package/lib/src/core/classes/AudioDevice.ts +6 -1
- package/lib/src/core/classes/Channel.ts +126 -13
- package/lib/src/core/classes/DpsPipeline.ts +7 -3
- package/lib/src/core/classes/Effector.ts +3 -2
- package/lib/src/core/classes/Master.ts +101 -13
- package/lib/src/effects/classes/Analyser.ts +84 -0
- package/lib/src/effects/classes/Chorus.ts +22 -13
- package/lib/src/effects/classes/clips/HardClip.ts +17 -10
- package/lib/src/effects/classes/clips/SoftClip.ts +17 -10
- package/lib/src/effects/classes/filters/LowPassFilter.ts +28 -15
- package/lib/src/effects/exports.ts +2 -1
- package/lib/src/index.ts +27 -29
- package/lib/src/typings.ts +14 -14
- package/lib/src/utilities/debugger.ts +6 -6
- package/lib/src/utilities/helpers.ts +39 -15
- package/lib/src/utilities/web-assembly.ts +8 -0
- package/package.json +1 -1
- 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/dist/effects/classes/SoftClip.d.ts +0 -10
- package/lib/dist/effects/classes/SoftClip.d.ts.map +0 -1
- package/lib/dist/effects/classes/SoftClip.js +0 -39
- package/lib/dist/test/linkable-channels.d.ts +0 -2
- package/lib/dist/test/linkable-channels.d.ts.map +0 -1
- package/lib/dist/test/linkable-channels.js +0 -16
- package/lib/src/core/functions/rebuild-effect-chain.ts +0 -5
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
import { Effector } from "../../../core/classes/Effector";
|
|
2
|
-
import { SendMessageToWorklet, CreateAudioWorkletNode } from "../../../utilities/helpers";
|
|
3
|
-
import { LowPassFilterMessageCommandId, AudioWorkletProcessorNames } from "../../../typings";
|
|
2
|
+
import { CoerceFiniteNumber, SendMessageToWorklet, CreateAudioWorkletNode } from "../../../utilities/helpers";
|
|
3
|
+
import { LowPassFilterMessageCommandId, AudioWorkletProcessorNames, StrictMode } from "../../../typings";
|
|
4
4
|
export class LowPassFilter extends Effector {
|
|
5
5
|
name = "LowPassFilter";
|
|
6
6
|
label = "LowPassFilter";
|
|
7
7
|
cutoff = 1000;
|
|
8
8
|
q = 0.7;
|
|
9
9
|
minFrequency = 10;
|
|
10
|
-
|
|
10
|
+
strictMode = StrictMode.Disabled;
|
|
11
|
+
constructor({ cutoff, minFrequency, q, strictMode }) {
|
|
11
12
|
super();
|
|
12
|
-
this.cutoff = cutoff
|
|
13
|
-
this.minFrequency = minFrequency
|
|
14
|
-
this.q = q
|
|
13
|
+
this.cutoff = CoerceFiniteNumber(cutoff, this.cutoff);
|
|
14
|
+
this.minFrequency = CoerceFiniteNumber(minFrequency, this.minFrequency);
|
|
15
|
+
this.q = CoerceFiniteNumber(q, this.q);
|
|
16
|
+
const mode = CoerceFiniteNumber(strictMode, this.strictMode);
|
|
17
|
+
this.strictMode = mode === StrictMode.Enabled ? StrictMode.Enabled : StrictMode.Disabled;
|
|
15
18
|
}
|
|
16
|
-
async InitializeOnAttachment(
|
|
17
|
-
this.
|
|
18
|
-
this.audioWorkletNode = CreateAudioWorkletNode(
|
|
19
|
-
this.registerMessageEventListener(this.audioWorkletNode);
|
|
19
|
+
async InitializeOnAttachment(context) {
|
|
20
|
+
this.context = context;
|
|
21
|
+
this.audioWorkletNode = CreateAudioWorkletNode(context, AudioWorkletProcessorNames.LowPassFilter, this.ReturnOptionsAsObject());
|
|
22
|
+
this.audioWorkletNode && this.registerMessageEventListener(this.audioWorkletNode);
|
|
20
23
|
}
|
|
21
24
|
ReturnOptionsAsObject() {
|
|
22
25
|
return {
|
|
23
26
|
cutoff: this.cutoff,
|
|
24
27
|
minFrequency: this.minFrequency,
|
|
25
|
-
q: this.q
|
|
28
|
+
q: this.q,
|
|
29
|
+
strictMode: this.strictMode
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
SetCutoff(cutoff = 1000) {
|
|
29
|
-
if (!this.
|
|
33
|
+
if (!this.context)
|
|
30
34
|
return false;
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
cutoff = CoerceFiniteNumber(cutoff, this.cutoff);
|
|
36
|
+
cutoff = Math.max(this.minFrequency, cutoff);
|
|
37
|
+
if (cutoff >= this.context.sampleRate)
|
|
38
|
+
cutoff = this.context.sampleRate;
|
|
33
39
|
this.cutoff = cutoff;
|
|
34
40
|
return SendMessageToWorklet(this.audioWorkletNode, LowPassFilterMessageCommandId.SetCutoff, cutoff);
|
|
35
41
|
}
|
|
36
42
|
SetMinFrequency(minFrequency = 10) {
|
|
43
|
+
minFrequency = CoerceFiniteNumber(minFrequency, this.minFrequency);
|
|
37
44
|
if (minFrequency < 10)
|
|
38
45
|
minFrequency = 10;
|
|
39
46
|
this.minFrequency = minFrequency;
|
|
40
47
|
return SendMessageToWorklet(this.audioWorkletNode, LowPassFilterMessageCommandId.SetMinFrequency, minFrequency);
|
|
41
48
|
}
|
|
42
49
|
SetQ(q = 0.7) {
|
|
50
|
+
q = CoerceFiniteNumber(q, this.q);
|
|
51
|
+
q = Math.max(0.0001, q);
|
|
43
52
|
if (q > 4)
|
|
44
53
|
q = 4;
|
|
45
54
|
this.q = q;
|
|
@@ -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,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,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,EAA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AC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC"}
|
package/lib/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* FluexGL Audio
|
|
3
3
|
* A javascript digital audio processor library.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
export declare const
|
|
7
|
-
export { Chorus, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter, HardClip } from "./effects/exports";
|
|
5
|
+
import { DspOptions } from "./typings";
|
|
6
|
+
export declare const DSP: DspOptions;
|
|
7
|
+
export { Chorus, Analyser, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter, HardClip } from "./effects/exports";
|
|
8
8
|
export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline, AudioClipPlayer } from "./core/exports";
|
|
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
|
|
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";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
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"}
|
package/lib/dist/index.js
CHANGED
|
@@ -2,27 +2,22 @@
|
|
|
2
2
|
* FluexGL Audio
|
|
3
3
|
* A javascript digital audio processor library.
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
debugger: {
|
|
17
|
-
showErrors: true,
|
|
18
|
-
showInfo: true,
|
|
19
|
-
showWarnings: true,
|
|
20
|
-
breakOnError: true
|
|
21
|
-
}
|
|
5
|
+
export const DSP = {
|
|
6
|
+
maxMasterChannels: 8,
|
|
7
|
+
maxTotalChannels: 128,
|
|
8
|
+
sampleRate: 44000,
|
|
9
|
+
spatialization: "stereo",
|
|
10
|
+
overrideMaxAudioBufferNodes: false,
|
|
11
|
+
debugger: {
|
|
12
|
+
showErrors: true,
|
|
13
|
+
showInfo: true,
|
|
14
|
+
showWarnings: true,
|
|
15
|
+
breakOnError: true
|
|
22
16
|
}
|
|
23
17
|
};
|
|
24
|
-
export { Chorus, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter, HardClip } from "./effects/exports";
|
|
18
|
+
export { Chorus, Analyser, Distortion, Equalizer, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip, LowPassFilter, HardClip } from "./effects/exports";
|
|
25
19
|
export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline, AudioClipPlayer } from "./core/exports";
|
|
26
20
|
export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnAudioDevice, SendMessageToWorklet } from "./utilities/helpers";
|
|
27
21
|
export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
|
|
28
22
|
export { hasInitializedWasm, } from "./utilities/web-assembly";
|
|
23
|
+
export { StrictMode, ProcessorIdentificationCodes, HardClipMessageCommandId, SoftClipMessageCommandId, AudioWorkletProcessorNames, ChorusMessageCommandId, LowPassFilterMessageCommandId } from "./typings";
|
package/lib/dist/typings.d.ts
CHANGED
|
@@ -51,26 +51,23 @@ export declare enum ProcessorIdentificationCodes {
|
|
|
51
51
|
UnknownProcessorName = "UNKNOWN_PROCESSOR_NAME",
|
|
52
52
|
UnknownProcessorCreationDate = "UNKNOWN_PROCESSOR_CREATION_DATE"
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export declare enum StrictMode {
|
|
55
|
+
Disabled = 0,
|
|
56
|
+
Enabled = 1
|
|
57
|
+
}
|
|
58
|
+
export interface DspDebuggerOptions {
|
|
55
59
|
breakOnError: boolean;
|
|
56
60
|
showInfo: boolean;
|
|
57
61
|
showErrors: boolean;
|
|
58
62
|
showWarnings: boolean;
|
|
59
63
|
}
|
|
60
|
-
export interface
|
|
64
|
+
export interface DspOptions {
|
|
61
65
|
maxMasterChannels: number;
|
|
62
66
|
maxTotalChannels: number;
|
|
63
67
|
sampleRate: number;
|
|
64
68
|
spatialization: ChannelSpatialization;
|
|
65
|
-
debugger:
|
|
66
|
-
|
|
67
|
-
export interface FluexGLAudioDescriptor {
|
|
68
|
-
name: string;
|
|
69
|
-
author: string;
|
|
70
|
-
version: string;
|
|
71
|
-
license: string;
|
|
72
|
-
repository: string;
|
|
73
|
-
options: FluexGLAudioOptions;
|
|
69
|
+
debugger: DspDebuggerOptions;
|
|
70
|
+
overrideMaxAudioBufferNodes: boolean;
|
|
74
71
|
}
|
|
75
72
|
export interface LoadAudioSourceOptions {
|
|
76
73
|
allowForeignFileTypes: boolean;
|
|
@@ -99,6 +96,7 @@ export interface AudioClipEventMap {
|
|
|
99
96
|
export interface DspPipelineInitializationOptions {
|
|
100
97
|
pathToWasm: string;
|
|
101
98
|
pathToWorklet: string;
|
|
99
|
+
options?: Partial<DspOptions>;
|
|
102
100
|
}
|
|
103
101
|
export interface DspPipelineInitializationState {
|
|
104
102
|
success: boolean;
|
|
@@ -110,19 +108,23 @@ export interface ChorusEffectOptions {
|
|
|
110
108
|
rateHz: number;
|
|
111
109
|
mix: number;
|
|
112
110
|
feedback: number;
|
|
111
|
+
strictMode: StrictMode;
|
|
113
112
|
}
|
|
114
113
|
export interface LowPassFilterOptions {
|
|
115
114
|
cutoff: number;
|
|
116
115
|
minFrequency: number;
|
|
117
116
|
q: number;
|
|
117
|
+
strictMode: StrictMode;
|
|
118
118
|
}
|
|
119
119
|
export interface SoftClipOptions {
|
|
120
120
|
drive: number;
|
|
121
121
|
gain: number;
|
|
122
|
+
strictMode: StrictMode;
|
|
122
123
|
}
|
|
123
124
|
export interface HardClipOptions {
|
|
124
125
|
drive: number;
|
|
125
126
|
gain: number;
|
|
127
|
+
strictMode: StrictMode;
|
|
126
128
|
}
|
|
127
129
|
export interface EffectorEventMap {
|
|
128
130
|
"incoming-processor-message": (message: IncomingProcessorMessage) => void;
|
|
@@ -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,eAAe,IAAA;IACf,IAAI,IAAA;CACP;AAED,oBAAY,sBAAsB;IAC9B,cAAc,IAAA;IACd,UAAU,IAAA;IACV,SAAS,IAAA;IACT,MAAM,IAAA;IACN,WAAW,IAAA;CACd;AAED,oBAAY,wBAAwB;IAChC,QAAQ,IAAA;IACR,OAAO,IAAA;CACV;AAED,oBAAY,wBAAwB;IAChC,QAAQ,IAAA;IACR,OAAO,IAAA;CACV;AAED,oBAAY,0BAA0B;IAClC,UAAU,wBAAwB;IAClC,mBAAmB,iCAAiC;IACpD,aAAa,2BAA2B;IACxC,SAAS,uBAAuB;IAChC,aAAa,2BAA2B;IACxC,WAAW,yBAAyB;IACpC,aAAa,2BAA2B;IACxC,cAAc,4BAA4B;IAC1C,cAAc,4BAA4B;IAC1C,WAAW,yBAAyB;IACpC,MAAM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AAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACxE,mCAAmC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACjF,6BAA6B,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;CAC9E;AAED,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,GAAG,4BAA4B,CAAC,kBAAkB,CAAC;IAC7D,IAAI,EAAE,MAAM,GAAG,4BAA4B,CAAC,oBAAoB,CAAC;IACjE,SAAS,EAAE,MAAM,GAAG,4BAA4B,CAAC,4BAA4B,CAAC;CACjF;AAED,MAAM,WAAW,wBAAwB;IACrC,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"}
|
package/lib/dist/typings.js
CHANGED
|
@@ -47,3 +47,8 @@ export var ProcessorIdentificationCodes;
|
|
|
47
47
|
ProcessorIdentificationCodes["UnknownProcessorName"] = "UNKNOWN_PROCESSOR_NAME";
|
|
48
48
|
ProcessorIdentificationCodes["UnknownProcessorCreationDate"] = "UNKNOWN_PROCESSOR_CREATION_DATE";
|
|
49
49
|
})(ProcessorIdentificationCodes || (ProcessorIdentificationCodes = {}));
|
|
50
|
+
export var StrictMode;
|
|
51
|
+
(function (StrictMode) {
|
|
52
|
+
StrictMode[StrictMode["Disabled"] = 0] = "Disabled";
|
|
53
|
+
StrictMode[StrictMode["Enabled"] = 1] = "Enabled";
|
|
54
|
+
})(StrictMode || (StrictMode = {}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DSP } from "../index";
|
|
2
2
|
export var Debug;
|
|
3
3
|
(function (Debug) {
|
|
4
4
|
function Log(message, additionalDetails) {
|
|
5
|
-
if (!
|
|
5
|
+
if (!DSP.debugger.showInfo)
|
|
6
6
|
return;
|
|
7
7
|
let outputString = `%c[INFO]: %c${message} %c`;
|
|
8
8
|
additionalDetails && additionalDetails.forEach(function (detail) {
|
|
@@ -12,7 +12,7 @@ export var Debug;
|
|
|
12
12
|
}
|
|
13
13
|
Debug.Log = Log;
|
|
14
14
|
function Success(message, additionalDetails) {
|
|
15
|
-
if (!
|
|
15
|
+
if (!DSP.debugger.showInfo)
|
|
16
16
|
return;
|
|
17
17
|
let outputString = `%c[SUCCESS]: %c${message} %c`;
|
|
18
18
|
additionalDetails && additionalDetails.forEach(function (detail) {
|
|
@@ -22,7 +22,7 @@ export var Debug;
|
|
|
22
22
|
}
|
|
23
23
|
Debug.Success = Success;
|
|
24
24
|
function Warn(message, additionalDetails, warningCode) {
|
|
25
|
-
if (!
|
|
25
|
+
if (!DSP.debugger.showWarnings)
|
|
26
26
|
return;
|
|
27
27
|
let outputString = `%c(${warningCode ? warningCode : "Unknown".toUpperCase()}) %c[WARNING]: %c${message} %c`;
|
|
28
28
|
(additionalDetails && additionalDetails !== null) && additionalDetails.forEach(function (detail) {
|
|
@@ -32,14 +32,14 @@ export var Debug;
|
|
|
32
32
|
}
|
|
33
33
|
Debug.Warn = Warn;
|
|
34
34
|
function Error(message, additionalDetails, errorCode) {
|
|
35
|
-
if (!
|
|
35
|
+
if (!DSP.debugger.showErrors)
|
|
36
36
|
return;
|
|
37
37
|
let outputString = `%c(${errorCode ? errorCode : "Unknown".toUpperCase()}) %c[ERROR]: %c${message} %c`;
|
|
38
38
|
(additionalDetails && additionalDetails !== null) && additionalDetails.forEach(function (detail) {
|
|
39
39
|
outputString += `\n\u0009 > ${detail}`;
|
|
40
40
|
});
|
|
41
41
|
console.log(outputString, "color: red", "color: red;", "color: white", "color: white; font-style: italic;");
|
|
42
|
-
if (
|
|
42
|
+
if (DSP.debugger.breakOnError) {
|
|
43
43
|
for (let char of message)
|
|
44
44
|
outputString = outputString.replace("%c", "");
|
|
45
45
|
throw new window.Error(outputString);
|
|
@@ -42,5 +42,7 @@ export declare function LoadAudioSourceFromBlob(blob: Blob): Promise<AudioSource
|
|
|
42
42
|
export declare function ConstructProcessorWorklet(code: string): string;
|
|
43
43
|
export declare function LoadWorkletOnAudioDevice(audioDevice: AudioDevice, workletBlobUrl: string): Promise<boolean>;
|
|
44
44
|
export declare function SendMessageToWorklet<T, K = any>(node: AudioWorkletNode | null, commandId: T, data: K): boolean;
|
|
45
|
+
export declare function IsFiniteNumber(value: unknown): value is number;
|
|
46
|
+
export declare function CoerceFiniteNumber(value: unknown, fallback: number): number;
|
|
45
47
|
export declare function CreateAudioWorkletNode<T = any>(context: AudioContext, name: AudioWorkletProcessorNames | string, data: T): AudioWorkletNode | null;
|
|
46
48
|
//# 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;AAS1D,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEnK;;;;;;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,G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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,wBAAwB,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAgB9F;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,WAepG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,0BAA0B,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,2BA8BxH"}
|
|
@@ -161,26 +161,49 @@ export async function LoadWorkletOnAudioDevice(audioDevice, workletBlobUrl) {
|
|
|
161
161
|
export function SendMessageToWorklet(node, commandId, data) {
|
|
162
162
|
if (!node)
|
|
163
163
|
return false;
|
|
164
|
+
if (typeof data === "number" && !Number.isFinite(data)) {
|
|
165
|
+
Debug.Warn("Refusing to send non-finite numeric value to AudioWorkletNode.", [
|
|
166
|
+
`Command: ${String(commandId)}`,
|
|
167
|
+
`Value: ${String(data)}`
|
|
168
|
+
]);
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
164
171
|
node.port.postMessage({ commandId, data });
|
|
165
172
|
return true;
|
|
166
173
|
}
|
|
174
|
+
export function IsFiniteNumber(value) {
|
|
175
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
176
|
+
}
|
|
177
|
+
export function CoerceFiniteNumber(value, fallback) {
|
|
178
|
+
return IsFiniteNumber(value) ? value : fallback;
|
|
179
|
+
}
|
|
167
180
|
export function CreateAudioWorkletNode(context, name, data) {
|
|
168
181
|
if (!compiledWebAssemblyModule) {
|
|
169
182
|
Debug.Error("Failed to create audio worklet node, because the web assembly module has not been compiled properly.", [
|
|
170
183
|
`Request audio worklet node: ${name}.`
|
|
184
|
+
], ErrorCodes.WORKLET_NO_WASM_MODULE_INSTANTIATED);
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return new AudioWorkletNode(context, name, {
|
|
189
|
+
numberOfInputs: 1,
|
|
190
|
+
numberOfOutputs: 1,
|
|
191
|
+
outputChannelCount: [2],
|
|
192
|
+
parameterData: {
|
|
193
|
+
...data,
|
|
194
|
+
sampleRate: context.sampleRate
|
|
195
|
+
},
|
|
196
|
+
processorOptions: {
|
|
197
|
+
module: compiledWebAssemblyModule
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
Debug.Error("Failed to create audio worklet node.", [
|
|
203
|
+
`Request audio worklet node: ${name}.`,
|
|
204
|
+
"Make sure you called InitializeDspPipeline/InitializeDpsPipeline and loaded the worklet module on the same AudioContext.",
|
|
205
|
+
String(err)
|
|
171
206
|
]);
|
|
172
207
|
return null;
|
|
173
208
|
}
|
|
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
209
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-assembly.d.ts","sourceRoot":"","sources":["../../src/utilities/web-assembly.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-assembly.d.ts","sourceRoot":"","sources":["../../src/utilities/web-assembly.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,kBAAkB,EAAE,OAAe,CAAC;AAC/C,eAAO,IAAI,yBAAyB,EAAE,WAAW,CAAC,MAAM,GAAG,IAAW,CAAC;AAEvE,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAcrF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Debug } from "./debugger";
|
|
2
|
+
import { ErrorCodes } from "../console-codes";
|
|
1
3
|
export let hasInitializedWasm = false;
|
|
2
4
|
export let compiledWebAssemblyModule = null;
|
|
3
5
|
export async function LoadWebAssemblyModule(path) {
|
|
@@ -6,6 +8,10 @@ export async function LoadWebAssemblyModule(path) {
|
|
|
6
8
|
compiledWebAssemblyModule = module;
|
|
7
9
|
resolve(module);
|
|
8
10
|
}).catch(function (error) {
|
|
11
|
+
Debug.Error("Failed to load WebAssembly module from path: " + path, [
|
|
12
|
+
"Make sure the path is correct and the server is serving the .wasm file with the correct MIME type (application/wasm).",
|
|
13
|
+
"Error details: " + error.message
|
|
14
|
+
], ErrorCodes.WASM_COMPILATION_ERROR);
|
|
9
15
|
reject(error);
|
|
10
16
|
});
|
|
11
17
|
});
|
package/lib/src/console-codes.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
export enum ErrorCodes {
|
|
2
|
-
NO_CONTEXT_PERMISSION = "FLUEXGL@
|
|
3
|
-
NO_FILE_TYPE_FOUND = "FLUEXGL@
|
|
4
|
-
PATH_TO_FILE_NOT_FOUND = "FLUEXGL@
|
|
5
|
-
SAME_MASTER_CHANNEL = "FLUEXGL@
|
|
6
|
-
WASM_MODULE_INITIALIZATION_FAILED = "FLUEXGL@
|
|
7
|
-
PATH_TO_WASM_FILE_NOT_FOUND = "FLUEXGL@
|
|
2
|
+
NO_CONTEXT_PERMISSION = "ERROR:FLUEXGL-DSP@0001",
|
|
3
|
+
NO_FILE_TYPE_FOUND = "ERROR:FLUEXGL-DSP@0002",
|
|
4
|
+
PATH_TO_FILE_NOT_FOUND = "ERROR:FLUEXGL-DSP@0003",
|
|
5
|
+
SAME_MASTER_CHANNEL = "ERROR:FLUEXGL-DSP@0004",
|
|
6
|
+
WASM_MODULE_INITIALIZATION_FAILED = "ERROR:FLUEXGL-DSP@0005",
|
|
7
|
+
PATH_TO_WASM_FILE_NOT_FOUND = "ERROR:FLUEXGL-DSP@0006",
|
|
8
|
+
WASM_COMPILATION_ERROR = "ERROR:FLUEXGL-DSP@0007",
|
|
9
|
+
WORKLET_NO_WASM_MODULE_INSTANTIATED = "ERROR:FLUEXGL-DSP@0008",
|
|
10
|
+
EFFECT_ALREADY_ATTACHED = "ERROR:FLUEXGL-DSP@0009",
|
|
11
|
+
EFFECT_NOT_FOUND = "ERROR:FLUEXGL-DSP@0010",
|
|
12
|
+
CHANNEL_ALREADY_ATTACHED = "ERROR:FLUEXGL-DSP@0011",
|
|
13
|
+
CHANNEL_NOT_FOUND = "ERROR:FLUEXGL-DSP@0012",
|
|
14
|
+
CHANNEL_CANNOT_LINK_TO_ITSELF = "ERROR:FLUEXGL-DSP@0013",
|
|
15
|
+
CHANNEL_NOT_INITIALIZED = "ERROR:FLUEXGL-DSP@0014",
|
|
16
|
+
CHANNEL_NOT_SAME_AUDIO_CONTEXT = "ERROR:FLUEXGL-DSP@0015",
|
|
17
|
+
CHANNEL_ALREADY_LINKED = "ERROR:FLUEXGL-DSP@0016",
|
|
18
|
+
CHANNEL_POSSIBLE_FEEDBACK_LOOP = "ERROR:FLUEXGL-DSP@0017",
|
|
19
|
+
AUDIO_CLIP_ALREADY_ATTACHED = "ERROR:FLUEXGL-DSP@0018",
|
|
20
|
+
AUDIO_CLIP_NOT_FOUND = "ERROR:FLUEXGL-DSP@0019",
|
|
21
|
+
AUDIO_CLIP_PLAYER_NO_CONTEXT = "ERROR:FLUEXGL-DSP@0020",
|
|
22
|
+
PANNING_OUT_OF_RANGE = "ERROR:FLUEXGL-DSP@0021"
|
|
8
23
|
}
|
|
9
24
|
|
|
10
25
|
export enum WarningCodes {
|
|
11
|
-
NO_DEFAULT_AUDIO_DEVICE_FOUND = "FLUEXGL@
|
|
26
|
+
NO_DEFAULT_AUDIO_DEVICE_FOUND = "WARNING:FLUEXGL-DSP@0001"
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
export enum SuccessCodes {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { v4 } from "uuid";
|
|
2
2
|
import { format } from "date-fns";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { AudioClipEventMap, AudioClipEvents, AudioSourceData } from "../../typings";
|
|
5
5
|
import { Debug } from "../../utilities/debugger";
|
|
6
6
|
import { Channel } from "./Channel";
|
|
7
7
|
import { AudioClipPlayer } from "./AudioClipPlayer";
|
|
8
|
+
import { Master } from "./Master";
|
|
9
|
+
import { DSP } from "../../index";
|
|
10
|
+
import { ErrorCodes } from "lib/src/console-codes";
|
|
8
11
|
|
|
9
12
|
type ProgressPayload = Parameters<AudioClipEventMap["progress"]>[0];
|
|
10
13
|
|
|
@@ -85,7 +88,7 @@ export class AudioClip {
|
|
|
85
88
|
if (!audioClipPlayer.context) return Debug.Error("Could not initialize AudioClip, because the AudioClipPlayer somehow has no audio context.", [
|
|
86
89
|
`AudioClipPlayer id: ${audioClipPlayer.id}`,
|
|
87
90
|
`AudioClip id: ${this.id}`
|
|
88
|
-
]);
|
|
91
|
+
], ErrorCodes.AUDIO_CLIP_PLAYER_NO_CONTEXT);
|
|
89
92
|
|
|
90
93
|
this.audioClipPlayer = audioClipPlayer;
|
|
91
94
|
this.context = audioClipPlayer.context;
|
|
@@ -207,11 +210,7 @@ export class AudioClip {
|
|
|
207
210
|
|
|
208
211
|
if (!this.context) Debug.Error("Could not set volume because the context (AudioContext) of this AudioClip is undefined.", [
|
|
209
212
|
"Make sure to attach this AudioClip to an AudioClipPlayer instance before calling .SetVolume() on this AudioClip.",
|
|
210
|
-
]);
|
|
211
|
-
|
|
212
|
-
if (!this.gainNode) Debug.Error("Could not set volume because the gainNode (GainNode) of this AudioClip is undefined.", [
|
|
213
|
-
"Make sure to attach this AudioClip to an AudioClipPlayer instance before calling .SetVolume() on this AudioClip.",
|
|
214
|
-
]);
|
|
213
|
+
], ErrorCodes.AUDIO_CLIP_PLAYER_NO_CONTEXT);
|
|
215
214
|
|
|
216
215
|
this.gainNode?.gain.setValueAtTime(volume, this.context?.currentTime ?? 0);
|
|
217
216
|
return this;
|
|
@@ -221,16 +220,12 @@ export class AudioClip {
|
|
|
221
220
|
|
|
222
221
|
if (!this.context) Debug.Error("Could not set volume because the context (AudioContext) of this AudioClip is undefined.", [
|
|
223
222
|
"Make sure to attach this AudioClip to an AudioClipPlayer instance before calling .SetPanLevel() on this AudioClip.",
|
|
224
|
-
]);
|
|
225
|
-
|
|
226
|
-
if (!this.stereoPannerNode) Debug.Error("Could not set volume because the stereoPannerNode (StereoPannerNode) of this AudioClip is undefined.", [
|
|
227
|
-
"Make sure to attach this AudioClip to an AudioClipPlayer instance before calling .SetPanLevel() on this AudioClip.",
|
|
228
|
-
]);
|
|
223
|
+
], ErrorCodes.AUDIO_CLIP_PLAYER_NO_CONTEXT);
|
|
229
224
|
|
|
230
225
|
if (panLevel < -1 || panLevel > 1) Debug.Error("Could not set the pan level because it is not between -1 and 1.", [
|
|
231
226
|
`Given value: ${panLevel}.`,
|
|
232
227
|
`Accepts a value between -1 and 1. Can be a floating number.`
|
|
233
|
-
]);
|
|
228
|
+
], ErrorCodes.PANNING_OUT_OF_RANGE);
|
|
234
229
|
|
|
235
230
|
this.stereoPannerNode?.pan.setValueAtTime(panLevel, this.context?.currentTime ?? 0);
|
|
236
231
|
return this;
|
|
@@ -248,9 +243,12 @@ export class AudioClip {
|
|
|
248
243
|
|
|
249
244
|
public SetMaxAudioBufferSourceNodes(value: number): AudioClip {
|
|
250
245
|
|
|
251
|
-
|
|
252
|
-
"
|
|
253
|
-
|
|
246
|
+
if (!DSP.overrideMaxAudioBufferNodes) {
|
|
247
|
+
Debug.Warn("Cannot set maxAudioBufferSourceNodes because the option to override the current maximum value is disabled.", [
|
|
248
|
+
"Set overrideMaxAudioBufferNodes on DSP to true, in order to override the maximum audio buffer source nodes."
|
|
249
|
+
]);
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
254
252
|
|
|
255
253
|
this.maxAudioBufferSourceNodes = value;
|
|
256
254
|
return this;
|
|
@@ -316,15 +314,26 @@ export class AudioClip {
|
|
|
316
314
|
return this.data.audioBuffer.getChannelData(channel);
|
|
317
315
|
}
|
|
318
316
|
|
|
319
|
-
public Send(channel: Channel) {
|
|
317
|
+
public Send(channel: Channel | Master) {
|
|
318
|
+
|
|
319
|
+
if (!channel.audioClipPlayer) return Debug.Error("Could not send AudioClip signal to channel, because the channel's AudioClipPlayer is undefined.", [
|
|
320
|
+
"Make sure to initialize the Channel.",
|
|
321
|
+
`Channel id: ${channel.id}.`,
|
|
322
|
+
`AudioClip id: ${this.id}.`
|
|
323
|
+
]);
|
|
324
|
+
|
|
325
|
+
channel.audioClipPlayer.AttachAudioClip(this);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public Unsend(channel: Channel | Master) {
|
|
320
329
|
|
|
321
|
-
if(!channel.
|
|
330
|
+
if (!channel.audioClipPlayer) return Debug.Error("Could not unsend AudioClip signal to channel, because the channel's AudioClipPlayer is undefined.", [
|
|
322
331
|
"Make sure to initialize the Channel.",
|
|
323
332
|
`Channel id: ${channel.id}.`,
|
|
324
333
|
`AudioClip id: ${this.id}.`
|
|
325
334
|
]);
|
|
326
335
|
|
|
327
|
-
channel.
|
|
336
|
+
channel.audioClipPlayer.DetachAudioClip(this);
|
|
328
337
|
}
|
|
329
338
|
|
|
330
339
|
public get currentPlaybackTime(): number {
|