fix: tempo octave choice, start-of-music anchoring, mean-normalised combs, pure toMono

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Sonnet 5.5 committed 2026-10-30 04:46:09 +01:00
1 parent 4ab92d4a86
commit 1d490f6897
4 files changed
+194 -99

No files matched your search

+1 -10
View File
@@ -67,16 +67,7 @@ export async function writeWav(path: string, a: Audio): Promise<void> {
await Bun.write(path, out);
}
/** Average all channels into one mono signal. */
export function toMono(a: Audio): Float32Array {
const n = a.channels[0]?.length ?? 0;
if (a.channels.length === 1) return a.channels[0]!.slice();
const out = new Float32Array(n);
for (const ch of a.channels) for (let i = 0; i < n; i++) out[i]! += ch[i]!;
const k = 1 / a.channels.length;
for (let i = 0; i < n; i++) out[i]! *= k;
return out;
}
export { toMono } from "../dsp/mono.ts";
const sinc = (x: number) => (x === 0 ? 1 : Math.sin(Math.PI * x) / (Math.PI * x));