From a592ebe9a7f11f04d040e43606199a97064df2f5 Mon Sep 17 00:00:00 2001 From: loucass003 Date: Mon, 3 Feb 2025 00:49:48 +0100 Subject: [PATCH] Woops forgot to remove the old one --- gui/src/sounds/sounds.tsx | 85 --------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 gui/src/sounds/sounds.tsx diff --git a/gui/src/sounds/sounds.tsx b/gui/src/sounds/sounds.tsx deleted file mode 100644 index fbc6da1816..0000000000 --- a/gui/src/sounds/sounds.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { fetchResourceUrl } from '@/utils/tauri'; -import { ResetType } from 'solarxr-protocol'; - -const quickResetStartedSound = new Audio( - await fetchResourceUrl('/sounds/quick-reset-started-sound.mp3') -); -const fullResetStartedSound = new Audio( - await fetchResourceUrl('/sounds/full-reset-started-sound.mp3') -); -const mountingResetStartedSound = new Audio( - await fetchResourceUrl('/sounds/mounting-reset-started-sound.mp3') -); -const tapSetupSound1 = new Audio( - await fetchResourceUrl('/sounds/first-tap.mp3') -); -const tapSetupSound2 = new Audio( - await fetchResourceUrl('/sounds/second-tap.mp3') -); -const tapSetupSound3 = new Audio( - await fetchResourceUrl('/sounds/third-tap.mp3') -); -const tapSetupSound4 = new Audio( - await fetchResourceUrl('/sounds/fourth-tap.mp3') -); -const tapSetupSound5 = new Audio( - await fetchResourceUrl('/sounds/fifth-tap.mp3') -); -const tapSetupSoundEnd = new Audio( - await fetchResourceUrl('/sounds/end-tap.mp3') -); -const tapSetupExtraSound = new Audio( - await fetchResourceUrl('/sounds/tapextrasetup.mp3') -); - -function restartAndPlay(audio: HTMLAudioElement, volume: number) { - audio.volume = Math.min(1, Math.pow(volume, Math.E) + 0.05); - if (audio.paused) { - audio.play(); - } else { - audio.currentTime = 0; - } -} - -export function playSoundOnResetStarted(resetType: ResetType, volume = 1) { - switch (resetType) { - case ResetType.Yaw: { - restartAndPlay(quickResetStartedSound, volume); - break; - } - case ResetType.Full: { - restartAndPlay(fullResetStartedSound, volume); - break; - } - case ResetType.Mounting: { - restartAndPlay(mountingResetStartedSound, volume); - break; - } - } -} - -let lastKnownVolume = 1; -/* Easter egg */ -tapSetupSoundEnd.onended = () => { - if (Math.floor(Math.random() * 12000) !== 0) return; - restartAndPlay(tapSetupExtraSound, lastKnownVolume); -}; - -const order = [ - tapSetupSound1, - tapSetupSound2, - tapSetupSound3, - tapSetupSound4, - tapSetupSound5, - tapSetupSoundEnd, - tapSetupSoundEnd, - tapSetupSoundEnd, -]; -let lastTap = 0; -export function playTapSetupSound(volume = 1) { - lastKnownVolume = volume; - restartAndPlay(order[lastTap++], volume); - if (lastTap >= order.length) { - lastTap = 0; - } -}