@algo-wasm/algo-wasm 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +6 -4
- package/dist/algo-wasm-error.d.ts +13 -0
- package/dist/algo-wasm-player.d.ts +169 -0
- package/dist/algo_wasm.wasm +0 -0
- package/dist/built-in-profiles.d.ts +5 -0
- package/dist/engine-core.d.ts +96 -0
- package/dist/events.d.ts +5 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -6
- package/dist/integrations/phaser.d.ts +9 -2
- package/dist/integrations/phaser.js +1 -16
- package/dist/integrations/react.d.ts +8 -2
- package/dist/integrations/react.js +1 -28
- package/dist/integrations/svelte.d.ts +6 -2
- package/dist/integrations/svelte.js +1 -17
- package/dist/integrations/vue.d.ts +7 -2
- package/dist/integrations/vue.js +1 -16
- package/dist/load-wasm.d.ts +92 -0
- package/dist/profile-schema.json +317 -228
- package/dist/profile-spec.d.ts +178 -0
- package/dist/profile-wire.d.ts +50 -0
- package/dist/profile.d.ts +25 -1
- package/dist/types.d.ts +25 -1
- package/dist/wire-decode.d.ts +18 -0
- package/dist/worklet/algo-worklet.d.ts +1 -83
- package/dist/worklet/algo-worklet.js +1 -471
- package/package.json +1 -1
- package/dist/AlgoWasmError.d.ts +0 -8
- package/dist/AlgoWasmError.d.ts.map +0 -1
- package/dist/AlgoWasmError.js +0 -9
- package/dist/AlgoWasmError.js.map +0 -1
- package/dist/AlgoWasmPlayer.d.ts +0 -48
- package/dist/AlgoWasmPlayer.d.ts.map +0 -1
- package/dist/AlgoWasmPlayer.js +0 -375
- package/dist/AlgoWasmPlayer.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -25
- package/dist/events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/phaser.d.ts.map +0 -1
- package/dist/integrations/phaser.js.map +0 -1
- package/dist/integrations/react.d.ts.map +0 -1
- package/dist/integrations/react.js.map +0 -1
- package/dist/integrations/svelte.d.ts.map +0 -1
- package/dist/integrations/svelte.js.map +0 -1
- package/dist/integrations/vue.d.ts.map +0 -1
- package/dist/integrations/vue.js.map +0 -1
- package/dist/loadWasm.d.ts +0 -47
- package/dist/loadWasm.d.ts.map +0 -1
- package/dist/loadWasm.js +0 -229
- package/dist/loadWasm.js.map +0 -1
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -525
- package/dist/profile.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/worklet/algo-worklet.d.ts.map +0 -1
- package/dist/worklet/algo-worklet.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { EngineCore } from './engine-core.js';
|
|
2
|
+
import type { AlgoWasmGeneratedEvent, AlgoWasmMood, AlgoWasmProfile, AlgoWasmSnapshot, AlgoWasmTrackId } from './types.js';
|
|
3
|
+
/** A compiled and instantiated AlgoWASM binary. */
|
|
4
|
+
export interface AlgoWasmInstantiation {
|
|
5
|
+
instance: WebAssembly.Instance;
|
|
6
|
+
module: WebAssembly.Module;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fetches and instantiates the AlgoWASM binary.
|
|
10
|
+
*
|
|
11
|
+
* Streaming compilation is used when the server sends `application/wasm`. If
|
|
12
|
+
* the MIME type is wrong, as on some local servers, the file is fetched again
|
|
13
|
+
* and compiled from bytes instead.
|
|
14
|
+
*
|
|
15
|
+
* @throws {AlgoWasmError} With code `wasm_load_failed` when the file cannot
|
|
16
|
+
* be fetched or compiled.
|
|
17
|
+
*/
|
|
18
|
+
export declare function instantiateAlgoWasm(wasmUrl: string | URL): Promise<AlgoWasmInstantiation>;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a mood id to its engine index.
|
|
21
|
+
*
|
|
22
|
+
* @throws {TypeError} When the mood is not recognised.
|
|
23
|
+
*/
|
|
24
|
+
export declare function moodIndex(mood: AlgoWasmMood): number;
|
|
25
|
+
/**
|
|
26
|
+
* Converts a track id to its engine index.
|
|
27
|
+
*
|
|
28
|
+
* @throws {TypeError} When the track id is not recognised.
|
|
29
|
+
*/
|
|
30
|
+
export declare function trackIndex(trackId: AlgoWasmTrackId): number;
|
|
31
|
+
/**
|
|
32
|
+
* Typed binding to one engine inside a WASM instance, for use outside an
|
|
33
|
+
* `AlgoWasmPlayer`, for example to render audio offline.
|
|
34
|
+
*
|
|
35
|
+
* Memory ownership: the binding owns the WASM buffers it allocates. Call
|
|
36
|
+
* `destroy` when finished to free them.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const { instance } = await instantiateAlgoWasm(wasmUrl);
|
|
40
|
+
* const binding = new AlgoWasmEngineBinding(instance);
|
|
41
|
+
*
|
|
42
|
+
* try {
|
|
43
|
+
* binding.create(48000, 42n, builtInProfiles.dubstep());
|
|
44
|
+
* binding.start();
|
|
45
|
+
* binding.renderTo(output);
|
|
46
|
+
* } finally {
|
|
47
|
+
* binding.destroy();
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class AlgoWasmEngineBinding extends EngineCore {
|
|
52
|
+
/**
|
|
53
|
+
* Validates the profile and creates the engine.
|
|
54
|
+
*
|
|
55
|
+
* @throws {AlgoWasmError} With code `profile_invalid` or `engine_failed`.
|
|
56
|
+
*/
|
|
57
|
+
create(sampleRate: number, seed: bigint, profile: AlgoWasmProfile): void;
|
|
58
|
+
/** Re-seeds the engine and restarts the song. */
|
|
59
|
+
setSeed(seed: bigint): void;
|
|
60
|
+
/**
|
|
61
|
+
* Validates and applies a new profile, then restarts the song.
|
|
62
|
+
*
|
|
63
|
+
* @throws {AlgoWasmError} With code `profile_invalid` or `engine_failed`.
|
|
64
|
+
*/
|
|
65
|
+
setProfile(profile: AlgoWasmProfile): void;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the mood.
|
|
68
|
+
*
|
|
69
|
+
* @throws {TypeError} When the mood is not recognised.
|
|
70
|
+
*/
|
|
71
|
+
setMood(value: AlgoWasmMood): void;
|
|
72
|
+
/**
|
|
73
|
+
* Mutes or unmutes a track.
|
|
74
|
+
*
|
|
75
|
+
* @throws {TypeError} When the track id is not recognised.
|
|
76
|
+
*/
|
|
77
|
+
setMuted(trackId: AlgoWasmTrackId, muted: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Solos or unsolos a track.
|
|
80
|
+
*
|
|
81
|
+
* @throws {TypeError} When the track id is not recognised.
|
|
82
|
+
*/
|
|
83
|
+
setSolo(trackId: AlgoWasmTrackId, solo: boolean): void;
|
|
84
|
+
/** Returns the engine's current state. */
|
|
85
|
+
snapshot(): AlgoWasmSnapshot;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the events generated since the last call, and removes them from
|
|
88
|
+
* the engine's buffer. The buffer holds up to 512 events, so call this
|
|
89
|
+
* often enough that it does not fill.
|
|
90
|
+
*/
|
|
91
|
+
events(): AlgoWasmGeneratedEvent[];
|
|
92
|
+
}
|