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:
1 parent
4ab92d4a86
commit
1d490f6897
4 files changed
+194
-99
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// Pure channel downmix. Re-exported from src/audio/wav.ts for existing importers.
|
||||
import type { Audio } from "../core/types.ts";
|
||||
|
||||
/** 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;
|
||||
}
|
||||
Reference in new issue
Block a user