From dbdd3be2bf41ceffd1b361f38395a84a1b6d9b26 Mon Sep 17 00:00:00 2001 From: spessasus Date: Wed, 19 Jun 2024 21:05:29 +0200 Subject: [PATCH] better estimated time display --- .../worklet_methods/controller_control.js | 19 +++++++++---------- .../worklet_processor_channel.js | 2 -- src/website/demo_main.js | 4 ++-- src/website/main.js | 4 ++-- .../ui/synthesizer_ui/synthui_selector.js | 7 ++++++- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/controller_control.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/controller_control.js index 17259d5d..4acadf54 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/controller_control.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/controller_control.js @@ -168,16 +168,7 @@ export function resetAllControllers() **/ const ch = this.workletProcessorChannels[channelNumber]; - // call all the event listeners - this.callEvent("programchange", { - channel: channelNumber, - program: ch.preset.program, - bank: ch.preset.bank, - userCalled: false - }); - - - // if preset is unlocked, switch to non drums + // if preset is unlocked, switch to non drums and call event if(!ch.lockPreset) { ch.midiControllers[midiControllers.bankSelect] = 0; @@ -201,6 +192,14 @@ export function resetAllControllers() } } + // call program change + this.callEvent("programchange", { + channel: channelNumber, + program: ch.preset.program, + bank: ch.preset.bank, + userCalled: false + }); + let restoreControllerValueEvent = ccNum => { if(this.workletProcessorChannels[channelNumber].lockedControllers[ccNum]) diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js index 33e87aac..56a7efbb 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js @@ -12,7 +12,6 @@ import { modulatorSources } from '../../../soundfont/chunk/modulators.js' * @property {number} NRPFine - the current fine value of the Non-Registered Parameter * @property {number} RPValue - the current value of the Registered Parameter * - * @property {number} program - the channel's program number * @property {Preset} preset - the channel's preset * @property {boolean} lockPreset - indicates whether the program on the channel is locked * @@ -58,7 +57,6 @@ export function createWorkletChannel(sendEvent = false) isMuted: false, drumChannel: false, lockPreset: false, - program: 0, } for (let i = 0; i < 128; i++) { diff --git a/src/website/demo_main.js b/src/website/demo_main.js index 07391771..3b6ca39e 100644 --- a/src/website/demo_main.js +++ b/src/website/demo_main.js @@ -3,7 +3,7 @@ import { Manager } from './manager.js' import { MIDI } from '../spessasynth_lib/midi_parser/midi_loader.js' -import { formatTitle } from '../spessasynth_lib/utils/other.js' +import { formatTime, formatTitle } from '../spessasynth_lib/utils/other.js' import { SpessaSynthInfo, SpessaSynthWarn } from '../spessasynth_lib/utils/loggin.js' import { audioBufferToWav } from '../spessasynth_lib/utils/buffer_to_wav.js' @@ -240,7 +240,7 @@ async function startMidi(midiFiles) const duration = window.manager.seq.midiData.duration; const buffer = await window.manager.renderAudio((progress, speed) => { const estimated = (1 - progress) / speed * duration; - titleMessage.innerText = `${message} ${Math.round(progress * 100)}%\n ${estimatedMessage} ${Math.round(estimated)}s` + titleMessage.innerText = `${message} ${Math.round(progress * 100)}%\n ${estimatedMessage} ${formatTime(estimated).time}s` }); titleMessage.textContent = title; diff --git a/src/website/main.js b/src/website/main.js index 9c43460b..756ed50c 100644 --- a/src/website/main.js +++ b/src/website/main.js @@ -3,7 +3,7 @@ import {Manager} from "./manager.js"; import {MIDI} from "../spessasynth_lib/midi_parser/midi_loader.js"; -import { formatTitle } from '../spessasynth_lib/utils/other.js' +import { formatTime, formatTitle } from '../spessasynth_lib/utils/other.js' import { audioBufferToWav } from '../spessasynth_lib/utils/buffer_to_wav.js' /** @@ -178,7 +178,7 @@ async function startMidi(midiFiles) const duration = window.manager.seq.midiData.duration; const buffer = await window.manager.renderAudio((progress, speed) => { const estimated = (1 - progress) / speed * duration; - titleMessage.innerText = `${message} ${Math.round(progress * 100)}%\n ${estimatedMessage} ${Math.round(estimated)}s` + titleMessage.innerText = `${message} ${Math.round(progress * 100)}%\n ${estimatedMessage} ${formatTime(estimated).time}` }); titleMessage.textContent = title; diff --git a/src/website/ui/synthesizer_ui/synthui_selector.js b/src/website/ui/synthesizer_ui/synthui_selector.js index d111cbfe..9637154b 100644 --- a/src/website/ui/synthesizer_ui/synthui_selector.js +++ b/src/website/ui/synthesizer_ui/synthui_selector.js @@ -128,6 +128,10 @@ export class Selector this.value = value; if(this.isShown) { + if(!this.isReloaded) + { + this.reload(); + } this.mainDiv.value = value; } } @@ -135,7 +139,8 @@ export class Selector show() { this.isShown = true; - if(!this.isReloaded) { + if(!this.isReloaded) + { this.reload(); } this.mainDiv.value = this.value;