Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/webgal/src/Stage/AudioContainer/AudioContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const AudioContainer = () => {
const isShowTitle = useSelector((webgalStore: RootState) => webgalStore.GUI.showTitle);
const userDataState = useSelector((state: RootState) => state.userData);
const mainVol = userDataState.optionData.volumeMain;
const vocalVol = mainVol * 0.01 * userDataState.optionData.vocalVolume * 0.01 * stageStore.vocalVolume * 0.01;
const vocalBaseVol = mainVol * 0.01 * userDataState.optionData.vocalVolume * 0.01;
const vocalVol = vocalBaseVol * stageStore.vocalVolume * 0.01;
Comment on lines +13 to +14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and to avoid magic numbers, consider using division by 100 to convert percentage values to decimals instead of multiplying by 0.01. This makes the code's intent clearer.

Suggested change
const vocalBaseVol = mainVol * 0.01 * userDataState.optionData.vocalVolume * 0.01;
const vocalVol = vocalBaseVol * stageStore.vocalVolume * 0.01;
const vocalBaseVol = (mainVol / 100) * (userDataState.optionData.vocalVolume / 100);
const vocalVol = vocalBaseVol * (stageStore.vocalVolume / 100);

const bgmVol = mainVol * 0.01 * userDataState.optionData.bgmVolume * 0.01 * stageStore.bgm.volume * 0.01;
const bgmEnter = stageStore.bgm.enter;
const uiSoundEffects = stageStore.uiSe;
Expand Down Expand Up @@ -83,7 +84,7 @@ export const AudioContainer = () => {
if (vocalElement) {
vocalElement.volume = vocalVol.toString();
}
}, [vocalVol]);
}, [vocalVol, stageStore.playVocal]);

useEffect(() => {
if (uiSoundEffects === '') return;
Expand Down