Synthesis
Build procedural sounds from oscillators, envelopes and effects.
Generated from the reviewed SDK 0.1.0 contract snapshot. Unreviewed workspace changes are not included.
Public exports
Import from @scape/sdk.
GIZMO_SOUND_RATE, GizmoSoundEffect, GizmoSoundEnvelope, GizmoSoundFilter, GizmoSoundPoint, GizmoSoundSamples, GizmoSoundVoice, GizmoSynth, gizmoSynthError, renderGizmoSynth.
Type declarations
These declarations preserve source comments and related types. Import only the public exports listed above; module-relative paths below describe how the package is organized.
ts
/** Times are seconds relative to the start of a voice. Curve belongs to the incoming segment. */
export interface GizmoSoundPoint {
time: number;
value: number;
curve?: 'linear' | 'exponential' | 'step';
}
export type GizmoSoundEnvelope = number | GizmoSoundPoint[];
export interface GizmoSoundFilter {
type: 'lowpass' | 'highpass' | 'bandpass';
frequency: number;
q: number;
}
export interface GizmoSoundVoice {
wave: 'sine' | 'triangle' | 'square' | 'sawtooth' | 'noise';
start: number;
duration: number;
frequency?: GizmoSoundEnvelope;
gain: GizmoSoundEnvelope;
pan?: number;
fade?: [number, number];
noiseDuration?: number;
noiseRate?: number;
filter?: GizmoSoundFilter;
}
export type GizmoSoundEffect = GizmoSoundFilter | {
type: 'delay';
time: number;
feedback: number;
mix: number;
parallel?: boolean;
} | {
type: 'noise-reverb';
duration: number;
decay: number;
seed: number;
mix: number;
parallel?: boolean;
} | {
type: 'reverb';
decay: number;
mix: number;
};
/** Portable sound design. No audio nodes, device access, timers or instrument presets. */
export interface GizmoSynth {
kind: 'synth';
duration: number;
seed?: number;
voices: GizmoSoundVoice[];
effects?: GizmoSoundEffect[];
}
export interface GizmoSoundSamples {
samples: Float32Array<ArrayBuffer>[];
rate: number;
duration: number;
}
export declare const GIZMO_SOUND_RATE = 48000;
export declare function gizmoSynthError(value: unknown, path?: string): string | null;
/** Deterministic PCM rendering. Hosts run this in a bounded worker, never on the game frame. */
export declare function renderGizmoSynth(sound: GizmoSynth): GizmoSoundSamples;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Usage and limits
See Gizmo guides, working examples, and limits for lifecycle, validation and host behavior.
