diff --git a/index.html b/index.html index 824acf16..34206347 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@ +

Loading...

diff --git a/src/website/css/style.css b/src/website/css/style.css index 7a1ffac1..7b45a4f2 100644 --- a/src/website/css/style.css +++ b/src/website/css/style.css @@ -198,6 +198,7 @@ button{ } .loading { + flex-direction: column; display: flex; justify-content: center; align-items: center; @@ -211,6 +212,7 @@ button{ } .loading svg { + margin: 3em; animation: spin 1s ease-in-out infinite; } diff --git a/src/website/demo/demo_main.js b/src/website/demo/demo_main.js index f00588ad..3df35639 100644 --- a/src/website/demo/demo_main.js +++ b/src/website/demo/demo_main.js @@ -19,20 +19,17 @@ const TITLE = "SpessaSynth: SoundFont2 Javascript Synthetizer Online Demo"; * @type {HTMLHeadingElement} */ let titleMessage = document.getElementById("title"); - - /** * @type {HTMLInputElement} */ let fileInput = document.getElementById("midi_file_input"); - - let sfInput = document.getElementById("sf_file_input"); - /** * @type {HTMLButtonElement} */ const exportButton = document.getElementById("export_button"); +const loading = document.getElementsByClassName("loading")[0]; +const loadingMessage = document.getElementById("loading_message"); // IndexedDB stuff const dbName = "spessasynth-db"; @@ -95,11 +92,10 @@ async function demoInit() SpessaSynthWarn("Failed to load from db, fetching online instead"); loadedFromDb = false; const progressBar = document.getElementById("progress_bar"); - titleMessage.innerText = "Loading bundled SoundFont, please wait."; + loadingMessage.innerText = "Loading bundled soundfont..."; soundFontBuffer = await fetchFont(`soundfonts/${SF_NAME}`, percent => { - titleMessage.innerText = `Loading bundled SoundFont (${percent}%), please wait.`; - progressBar.style.width = `${(percent / 100) * titleMessage.offsetWidth}px` + loadingMessage.textContent =`Loading bundled SoundFont.. ${percent}%`; }); progressBar.style.width = "0"; } @@ -117,11 +113,13 @@ async function demoInit() } catch (e) { + titleMessage.innerHTML = `Error parsing soundfont:
${e}
`; console.log(e); return; } await prepareUI(); + loadingMessage.textContent = "Ready!"; } async function fetchFont(url, callback) @@ -250,7 +248,6 @@ async function startMidi(midiFiles) async function prepareUI() { titleMessage.innerText = TITLE; - try { const context = window.AudioContext || window.webkitAudioContext; window.audioContextMain = new context({ sampleRate: 44100 }); @@ -272,6 +269,7 @@ async function prepareUI() } // prepare midi interface + loadingMessage.textContent = "Initializing synthesizer..."; window.manager = new Manager(audioContextMain, soundFontParser); await manager.ready; @@ -350,14 +348,12 @@ fileInput.value = ""; fileInput.focus(); // set initial styles exportButton.style.display = "none"; -titleMessage.innerText = "Loading..."; document.getElementById("sf_upload").style.display = "none"; document.getElementById("file_upload").style.display = "none"; demoInit().then(() => { document.getElementById("sf_upload").style.display = "flex"; document.getElementById("file_upload").style.display = "flex"; - const loading = document.getElementsByClassName("loading")[0]; loading.style.opacity = "0"; setTimeout(() => { loading.style.display = "none";