22#include < apu/embedded_player.h>
33#include < user/config.h>
44
5+ #include < res/music/installer.ogg.h>
56#include < res/sounds/sys_worldmap_cursor.ogg.h>
67#include < res/sounds/sys_worldmap_finaldecide.ogg.h>
78#include < res/sounds/sys_actstg_pausecansel.ogg.h>
@@ -87,13 +88,17 @@ static void PlayEmbeddedSound(EmbeddedSound s)
8788 data.chunk = Mix_LoadWAV_RW (SDL_RWFromConstMem (soundData, soundDataSize), 1 );
8889 }
8990
91+ Mix_VolumeChunk (data.chunk , Config::MasterVolume * Config::EffectsVolume * MIX_MAX_VOLUME );
9092 Mix_PlayChannel (g_channelIndex % MIX_CHANNELS , data.chunk , 0 );
9193 ++g_channelIndex;
9294}
9395
96+ static Mix_Music* g_installerMusic;
97+
9498void EmbeddedPlayer::Init ()
9599{
96- Mix_OpenAudio (XAUDIO_SAMPLES_HZ , AUDIO_F32SYS , 2 , 256 );
100+ Mix_OpenAudio (XAUDIO_SAMPLES_HZ , AUDIO_F32SYS , 2 , 2048 );
101+ g_installerMusic = Mix_LoadMUS_RW (SDL_RWFromConstMem (g_installer_music, sizeof (g_installer_music)), 1 );
97102
98103 s_isActive = true ;
99104}
@@ -111,6 +116,21 @@ void EmbeddedPlayer::Play(const char *name)
111116 PlayEmbeddedSound (it->second );
112117}
113118
119+ void EmbeddedPlayer::PlayMusic ()
120+ {
121+ if (!Mix_PlayingMusic ())
122+ {
123+ Mix_PlayMusic (g_installerMusic, INT_MAX );
124+ Mix_VolumeMusic (Config::MasterVolume * Config::MusicVolume * MUSIC_VOLUME * MIX_MAX_VOLUME );
125+ }
126+ }
127+
128+ void EmbeddedPlayer::FadeOutMusic ()
129+ {
130+ if (Mix_PlayingMusic ())
131+ Mix_FadeOutMusic (1000 );
132+ }
133+
114134void EmbeddedPlayer::Shutdown ()
115135{
116136 for (EmbeddedSoundData &data : g_embeddedSoundData)
@@ -119,6 +139,9 @@ void EmbeddedPlayer::Shutdown()
119139 Mix_FreeChunk (data.chunk );
120140 }
121141
142+ Mix_HaltMusic ();
143+ Mix_FreeMusic (g_installerMusic);
144+
122145 Mix_CloseAudio ();
123146 Mix_Quit ();
124147
0 commit comments