@fluex/fluexgl-dsp 0.1.2 → 0.2.1
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/core/classes/AudioClip.d.ts +5 -4
- package/lib/dist/core/classes/AudioClip.d.ts.map +1 -1
- package/lib/dist/core/classes/AudioClip.js +2 -6
- package/lib/dist/core/classes/Channel.d.ts +12 -0
- package/lib/dist/core/classes/Channel.d.ts.map +1 -1
- package/lib/dist/core/classes/Channel.js +68 -2
- package/lib/dist/core/classes/Effector.d.ts +1 -0
- package/lib/dist/core/classes/Effector.d.ts.map +1 -1
- package/lib/dist/core/classes/Effector.js +1 -0
- package/lib/dist/effects/classes/Chorus.d.ts +2 -0
- package/lib/dist/effects/classes/Chorus.d.ts.map +1 -1
- package/lib/dist/effects/classes/Chorus.js +2 -0
- package/lib/dist/effects/classes/Distortion.d.ts +5 -1
- package/lib/dist/effects/classes/Distortion.d.ts.map +1 -1
- package/lib/dist/effects/classes/Distortion.js +8 -1
- package/lib/dist/effects/classes/Saturation.d.ts.map +1 -1
- package/lib/dist/effects/classes/SoftClip.d.ts +2 -0
- package/lib/dist/effects/classes/SoftClip.d.ts.map +1 -1
- package/lib/dist/effects/classes/SoftClip.js +2 -0
- package/lib/dist/effects/classes/StereoPanner.d.ts +1 -0
- package/lib/dist/effects/classes/StereoPanner.d.ts.map +1 -1
- package/lib/dist/effects/classes/StereoPanner.js +1 -0
- package/lib/dist/index.d.ts +1 -1
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +1 -1
- package/lib/dist/utilities/helpers.d.ts +4 -0
- package/lib/dist/utilities/helpers.d.ts.map +1 -1
- package/lib/dist/utilities/helpers.js +12 -0
- package/lib/dist/utilities/web-assembly.d.ts.map +1 -1
- package/lib/src/console-codes.ts +15 -15
- package/lib/src/core/classes/AudioClip.ts +539 -544
- package/lib/src/core/classes/AudioDevice.ts +38 -38
- package/lib/src/core/classes/Channel.ts +288 -198
- package/lib/src/core/classes/DpsPipeline.ts +152 -152
- package/lib/src/core/classes/Effector.ts +11 -10
- package/lib/src/core/classes/Master.ts +49 -49
- package/lib/src/core/exports.ts +5 -5
- package/lib/src/effects/classes/Chorus.ts +111 -108
- package/lib/src/effects/classes/Distortion.ts +14 -1
- package/lib/src/effects/classes/Saturation.ts +3 -1
- package/lib/src/effects/classes/SoftClip.ts +44 -41
- package/lib/src/effects/classes/StereoPanner.ts +3 -1
- package/lib/src/effects/exports.ts +22 -22
- package/lib/src/index.ts +93 -92
- package/lib/src/typings.ts +78 -78
- package/lib/src/utilities/constants.ts +8 -8
- package/lib/src/utilities/debugger.ts +65 -65
- package/lib/src/utilities/helpers.ts +237 -215
- package/lib/src/utilities/web-assembly.ts +12 -13
- package/package.json +51 -50
package/README.md
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
# 🎚️ FluexGL DSP
|
|
2
|
-
An open-source, web-based DSP library developed alongside FluexGL, with the purpose of creating and manipulating sound in various contexts.
|
|
3
|
-
|
|
4
|
-
This open-source project is part of the Fluex ecosystem and is maintained by Rohan Kanhaisingh, the lead developer of this library.
|
|
5
|
-
|
|
6
|
-
**Note: this project is still under development and may not work yet.**
|
|
7
|
-
|
|
8
|
-
## 🧩 About
|
|
9
|
-
FluexGL DSP is a modern, TypeScript-based Web Audio library for creating and manipulating sound. Inspired by and based on DAW-style workflows, it provides a flexible, object-oriented channel system with master and sub channels.
|
|
10
|
-
|
|
11
|
-
It integrates smoothly with FluexGL, making it ideal for use in games, interactive web experiences, and multimedia projects.
|
|
12
|
-
|
|
13
|
-
## 📦 Installation
|
|
14
|
-
|
|
15
|
-
See down below for more details.
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
$ npm
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## ⚡ Quick start
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
import {
|
|
25
|
-
AudioDevice,
|
|
26
|
-
InitializeDspPipeline,
|
|
27
|
-
LoadAudioSource,
|
|
28
|
-
ResolveDefaultAudioOutputDevice,
|
|
29
|
-
Channel,
|
|
30
|
-
AudioSourceData,
|
|
31
|
-
AudioClip
|
|
32
|
-
} from "@fluexgl/dsp";
|
|
33
|
-
|
|
34
|
-
(async function() {
|
|
35
|
-
|
|
36
|
-
// Make sure that FluexGL can access audio devices.
|
|
37
|
-
const hasInitialized = await InitializeDspPipeline();
|
|
38
|
-
|
|
39
|
-
if(!hasInitialized) return null;
|
|
40
|
-
|
|
41
|
-
// Resolves the default audio output device.
|
|
42
|
-
const audioDevice: AudioDevice | null = await ResolveDefaultAudioOutputDevice({
|
|
43
|
-
pathToWasm: "/wasm/fluexgl-dsp-wasm_bg.wasm"
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if(!audioDevice) return;
|
|
47
|
-
|
|
48
|
-
// Get the master channel from the default audio output device.
|
|
49
|
-
const masterChannel = audioDevice.GetMasterChannel();
|
|
50
|
-
|
|
51
|
-
// Create a new empty channel.
|
|
52
|
-
const channel = new Channel();
|
|
53
|
-
|
|
54
|
-
// Label the channel as 'BackgroundMusic'.
|
|
55
|
-
channel.SetLabel("BackgroundMusic");
|
|
56
|
-
|
|
57
|
-
// Attach the 'BackgroundMusic' channel, to the device's master channel.
|
|
58
|
-
masterChannel.AttachChannel(channel);
|
|
59
|
-
|
|
60
|
-
// Load the data from the audio source.
|
|
61
|
-
const audioSourceData: AudioSourceData | null = await LoadAudioSource("/assets/data/bruh.mp3");
|
|
62
|
-
|
|
63
|
-
if(!audioSourceData) return;
|
|
64
|
-
|
|
65
|
-
// Create a audio node based on the data.
|
|
66
|
-
const audioClip = new AudioClip(audioSourceData);
|
|
67
|
-
|
|
68
|
-
// Attach the audio node to the channel.
|
|
69
|
-
channel.AttachAudioClip(audioClip);
|
|
70
|
-
|
|
71
|
-
// Click event listener on window.
|
|
72
|
-
window.addEventListener("click", function() {
|
|
73
|
-
|
|
74
|
-
// Play the audio clip
|
|
75
|
-
audioClip.Play();
|
|
76
|
-
});
|
|
77
|
-
})();
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## 💡 Effects, tools and more
|
|
81
|
-
FluexGL DSP provides built-in such as effects, tools, and utilities for advanced web audio processing, such as reverbs, delays, and stereo imaging effects.
|
|
82
|
-
|
|
83
|
-
The library also includes a powerful debugging system that allows developers to inspect and analyze the audio pipeline for easier troubleshooting and optimization.
|
|
84
|
-
|
|
85
|
-
## Web Assembly
|
|
86
|
-
|
|
1
|
+
# 🎚️ FluexGL DSP
|
|
2
|
+
An open-source, web-based DSP library developed alongside FluexGL, with the purpose of creating and manipulating sound in various contexts.
|
|
3
|
+
|
|
4
|
+
This open-source project is part of the Fluex ecosystem and is maintained by Rohan Kanhaisingh, the lead developer of this library.
|
|
5
|
+
|
|
6
|
+
**Note: this project is still under development and may not work yet.**
|
|
7
|
+
|
|
8
|
+
## 🧩 About
|
|
9
|
+
FluexGL DSP is a modern, TypeScript-based Web Audio library for creating and manipulating sound. Inspired by and based on DAW-style workflows, it provides a flexible, object-oriented channel system with master and sub channels.
|
|
10
|
+
|
|
11
|
+
It integrates smoothly with FluexGL, making it ideal for use in games, interactive web experiences, and multimedia projects.
|
|
12
|
+
|
|
13
|
+
## 📦 Installation
|
|
14
|
+
|
|
15
|
+
See down below for more details.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ npm i @fluex/fluexgl-dsp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## ⚡ Quick start
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
AudioDevice,
|
|
26
|
+
InitializeDspPipeline,
|
|
27
|
+
LoadAudioSource,
|
|
28
|
+
ResolveDefaultAudioOutputDevice,
|
|
29
|
+
Channel,
|
|
30
|
+
AudioSourceData,
|
|
31
|
+
AudioClip
|
|
32
|
+
} from "@fluexgl/dsp";
|
|
33
|
+
|
|
34
|
+
(async function() {
|
|
35
|
+
|
|
36
|
+
// Make sure that FluexGL can access audio devices.
|
|
37
|
+
const hasInitialized = await InitializeDspPipeline();
|
|
38
|
+
|
|
39
|
+
if(!hasInitialized) return null;
|
|
40
|
+
|
|
41
|
+
// Resolves the default audio output device.
|
|
42
|
+
const audioDevice: AudioDevice | null = await ResolveDefaultAudioOutputDevice({
|
|
43
|
+
pathToWasm: "/wasm/fluexgl-dsp-wasm_bg.wasm"
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if(!audioDevice) return;
|
|
47
|
+
|
|
48
|
+
// Get the master channel from the default audio output device.
|
|
49
|
+
const masterChannel = audioDevice.GetMasterChannel();
|
|
50
|
+
|
|
51
|
+
// Create a new empty channel.
|
|
52
|
+
const channel = new Channel();
|
|
53
|
+
|
|
54
|
+
// Label the channel as 'BackgroundMusic'.
|
|
55
|
+
channel.SetLabel("BackgroundMusic");
|
|
56
|
+
|
|
57
|
+
// Attach the 'BackgroundMusic' channel, to the device's master channel.
|
|
58
|
+
masterChannel.AttachChannel(channel);
|
|
59
|
+
|
|
60
|
+
// Load the data from the audio source.
|
|
61
|
+
const audioSourceData: AudioSourceData | null = await LoadAudioSource("/assets/data/bruh.mp3");
|
|
62
|
+
|
|
63
|
+
if(!audioSourceData) return;
|
|
64
|
+
|
|
65
|
+
// Create a audio node based on the data.
|
|
66
|
+
const audioClip = new AudioClip(audioSourceData);
|
|
67
|
+
|
|
68
|
+
// Attach the audio node to the channel.
|
|
69
|
+
channel.AttachAudioClip(audioClip);
|
|
70
|
+
|
|
71
|
+
// Click event listener on window.
|
|
72
|
+
window.addEventListener("click", function() {
|
|
73
|
+
|
|
74
|
+
// Play the audio clip
|
|
75
|
+
audioClip.Play();
|
|
76
|
+
});
|
|
77
|
+
})();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 💡 Effects, tools and more
|
|
81
|
+
FluexGL DSP provides built-in such as effects, tools, and utilities for advanced web audio processing, such as reverbs, delays, and stereo imaging effects.
|
|
82
|
+
|
|
83
|
+
The library also includes a powerful debugging system that allows developers to inspect and analyze the audio pipeline for easier troubleshooting and optimization.
|
|
84
|
+
|
|
85
|
+
## Web Assembly
|
|
86
|
+
|
|
87
87
|
FluexGL DSP is partially made using Web Assembly, and Rust as programming language. In order to use FluexGL DSP, the wasm source code must be provided when initializing the DSP pipeline. The source code can be found at the [FluexGL DSP WebAssembly Github repository](https://github.com/rohankanhaisingh/FluexGL-DSP-WebAssembly).
|
|
@@ -4,6 +4,7 @@ export declare class AudioClip {
|
|
|
4
4
|
data: AudioSourceData;
|
|
5
5
|
id: string;
|
|
6
6
|
hasAttachedToChannel: boolean;
|
|
7
|
+
label: string | null;
|
|
7
8
|
loop: boolean;
|
|
8
9
|
isPlaying: boolean;
|
|
9
10
|
startTime: number;
|
|
@@ -19,10 +20,10 @@ export declare class AudioClip {
|
|
|
19
20
|
postAnalyserEnabled: boolean;
|
|
20
21
|
preAnalyserOptions: AnalyserOptions;
|
|
21
22
|
postAnalyserOptions: AnalyserOptions;
|
|
22
|
-
preAnalyserFloatArrayBuffer: Float32Array
|
|
23
|
-
postAnalyserFloatArrayBuffer: Float32Array
|
|
24
|
-
preAnalyserByteArrayBuffer: Uint8Array
|
|
25
|
-
postAnalyserByteArrayBuffer: Uint8Array
|
|
23
|
+
preAnalyserFloatArrayBuffer: Float32Array<ArrayBuffer>;
|
|
24
|
+
postAnalyserFloatArrayBuffer: Float32Array<ArrayBuffer>;
|
|
25
|
+
preAnalyserByteArrayBuffer: Uint8Array<ArrayBuffer>;
|
|
26
|
+
postAnalyserByteArrayBuffer: Uint8Array<ArrayBuffer>;
|
|
26
27
|
private audioBufferSourceNodes;
|
|
27
28
|
private maxAudioBufferSourceNodes;
|
|
28
29
|
private progressInterval;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioClip.d.ts","sourceRoot":"","sources":["../../../src/core/classes/AudioClip.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,iBAAiB,EAAmB,eAAe,EAAE,MAAM,eAAe,CAAC;AAEtI,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"AudioClip.d.ts","sourceRoot":"","sources":["../../../src/core/classes/AudioClip.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,6 +5,7 @@ export class AudioClip {
|
|
|
5
5
|
data;
|
|
6
6
|
id = v4();
|
|
7
7
|
hasAttachedToChannel = false;
|
|
8
|
+
label = null;
|
|
8
9
|
loop = false;
|
|
9
10
|
isPlaying = false;
|
|
10
11
|
startTime = 0;
|
|
@@ -216,13 +217,8 @@ export class AudioClip {
|
|
|
216
217
|
return this;
|
|
217
218
|
}
|
|
218
219
|
DisconnectAllAudioBufferSourceNodes() {
|
|
219
|
-
if (!this.parentialAudioContext)
|
|
220
|
-
Debug.Error("Could not disconnect audio buffer source nodes, because the parential audio contex has not been found", [
|
|
221
|
-
`Clip ID: ${this.id}`,
|
|
222
|
-
`Parential channel id: ${this.parentialChannel ? this.parentialChannel.id : "none"}`
|
|
223
|
-
]);
|
|
220
|
+
if (!this.parentialAudioContext)
|
|
224
221
|
return false;
|
|
225
|
-
}
|
|
226
222
|
const contextCurrentTime = this.parentialAudioContext?.currentTime;
|
|
227
223
|
this.audioBufferSourceNodes.forEach(function (node) {
|
|
228
224
|
node.stop(contextCurrentTime);
|
|
@@ -12,7 +12,12 @@ export declare class Channel {
|
|
|
12
12
|
audioClips: AudioClip[];
|
|
13
13
|
gainNode: GainNode | null;
|
|
14
14
|
stereoPannerNode: StereoPannerNode | null;
|
|
15
|
+
analyserNode: AnalyserNode | null;
|
|
16
|
+
channelSplitterNode: ChannelSplitterNode | null;
|
|
17
|
+
analyserFloatArrayBuffer: Float32Array<ArrayBuffer>;
|
|
18
|
+
analyserByteArrayBuffer: Uint8Array<ArrayBuffer>;
|
|
15
19
|
audioClipsInputGainNode: GainNode | null;
|
|
20
|
+
analyserOptions: AnalyserOptions;
|
|
16
21
|
constructor(options?: Partial<ChannelOptions>);
|
|
17
22
|
private rebuildEffectChain;
|
|
18
23
|
InitializeChannelOnMasterAttachment(master: Master): void;
|
|
@@ -20,10 +25,17 @@ export declare class Channel {
|
|
|
20
25
|
ClearLabel(): void;
|
|
21
26
|
AttachAudioClip(clip: AudioClip): void;
|
|
22
27
|
DetachAudioClip(clip: AudioClip): void;
|
|
28
|
+
HasAudioClip(clip: AudioClip): boolean;
|
|
23
29
|
SetVolume(volume: number): void;
|
|
24
30
|
SetPanLevel(pan: number): void;
|
|
25
31
|
AddEffect(effect: Effector): void;
|
|
32
|
+
AttachEffect(effect: Effector): void;
|
|
26
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;
|
|
27
39
|
get volume(): number | null;
|
|
28
40
|
get panLevel(): number | null;
|
|
29
41
|
}
|
|
@@ -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"}
|
|
@@ -10,7 +10,12 @@ export class Channel {
|
|
|
10
10
|
audioClips = [];
|
|
11
11
|
gainNode = null;
|
|
12
12
|
stereoPannerNode = null;
|
|
13
|
+
analyserNode = null;
|
|
14
|
+
channelSplitterNode = null;
|
|
15
|
+
analyserFloatArrayBuffer = new Float32Array();
|
|
16
|
+
analyserByteArrayBuffer = new Uint8Array();
|
|
13
17
|
audioClipsInputGainNode = null;
|
|
18
|
+
analyserOptions = { fftSize: 32 };
|
|
14
19
|
constructor(options = { maxAudioNodes: 8, maxEffects: 8 }) {
|
|
15
20
|
this.options = options;
|
|
16
21
|
this.label = options.label ?? null;
|
|
@@ -26,7 +31,7 @@ export class Channel {
|
|
|
26
31
|
for (const effect of this.effects) {
|
|
27
32
|
effect.audioWorkletNode?.disconnect();
|
|
28
33
|
}
|
|
29
|
-
const activeEffects = this.effects.filter(e => !!e.audioWorkletNode
|
|
34
|
+
const activeEffects = this.effects.filter(e => !!e.audioWorkletNode);
|
|
30
35
|
if (activeEffects.length === 0) {
|
|
31
36
|
this.audioClipsInputGainNode.connect(this.gainNode);
|
|
32
37
|
}
|
|
@@ -51,10 +56,14 @@ export class Channel {
|
|
|
51
56
|
this.parentialContext = master.context;
|
|
52
57
|
this.gainNode = new GainNode(this.parentialContext);
|
|
53
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);
|
|
54
62
|
this.audioClipsInputGainNode = new GainNode(this.parentialContext);
|
|
55
63
|
this.audioClipsInputGainNode.connect(this.stereoPannerNode);
|
|
56
64
|
this.stereoPannerNode.connect(this.gainNode);
|
|
57
|
-
this.gainNode.connect(this.
|
|
65
|
+
this.gainNode.connect(this.analyserNode);
|
|
66
|
+
this.analyserNode.connect(this.parentialMasterChannel.gainNode);
|
|
58
67
|
}
|
|
59
68
|
SetLabel(label) {
|
|
60
69
|
this.options.label = label;
|
|
@@ -89,6 +98,13 @@ export class Channel {
|
|
|
89
98
|
return self.audioClips.splice(index, 1);
|
|
90
99
|
});
|
|
91
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
|
+
}
|
|
92
108
|
SetVolume(volume) {
|
|
93
109
|
if (!this.gainNode)
|
|
94
110
|
return Debug.Error("Could not set channel volume because the channel is not attached to a master channel.", [
|
|
@@ -118,6 +134,9 @@ export class Channel {
|
|
|
118
134
|
this.effects.push(effect);
|
|
119
135
|
this.rebuildEffectChain();
|
|
120
136
|
}
|
|
137
|
+
AttachEffect(effect) {
|
|
138
|
+
return this.AddEffect(effect);
|
|
139
|
+
}
|
|
121
140
|
RemoveEffect(effect) {
|
|
122
141
|
if (!this.effects.includes(effect))
|
|
123
142
|
return Debug.Error("Could not remove effect, because it is not part of this channel.", [
|
|
@@ -130,6 +149,53 @@ export class Channel {
|
|
|
130
149
|
});
|
|
131
150
|
this.rebuildEffectChain();
|
|
132
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
|
+
}
|
|
133
199
|
// Public getters and setters
|
|
134
200
|
get volume() {
|
|
135
201
|
if (!this.gainNode)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Effector.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Effector.ts"],"names":[],"mappings":"AAEA,8BAAsB,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAQ;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACjD,gBAAgB,EAAE,YAAY,GAAG,IAAI,CAAQ;aAEpC,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CACxF"}
|
|
1
|
+
{"version":3,"file":"Effector.d.ts","sourceRoot":"","sources":["../../../src/core/classes/Effector.ts"],"names":[],"mappings":"AAEA,8BAAsB,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAQ;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,IAAI,EAAE,MAAM,CAAc;IAC1B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IACjD,gBAAgB,EAAE,YAAY,GAAG,IAAI,CAAQ;aAEpC,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chorus.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Chorus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,WAAW,EAAE,MAAM,CAAM;IACzB,OAAO,EAAE,MAAM,CAAK;IACpB,MAAM,EAAE,MAAM,CAAO;IACrB,GAAG,EAAE,MAAM,CAAO;IAClB,QAAQ,EAAE,MAAM,CAAO;IAEvB,OAAO,EAAE,mBAAmB,CAAM;IAEzC,OAAO,CAAC,UAAU,CAAa;gBAEnB,OAAO,CAAC,EAAE,mBAAmB;IAa5B,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3E,cAAc,CAAC,KAAK,EAAE,MAAM;IAW5B,UAAU,CAAC,KAAK,EAAE,MAAM;IAWxB,SAAS,CAAC,KAAK,EAAE,MAAM;IAWvB,MAAM,CAAC,KAAK,EAAE,MAAM;IAWpB,WAAW,CAAC,KAAK,EAAE,MAAM;CAUnC"}
|
|
1
|
+
{"version":3,"file":"Chorus.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Chorus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,qBAAa,MAAO,SAAQ,QAAQ;IAEzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAY;IAChC,IAAI,EAAE,MAAM,CAAY;IAExB,WAAW,EAAE,MAAM,CAAM;IACzB,OAAO,EAAE,MAAM,CAAK;IACpB,MAAM,EAAE,MAAM,CAAO;IACrB,GAAG,EAAE,MAAM,CAAO;IAClB,QAAQ,EAAE,MAAM,CAAO;IAEvB,OAAO,EAAE,mBAAmB,CAAM;IAEzC,OAAO,CAAC,UAAU,CAAa;gBAEnB,OAAO,CAAC,EAAE,mBAAmB;IAa5B,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3E,cAAc,CAAC,KAAK,EAAE,MAAM;IAW5B,UAAU,CAAC,KAAK,EAAE,MAAM;IAWxB,SAAS,CAAC,KAAK,EAAE,MAAM;IAWvB,MAAM,CAAC,KAAK,EAAE,MAAM;IAWpB,WAAW,CAAC,KAAK,EAAE,MAAM;CAUnC"}
|
|
@@ -2,6 +2,8 @@ import { compiledWebAssemblyModule } from "../../utilities/web-assembly";
|
|
|
2
2
|
import { Effector } from "../../core/classes/Effector";
|
|
3
3
|
import { Debug } from "../../utilities/debugger";
|
|
4
4
|
export class Chorus extends Effector {
|
|
5
|
+
label = "Chorus";
|
|
6
|
+
name = "Chorus";
|
|
5
7
|
baseDelayMs = 15;
|
|
6
8
|
depthMs = 8;
|
|
7
9
|
rateHz = 1.5;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Effector } from "../../core/classes/Effector";
|
|
2
|
+
export declare class Distortion extends Effector {
|
|
3
|
+
name: string;
|
|
4
|
+
constructor();
|
|
5
|
+
InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
|
|
2
6
|
}
|
|
3
7
|
//# sourceMappingURL=Distortion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Distortion.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Distortion.ts"],"names":[],"mappings":"AAAA,qBAAa,
|
|
1
|
+
{"version":3,"file":"Distortion.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Distortion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,qBAAa,UAAW,SAAQ,QAAQ;IAE7B,IAAI,EAAE,MAAM,CAAgB;;IAMtB,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saturation.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Saturation.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"Saturation.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/Saturation.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;CAEtB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Effector } from "../../core/classes/Effector";
|
|
2
2
|
export declare class SoftClip extends Effector {
|
|
3
3
|
drive: number;
|
|
4
|
+
label: string | null;
|
|
5
|
+
name: string;
|
|
4
6
|
constructor(drive?: number);
|
|
5
7
|
InitializeOnAttachment(parentialContext: AudioContext): Promise<void>;
|
|
6
8
|
SetDrive(drive: number): SoftClip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SoftClip.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/SoftClip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGvD,qBAAa,QAAS,SAAQ,QAAQ;
|
|
1
|
+
{"version":3,"file":"SoftClip.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/SoftClip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGvD,qBAAa,QAAS,SAAQ,QAAQ;IAKf,KAAK,EAAE,MAAM;IAHzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAc;IAClC,IAAI,EAAE,MAAM,CAAc;gBAEd,KAAK,GAAE,MAAU;IAIvB,sBAAsB,CAAC,gBAAgB,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB3E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;CAU3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StereoPanner.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/StereoPanner.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"StereoPanner.d.ts","sourceRoot":"","sources":["../../../src/effects/classes/StereoPanner.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IACd,IAAI,EAAE,MAAM,CAAkB;CACxC"}
|
package/lib/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { FluexGLAudioDescriptor } from "./typings";
|
|
|
6
6
|
export declare const FluexGLAudio: FluexGLAudioDescriptor;
|
|
7
7
|
export { Chorus, Distortion, Equalizer, Filter, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip } from "./effects/exports";
|
|
8
8
|
export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline } from "./core/exports";
|
|
9
|
-
export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
|
|
9
|
+
export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
|
|
10
10
|
export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
|
|
11
11
|
export { hasInitializedWasm, } from "./utilities/web-assembly";
|
|
12
12
|
export type { FluexGLAudioDescriptor, FluexGLAudioDebuggerOptions, FluexGLAudioOptions, LoadAudioSourceOptions, AudioSourceData, ChannelOptions, ChannelSpatialization, AudioClipEventMap, AudioClipEvents, AudioClipOnProgressEvent, AudioClipAnalyserProperty, AudioClipAnalyserType, DspPipelineInitializationOptions, DspPipelineInitializationState, ChorusEffectOptions } from "./typings";
|
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,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,YAAY,EAAE,sBAkB1B,CAAA;AAED,OAAO,EACH,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,0BAA0B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACR,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAC9B,mBAAmB,EACtB,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,YAAY,EAAE,sBAkB1B,CAAA;AAED,OAAO,EACH,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,kBAAkB,GACrB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACR,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAC9B,mBAAmB,EACtB,MAAM,WAAW,CAAC"}
|
package/lib/dist/index.js
CHANGED
|
@@ -23,6 +23,6 @@ export const FluexGLAudio = {
|
|
|
23
23
|
};
|
|
24
24
|
export { Chorus, Distortion, Equalizer, Filter, Limiter, Saturation, StereoPanner, Compressor, MultibandCompressor, AdvancedDelay, MonoDelay, PingPongDelay, StereoDelay, ChamberReverb, ConvolverReverb, GenericReverb, HallReverb, RoomReverb, SoftClip } from "./effects/exports";
|
|
25
25
|
export { AudioDevice, Channel, Effector, Master, AudioClip, DspPipeline } from "./core/exports";
|
|
26
|
-
export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
|
|
26
|
+
export { InitializeDspPipeline, ResolveAudioOutputDevices, ResolveAudioInputDevices, ResolveDefaultAudioInputDevice, ResolveDefaultAudioOutputDevice, LoadAudioSource, LoadAudioSourceFromBlob, LoadWorkletOnMasterChannel, } from "./utilities/helpers";
|
|
27
27
|
export { SUPPORTED_FILE_TYPES } from "./utilities/constants";
|
|
28
28
|
export { hasInitializedWasm, } from "./utilities/web-assembly";
|
|
@@ -36,6 +36,10 @@ export declare function ResolveDefaultAudioInputDevice(init: DspPipelineInitiali
|
|
|
36
36
|
* @returns
|
|
37
37
|
*/
|
|
38
38
|
export declare function LoadAudioSource(path: string, options?: Partial<LoadAudioSourceOptions>): Promise<AudioSourceData | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Loads an audio file from a blob.
|
|
41
|
+
*/
|
|
42
|
+
export declare function LoadAudioSourceFromBlob(blob: Blob): Promise<AudioSourceData | null>;
|
|
39
43
|
export declare function ConstructProcessorWorklet(code: string): string;
|
|
40
44
|
export declare function LoadWorkletOnMasterChannel(master: Master, workletBlobUrl: string): Promise<boolean>;
|
|
41
45
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utilities/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utilities/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAahD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAEvI;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAwCrI;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAUxE;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAUvE;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAmBvH;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAmBtH;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAoC,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoChK;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAYzF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9D;AAED,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAgBtF"}
|
|
@@ -130,6 +130,18 @@ export async function LoadAudioSource(path, options = { allowForeignFileTypes: f
|
|
|
130
130
|
timestamp: Date.now()
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Loads an audio file from a blob.
|
|
135
|
+
*/
|
|
136
|
+
export async function LoadAudioSourceFromBlob(blob) {
|
|
137
|
+
const tempContext = new AudioContext(), arrayBuffer = await blob.arrayBuffer();
|
|
138
|
+
const audioBuffer = await tempContext.decodeAudioData(arrayBuffer);
|
|
139
|
+
return {
|
|
140
|
+
id: v4(),
|
|
141
|
+
timestamp: Date.now(),
|
|
142
|
+
audioBuffer, arrayBuffer
|
|
143
|
+
};
|
|
144
|
+
}
|
|
133
145
|
export function ConstructProcessorWorklet(code) {
|
|
134
146
|
const blob = new Blob([code], {
|
|
135
147
|
type: "application/javascript"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-assembly.d.ts","sourceRoot":"","sources":["../../src/utilities/web-assembly.ts"],"names":[],"mappings":"AAAA,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,
|
|
1
|
+
{"version":3,"file":"web-assembly.d.ts","sourceRoot":"","sources":["../../src/utilities/web-assembly.ts"],"names":[],"mappings":"AAAA,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,CASrF"}
|
package/lib/src/console-codes.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export enum ErrorCodes {
|
|
2
|
-
NO_CONTEXT_PERMISSION = "FLUEXGL@AUDIO_ERROR_0001",
|
|
3
|
-
NO_FILE_TYPE_FOUND = "FLUEXGL@AUDIO_ERROR_0002",
|
|
4
|
-
PATH_TO_FILE_NOT_FOUND = "FLUEXGL@AUDIO_ERROR_0003",
|
|
5
|
-
SAME_MASTER_CHANNEL = "FLUEXGL@AUDIO_ERROR_0004",
|
|
6
|
-
WASM_MODULE_INITIALIZATION_FAILED = "FLUEXGL@AUDIO_ERROR_0005",
|
|
7
|
-
PATH_TO_WASM_FILE_NOT_FOUND = "FLUEXGL@AUDIO_ERROR_0006"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export enum WarningCodes {
|
|
11
|
-
NO_DEFAULT_AUDIO_DEVICE_FOUND = "FLUEXGL@AUDIO_WARNING_0001"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export enum SuccessCodes {
|
|
15
|
-
|
|
1
|
+
export enum ErrorCodes {
|
|
2
|
+
NO_CONTEXT_PERMISSION = "FLUEXGL@AUDIO_ERROR_0001",
|
|
3
|
+
NO_FILE_TYPE_FOUND = "FLUEXGL@AUDIO_ERROR_0002",
|
|
4
|
+
PATH_TO_FILE_NOT_FOUND = "FLUEXGL@AUDIO_ERROR_0003",
|
|
5
|
+
SAME_MASTER_CHANNEL = "FLUEXGL@AUDIO_ERROR_0004",
|
|
6
|
+
WASM_MODULE_INITIALIZATION_FAILED = "FLUEXGL@AUDIO_ERROR_0005",
|
|
7
|
+
PATH_TO_WASM_FILE_NOT_FOUND = "FLUEXGL@AUDIO_ERROR_0006"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum WarningCodes {
|
|
11
|
+
NO_DEFAULT_AUDIO_DEVICE_FOUND = "FLUEXGL@AUDIO_WARNING_0001"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum SuccessCodes {
|
|
15
|
+
|
|
16
16
|
}
|