Skip to content

Commit d481572

Browse files
committed
Redo all tap sounds with better volume and tones / remove mp3s
1 parent c649b9a commit d481572

15 files changed

+350
-70
lines changed

gui/public/sounds/end-tap.mp3

-13.6 KB
Binary file not shown.

gui/public/sounds/fifth-tap.mp3

-11.4 KB
Binary file not shown.

gui/public/sounds/first-tap.mp3

-11.6 KB
Binary file not shown.

gui/public/sounds/fourth-tap.mp3

-12.3 KB
Binary file not shown.
-82.1 KB
Binary file not shown.
Binary file not shown.
-81.5 KB
Binary file not shown.

gui/public/sounds/second-tap.mp3

-12.5 KB
Binary file not shown.

gui/public/sounds/tapextrasetup.mp3

-82.4 KB
Binary file not shown.

gui/public/sounds/third-tap.mp3

-12.7 KB
Binary file not shown.

gui/src/components/Preload.tsx

-23
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,6 @@ export function Preload() {
1010

1111
<link rel="preload" href="/videos/autobone.webm" as="video" />
1212

13-
<link
14-
rel="preload"
15-
href="/sounds/quick-reset-started-sound.mp3"
16-
as="audio"
17-
/>
18-
<link
19-
rel="preload"
20-
href="/sounds/full-reset-started-sound.mp3"
21-
as="audio"
22-
/>
23-
<link
24-
rel="preload"
25-
href="/sounds/mounting-reset-started-sound.mp3"
26-
as="audio"
27-
/>
28-
<link rel="preload" href="/sounds/first-tap.mp3" as="audio" />
29-
<link rel="preload" href="/sounds/second-tap.mp3" as="audio" />
30-
<link rel="preload" href="/sounds/third-tap.mp3" as="audio" />
31-
<link rel="preload" href="/sounds/fourth-tap.mp3" as="audio" />
32-
<link rel="preload" href="/sounds/fifth-tap.mp3" as="audio" />
33-
<link rel="preload" href="/sounds/end-tap.mp3" as="audio" />
34-
<link rel="preload" href="/sounds/tapextrasetup.mp3" as="audio" />
35-
3613
<link
3714
rel="preload"
3815
href="/models/tracker.gltf"

gui/src/components/home/ResetButton.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export function ResetButton({
8888

8989
const maybePlaySoundOnResetStart = () => {
9090
if (!config?.feedbackSound) return;
91-
playSoundOnResetStarted(config?.feedbackSoundVolume);
91+
if (type !== ResetType.Yaw)
92+
playSoundOnResetStarted(config?.feedbackSoundVolume);
9293
};
9394

9495
return variant === 'small' ? (

gui/src/hooks/app.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
DeviceDataT,
1616
ResetResponseT,
1717
ResetStatus,
18+
ResetType,
1819
RpcMessage,
1920
StartDataFeedT,
2021
TrackerDataT,
@@ -118,7 +119,8 @@ export function useProvideAppContext(): AppContext {
118119
try {
119120
switch (status) {
120121
case ResetStatus.STARTED: {
121-
playSoundOnResetStarted(config?.feedbackSoundVolume);
122+
if (resetType !== ResetType.Yaw)
123+
playSoundOnResetStarted(config?.feedbackSoundVolume);
122124
break;
123125
}
124126
case ResetStatus.FINISHED: {

gui/src/sounds/sounds.ts

+56-45
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,79 @@
1-
import { fetchResourceUrl } from '@/utils/tauri';
21
import { ResetType } from 'solarxr-protocol';
2+
import Xylophone from './xylophone';
33

4-
const tapSetupSound1 = new Audio(await fetchResourceUrl('/sounds/first-tap.mp3'));
5-
const tapSetupSound2 = new Audio(await fetchResourceUrl('/sounds/second-tap.mp3'));
6-
const tapSetupSound3 = new Audio(await fetchResourceUrl('/sounds/third-tap.mp3'));
7-
const tapSetupSound4 = new Audio(await fetchResourceUrl('/sounds/fourth-tap.mp3'));
8-
const tapSetupSound5 = new Audio(await fetchResourceUrl('/sounds/fifth-tap.mp3'));
9-
const tapSetupSoundEnd = new Audio(await fetchResourceUrl('/sounds/end-tap.mp3'));
10-
const tapSetupExtraSound = new Audio(
11-
await fetchResourceUrl('/sounds/tapextrasetup.mp3')
12-
);
4+
const tones = [
5+
['C4', 'E4', 'G4'],
6+
['E4', 'G4', 'C5'],
7+
['G4', 'C5', 'E5'],
8+
['C5', 'E5', 'G5'],
9+
['E5', 'G5', 'C6'],
10+
['G5', 'C6', 'E6'],
11+
];
1312

14-
function restartAndPlay(audio: HTMLAudioElement, volume: number) {
15-
audio.volume = Math.min(1, Math.pow(volume, Math.E) + 0.05);
16-
if (audio.paused) {
17-
audio.play();
18-
} else {
19-
audio.currentTime = 0;
20-
}
21-
}
13+
const xylophone = new Xylophone()
2214

23-
export function playSoundOnResetEnded(resetType: ResetType, volume = 1) {
15+
export async function playSoundOnResetEnded(resetType: ResetType, volume = 1) {
2416
switch (resetType) {
2517
case ResetType.Yaw: {
26-
restartAndPlay(tapSetupSound2, volume);
18+
xylophone.play({
19+
notes: ['C4'],
20+
offset: 0.15,
21+
type: 'square',
22+
volume
23+
})
2724
break;
2825
}
2926
case ResetType.Full: {
30-
restartAndPlay(tapSetupSound3, volume);
27+
xylophone.play({
28+
notes: ['C4', 'E4'],
29+
offset: 0.15,
30+
type: 'square',
31+
volume
32+
})
3133
break;
3234
}
3335
case ResetType.Mounting: {
34-
restartAndPlay(tapSetupSound4, volume);
36+
xylophone.play({
37+
notes: ['C4', 'E4', 'G4'],
38+
offset: 0.15,
39+
type: 'square',
40+
volume
41+
})
3542
break;
3643
}
3744
}
3845
}
3946

40-
export function playSoundOnResetStarted(volume = 1) {
41-
restartAndPlay(tapSetupSound1, volume);
47+
export async function playSoundOnResetStarted(volume = 1) {
48+
await xylophone.play({
49+
notes: ['A4'],
50+
offset: 0.4,
51+
type: 'square',
52+
volume
53+
})
4254
}
4355

44-
let lastKnownVolume = 1;
45-
/* Easter egg */
46-
tapSetupSoundEnd.onended = () => {
47-
if (Math.floor(Math.random() * 12000) !== 0) return;
48-
restartAndPlay(tapSetupExtraSound, lastKnownVolume);
49-
};
50-
51-
const order = [
52-
tapSetupSound1,
53-
tapSetupSound2,
54-
tapSetupSound3,
55-
tapSetupSound4,
56-
tapSetupSound5,
57-
tapSetupSoundEnd,
58-
tapSetupSoundEnd,
59-
tapSetupSoundEnd,
60-
];
6156
let lastTap = 0;
62-
export function playTapSetupSound(volume = 1) {
63-
lastKnownVolume = volume;
64-
restartAndPlay(order[lastTap++], volume);
65-
if (lastTap >= order.length) {
57+
export async function playTapSetupSound(volume = 1) {
58+
if (Math.floor(Math.random() * 12000) !== 0) {
59+
xylophone.play({
60+
notes: tones[lastTap],
61+
offset: 0.15,
62+
type: 'square',
63+
volume
64+
})
65+
}
66+
else {
67+
xylophone.play({
68+
notes: ['D4', 'E4', 'G4', 'E4', 'B4', 'B4', 'A4'],
69+
offset: 0.15,
70+
length: 1,
71+
type: 'sawtooth',
72+
volume
73+
})
74+
}
75+
lastTap++;
76+
if (lastTap >= tones.length) {
6677
lastTap = 0;
6778
}
6879
}

0 commit comments

Comments
 (0)