@adatechnology/game-audio 0.7.0 → 0.9.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/README.md +69 -1
- package/assets/sfx/CREDITOS.md +2 -2
- package/assets/sfx/manifest.json +48 -0
- package/dist/bank-Dsj1VAht.d.ts +391 -0
- package/dist/chunk-JV5XXCQE.js +180 -0
- package/dist/chunk-JV5XXCQE.js.map +1 -0
- package/dist/{chunk-BXUGSOPY.js → chunk-UUWKSG4J.js} +240 -167
- package/dist/chunk-UUWKSG4J.js.map +1 -0
- package/dist/fitted.d.ts +89 -0
- package/dist/fitted.js +139 -0
- package/dist/fitted.js.map +1 -0
- package/dist/index.d.ts +138 -3
- package/dist/index.global.js +642 -200
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +258 -20
- package/dist/index.js.map +1 -1
- package/dist/{locale-CJfDpWnI.d.ts → locale-YHyJwN2P.d.ts} +108 -440
- package/dist/testing.d.ts +5 -4
- package/dist/testing.js +2 -1
- package/package.json +6 -2
- package/dist/chunk-BXUGSOPY.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as SampleSound, B as BusId, a as SoundBank, F as Falloff, L as LoopRecipe, b as SoundRecipe, P as ParamRef, R as Range, d as Layer, e as SoundSet } from './bank-Dsj1VAht.js';
|
|
2
|
+
export { A as Automation, f as BUILD_ORDERS, g as BUS_IDS, h as BuildOrder, C as Curve, D as DeepPartial, E as Envelope, i as EnvelopePoint, j as FilterBank, k as FilterSpec, l as FormantVoiceSource, m as LayerSource, n as LoopOrder, M as Modulator, N as NoiseSource, O as OscSource, o as SampleAlias, p as SampleCrossover, q as SampleEnvironment, r as SampleRef, s as SampleTail, t as SampleTier, S as SoundRegistry, T as Time, u as aliasSample, v as createSoundRegistry } from './bank-Dsj1VAht.js';
|
|
3
|
+
import { S as SampleLoader, a as SfxManifest, b as SampleDefaults, A as AudioEngine, c as SoundPlan, d as SamplePlan, e as AudioLoopHandle, L as LoopEntry, f as Listener, D as DistanceMode, M as MixProfile } from './locale-YHyJwN2P.js';
|
|
4
|
+
export { g as ActionCheck, h as AudioBenchText, i as AudioChannel, j as AudioEngineOptions, k as AudioScenarioLike, l as AudioStats, m as AudioTestModule, n as AudioTestModuleOptions, B as BENCH_BANK, o as BUS_PRIORITY, p as BusSetting, C as CRITERIA, q as CRITERIA_TARGETS, r as CriterionId, s as CriterionResult, t as DEFAULT_CROSSOVER, u as DEFAULT_LISTENER, v as DEFAULT_MAX_VOICES, w as DEFAULT_MIX, x as DEFAULT_SAMPLE_CUTOFF_K, y as DEFAULT_SAMPLE_FALLOFF, z as DEFAULT_SAMPLE_PITCH, E as DEFAULT_TAIL_GAIN, K as KIT_SAMPLES_BANK, F as LAYER_FLOOR, G as LoadUserSamplesOptions, H as LoopSet, I as MIX_PROFILES, J as MeasureOptions, O as OPEN_CUTOFF, P as PAN_LIMIT, N as PAN_MIN_DISTANCE, Q as PlanInput, R as PlannedAutomation, T as PlannedEnvelopePoint, U as PlannedFilter, V as PlannedLayer, W as PlannedModulator, X as PlannedSampleLayer, Y as PlannedSource, Z as PlayOptions, _ as SAMPLE_ENVIRONMENTS, $ as SDK_LICENSES, a0 as SFX_BLOWS, a1 as SFX_CATALOG, a2 as SFX_CATEGORIES, a3 as SFX_IMPACTS, a4 as SFX_LAYERS, a5 as SFX_MATERIALS, a6 as SFX_TIERS, a7 as SampleBankOptions, a8 as SampleLayerRole, a9 as SampleLoadReport, aa as SampleMemory, ab as SampleOptions, ac as SamplePlanInput, ad as SampleStatus, ae as SampleStore, af as SdkLicense, ag as SfxBlow, ah as SfxCategory, ai as SfxEntry, aj as SfxFileEntry, ak as SfxLayer, al as SfxManifestLike, am as SfxManifestSound, an as SfxMaterial, ao as SfxPriority, ap as SfxState, aq as SoundSource, ar as StartQueueOptions, as as USER_SAMPLES_BANK, at as USER_SOUND_PREFIX, au as UserSampleBankOptions, av as UserSampleBankResult, aw as UserSfxFile, ax as UserSfxManifest, ay as UserSfxSound, az as UserSoundPick, aA as UserSoundPicks, aB as UserSoundRole, aC as VOICE_GROUPS, aD as VoiceDecision, aE as VoiceGroup, aF as VoiceHandle, aG as VoiceManager, aH as VoiceManagerOptions, aI as VoiceRefusal, aJ as VoiceRequest, aK as VoiceStartEvent, aL as VoiceStats, aM as audioBenchTextOf, aN as busGain, aO as busPriority, aP as createAudioEngine, aQ as createAudioTestModule, aR as createSampleStore, aS as createVoiceManager, aT as crossGains, aU as farMixAt, aV as fetchLoader, aW as impactSoundId, aX as inlineLoader, aY as limiterCurve, aZ as listenerDistance, a_ as loadUserSamples, a$ as measureCriteria, b0 as panFor, b1 as parseSfxName, b2 as pickTake, b3 as planSample, b4 as planSound, b5 as recordOutput, b6 as resolveMix, b7 as sampleBankFromManifest, b8 as sampleCutoff, b9 as sampleUrls, ba as sfxState, bb as soundSourceOf, bc as splitTier, bd as tierFor, be as userSampleBank } from './locale-YHyJwN2P.js';
|
|
3
5
|
import { AudioSink } from '@adatechnology/game-contracts';
|
|
4
6
|
|
|
5
7
|
/** Deterministic mulberry32 generator; floats in [0, 1). The same generator the golden tool seeds `Math.random` with, so a team routine and its recipe draw the same numbers. */
|
|
@@ -90,6 +92,107 @@ type Registers = {
|
|
|
90
92
|
* `file://`, the folder not served): the recipes keep playing, so that is not an error.
|
|
91
93
|
*/
|
|
92
94
|
declare function loadKitSamples(engine: Registers, options?: LoadKitSamplesOptions): Promise<SoundBank | null>;
|
|
95
|
+
/** A game's own files, by sound id: one url or several takes (relative to `baseUrl`). */
|
|
96
|
+
type SampleFiles = Readonly<Record<string, string | readonly string[]>>;
|
|
97
|
+
type PointSamplesOptions = {
|
|
98
|
+
/** Put before every url (the game's folder, `./sfx/` say). */
|
|
99
|
+
readonly baseUrl?: string;
|
|
100
|
+
/** The bank id (default `game_samples`). */
|
|
101
|
+
readonly id?: string;
|
|
102
|
+
/** Bus of an id the kit has no sound for (default `world`). */
|
|
103
|
+
readonly bus?: BusId;
|
|
104
|
+
};
|
|
105
|
+
type PointsSamples = {
|
|
106
|
+
register(bank: SoundBank): void;
|
|
107
|
+
readonly registry: {
|
|
108
|
+
sample(id: string): SampleSound | undefined;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Points sound ids at a game's own files: each id keeps the kit's numbers (bus, level, pitch spread, falloff, choke) and plays the game's takes in
|
|
113
|
+
* place of the kit's (its far takes, tiers and room tails included, since they are the kit's files); an id the kit has no sound for is added on
|
|
114
|
+
* `bus`. Call it after the kit's bank (`loadKitSamples`): a later bank wins, so the rest of the kit's sounds stay. For a whole folder laid out like
|
|
115
|
+
* the kit's (`<categoria>/<nome>.ogg` and a `manifest.json`), `loadKitSamples(engine, { baseUrl: '<folder>/', id: 'game_samples' })` does the same.
|
|
116
|
+
*/
|
|
117
|
+
declare function pointSamples(engine: PointsSamples, files: SampleFiles, options?: PointSamplesOptions): SoundBank;
|
|
118
|
+
|
|
119
|
+
declare const LOCAL_PACK_LICENSES: readonly ["CC0", "CC-BY", "unknown", "proprietary"];
|
|
120
|
+
type LocalPackLicense = (typeof LOCAL_PACK_LICENSES)[number];
|
|
121
|
+
/** Which sound an id plays when the SDK also has a recording for it: the pack's files (default) or the SDK's, the pack staying as the alternative. */
|
|
122
|
+
declare const LOCAL_PACK_PREFERENCES: readonly ["pack", "sdk"];
|
|
123
|
+
type LocalPackPreference = (typeof LOCAL_PACK_PREFERENCES)[number];
|
|
124
|
+
type LocalSoundEntry = {
|
|
125
|
+
/** Paths or urls of the takes, relative to the pack's base. */
|
|
126
|
+
readonly files: readonly string[];
|
|
127
|
+
readonly license: LocalPackLicense;
|
|
128
|
+
/** Default `pack`; `sdk` keeps the SDK recording when there is one (the pack's files are then not even fetched). */
|
|
129
|
+
readonly prefer?: LocalPackPreference;
|
|
130
|
+
/** Bus of the sound (default the bus of its catalogue category). */
|
|
131
|
+
readonly bus?: BusId;
|
|
132
|
+
readonly gain?: number;
|
|
133
|
+
/** 0–10: how well the files fit the id (a reviewer's note, shown by tools). */
|
|
134
|
+
readonly score?: number;
|
|
135
|
+
readonly note?: string;
|
|
136
|
+
};
|
|
137
|
+
type LocalSoundPack = {
|
|
138
|
+
readonly version: 1;
|
|
139
|
+
/** Prefix of every file (a folder served next to the page, or a url); the consumer can override it. */
|
|
140
|
+
readonly baseUrl?: string;
|
|
141
|
+
/** SDK sound id → its files. */
|
|
142
|
+
readonly sounds: Readonly<Record<string, LocalSoundEntry>>;
|
|
143
|
+
};
|
|
144
|
+
declare class LocalSoundPackError extends Error {
|
|
145
|
+
readonly problems: readonly string[];
|
|
146
|
+
constructor(problems: readonly string[]);
|
|
147
|
+
}
|
|
148
|
+
/** Checks a parsed JSON config; every problem is reported at once. */
|
|
149
|
+
declare function parseLocalSoundPack(value: unknown): LocalSoundPack;
|
|
150
|
+
/** Whether the SDK may ship a file of this licence (public domain or attribution). */
|
|
151
|
+
declare const isShippableLicense: (license: string | undefined) => boolean;
|
|
152
|
+
type LocalPackSampleOptions = {
|
|
153
|
+
/** Overrides the pack's `baseUrl`. */
|
|
154
|
+
readonly baseUrl?: string;
|
|
155
|
+
};
|
|
156
|
+
/** The pack as sample sounds, one per id, with the synthesized sound of the catalogue as the fallback. */
|
|
157
|
+
declare function localPackSamples(pack: LocalSoundPack, options?: LocalPackSampleOptions): SampleSound[];
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Puts a local sound pack on an engine without touching the frame a sound is played in. Each id's files are fetched and decoded in idle time
|
|
161
|
+
* (one id per idle slot), once per url (the engine's sample store shares buffers between ids and voices). Until they decode, the id plays what it
|
|
162
|
+
* played before (the SDK's recording, else its synthesized recipe); once they do, the id is swapped to the files. The choice is made once, when the
|
|
163
|
+
* files load: a file that fails leaves the id on the SDK's sound for good, so `play` never fetches or decodes anything.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
declare const LOCAL_PACK_BANK_ID = "local_sound_pack";
|
|
167
|
+
/** `pending` while loading, `file` once the pack's files play, `fallback` when they failed and the SDK's sound stays, `sdk` when the entry prefers the SDK recording and there is one. */
|
|
168
|
+
type LocalPackStatus = 'pending' | 'file' | 'fallback' | 'sdk';
|
|
169
|
+
type LocalPackReport = {
|
|
170
|
+
readonly file: readonly string[];
|
|
171
|
+
/** Ids that kept the SDK recording by preference (their files were not fetched). */
|
|
172
|
+
readonly sdk: readonly string[];
|
|
173
|
+
readonly fallback: readonly {
|
|
174
|
+
readonly id: string;
|
|
175
|
+
readonly error: string;
|
|
176
|
+
}[];
|
|
177
|
+
};
|
|
178
|
+
/** Runs a task when the page is idle; returns a cancel function. */
|
|
179
|
+
type IdleScheduler = (task: () => void) => () => void;
|
|
180
|
+
/** `requestIdleCallback` where there is one, else the next macrotask. */
|
|
181
|
+
declare const defaultIdleScheduler: IdleScheduler;
|
|
182
|
+
type ApplyLocalSoundPackOptions = LocalPackSampleOptions & {
|
|
183
|
+
readonly schedule?: IdleScheduler;
|
|
184
|
+
};
|
|
185
|
+
type LocalPackHandle = {
|
|
186
|
+
/** Resolves when every id has loaded or fallen back. */
|
|
187
|
+
readonly done: Promise<LocalPackReport>;
|
|
188
|
+
status(id: string): LocalPackStatus | undefined;
|
|
189
|
+
/** The ids playing a pack file whose licence is not CC0 / CC-BY. */
|
|
190
|
+
unlicensed(): readonly string[];
|
|
191
|
+
/** Stops loading and gives every swapped id back the sound it had before. */
|
|
192
|
+
dispose(): void;
|
|
193
|
+
};
|
|
194
|
+
type Engine = Pick<AudioEngine, 'registry' | 'register' | 'loadSamples'>;
|
|
195
|
+
declare function applyLocalSoundPack(engine: Engine, pack: LocalSoundPack, options?: ApplyLocalSoundPackOptions): LocalPackHandle;
|
|
93
196
|
|
|
94
197
|
/** The distance curves of the team routines, by name. Each recipe carries its own; these are the values to copy. */
|
|
95
198
|
declare const DISTANCE_CURVES: {
|
|
@@ -256,6 +359,31 @@ declare const LIBRARY_BANK: SoundBank;
|
|
|
256
359
|
declare const CABIN_SOUNDS: readonly SoundRecipe[];
|
|
257
360
|
declare const CABIN_BANK: SoundBank;
|
|
258
361
|
|
|
362
|
+
type Note = readonly [beat: number, midi: number, beats: number];
|
|
363
|
+
type TrackSpec = {
|
|
364
|
+
id: string;
|
|
365
|
+
bpm: number;
|
|
366
|
+
bars: number;
|
|
367
|
+
wave: 'sine' | 'triangle' | 'square' | 'sawtooth';
|
|
368
|
+
bass: readonly Note[];
|
|
369
|
+
chords: readonly Note[];
|
|
370
|
+
melody: readonly Note[];
|
|
371
|
+
};
|
|
372
|
+
/** A song of the radio: the ids of its bars in order and the seconds of one bar. */
|
|
373
|
+
type RadioSong = {
|
|
374
|
+
readonly id: string;
|
|
375
|
+
readonly barSeconds: number;
|
|
376
|
+
readonly bars: readonly string[];
|
|
377
|
+
};
|
|
378
|
+
/** One song cut in bars: every note a layer at its beat inside its bar. */
|
|
379
|
+
declare function radioTrack(spec: TrackSpec): {
|
|
380
|
+
song: RadioSong;
|
|
381
|
+
recipes: SoundRecipe[];
|
|
382
|
+
};
|
|
383
|
+
/** The songs a cabin steps through. */
|
|
384
|
+
declare const RADIO_TRACKS: readonly RadioSong[];
|
|
385
|
+
declare const RADIO_BANK: SoundBank;
|
|
386
|
+
|
|
259
387
|
/** Small sounds of the hand: `vol / (1 + d² × 0.02)`, lowpass cutoffs `/ (1 + d × 0.04)`, silent below 0.004 (a latch at 10 m is a third, at 50 m gone). */
|
|
260
388
|
declare const FOLEY_FALLOFF: Falloff;
|
|
261
389
|
/** The doors and lids of furniture and vehicles, by what the leaf is (the room picks one from the item, else from the leaf's material). */
|
|
@@ -324,6 +452,8 @@ type RealizedVoice = {
|
|
|
324
452
|
stop(): void;
|
|
325
453
|
};
|
|
326
454
|
|
|
455
|
+
/** Seconds a trimmed take fades out over at its cut. */
|
|
456
|
+
declare const TRIM_FADE = 0.04;
|
|
327
457
|
type SampleTarget = {
|
|
328
458
|
readonly context: BaseAudioContext;
|
|
329
459
|
readonly output: AudioNode;
|
|
@@ -366,7 +496,12 @@ type SampleLoopHost = {
|
|
|
366
496
|
unregister(loop: LoopEntry): void;
|
|
367
497
|
/** Whether a bus is muted now. */
|
|
368
498
|
muted(bus: BusId): boolean;
|
|
499
|
+
/** Where the listener is, for a loop placed by `set({ position })`. */
|
|
500
|
+
listener?(): Listener;
|
|
501
|
+
distance?: DistanceMode;
|
|
369
502
|
};
|
|
503
|
+
/** The rate a loop with `baseFrequency` plays at for a frequency. */
|
|
504
|
+
declare const loopRate: (sound: SampleSound, frequency: number) => number;
|
|
370
505
|
|
|
371
506
|
/** Builds a plan's nodes on `target`, in the node order of the team routine its `order` names. */
|
|
372
507
|
declare function realize(plan: SoundPlan, target: RealizeTarget): RealizedVoice;
|
|
@@ -409,4 +544,4 @@ type EngineSink = AudioSink & {
|
|
|
409
544
|
/** Lends an engine as the host's `audio`: sounds by key, loops, the listener, and banks registered into the same engine. */
|
|
410
545
|
declare function createAudioSink(engine: AudioEngine): EngineSink;
|
|
411
546
|
|
|
412
|
-
export { AudioEngine, AudioLoopHandle, BODY_FALLOFF, BODY_FOLEY_BANK, BODY_FOLEY_SET_IDS, BODY_FOLEY_TAKES, BusId, CABIN_BANK, CABIN_SOUNDS, CALIBRATION_ID, CALIBRATION_LOOP_ID, CALIBRATION_LOOP_SOUND, CALIBRATION_SOUND, CROSSFADE_STEPS, DEFAULT_LOOP_CROSSFADE, DISTANCE_CURVES, type DistanceCurveName, type EngineSink, FOLEY_BANK, FOLEY_FALLOFF, FOOTSTEP_FALLOFF, Falloff, GAME_SFX_BANK, GAME_SFX_CLASSES, GAME_SFX_FALLBACK, ITEM_FOLEY, KIT_CATEGORY_BUS, KIT_SAMPLE_ALIASES, type KitSampleBankOptions, LEAF_FOLEY, LEAF_FOLEY_SETS, LIBRARY_BANK, LIBRARY_LOOPS, LIBRARY_SOUNDS, LOOP_SMOOTHING, LOOP_START_ABOVE, Layer, type LeafFoley, type LoadKitSamplesOptions, type LoopAction, LoopRecipe, type LoopState, type MixChain, MixProfile, type NoiseClass, PICKUP_CLASSES, ParamRef, type PickupClass, Range, type RealizeTarget, type RealizedSampleVoice, type RealizedVoice, SampleDefaults, SampleLoader, type SampleLoopHost, SamplePlan, SampleSound, type SampleTarget, type SceneLength, type SceneNoise, type SceneRecipeOptions, type SceneTone, type SceneVoice, type SetPicker, SfxManifest, SoundBank, SoundPlan, SoundRecipe, SoundSet, balanceOf, bufferOf, buildChain, calibrationLoader, centroidHz, countHits, createAudioSink, createLoopState, createRng, createSetPicker, cutoffDivisor, dbOf, drawBetween, encodeWav, endDropDb, equalPowerIn, falloffGain, fillImpulse, fillNoise, globalContext, isCalibrationUrl, isSilent, kitSampleBank, kitSampleDefaults, loadKitSamples, loopCrossfade, noiseClassRecipe, onsetIndex, peakIndex, peakOf, realize, realizeSample, retunePlan, ringSeconds, rmsDb, sampleLength, sceneMany, sceneNoise, sceneRecipe, sceneTone, sceneVoice, streamFor, streamSeed, unlockContext, withAliases };
|
|
547
|
+
export { type ApplyLocalSoundPackOptions, AudioEngine, AudioLoopHandle, BODY_FALLOFF, BODY_FOLEY_BANK, BODY_FOLEY_SET_IDS, BODY_FOLEY_TAKES, BusId, CABIN_BANK, CABIN_SOUNDS, CALIBRATION_ID, CALIBRATION_LOOP_ID, CALIBRATION_LOOP_SOUND, CALIBRATION_SOUND, CROSSFADE_STEPS, DEFAULT_LOOP_CROSSFADE, DISTANCE_CURVES, type DistanceCurveName, DistanceMode, type EngineSink, FOLEY_BANK, FOLEY_FALLOFF, FOOTSTEP_FALLOFF, Falloff, GAME_SFX_BANK, GAME_SFX_CLASSES, GAME_SFX_FALLBACK, ITEM_FOLEY, type IdleScheduler, KIT_CATEGORY_BUS, KIT_SAMPLE_ALIASES, type KitSampleBankOptions, LEAF_FOLEY, LEAF_FOLEY_SETS, LIBRARY_BANK, LIBRARY_LOOPS, LIBRARY_SOUNDS, LOCAL_PACK_BANK_ID, LOCAL_PACK_LICENSES, LOCAL_PACK_PREFERENCES, LOOP_SMOOTHING, LOOP_START_ABOVE, Layer, type LeafFoley, Listener, type LoadKitSamplesOptions, type LocalPackHandle, type LocalPackLicense, type LocalPackPreference, type LocalPackReport, type LocalPackSampleOptions, type LocalPackStatus, type LocalSoundEntry, type LocalSoundPack, LocalSoundPackError, type LoopAction, LoopRecipe, type LoopState, type MixChain, MixProfile, type NoiseClass, PICKUP_CLASSES, ParamRef, type PickupClass, type PointSamplesOptions, RADIO_BANK, RADIO_TRACKS, type RadioSong, Range, type RealizeTarget, type RealizedSampleVoice, type RealizedVoice, SampleDefaults, type SampleFiles, SampleLoader, type SampleLoopHost, SamplePlan, SampleSound, type SampleTarget, type SceneLength, type SceneNoise, type SceneRecipeOptions, type SceneTone, type SceneVoice, type SetPicker, SfxManifest, SoundBank, SoundPlan, SoundRecipe, SoundSet, TRIM_FADE, applyLocalSoundPack, balanceOf, bufferOf, buildChain, calibrationLoader, centroidHz, countHits, createAudioSink, createLoopState, createRng, createSetPicker, cutoffDivisor, dbOf, defaultIdleScheduler, drawBetween, encodeWav, endDropDb, equalPowerIn, falloffGain, fillImpulse, fillNoise, globalContext, isCalibrationUrl, isShippableLicense, isSilent, kitSampleBank, kitSampleDefaults, loadKitSamples, localPackSamples, loopCrossfade, loopRate, noiseClassRecipe, onsetIndex, parseLocalSoundPack, peakIndex, peakOf, pointSamples, radioTrack, realize, realizeSample, retunePlan, ringSeconds, rmsDb, sampleLength, sceneMany, sceneNoise, sceneRecipe, sceneTone, sceneVoice, streamFor, streamSeed, unlockContext, withAliases };
|