// Node-only: WAV -> analysis -> song. The browser does the same with a // decoded AudioBuffer; this keeps the tools honest about the same pipeline. import { readFileSync } from 'node:fs'; import { decodeWav, mono } from '../src/audio/wav.js'; import { analyse } from '../src/audio/analyse.js'; import { buildSong } from '../src/song/song.js'; export function loadSong(path, { fps = 30, seed = 12345 } = {}) { const wav = decodeWav(readFileSync(path)); if (!wav) throw new Error(`not a WAV: ${path}`); const pcm = mono(wav.channels); const analysis = analyse(pcm, wav.sampleRate, { fps }); const song = buildSong(analysis, seed); return { pcm, sampleRate: wav.sampleRate, analysis, song, name: path.split('/').pop().replace(/\.wav$/i, '') }; }