@biunow/agent-biutalk 0.0.0-stage → 1.1.1
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/bin/server.js +355 -0
- package/engine/AGENTS.md +1414 -0
- package/engine/CLAUDE.md +1 -0
- package/engine/LICENSE +21 -0
- package/engine/README.md +216 -0
- package/engine/bin/explainroo.js +19 -0
- package/engine/dev/audio-lab.mjs +268 -0
- package/engine/docs/media/contact-sheet.jpg +0 -0
- package/engine/docs/media/dns-poster.jpg +0 -0
- package/engine/docs/media/intro-poster.jpg +0 -0
- package/engine/docs/media/logo-dark.png +0 -0
- package/engine/docs/media/logo-light.png +0 -0
- package/engine/docs/media/looks-dark.webp +0 -0
- package/engine/docs/media/looks-light.webp +0 -0
- package/engine/docs/media/product-demo.webp +0 -0
- package/engine/docs/media/rebase-poster.jpg +0 -0
- package/engine/docs/media/sizes-dark.webp +0 -0
- package/engine/docs/media/sizes-light.webp +0 -0
- package/engine/engine/audio/dsp.js +69 -0
- package/engine/engine/audio/instruments.js +147 -0
- package/engine/engine/audio/music.js +576 -0
- package/engine/engine/audio/pcm.js +93 -0
- package/engine/engine/audio/rng.js +40 -0
- package/engine/engine/audio/sfx.js +287 -0
- package/engine/engine/audio/soundtrack.js +201 -0
- package/engine/engine/audio/synth.js +721 -0
- package/engine/engine/audio/theory.js +105 -0
- package/engine/engine/audio/wav.js +47 -0
- package/engine/engine/captions.js +131 -0
- package/engine/engine/clips.js +107 -0
- package/engine/engine/code.js +179 -0
- package/engine/engine/director.js +475 -0
- package/engine/engine/frame.html +135 -0
- package/engine/engine/icons/LICENSE-lucide.txt +43 -0
- package/engine/engine/icons/lucide-tags.json +1 -0
- package/engine/engine/icons/lucide.json +1 -0
- package/engine/engine/layout.js +69 -0
- package/engine/engine/pathdata.js +234 -0
- package/engine/engine/pen.js +240 -0
- package/engine/engine/player.html +67 -0
- package/engine/engine/player.js +219 -0
- package/engine/engine/readability.js +9 -0
- package/engine/engine/runtime.js +690 -0
- package/engine/engine/stage.js +2247 -0
- package/engine/engine/studio.html +216 -0
- package/engine/engine/text.js +81 -0
- package/engine/engine/themes.js +360 -0
- package/engine/engine/transitions.js +161 -0
- package/engine/engine/ui.js +1042 -0
- package/engine/engine/upload.js +32 -0
- package/engine/engine/util.js +204 -0
- package/engine/examples/callbacks-to-async-await/code-versions.js +34 -0
- package/engine/examples/callbacks-to-async-await/scenes.js +106 -0
- package/engine/examples/callbacks-to-async-await/script.md +22 -0
- package/engine/examples/callbacks-to-async-await/video.json +16 -0
- package/engine/examples/circle-area/scenes.js +228 -0
- package/engine/examples/circle-area/script.md +37 -0
- package/engine/examples/circle-area/video.json +14 -0
- package/engine/examples/explainroo-intro/scenes.js +133 -0
- package/engine/examples/explainroo-intro/script.md +27 -0
- package/engine/examples/explainroo-intro/video.json +8 -0
- package/engine/examples/how-dns-works/scenes.js +130 -0
- package/engine/examples/how-dns-works/script.md +28 -0
- package/engine/examples/how-dns-works/video.json +8 -0
- package/engine/examples/leap-years/scenes.js +156 -0
- package/engine/examples/leap-years/script.md +25 -0
- package/engine/examples/leap-years/video.json +16 -0
- package/engine/examples/leap-years-ja/scenes.js +194 -0
- package/engine/examples/leap-years-ja/script.md +32 -0
- package/engine/examples/leap-years-ja/video.json +17 -0
- package/engine/examples/merge-vs-rebase/scenes.js +129 -0
- package/engine/examples/merge-vs-rebase/script.md +22 -0
- package/engine/examples/merge-vs-rebase/video.json +8 -0
- package/engine/examples/password-storage-zh/scenes.js +185 -0
- package/engine/examples/password-storage-zh/script.md +25 -0
- package/engine/examples/password-storage-zh/video.json +19 -0
- package/engine/examples/sqlite-demo/README.md +19 -0
- package/engine/examples/sqlite-demo/scenes.js +423 -0
- package/engine/examples/sqlite-demo/script.md +35 -0
- package/engine/examples/sqlite-demo/video.json +17 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-400.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-500.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-600.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-700.woff2 +0 -0
- package/engine/examples/unspar-demo/assets/fonts/Figtree-OFL.txt +93 -0
- package/engine/examples/unspar-demo/assets/unspar-logo.svg +23 -0
- package/engine/examples/unspar-demo/scenes.js +367 -0
- package/engine/examples/unspar-demo/script.md +25 -0
- package/engine/examples/unspar-demo/video.json +21 -0
- package/engine/examples/why-is-the-sky-blue-es/scenes.js +160 -0
- package/engine/examples/why-is-the-sky-blue-es/script.md +22 -0
- package/engine/examples/why-is-the-sky-blue-es/video.json +15 -0
- package/engine/fonts/ArchitectsDaughter-400-latin-ext.woff2 +0 -0
- package/engine/fonts/ArchitectsDaughter-400-latin.woff2 +0 -0
- package/engine/fonts/CabinSketch-400-latin.woff2 +0 -0
- package/engine/fonts/CabinSketch-700-latin.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-italic-latin-ext.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-italic-latin.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-normal-latin-ext.woff2 +0 -0
- package/engine/fonts/InstrumentSerif-400-normal-latin.woff2 +0 -0
- package/engine/fonts/Inter-400-latin-ext.woff2 +0 -0
- package/engine/fonts/Inter-400-latin.woff2 +0 -0
- package/engine/fonts/JetBrainsMono-400-latin-ext.woff2 +0 -0
- package/engine/fonts/JetBrainsMono-400-latin.woff2 +0 -0
- package/engine/fonts/Kalam-400-latin-ext.woff2 +0 -0
- package/engine/fonts/Kalam-400-latin.woff2 +0 -0
- package/engine/fonts/Kalam-700-latin-ext.woff2 +0 -0
- package/engine/fonts/Kalam-700-latin.woff2 +0 -0
- package/engine/fonts/NotoSansDevanagari-400.ttf +0 -0
- package/engine/fonts/NotoSansDevanagari-700.ttf +0 -0
- package/engine/fonts/PatrickHand-400-latin-ext.woff2 +0 -0
- package/engine/fonts/PatrickHand-400-latin.woff2 +0 -0
- package/engine/fonts/PlusJakartaSans-600-latin-ext.woff2 +0 -0
- package/engine/fonts/PlusJakartaSans-600-latin.woff2 +0 -0
- package/engine/fonts/SpaceGrotesk-500-latin-ext.woff2 +0 -0
- package/engine/fonts/SpaceGrotesk-500-latin.woff2 +0 -0
- package/engine/fonts/fonts.json +216 -0
- package/engine/fonts/licenses/ArchitectsDaughter-OFL.txt +93 -0
- package/engine/fonts/licenses/CabinSketch-OFL.txt +93 -0
- package/engine/fonts/licenses/InstrumentSerif-OFL.txt +93 -0
- package/engine/fonts/licenses/Inter-OFL.txt +93 -0
- package/engine/fonts/licenses/JetBrainsMono-OFL.txt +93 -0
- package/engine/fonts/licenses/Kalam-OFL.txt +93 -0
- package/engine/fonts/licenses/NotoSansDevanagari-OFL.txt +118 -0
- package/engine/fonts/licenses/PatrickHand-OFL.txt +93 -0
- package/engine/fonts/licenses/PlusJakartaSans-OFL.txt +93 -0
- package/engine/fonts/licenses/SpaceGrotesk-OFL.txt +93 -0
- package/engine/package-lock.json +1201 -0
- package/engine/package.json +67 -0
- package/engine/scripts/build-icons.mjs +74 -0
- package/engine/scripts/fetch-fonts.mjs +68 -0
- package/engine/skills/explainroo/SKILL.md +51 -0
- package/engine/src/align.js +357 -0
- package/engine/src/browser.js +121 -0
- package/engine/src/capture.js +315 -0
- package/engine/src/chapters.js +32 -0
- package/engine/src/cli.js +421 -0
- package/engine/src/clips.js +19 -0
- package/engine/src/elevenlabs.js +90 -0
- package/engine/src/env.js +16 -0
- package/engine/src/export.js +187 -0
- package/engine/src/ffmpeg.js +103 -0
- package/engine/src/fonts.js +86 -0
- package/engine/src/g2p.py +76 -0
- package/engine/src/images.js +151 -0
- package/engine/src/licenses/misaki-Apache-2.0.txt +201 -0
- package/engine/src/math.js +83 -0
- package/engine/src/models.js +161 -0
- package/engine/src/phonemes.js +162 -0
- package/engine/src/pipeline.js +63 -0
- package/engine/src/project.js +331 -0
- package/engine/src/qa.js +186 -0
- package/engine/src/recordings.js +89 -0
- package/engine/src/render.js +156 -0
- package/engine/src/script.js +266 -0
- package/engine/src/server.js +288 -0
- package/engine/src/subtitles.js +78 -0
- package/engine/src/timeline.js +55 -0
- package/engine/src/voice.js +240 -0
- package/engine/src/wav.js +98 -0
- package/engine/templates/starter/scenes.js +31 -0
- package/engine/templates/starter/script.md +14 -0
- package/engine/test/align.test.js +108 -0
- package/engine/test/brand.test.js +41 -0
- package/engine/test/browser.test.js +89 -0
- package/engine/test/camera-browser.test.js +225 -0
- package/engine/test/caption-phrases.test.js +35 -0
- package/engine/test/capture-browser.test.js +90 -0
- package/engine/test/capture-fixture.js +46 -0
- package/engine/test/capture.test.js +62 -0
- package/engine/test/chapters.test.js +41 -0
- package/engine/test/cjk-browser.test.js +101 -0
- package/engine/test/cjk.test.js +232 -0
- package/engine/test/cli-exit.test.js +25 -0
- package/engine/test/cli.test.js +116 -0
- package/engine/test/clips-browser.test.js +125 -0
- package/engine/test/clips.test.js +67 -0
- package/engine/test/code-morph-browser.test.js +99 -0
- package/engine/test/code-morph.test.js +110 -0
- package/engine/test/contrast-browser.test.js +63 -0
- package/engine/test/contrast.test.js +80 -0
- package/engine/test/director.test.js +316 -0
- package/engine/test/engine-pure.test.js +29 -0
- package/engine/test/export-browser.test.js +224 -0
- package/engine/test/export.test.js +96 -0
- package/engine/test/fixtures/capture.html +55 -0
- package/engine/test/formats-pace.test.js +104 -0
- package/engine/test/languages-browser.test.js +78 -0
- package/engine/test/languages.test.js +140 -0
- package/engine/test/looks-browser.test.js +109 -0
- package/engine/test/looks-preview.test.js +57 -0
- package/engine/test/looks.test.js +130 -0
- package/engine/test/math-browser.test.js +114 -0
- package/engine/test/math.test.js +54 -0
- package/engine/test/multi-size-browser.test.js +133 -0
- package/engine/test/multi-size.test.js +116 -0
- package/engine/test/phonemes.test.js +92 -0
- package/engine/test/readability-browser.test.js +36 -0
- package/engine/test/readability.test.js +20 -0
- package/engine/test/render-options.test.js +52 -0
- package/engine/test/script.test.js +67 -0
- package/engine/test/server.test.js +256 -0
- package/engine/test/stills-browser.test.js +70 -0
- package/engine/test/subtitles.test.js +83 -0
- package/engine/test/timeline.test.js +31 -0
- package/engine/test/transparent-browser.test.js +123 -0
- package/engine/test/ui-kit.test.js +96 -0
- package/engine/test/upload-browser.test.js +55 -0
- package/engine/test/voice-providers.test.js +338 -0
- package/lib/host.mjs +480 -0
- package/manifest.json +54 -0
- package/package.json +8 -4
- package/skills/biutalk/SKILL.md +21 -0
- package/studio/app.js +209 -0
- package/studio/assert-panel-permit.mjs +67 -0
- package/studio/composer.css +354 -0
- package/studio/composer.js +169 -0
- package/studio/index.html +82 -0
- package/studio/looks/blueprint.svg +21 -0
- package/studio/looks/chalk.svg +15 -0
- package/studio/looks/clean.svg +20 -0
- package/studio/looks/editorial.svg +18 -0
- package/studio/looks/midnight.svg +17 -0
- package/studio/looks/paper.svg +11 -0
- package/studio/select-menu.js +268 -0
- package/studio/styles.css +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Seeded randomness. The audio engine never calls Math.random, so the same
|
|
2
|
+
// inputs always render the same samples.
|
|
3
|
+
|
|
4
|
+
export function mulberry32(seed) {
|
|
5
|
+
let a = seed >>> 0;
|
|
6
|
+
return function next() {
|
|
7
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
8
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
9
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
10
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// FNV-1a over the string form of every part, so seeds can be built from
|
|
15
|
+
// names, times and indices.
|
|
16
|
+
export function hashSeed(...parts) {
|
|
17
|
+
let h = 2166136261 >>> 0;
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
const s = String(part);
|
|
20
|
+
for (let i = 0; i < s.length; i++) {
|
|
21
|
+
h ^= s.charCodeAt(i);
|
|
22
|
+
h = Math.imul(h, 16777619);
|
|
23
|
+
}
|
|
24
|
+
h ^= 0x2f;
|
|
25
|
+
h = Math.imul(h, 16777619);
|
|
26
|
+
}
|
|
27
|
+
return h >>> 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function makeRng(seed) {
|
|
31
|
+
const next = mulberry32(seed);
|
|
32
|
+
return {
|
|
33
|
+
next,
|
|
34
|
+
range: (lo, hi) => lo + (hi - lo) * next(),
|
|
35
|
+
int: (lo, hi) => lo + Math.floor(next() * (hi - lo + 1)),
|
|
36
|
+
pick: (list) => list[Math.floor(next() * list.length)],
|
|
37
|
+
chance: (p) => next() < p,
|
|
38
|
+
jitter: (amount) => (next() * 2 - 1) * amount,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// Synthesized sound effects. Each effect adds voices to a stereo Synth lane;
|
|
2
|
+
// `p.amp` already includes the per-effect trim, the cue gain and sfxVolume.
|
|
3
|
+
import { Voice, Env, WAVES } from './synth.js';
|
|
4
|
+
import { mtof, dbToGain } from './dsp.js';
|
|
5
|
+
import { pentaNote } from './theory.js';
|
|
6
|
+
import { makeRng, hashSeed } from './rng.js';
|
|
7
|
+
|
|
8
|
+
const perc = (t, peak, attack, tau) => new Env(0).set(0, t).lin(peak, t + attack).target(0, t + attack, tau);
|
|
9
|
+
const seedOf = (rng) => Math.floor(rng.next() * 4294967295) || 1;
|
|
10
|
+
|
|
11
|
+
// Bell-like ping with a few inharmonic partials.
|
|
12
|
+
const PING = [[1, 1, 1], [2, 0.35, 0.55], [2.76, 0.2, 0.4], [5.4, 0.08, 0.2]];
|
|
13
|
+
|
|
14
|
+
function ping(syn, lane, t, midi, peak, decay, { partials = PING, pan = 0 } = {}) {
|
|
15
|
+
const f = mtof(midi);
|
|
16
|
+
const parts = partials.filter(([ratio]) => f * ratio < 16000);
|
|
17
|
+
const v = new Voice(t, t + (decay / 4) * 7 + 0.02);
|
|
18
|
+
for (const [ratio, amp, df] of parts) v.layer({ wave: WAVES.sine, freq: f * ratio, amp: perc(t, peak * amp, 0.0015, (decay * df) / 4) });
|
|
19
|
+
v.pan = pan;
|
|
20
|
+
syn.add(lane, v);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function noiseBurst(syn, lane, t, peak, tau, rng, { type = 'highpass', freq = 3000, q = 0.8, pink = false, attack = 0.0008, pan = 0 } = {}) {
|
|
24
|
+
const v = new Voice(t, t + attack + tau * 7 + 0.01);
|
|
25
|
+
v.layer({ wave: pink ? WAVES.pink : WAVES.noise, seed: seedOf(rng), amp: perc(t, peak, attack, tau) });
|
|
26
|
+
v.filter = { type, freq, q };
|
|
27
|
+
v.pan = pan;
|
|
28
|
+
syn.add(lane, v);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function tone(syn, lane, t, wave, freq, peak, attack, tau, { freqEnv = null, pan = 0, length } = {}) {
|
|
32
|
+
const v = new Voice(t, t + (length ?? attack + tau * 7 + 0.01));
|
|
33
|
+
v.layer({ wave, freq, freqEnv, amp: perc(t, peak, attack, tau) });
|
|
34
|
+
v.pan = pan;
|
|
35
|
+
syn.add(lane, v);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Felt-marker / chalk strokes: one filtered noise voice whose gain and centre
|
|
39
|
+
// frequency are automated stroke by stroke.
|
|
40
|
+
function strokes(syn, lane, t, p, { dur, band, q, pink, grain, squeak }) {
|
|
41
|
+
const rng = p.rng;
|
|
42
|
+
const amp = new Env(0).set(0, t);
|
|
43
|
+
const freq = new Env(band[0]).set(band[0], t);
|
|
44
|
+
const end = t + dur;
|
|
45
|
+
const squeaks = [];
|
|
46
|
+
let s = t;
|
|
47
|
+
while (s < end - 0.04) {
|
|
48
|
+
const len = Math.min(end - s, rng.range(0.09, 0.22));
|
|
49
|
+
const peak = p.amp * rng.range(0.7, 1);
|
|
50
|
+
const f0 = rng.range(band[0], band[1]);
|
|
51
|
+
freq.set(f0, s).lin(f0 * rng.range(0.8, 1.25), s + len);
|
|
52
|
+
amp.set(0, s).lin(peak, s + 0.018);
|
|
53
|
+
if (grain) {
|
|
54
|
+
for (let x = s + 0.03; x < s + len - 0.03; x += rng.range(0.012, 0.025)) amp.lin(peak * rng.range(0.35, 1), x);
|
|
55
|
+
} else {
|
|
56
|
+
amp.lin(peak * rng.range(0.75, 0.95), s + len - 0.022);
|
|
57
|
+
}
|
|
58
|
+
amp.lin(0, s + len);
|
|
59
|
+
if (squeak && rng.chance(0.25)) squeaks.push([s + rng.range(0.02, Math.max(0.03, len - 0.08)), rng.range(2600, 3400)]);
|
|
60
|
+
s += len + rng.range(0.02, 0.05);
|
|
61
|
+
}
|
|
62
|
+
const v = new Voice(t, end + 0.05);
|
|
63
|
+
v.layer({ wave: pink ? WAVES.pink : WAVES.noise, seed: seedOf(rng), amp });
|
|
64
|
+
v.filter = { type: 'bandpass', q, freqEnv: freq };
|
|
65
|
+
v.pan = rng.range(-0.15, 0.15);
|
|
66
|
+
syn.add(lane, v);
|
|
67
|
+
for (const [at, f] of squeaks) {
|
|
68
|
+
const sv = new Voice(at, at + 0.2);
|
|
69
|
+
sv.layer({ wave: WAVES.sine, freqEnv: new Env(f).set(f, at).lin(f * rng.range(0.9, 1.1), at + 0.06), amp: perc(at, p.amp * 0.18, 0.01, 0.025) });
|
|
70
|
+
syn.add(lane, sv);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Filtered-noise sweep panned across the stereo field.
|
|
75
|
+
function sweep(syn, lane, t, p, { dur, from, to, back, q, panFrom, panTo, peakAt = 0.55 }) {
|
|
76
|
+
const v = new Voice(t, t + dur * 1.6 + 0.05);
|
|
77
|
+
v.layer({
|
|
78
|
+
wave: WAVES.pink,
|
|
79
|
+
seed: seedOf(p.rng),
|
|
80
|
+
amp: new Env(0).set(0.0001, t).exp(p.amp, t + dur * peakAt).target(0, t + dur * peakAt, dur * 0.18),
|
|
81
|
+
});
|
|
82
|
+
v.filter = { type: 'bandpass', q, freqEnv: new Env(from).set(from, t).exp(to, t + dur * 0.7).exp(back, t + dur) };
|
|
83
|
+
v.panEnv = new Env(panFrom).set(panFrom, t).lin(panTo, t + dur);
|
|
84
|
+
syn.add(lane, v);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// name -> { description, trimDb, dur (default), play(syn, lane, t, p) }
|
|
88
|
+
// trimDb calibrates each effect's peak at gain 1: short effects about -18 dBFS,
|
|
89
|
+
// textures (whoosh, scribble, chalk, type) a few dB lower, i.e. roughly
|
|
90
|
+
// 11 dB under Kokoro narration peaks.
|
|
91
|
+
export const SFX_DEFS = {
|
|
92
|
+
pop: {
|
|
93
|
+
description: 'Short round pop for things appearing (boxes, icons, labels).',
|
|
94
|
+
trimDb: -20.1,
|
|
95
|
+
play(syn, lane, t, p) {
|
|
96
|
+
const f0 = p.rng.range(360, 420);
|
|
97
|
+
tone(syn, lane, t, WAVES.sine, 0, p.amp, 0.002, 0.03, { freqEnv: new Env(f0).set(f0, t).exp(p.rng.range(780, 880), t + 0.045), length: 0.3 });
|
|
98
|
+
noiseBurst(syn, lane, t, p.amp * 0.25, 0.004, p.rng, { freq: 2500 });
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
click: {
|
|
102
|
+
description: 'Tiny UI click (buttons, toggles, cursor clicks).',
|
|
103
|
+
trimDb: -19.6,
|
|
104
|
+
play(syn, lane, t, p) {
|
|
105
|
+
noiseBurst(syn, lane, t, p.amp, 0.003, p.rng, { type: 'bandpass', freq: 3500, q: 1 });
|
|
106
|
+
tone(syn, lane, t, WAVES.sine, 1800, p.amp * 0.5, 0.0005, 0.004);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
whoosh: {
|
|
110
|
+
description: 'Airy whoosh for movement, arrows and slides (dur, default 0.45 s).',
|
|
111
|
+
trimDb: -12.9,
|
|
112
|
+
dur: 0.45,
|
|
113
|
+
play(syn, lane, t, p) {
|
|
114
|
+
sweep(syn, lane, t, p, { dur: p.dur, from: 350, to: 2600, back: 1300, q: 1.1, panFrom: -0.55, panTo: 0.55 });
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
swipe: {
|
|
118
|
+
description: 'Wider, deeper whoosh for scene transitions (dur, default 0.6 s).',
|
|
119
|
+
trimDb: -16.1,
|
|
120
|
+
dur: 0.6,
|
|
121
|
+
play(syn, lane, t, p) {
|
|
122
|
+
sweep(syn, lane, t, p, { dur: p.dur, from: 200, to: 4200, back: 1500, q: 0.8, panFrom: -0.8, panTo: 0.8 });
|
|
123
|
+
const v = new Voice(t, t + p.dur * 1.6);
|
|
124
|
+
v.layer({
|
|
125
|
+
wave: WAVES.sine,
|
|
126
|
+
freqEnv: new Env(90).set(90, t).exp(55, t + p.dur),
|
|
127
|
+
amp: new Env(0).set(0.0001, t).exp(p.amp * 0.35, t + p.dur * 0.5).target(0, t + p.dur * 0.5, p.dur * 0.2),
|
|
128
|
+
});
|
|
129
|
+
syn.add(lane, v);
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
tick: {
|
|
133
|
+
description: 'Single crisp tick (count-ups, typing, clock hands).',
|
|
134
|
+
trimDb: -21.1,
|
|
135
|
+
play(syn, lane, t, p) {
|
|
136
|
+
noiseBurst(syn, lane, t, p.amp * 0.7, 0.0018, p.rng, { freq: 3500 });
|
|
137
|
+
tone(syn, lane, t, WAVES.sine, 2800 * p.rng.range(0.94, 1.06), p.amp * 0.5, 0.0005, 0.005);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
type: {
|
|
141
|
+
description: 'Keyboard typing burst (dur, default 0.8 s).',
|
|
142
|
+
trimDb: -20.5,
|
|
143
|
+
dur: 0.8,
|
|
144
|
+
play(syn, lane, t, p) {
|
|
145
|
+
const rng = p.rng;
|
|
146
|
+
let k = t;
|
|
147
|
+
let n = 0;
|
|
148
|
+
while (k < t + p.dur) {
|
|
149
|
+
const space = n > 0 && n % 6 === 5;
|
|
150
|
+
const v = p.amp * rng.range(0.6, 1);
|
|
151
|
+
const pan = rng.range(-0.2, 0.2);
|
|
152
|
+
noiseBurst(syn, lane, k, v, 0.006, rng, { type: 'bandpass', freq: space ? 1800 : rng.range(2300, 3900), q: 1.4, pan });
|
|
153
|
+
tone(syn, lane, k, WAVES.sine, space ? 140 : rng.range(170, 215), v * 0.45, 0.001, 0.012, { pan });
|
|
154
|
+
k += rng.range(0.045, 0.11);
|
|
155
|
+
n++;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
ding: {
|
|
160
|
+
description: 'Clear bell ding on the tonic (a highlight or a correct answer).',
|
|
161
|
+
trimDb: -21,
|
|
162
|
+
play(syn, lane, t, p) {
|
|
163
|
+
ping(syn, lane, t, p.tonic + 24, p.amp, 1.4);
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
chime: {
|
|
167
|
+
description: 'Two-note rising chime (success, done, reveal).',
|
|
168
|
+
trimDb: -24.4,
|
|
169
|
+
play(syn, lane, t, p) {
|
|
170
|
+
ping(syn, lane, t, p.tonic + 19, p.amp * 0.85, 1.2, { pan: -0.15 });
|
|
171
|
+
ping(syn, lane, t + 0.11, p.tonic + 24, p.amp, 1.6, { pan: 0.15 });
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
thud: {
|
|
175
|
+
description: 'Soft low thud (something lands, a heavy point).',
|
|
176
|
+
trimDb: -17,
|
|
177
|
+
play(syn, lane, t, p) {
|
|
178
|
+
tone(syn, lane, t, WAVES.sine, 0, p.amp, 0.002, 0.09, { freqEnv: new Env(110).set(110, t).exp(42, t + 0.18), length: 0.7 });
|
|
179
|
+
noiseBurst(syn, lane, t, p.amp * 0.3, 0.03, p.rng, { type: 'lowpass', freq: 400 });
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
scribble: {
|
|
183
|
+
description: 'Felt marker on paper while something is drawn (dur, default 0.6 s).',
|
|
184
|
+
trimDb: -15.9,
|
|
185
|
+
dur: 0.6,
|
|
186
|
+
play(syn, lane, t, p) {
|
|
187
|
+
strokes(syn, lane, t, p, { dur: p.dur, band: [1500, 2700], q: 1.3, pink: true, grain: false, squeak: false });
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
chalk: {
|
|
191
|
+
description: 'Chalk on a blackboard while something is drawn (dur, default 0.6 s).',
|
|
192
|
+
trimDb: -22.3,
|
|
193
|
+
dur: 0.6,
|
|
194
|
+
play(syn, lane, t, p) {
|
|
195
|
+
strokes(syn, lane, t, p, { dur: p.dur, band: [2800, 4800], q: 0.9, pink: false, grain: true, squeak: true });
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
rise: {
|
|
199
|
+
description: 'Riser that builds from t and ends at t + dur (default 1 s) for a big reveal.',
|
|
200
|
+
trimDb: -18.3,
|
|
201
|
+
dur: 1,
|
|
202
|
+
play(syn, lane, t, p) {
|
|
203
|
+
const end = t + p.dur;
|
|
204
|
+
const nv = new Voice(t, end + 0.05);
|
|
205
|
+
nv.layer({ wave: WAVES.pink, seed: seedOf(p.rng), amp: new Env(0).set(0.0001, t).exp(p.amp, end).lin(0, end + 0.03) });
|
|
206
|
+
nv.filter = { type: 'bandpass', q: 1.6, freqEnv: new Env(300).set(300, t).exp(7000, end) };
|
|
207
|
+
syn.add(lane, nv);
|
|
208
|
+
const sv = new Voice(t, end + 0.05);
|
|
209
|
+
for (const d of [-9, 9]) {
|
|
210
|
+
sv.layer({
|
|
211
|
+
wave: WAVES.saw,
|
|
212
|
+
detune: d,
|
|
213
|
+
freqEnv: new Env(mtof(p.tonic - 12)).set(mtof(p.tonic - 12), t).exp(mtof(p.tonic + 12), end),
|
|
214
|
+
amp: new Env(0).set(0.0001, t).exp(p.amp * 0.3, end).lin(0, end + 0.03),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
sv.filter = { type: 'lowpass', q: 1.4, freqEnv: new Env(400).set(400, t).exp(6000, end) };
|
|
218
|
+
syn.add(lane, sv);
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
sparkle: {
|
|
222
|
+
description: 'Cluster of high bell pings (magic, delight, something new).',
|
|
223
|
+
trimDb: -26.3,
|
|
224
|
+
play(syn, lane, t, p) {
|
|
225
|
+
const rng = p.rng;
|
|
226
|
+
let at = t;
|
|
227
|
+
for (let k = 0; k < 6; k++) {
|
|
228
|
+
ping(syn, lane, at, pentaNote(p.tonic + 24, rng.int(0, 6)), p.amp * Math.pow(0.85, k), rng.range(0.5, 0.8), {
|
|
229
|
+
partials: [[1, 1, 1], [2.76, 0.2, 0.4], [5.4, 0.1, 0.2]],
|
|
230
|
+
pan: rng.range(-0.7, 0.7),
|
|
231
|
+
});
|
|
232
|
+
at += rng.range(0.035, 0.07);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
blip: {
|
|
237
|
+
description: "Short pitched blip; pitch = step in the key's pentatonic scale, so list items can ascend.",
|
|
238
|
+
trimDb: -19.4,
|
|
239
|
+
play(syn, lane, t, p) {
|
|
240
|
+
const f = mtof(pentaNote(p.tonic + 12, Math.round(p.pitch || 0)));
|
|
241
|
+
const v = new Voice(t, t + 0.4);
|
|
242
|
+
v.layer({ wave: WAVES.tri, freqEnv: new Env(f * 0.94).set(f * 0.94, t).exp(f, t + 0.015), amp: perc(t, p.amp, 0.002, 0.05) });
|
|
243
|
+
v.layer({ wave: WAVES.sine, freq: f * 2, amp: perc(t, p.amp * 0.25, 0.002, 0.025) });
|
|
244
|
+
syn.add(lane, v);
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
error: {
|
|
248
|
+
description: 'Soft low double buzz (wrong, blocked, failure).',
|
|
249
|
+
trimDb: -23.9,
|
|
250
|
+
play(syn, lane, t, p) {
|
|
251
|
+
const v = new Voice(t, t + 0.35);
|
|
252
|
+
for (const f of [110, 116.5]) {
|
|
253
|
+
const amp = new Env(0).set(0, t);
|
|
254
|
+
for (const s of [t, t + 0.17]) amp.set(0, s).lin(p.amp, s + 0.01).set(p.amp, s + 0.1).lin(0, s + 0.12);
|
|
255
|
+
v.layer({ wave: WAVES.saw, freq: f, amp });
|
|
256
|
+
}
|
|
257
|
+
v.filter = { type: 'lowpass', freq: 700, q: 0.8 };
|
|
258
|
+
syn.add(lane, v);
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export const SFX_INFO = Object.fromEntries(Object.entries(SFX_DEFS).map(([k, d]) => [k, d.description]));
|
|
264
|
+
|
|
265
|
+
export function validateSfx(cues) {
|
|
266
|
+
for (const cue of cues) {
|
|
267
|
+
if (!cue || !SFX_DEFS[cue.name]) {
|
|
268
|
+
throw new Error(`Unknown sound effect "${cue && cue.name}". Valid names: ${Object.keys(SFX_DEFS).join(', ')}`);
|
|
269
|
+
}
|
|
270
|
+
if (!Number.isFinite(Number(cue.t))) throw new Error(`Sound effect "${cue.name}" needs a numeric time t`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Adds every cue to `lane` (a stereo lane). `tonic` is a MIDI note in the key.
|
|
275
|
+
export function scheduleSfx(syn, lane, cues, { tonic = 60, volume = 1, duration = Infinity } = {}) {
|
|
276
|
+
cues.forEach((cue, index) => {
|
|
277
|
+
const def = SFX_DEFS[cue.name];
|
|
278
|
+
const t = Math.max(0, Number(cue.t));
|
|
279
|
+
if (t >= duration) return;
|
|
280
|
+
const gain = cue.gain == null ? 1 : Math.max(0, Number(cue.gain));
|
|
281
|
+
const amp = dbToGain(def.trimDb) * gain * volume;
|
|
282
|
+
if (amp <= 0) return;
|
|
283
|
+
const dur = Math.max(0.05, Number(cue.dur) || def.dur || 0.5);
|
|
284
|
+
const rng = makeRng(hashSeed('sfx', cue.name, t.toFixed(4), index));
|
|
285
|
+
def.play(syn, lane, t, { amp, dur, pitch: cue.pitch, rng, tonic });
|
|
286
|
+
});
|
|
287
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Soundtrack renderer: narration, generated music and synthesized sound
|
|
2
|
+
// effects mixed into one stereo AudioBuffer. Synthesis is plain JavaScript
|
|
3
|
+
// (see synth.js), so the same input always gives the same samples, in a page
|
|
4
|
+
// (headless Chrome for final renders, the preview page for playback) or in Node.
|
|
5
|
+
import { dbToGain, limitInPlace, fadeEdges } from './dsp.js';
|
|
6
|
+
import { BLOCK, Synth, Env, Compressor } from './synth.js';
|
|
7
|
+
import { createMusic, musicPlan, STYLE_INFO } from './music.js';
|
|
8
|
+
import { scheduleSfx, validateSfx, SFX_INFO } from './sfx.js';
|
|
9
|
+
import { parseWav, toMono, resample } from './pcm.js';
|
|
10
|
+
import { encodeWav } from './wav.js';
|
|
11
|
+
|
|
12
|
+
export { encodeWav, musicPlan };
|
|
13
|
+
|
|
14
|
+
export const MUSIC_STYLES = Object.fromEntries(Object.entries(STYLE_INFO).map(([k, v]) => [k, v.description]));
|
|
15
|
+
export const SFX = { ...SFX_INFO };
|
|
16
|
+
|
|
17
|
+
// Mix calibration (measured against Kokoro narration, which lands near
|
|
18
|
+
// -20 LUFS as stereo): at volume 0.5 the music bed sits about 12 LU under the
|
|
19
|
+
// voice and ducks a further 8 dB while someone talks; short effects peak about
|
|
20
|
+
// 11 dB under voice peaks.
|
|
21
|
+
const MUSIC_BASE_DB = 0;
|
|
22
|
+
const DUCK_DB = -8;
|
|
23
|
+
const DUCK_ATTACK = 0.2;
|
|
24
|
+
const DUCK_RELEASE = 0.5;
|
|
25
|
+
const SFX_BASE_DB = 0;
|
|
26
|
+
|
|
27
|
+
async function loadVoice(v, sr, cache) {
|
|
28
|
+
if (v.buffer) {
|
|
29
|
+
const b = v.buffer;
|
|
30
|
+
const chans = [];
|
|
31
|
+
for (let c = 0; c < b.numberOfChannels; c++) chans.push(b.getChannelData(c));
|
|
32
|
+
return resample(toMono(chans), b.sampleRate, sr);
|
|
33
|
+
}
|
|
34
|
+
if (v.data) return resample(v.data, v.sampleRate || sr, sr);
|
|
35
|
+
if (!v.url) throw new Error('voice entries need url, buffer or data');
|
|
36
|
+
if (!cache.has(v.url)) {
|
|
37
|
+
cache.set(
|
|
38
|
+
v.url,
|
|
39
|
+
(async () => {
|
|
40
|
+
const res = await fetch(v.url);
|
|
41
|
+
if (!res.ok) throw new Error(`Could not load voice audio ${v.url} (HTTP ${res.status})`);
|
|
42
|
+
const ab = await res.arrayBuffer();
|
|
43
|
+
try {
|
|
44
|
+
const wav = parseWav(ab);
|
|
45
|
+
return resample(toMono(wav.channels), wav.sampleRate, sr);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (typeof OfflineAudioContext === 'undefined') throw err;
|
|
48
|
+
const decoded = await new OfflineAudioContext(1, 1, sr).decodeAudioData(ab);
|
|
49
|
+
return decoded.getChannelData(0);
|
|
50
|
+
}
|
|
51
|
+
})(),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return cache.get(v.url);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Merge narration spans that are too close to release the music in between.
|
|
58
|
+
function mergeSpans(spans) {
|
|
59
|
+
const gap = DUCK_ATTACK + DUCK_RELEASE + 0.1;
|
|
60
|
+
const sorted = spans
|
|
61
|
+
.map((s) => ({ start: Number(s.start), end: Number(s.end) }))
|
|
62
|
+
.filter((s) => Number.isFinite(s.start) && Number.isFinite(s.end) && s.end > s.start)
|
|
63
|
+
.sort((a, b) => a.start - b.start);
|
|
64
|
+
const merged = [];
|
|
65
|
+
for (const s of sorted) {
|
|
66
|
+
const last = merged[merged.length - 1];
|
|
67
|
+
if (last && s.start - last.end < gap) last.end = Math.max(last.end, s.end);
|
|
68
|
+
else merged.push({ ...s });
|
|
69
|
+
}
|
|
70
|
+
return merged;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function duckEnv(spans) {
|
|
74
|
+
const low = dbToGain(DUCK_DB);
|
|
75
|
+
const e = new Env(1).set(1, 0);
|
|
76
|
+
for (const s of mergeSpans(spans)) {
|
|
77
|
+
const a0 = Math.max(0, s.start - DUCK_ATTACK);
|
|
78
|
+
e.set(1, a0).lin(low, Math.max(a0 + 0.001, s.start)).set(low, s.end).lin(1, s.end + DUCK_RELEASE);
|
|
79
|
+
}
|
|
80
|
+
return e;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function levelEnv(level, duration) {
|
|
84
|
+
const fadeIn = Math.min(1.5, duration * 0.25);
|
|
85
|
+
const fadeOut = Math.min(0.35, duration * 0.1);
|
|
86
|
+
return new Env(0).set(0, 0).lin(level, fadeIn).set(level, Math.max(fadeIn, duration - fadeOut)).lin(0, duration);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function toAudioBuffer(L, R, sampleRate) {
|
|
90
|
+
if (typeof AudioBuffer !== 'undefined') {
|
|
91
|
+
const buf = new AudioBuffer({ length: L.length, numberOfChannels: 2, sampleRate });
|
|
92
|
+
buf.copyToChannel(L, 0);
|
|
93
|
+
buf.copyToChannel(R, 1);
|
|
94
|
+
return buf;
|
|
95
|
+
}
|
|
96
|
+
const chans = [L, R];
|
|
97
|
+
return { sampleRate, length: L.length, numberOfChannels: 2, duration: L.length / sampleRate, getChannelData: (c) => chans[c] };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Renders one synth into (L, R), optionally through a compressor and gain curves.
|
|
101
|
+
function renderInto(syn, L, R, { compressor = null, gains = [] } = {}) {
|
|
102
|
+
const n = L.length;
|
|
103
|
+
const bl = new Float32Array(BLOCK);
|
|
104
|
+
const br = new Float32Array(BLOCK);
|
|
105
|
+
const g = gains.map(() => new Float32Array(BLOCK));
|
|
106
|
+
gains.forEach((e) => e.begin(syn.sr, 0));
|
|
107
|
+
for (let i0 = 0; i0 < n; i0 += BLOCK) {
|
|
108
|
+
const cnt = Math.min(BLOCK, n - i0);
|
|
109
|
+
bl.fill(0);
|
|
110
|
+
br.fill(0);
|
|
111
|
+
syn.renderBlock(i0, cnt, bl, br);
|
|
112
|
+
if (compressor) compressor.process(bl, br, cnt);
|
|
113
|
+
gains.forEach((e, j) => e.fill(g[j], cnt));
|
|
114
|
+
for (let k = 0; k < cnt; k++) {
|
|
115
|
+
let m = 1;
|
|
116
|
+
for (let j = 0; j < g.length; j++) m *= g[j][k];
|
|
117
|
+
L[i0 + k] += bl[k] * m;
|
|
118
|
+
R[i0 + k] += br[k] * m;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function renderSoundtrack(opts = {}) {
|
|
124
|
+
const {
|
|
125
|
+
duration,
|
|
126
|
+
sampleRate = 48000,
|
|
127
|
+
voice = [],
|
|
128
|
+
voiceSpans = [],
|
|
129
|
+
clips = [],
|
|
130
|
+
music = null,
|
|
131
|
+
sfx = [],
|
|
132
|
+
scenes = [],
|
|
133
|
+
sfxVolume = 1,
|
|
134
|
+
} = opts;
|
|
135
|
+
if (!Number.isFinite(duration) || duration <= 0) {
|
|
136
|
+
throw new Error('renderSoundtrack: duration must be a positive number of seconds');
|
|
137
|
+
}
|
|
138
|
+
validateSfx(sfx);
|
|
139
|
+
const plan = music ? musicPlan(music) : null; // throws early on a bad style or key
|
|
140
|
+
|
|
141
|
+
const sr = sampleRate;
|
|
142
|
+
const length = Math.max(1, Math.ceil(duration * sr));
|
|
143
|
+
const L = new Float32Array(length);
|
|
144
|
+
const R = new Float32Array(length);
|
|
145
|
+
|
|
146
|
+
// narration: straight into the mix, unprocessed
|
|
147
|
+
const cache = new Map();
|
|
148
|
+
for (const v of voice) {
|
|
149
|
+
const data = await loadVoice(v, sr, cache);
|
|
150
|
+
const gain = v.gain == null ? 1 : Number(v.gain);
|
|
151
|
+
const at = Math.round((Number(v.start) || 0) * sr);
|
|
152
|
+
const from = Math.max(0, -at);
|
|
153
|
+
const to = Math.min(data.length, length - at);
|
|
154
|
+
for (let i = from; i < to; i++) {
|
|
155
|
+
const s = data[i] * gain;
|
|
156
|
+
L[at + i] += s;
|
|
157
|
+
R[at + i] += s;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const clipSpans = [];
|
|
162
|
+
for (const clip of clips) {
|
|
163
|
+
if (clip.speed !== 1 || clip.volume <= 0) continue;
|
|
164
|
+
const data = await loadVoice(clip, sr, cache);
|
|
165
|
+
const clipLength = Math.max(1, Math.round(clip.duration * sr));
|
|
166
|
+
const start = Math.round(clip.start * sr);
|
|
167
|
+
const end = Math.min(length, Math.round(clip.end * sr));
|
|
168
|
+
const offset = Math.round(clip.from * sr);
|
|
169
|
+
for (let i = Math.max(0, start); i < end; i++) {
|
|
170
|
+
let source = offset + i - start;
|
|
171
|
+
if (clip.loop) source %= clipLength;
|
|
172
|
+
if (source >= clipLength) break;
|
|
173
|
+
const sample = (data[source] || 0) * clip.volume;
|
|
174
|
+
L[i] += sample;
|
|
175
|
+
R[i] += sample;
|
|
176
|
+
}
|
|
177
|
+
if (end > Math.max(0, start)) clipSpans.push({ start: Math.max(0, clip.start), end: end / sr });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// music: glue compressor, level with fades, ducked under narration
|
|
181
|
+
if (plan) {
|
|
182
|
+
const { synth } = createMusic({ ...music, style: plan.style, seed: plan.seed, bpm: plan.bpm, key: plan.keyRoot, duration, scenes, sampleRate: sr });
|
|
183
|
+
const volume = Math.max(0, Math.min(2, music.volume == null ? 0.5 : Number(music.volume)));
|
|
184
|
+
renderInto(synth, L, R, {
|
|
185
|
+
compressor: new Compressor(sr, { threshold: -18, ratio: 2, knee: 10, attack: 0.02, release: 0.3 }),
|
|
186
|
+
gains: [levelEnv(dbToGain(MUSIC_BASE_DB + plan.mixDb) * (volume / 0.5), duration), duckEnv([...voiceSpans, ...clipSpans])],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// sound effects with a little room, pitched ones in the music key
|
|
191
|
+
if (sfx.length) {
|
|
192
|
+
const syn = new Synth(sr, length, { reverb: { room: 0.45, damp: 0.5, preDelay: 0.006, lowCut: 300 }, reverbLevel: 0.25 });
|
|
193
|
+
const lane = syn.lane({ stereo: true, reverb: 1 });
|
|
194
|
+
scheduleSfx(syn, lane, sfx, { tonic: 60 + (plan ? plan.keyRoot : 0), duration, volume: dbToGain(SFX_BASE_DB) * Math.max(0, Number(sfxVolume)) });
|
|
195
|
+
renderInto(syn, L, R);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
limitInPlace([L, R], sr, { ceilingDb: -1 });
|
|
199
|
+
fadeEdges([L, R], sr);
|
|
200
|
+
return toAudioBuffer(L, R, sr);
|
|
201
|
+
}
|