else if (m.kind === "stopped") end("render stopped · nothing was saved"); else if (m.kind === "error") end("the render stopped: " + m.msg); }; window.addEventListener("message", RJ.on); document.body.appendChild(fr); place(); RJ.wait = setTimeout(() => end("the fresh copy of the board did not open, so nothing was made"), 20000); }; const songIn = document.getElementById("songIn"), loadBtn = document.getElementById("load"), songLbl = document.getElementById("song"); loadBtn.onclick = () => songIn.click(); songIn.onchange = async e => { const f = e.target.files && e.target.files[0]; if (!f) return; e.target.value = ""; try { setStat("listening through " + f.name + " …"); pauseAll(""); const A = audio(); const buf = await CleanRec.decode(A, await f.arrayBuffer()); const an = analyze(buf); if (SONG && SONG.url) { try { URL.revokeObjectURL(SONG.url); } catch (err) {} } const url = URL.createObjectURL(f), aud = new Audio(url); aud.preload = "auto"; aud.addEventListener("ended", () => setStat("the song ended — ▶ Play to hear it again, or ⏺ RENDER for a clean video")); AN = an; SONG = { name: f.name, dur: buf.duration, url, aud }; lastSongT = -1; songLbl.textContent = "♪ " + f.name.replace(/\.[^.]+$/, "") + " · " + rmmss(buf.duration) + " · " + AN.beats + " beats · " + (AN.switches.length + 1) + " sequences"; setStat("heard " + AN.events.length + " onsets in bass and highs · press ▶ Play"); } catch (err) { setStat((typeof CleanRec !== "undefined" && CleanRec.whyNot) ? CleanRec.whyNot(err) : "could not hear that file: " + (err && err.message || err)); } }; } })();