Improve web UI sound deployment

This commit is contained in:
Storm Dragon
2026-05-21 22:56:24 -04:00
parent c3a9b05392
commit 439f65ec6c
2 changed files with 18 additions and 2 deletions
+7 -2
View File
@@ -265,6 +265,7 @@ function reflectSettings() {
/** @type {AudioContext} */
let notificationAudioContext = null;
let userNotificationSoundsReady = false;
let notificationSoundGainScale = 2.5;
function notificationSoundsEnabled() {
return !!getSettings().notificationSounds;
@@ -309,7 +310,9 @@ function scheduleGlide(start, duration, fromFrequency, toFrequency, gainValue, t
oscillator.frequency.setValueAtTime(fromFrequency, start);
oscillator.frequency.exponentialRampToValueAtTime(toFrequency, start + duration);
gain.gain.setValueAtTime(0, start);
gain.gain.linearRampToValueAtTime(gainValue, start + 0.02);
gain.gain.linearRampToValueAtTime(
gainValue * notificationSoundGainScale, start + 0.02,
);
gain.gain.exponentialRampToValueAtTime(0.0001, start + duration);
oscillator.connect(gain);
gain.connect(context.destination);
@@ -335,7 +338,9 @@ function scheduleTone(offset, duration, frequency, gainValue, type) {
oscillator.type = type || 'sine';
oscillator.frequency.setValueAtTime(frequency, start);
gain.gain.setValueAtTime(0, start);
gain.gain.linearRampToValueAtTime(gainValue, start + 0.015);
gain.gain.linearRampToValueAtTime(
gainValue * notificationSoundGainScale, start + 0.015,
);
gain.gain.exponentialRampToValueAtTime(0.0001, start + duration);
oscillator.connect(gain);
gain.connect(context.destination);