@@ -395,23 +395,34 @@ fileInput.focus();
395395sfUpload . style . display = "none" ;
396396fileUpload . 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
417428await 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 }
0 commit comments