-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_template.ts
More file actions
41 lines (40 loc) · 1.43 KB
/
Copy path_template.ts
File metadata and controls
41 lines (40 loc) · 1.43 KB
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
/// <reference path="../env.d.ts" />
import { asHandle, callGain, type PresetEntry } from "./_meta.ts"
/**
* TEMPLATE — copy this file to `<your-id>.ts` and fill in the blanks.
*
* Checklist:
* 1. Pick a stable `id` (lower-case, kebab-style, single word if possible).
* 2. Keep `description` to one sentence.
* 3. Tag with at least one canonical tag (see `_meta.ts`).
* 4. Keep total duration ≤ 800 ms unless the sound is genuinely musical.
* 5. Always multiply your envelope peak by `callGain(opts)`.
* 6. Schedule a hard `stop()` past the envelope tail so the source is
* released — never rely on natural decay alone.
* 7. Wire up to `presets/index.ts` (one import + one entry).
*/
export const myPreset: PresetEntry = {
id: "my-preset",
label: "My Preset",
description: "One-sentence description of when to use this sound.",
tags: ["ui"],
recipe: "sine 1 kHz · 100 ms",
motion: "bounce",
accent: "blue",
// author: "your-github-handle",
factory(ctx, master, opts) {
const t = ctx.currentTime
const o = ctx.createOscillator()
const g = ctx.createGain()
o.type = "sine"
o.frequency.setValueAtTime(1000, t)
const peak = 0.1 * callGain(opts)
g.gain.setValueAtTime(0.0001, t)
g.gain.linearRampToValueAtTime(peak, t + 0.005)
g.gain.exponentialRampToValueAtTime(0.0001, t + 0.1)
o.connect(g).connect(master)
o.start(t)
o.stop(t + 0.12)
return asHandle([o])
},
}