1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

introduce functions to modulate user volume

This commit is contained in:
mothbeanie 2024-12-14 16:49:47 -08:00 committed by Ethan Lee
parent d4e472db1b
commit 420683a80f
2 changed files with 20 additions and 7 deletions

View file

@ -909,6 +909,16 @@ void musicclass::destroy(void)
VVV_freefunc(FAudio_Release, faudioctx); VVV_freefunc(FAudio_Release, faudioctx);
} }
void musicclass::set_music_volume(int volume)
{
MusicTrack::SetVolume(volume * user_music_volume / USER_VOLUME_MAX);
}
void musicclass::set_sound_volume(int volume)
{
SoundTrack::SetVolume(volume * user_sound_volume / USER_VOLUME_MAX);
}
void musicclass::play(int t) void musicclass::play(int t)
{ {
if (mmmmmm && usingmmmmmm) if (mmmmmm && usingmmmmmm)
@ -962,7 +972,7 @@ void musicclass::play(int t)
m_doFadeInVol = false; m_doFadeInVol = false;
m_doFadeOutVol = false; m_doFadeOutVol = false;
musicVolume = VVV_MAX_VOLUME; musicVolume = VVV_MAX_VOLUME;
MusicTrack::SetVolume(VVV_MAX_VOLUME * user_music_volume / USER_VOLUME_MAX); set_music_volume(musicVolume);
} }
} }
else else
@ -1100,7 +1110,7 @@ void musicclass::fadeMusicVolumeIn(int ms)
musicVolume = 0; musicVolume = 0;
/* Fix 1-frame glitch */ /* Fix 1-frame glitch */
MusicTrack::SetVolume(0); set_music_volume(0);
fade.step_ms = 0; fade.step_ms = 0;
fade.duration_ms = ms; fade.duration_ms = ms;
@ -1299,20 +1309,20 @@ void musicclass::updatemutestate(void)
{ {
if (game.muted) if (game.muted)
{ {
MusicTrack::SetVolume(0); set_music_volume(0);
SoundTrack::SetVolume(0); set_sound_volume(0);
} }
else else
{ {
SoundTrack::SetVolume(VVV_MAX_VOLUME * user_sound_volume / USER_VOLUME_MAX); set_sound_volume(VVV_MAX_VOLUME);
if (game.musicmuted) if (game.musicmuted)
{ {
MusicTrack::SetVolume(0); set_music_volume(0);
} }
else else
{ {
MusicTrack::SetVolume(musicVolume * user_music_volume / USER_VOLUME_MAX); set_music_volume(musicVolume);
} }
} }
} }

View file

@ -70,6 +70,9 @@ public:
void init(void); void init(void);
void destroy(void); void destroy(void);
void set_music_volume(int volume);
void set_sound_volume(int volume);
void play(int t); void play(int t);
void resume(void); void resume(void);
void resumefade(const int fadein_ms); void resumefade(const int fadein_ms);