Synthesis
Build procedural sounds from oscillators, envelopes and effects.
Public exports
Import from @scape-wtf/sdk.
GIZMO_SOUND_RATE, GizmoSoundEffect, GizmoSoundEnvelope, GizmoSoundFilter, GizmoSoundPoint, GizmoSoundSamples, GizmoSoundVoice, GizmoSynth, gizmoSynthError, renderGizmoSynth.
Type declarations
Import the public exports listed above from the package entry point.
ts
/** Times are seconds relative to the start of a voice. Curve belongs to the incoming segment. */
export interface GizmoSoundPoint {
/** Time in seconds from the start of the voice. */
time: number;
/** Value at this point, interpreted by the envelope field. */
value: number;
/** Interpolation used until the next point. */
curve?: 'linear' | 'exponential' | 'step';
}
/** A constant value or a bounded time/value envelope. */
export type GizmoSoundEnvelope = number | GizmoSoundPoint[];
/** Biquad filter settings applied to one synthesized voice. */
export interface GizmoSoundFilter {
/** Filter response shape. */
type: 'lowpass' | 'highpass' | 'bandpass';
/** Center or cutoff frequency in hertz. */
frequency: number;
/** Filter quality factor. */
q: number;
}
/** One bounded oscillator/noise voice in a procedural sound. */
export interface GizmoSoundVoice {
/** Waveform used by this voice. */
wave: 'sine' | 'triangle' | 'square' | 'sawtooth' | 'noise';
/** Start time in seconds. */
start: number;
/** Voice duration in seconds. */
duration: number;
/** Optional frequency envelope in hertz. */
frequency?: GizmoSoundEnvelope;
/** Amplitude envelope, from silence to the bounded voice gain. */
gain: GizmoSoundEnvelope;
/** Stereo pan from left (-1) to right (1). */
pan?: number;
/** Optional fade-in and fade-out durations in seconds. */
fade?: [number, number];
/** Noise duration used by noise voices. */
noiseDuration?: number;
/** Noise refresh rate used by noise voices. */
noiseRate?: number;
/** Optional filter applied after the oscillator. */
filter?: GizmoSoundFilter;
}
/** One bounded effect in a procedural sound chain. */
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 {
/** Discriminator for the synthesizer representation. */
kind: 'synth';
/** Total rendered duration in seconds. */
duration: number;
/** Optional deterministic seed for noise and diffuse effects. */
seed?: number;
/** Voices mixed into the sound. */
voices: GizmoSoundVoice[];
/** Optional ordered effects applied to the mixed voices. */
effects?: GizmoSoundEffect[];
}
/** Rendered PCM samples returned by local SDK helpers. */
export interface GizmoSoundSamples {
/** One Float32 channel array per output channel. */
samples: Float32Array<ArrayBuffer>[];
/** Sample rate in hertz. */
rate: number;
/** Duration represented by the sample arrays, in seconds. */
duration: number;
}
/** Sample rate used by Scape's portable procedural renderer. */
export declare const GIZMO_SOUND_RATE = 48000;
export declare function gizmoSynthError(value: unknown, path?: string): string | null;
/** Render deterministic PCM samples for local audio tests. */
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Usage and limits
See Gizmo guides, working examples, and limits for lifecycle, validation and Scape behavior.
