Skip to content

Commit 32a1eca

Browse files
committed
improve demo song ergonomics
1 parent d2d0612 commit 32a1eca

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/website/js/main/demo_main.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,23 +395,34 @@ fileInput.focus();
395395
sfUpload.style.display = "none";
396396
fileUpload.style.display = "none";
397397

398-
async function playDemoSong(fileName: string) {
399-
if (!window.manager) {
398+
interface DemoSong {
399+
name: string;
400+
fileName: string;
401+
credits: string;
402+
loop?: boolean;
403+
fullMIDISupport: boolean;
404+
}
405+
406+
async function playDemoSong(song: DemoSong) {
407+
if (!window.manager?.synth) {
400408
throw new Error("Unexpected lack of manager!");
401409
}
402410
titleMessage.textContent = window.manager.localeManager.getLocaleString(
403411
"locale.synthInit.genericLoading"
404412
);
405413
const r = await fetch(
406414
"https://spessasus.github.io/spessasynth-demo-songs/demo_songs/" +
407-
fileName
415+
song.fileName
408416
);
409-
if (window.manager.synth) {
417+
if (!song.fullMIDISupport) {
410418
window.manager.synth.setMasterParameter("nprnParamLock", true);
411419
window.manager.synth.setMasterParameter("drumLock", true);
412420
}
413421
// noinspection JSCheckFunctionSignatures
414-
await startMidi([new File([await r.arrayBuffer()], fileName)]);
422+
await startMidi([new File([await r.arrayBuffer()], song.fileName)]);
423+
setTimeout(() => {
424+
window.manager?.seqUI?.setLoopState?.(song?.loop ?? false);
425+
}, 500);
415426
}
416427

417428
await demoInit(initLocale);
@@ -543,11 +554,7 @@ demoSongButton.addEventListener("click", async () => {
543554
)
544555
// eslint-disable-next-line unicorn/no-await-expression-member
545556
.text();
546-
const songsJSON = JSON.parse(songs) as {
547-
name: string;
548-
fileName: string;
549-
credits: string;
550-
}[];
557+
const songsJSON = JSON.parse(songs) as DemoSong[];
551558
for (const song of songsJSON) {
552559
contents.push({
553560
type: "button",
@@ -580,7 +587,7 @@ demoSongButton.addEventListener("click", async () => {
580587
undefined,
581588
undefined,
582589
async () => {
583-
await playDemoSong(song.fileName);
590+
await playDemoSong(song);
584591
}
585592
);
586593
}

src/website/js/sequencer_ui/sequencer_ui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ export class SequencerUI {
794794
}
795795
}
796796

797-
protected setLoopState(loop: boolean) {
797+
public setLoopState(loop: boolean) {
798798
if (loop) {
799799
this.seq.loopCount = Infinity;
800800
this.enableIcon(this.loopButton);

0 commit comments

Comments
 (0)