diff --git a/source/common/music/s_music.h b/source/common/music/s_music.h index bca472f67..f3c9a0be9 100644 --- a/source/common/music/s_music.h +++ b/source/common/music/s_music.h @@ -97,5 +97,7 @@ extern MusPlayingInfo mus_playing; extern float relative_volume, saved_relative_volume; +// Note for later when the OPL player is ported. +// DN3D and related games use "d3dtimbr.tmb" #endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 082385980..341c75fc7 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5556,7 +5556,6 @@ static void G_Cleanup(void) void G_Shutdown(void) { S_SoundShutdown(); - S_MusicShutdown(); CONTROL_Shutdown(); engineUnInit(); G_Cleanup(); @@ -6174,7 +6173,6 @@ int GameInterface::app_main() videoSetPalette(0, myplayer.palette, 0); S_SoundStartup(); - S_MusicStartup(); } // check if the minifont will support lowercase letters (3136-3161) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 18b1a50ff..d2ff82e32 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -1760,10 +1760,8 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) mus_device = musicdevice; S_SoundShutdown(); - S_MusicShutdown(); S_SoundStartup(); - S_MusicStartup(); FX_StopAllSounds(); S_ClearSoundLocks(); diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 6f951cab4..718630463 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -326,10 +326,8 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm)) { UNREFERENCED_CONST_PARAMETER(parm); S_SoundShutdown(); - S_MusicShutdown(); S_SoundStartup(); - S_MusicStartup(); FX_StopAllSounds(); S_ClearSoundLocks(); @@ -340,36 +338,6 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm)) return OSDCMD_OK; } -static int osdcmd_music(osdcmdptr_t parm) -{ - if (parm->numparms == 1) - { - int32_t sel = G_GetMusicIdx(parm->parms[0]); - - if (sel == -1) - return OSDCMD_SHOWHELP; - - if (sel == -2) - { - OSD_Printf("%s is not a valid episode/level number pair\n", parm->parms[0]); - return OSDCMD_OK; - } - - if (!S_TryPlayLevelMusic(sel)) - { - G_PrintCurrentMusic(); - } - else - { - OSD_Printf("No music defined for %s\n", parm->parms[0]); - } - - return OSDCMD_OK; - } - - return OSDCMD_SHOWHELP; -} - int osdcmd_restartmap(osdcmdptr_t UNUSED(parm)) { UNREFERENCED_CONST_PARAMETER(parm); @@ -1012,8 +980,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); - OSD_RegisterFunction("music","music EL: change music", osdcmd_music); - OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index e45f61297..bc5dc94e1 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -88,7 +88,6 @@ void S_SoundStartup(void) cacheAllSounds(); snd_fxvolume.Callback(); - S_MusicVolume(mus_volume); snd_reversestereo.Callback(); FX_SetCallBack(S_Callback); @@ -97,9 +96,6 @@ void S_SoundStartup(void) void S_SoundShutdown(void) { - if (MusicVoice >= 0) - S_MusicShutdown(); - int status = FX_Shutdown(); if (status != FX_Ok) { @@ -108,45 +104,6 @@ void S_SoundShutdown(void) } } -void S_MusicStartup(void) -{ - initprintf("Initializing MIDI driver... "); - - int status; - if ((status = MUSIC_Init(MusicDevice)) == MUSIC_Ok) - { - if (MusicDevice == ASS_AutoDetect) - MusicDevice = MIDI_GetDevice(); - } - else if ((status = MUSIC_Init(ASS_AutoDetect)) == MUSIC_Ok) - { - MusicDevice = MIDI_GetDevice(); - } - else - { - initprintf("S_MusicStartup(): failed initializing: %s\n", MUSIC_ErrorString(status)); - return; - } - - MUSIC_SetVolume(mus_volume); - auto fr = kopenFileReader("d3dtimbr.tmb", 0); - - if (fr.isOpen()) - { - auto tmb = fr.Read(); - AL_RegisterTimbreBank(tmb.Data()); - } -} - -void S_MusicShutdown(void) -{ - S_StopMusic(); - - int status = MUSIC_Shutdown(); - if (status != MUSIC_Ok) - initprintf("S_MusicShutdown(): %s\n", MUSIC_ErrorString(status)); -} - void S_PauseSounds(bool paused) { if (SoundPaused == paused) @@ -162,17 +119,9 @@ void S_PauseSounds(bool paused) } } - -void S_MusicVolume(int32_t volume) -{ - if (MusicIsWaveform && MusicVoice >= 0) - FX_SetPan(MusicVoice, volume, volume, volume); - - MUSIC_SetVolume(volume); -} - void S_RestartMusic(void) { + // Fixme: This should be completely decided by the backend, not here. if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { S_PlayLevelMusicOrNothing(g_musicIndex); @@ -196,125 +145,7 @@ void S_MenuSound(void) S_PlaySound(s); } -#if 0 // In case you desperately want the old system back... ;) -static int S_PlayMusic(const char *, const char *fn, int loop) -{ - if (!MusicEnabled()) - return 0; - if (fn == NULL) - return 1; - - auto fp = S_OpenAudio(fn, 0, 1); - if (!fp.isOpen()) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open \"%s\" for playback!\n",fn); - return 2; - } - - int32_t MusicLen = fp.GetLength(); - - if (EDUKE32_PREDICT_FALSE(MusicLen < 4)) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: empty music file \"%s\"\n", fn); - return 3; - } - - char * MyMusicPtr = (char *)Xaligned_alloc(16, MusicLen); - int MyMusicSize = fp.Read(MyMusicPtr, MusicLen); - - if (EDUKE32_PREDICT_FALSE(MyMusicSize != MusicLen)) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: read %d bytes from \"%s\", expected %d\n", - MyMusicSize, fn, MusicLen); - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 4; - } - - if (!Bmemcmp(MyMusicPtr, "MThd", 4)) - { - int32_t retval = MUSIC_PlaySong(MyMusicPtr, MyMusicSize, MUSIC_LoopSong, fn); - - if (retval != MUSIC_Ok) - { - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 5; - } - - if (MusicIsWaveform && MusicVoice >= 0) - { - FX_StopSound(MusicVoice); - MusicVoice = -1; - } - - MusicIsWaveform = 0; - ALIGNED_FREE_AND_NULL(MusicPtr); - MusicPtr = MyMusicPtr; - g_musicSize = MyMusicSize; - } - else - { - int MyMusicVoice = FX_Play(MyMusicPtr, MusicLen, 0, 0, 0, mus_volume, mus_volume, mus_volume, - FX_MUSIC_PRIORITY, 1.f, MUSIC_ID); - - if (MyMusicVoice <= FX_Ok) - { - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 5; - } - - if (MusicIsWaveform && MusicVoice >= 0) - FX_StopSound(MusicVoice); - - MUSIC_StopSong(); - - MusicVoice = MyMusicVoice; - MusicIsWaveform = 1; - ALIGNED_FREE_AND_NULL(MusicPtr); - MusicPtr = MyMusicPtr; - g_musicSize = MyMusicSize; - } - - return 0; -} - -void S_StopMusic(void) -{ - MusicPaused = 0; - - if (MusicIsWaveform && MusicVoice >= 0) - { - FX_StopSound(MusicVoice); - MusicVoice = -1; - MusicIsWaveform = 0; - } - - MUSIC_StopSong(); - - ALIGNED_FREE_AND_NULL(MusicPtr); - g_musicSize = 0; -} - -void S_PauseMusic(bool paused) -{ - if (MusicPaused == paused || (MusicIsWaveform && MusicVoice < 0)) - return; - - MusicPaused = paused; - - if (MusicIsWaveform) - { - FX_PauseVoice(MusicVoice, paused); - return; - } - - if (paused) - MUSIC_Pause(); - else - MUSIC_Continue(); -} - -#else static int S_PlayMusic(const char *mapname, const char* fn, bool looping = true) { return Mus_Play(mapname, fn, looping); @@ -331,8 +162,6 @@ void S_PauseMusic(bool paused) } -#endif - static void S_SetMusicIndex(unsigned int m) { g_musicIndex = m; diff --git a/source/duke3d/src/sounds.h b/source/duke3d/src/sounds.h index b19471c53..1c7d51f13 100644 --- a/source/duke3d/src/sounds.h +++ b/source/duke3d/src/sounds.h @@ -70,9 +70,6 @@ inline void S_ClearSoundLocks(void) {} int32_t S_LoadSound(uint32_t num); void cacheAllSounds(void); void S_MenuSound(void); -void S_MusicShutdown(void); -void S_MusicStartup(void); -void S_MusicVolume(int32_t volume); void S_RestartMusic(void); void S_PauseMusic(bool paused); void S_PauseSounds(bool paused); diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 928497a2a..f9c4ff19a 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -7046,7 +7046,6 @@ static void G_Cleanup(void) void G_Shutdown(void) { S_SoundShutdown(); - S_MusicShutdown(); CONTROL_Shutdown(); G_SetFog(0); engineUnInit(); @@ -7708,7 +7707,6 @@ int GameInterface::app_main() } videoSetPalette(0, g_player[myconnectindex].ps->palette, 0); - S_MusicStartup(); S_SoundStartup(); } diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index 34dcd480a..11fb58d3b 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -3434,9 +3434,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) snd_numvoices = soundvoices; S_SoundShutdown(); - S_MusicShutdown(); - S_MusicStartup(); S_SoundStartup(); FX_StopAllSounds(); @@ -3623,8 +3621,6 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) G_SetStatusBarScale(newValue); else if (entry == &ME_SOUND_VOLUME_FX) FX_SetVolume(newValue); - else if (entry == &ME_SOUND_VOLUME_MUSIC) - S_MusicVolume(newValue); else if (entry == &ME_JOYSTICKAXIS_SCALE) CONTROL_SetAnalogAxisScale(M_JOYSTICKAXES.currentEntry, newValue, controldevice_joystick); else if (entry == &ME_JOYSTICKAXIS_DEAD) diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp index 0c1f02cb9..7448738c0 100644 --- a/source/rr/src/osdcmds.cpp +++ b/source/rr/src/osdcmds.cpp @@ -323,9 +323,7 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm)) { UNREFERENCED_CONST_PARAMETER(parm); S_SoundShutdown(); - S_MusicShutdown(); - S_MusicStartup(); S_SoundStartup(); FX_StopAllSounds(); @@ -337,36 +335,6 @@ static int osdcmd_restartsound(osdcmdptr_t UNUSED(parm)) return OSDCMD_OK; } -static int osdcmd_music(osdcmdptr_t parm) -{ - if (parm->numparms == 1) - { - int32_t sel = G_GetMusicIdx(parm->parms[0]); - - if (sel == -1) - return OSDCMD_SHOWHELP; - - if (sel == -2) - { - OSD_Printf("%s is not a valid episode/level number pair\n", parm->parms[0]); - return OSDCMD_OK; - } - - if (!S_TryPlayLevelMusic(sel)) - { - G_PrintCurrentMusic(); - } - else - { - OSD_Printf("No music defined for %s\n", parm->parms[0]); - } - - return OSDCMD_OK; - } - - return OSDCMD_SHOWHELP; -} - int osdcmd_restartmap(osdcmdptr_t UNUSED(parm)) { UNREFERENCED_CONST_PARAMETER(parm); @@ -864,8 +832,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers); #endif - OSD_RegisterFunction("music","music EL: change music", osdcmd_music); - OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); #if !defined NETCODE_DISABLE diff --git a/source/rr/src/sounds.cpp b/source/rr/src/sounds.cpp index 9b11fe2d9..292a96fc0 100644 --- a/source/rr/src/sounds.cpp +++ b/source/rr/src/sounds.cpp @@ -77,7 +77,6 @@ void S_SoundStartup(void) S_PrecacheSounds(); snd_fxvolume.Callback(); - S_MusicVolume(mus_volume); snd_reversestereo.Callback(); FX_SetCallBack(S_Callback); @@ -86,9 +85,6 @@ void S_SoundStartup(void) void S_SoundShutdown(void) { - if (MusicVoice >= 0) - S_MusicShutdown(); - if (FX_Shutdown() != FX_Ok) { Bsprintf(tempbuf, "S_SoundShutdown(): error: %s", FX_ErrorString(FX_Error)); @@ -96,26 +92,7 @@ void S_SoundShutdown(void) } } -void S_MusicStartup(void) -{ - initprintf("Initializing music...\n"); - if (MUSIC_Init(MusicDevice) == MUSIC_Ok) - { - MUSIC_SetVolume(mus_volume); - return; - } - - initprintf("S_MusicStartup(): failed initializing\n"); -} - -void S_MusicShutdown(void) -{ - S_StopMusic(); - - if (MUSIC_Shutdown() != MUSIC_Ok) - initprintf("%s\n", MUSIC_ErrorString(MUSIC_ErrorCode)); -} void S_PauseSounds(bool paused) { if (SoundPaused == paused) @@ -131,18 +108,9 @@ void S_PauseSounds(bool paused) } } - - -void S_MusicVolume(int32_t volume) -{ - if (MusicIsWaveform && MusicVoice >= 0) - FX_SetPan(MusicVoice, volume, volume, volume); - - MUSIC_SetVolume(volume); -} - void S_RestartMusic(void) { + // Fixme: This should be completely decided by the backend, not here. if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { S_PlayLevelMusicOrNothing(g_musicIndex); @@ -166,128 +134,7 @@ void S_MenuSound(void) S_PlaySound(s); } -#if 0 // In case you desperately want the old system back... ;) -static int S_PlayMusic(const char *, const char *fn, int loop) -{ - if (!MusicEnabled()) - return 0; - if (fn == NULL) - return 1; - - auto fp = S_OpenAudio(fn, 0, 1); - if (!fp.isOpen()) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open \"%s\" for playback!\n",fn); - return 2; - } - - int32_t MusicLen = fp.GetLength(); - - if (EDUKE32_PREDICT_FALSE(MusicLen < 4)) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: empty music file \"%s\"\n", fn); - return 3; - } - - char * MyMusicPtr = (char *)Xaligned_alloc(16, MusicLen); - int MyMusicSize = fp.Read(MyMusicPtr, MusicLen); - - if (EDUKE32_PREDICT_FALSE(MyMusicSize != MusicLen)) - { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: read %d bytes from \"%s\", expected %d\n", - MyMusicSize, fn, MusicLen); - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 4; - } - - if (!Bmemcmp(MyMusicPtr, "MThd", 4)) - { - int32_t retval = MUSIC_PlaySong(MyMusicPtr, MyMusicSize, loop); - - if (retval != MUSIC_Ok) - { - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 5; - } - - if (MusicIsWaveform && MusicVoice >= 0) - { - FX_StopSound(MusicVoice); - MusicVoice = -1; - } - - MusicIsWaveform = 0; - ALIGNED_FREE_AND_NULL(MusicPtr); - MusicPtr = MyMusicPtr; - g_musicSize = MyMusicSize; - } - else - { - int MyMusicVoice = FX_Play(MyMusicPtr, MusicLen, 0, 0, 0, mus_volume, mus_volume, mus_volume, - FX_MUSIC_PRIORITY, 1.f, MUSIC_ID); - - if (MyMusicVoice <= FX_Ok) - { - ALIGNED_FREE_AND_NULL(MyMusicPtr); - return 5; - } - - if (MusicIsWaveform && MusicVoice >= 0) - FX_StopSound(MusicVoice); - - MUSIC_StopSong(); - - MusicVoice = MyMusicVoice; - MusicIsWaveform = 1; - ALIGNED_FREE_AND_NULL(MusicPtr); - MusicPtr = MyMusicPtr; - g_musicSize = MyMusicSize; - } - - return 0; -} - - -void S_StopMusic(void) -{ - MusicPaused = 0; - - if (MusicIsWaveform && MusicVoice >= 0) - { - FX_StopSound(MusicVoice); - MusicVoice = -1; - MusicIsWaveform = 0; - } - - MUSIC_StopSong(); - - ALIGNED_FREE_AND_NULL(MusicPtr); - g_musicSize = 0; -} - -void S_PauseMusic(bool paused) -{ - if (MusicPaused == paused || (MusicIsWaveform && MusicVoice < 0)) - return; - - MusicPaused = paused; - - if (MusicIsWaveform) - { - FX_PauseVoice(MusicVoice, paused); - return; - } - - if (paused) - MUSIC_Pause(); - else - MUSIC_Continue(); -} - - - -#else static int S_PlayMusic(const char *mapname, const char* fn, bool looping = true) { return Mus_Play(mapname, fn, looping); @@ -304,8 +151,6 @@ void S_PauseMusic(bool paused) Mus_SetPaused(paused); } -#endif - static void S_SetMusicIndex(unsigned int m) { diff --git a/source/rr/src/sounds.h b/source/rr/src/sounds.h index 19f52c806..32809074b 100644 --- a/source/rr/src/sounds.h +++ b/source/rr/src/sounds.h @@ -71,9 +71,6 @@ inline void S_ClearSoundLocks(void) {} int32_t S_LoadSound(uint32_t num); void S_PrecacheSounds(void); void S_MenuSound(void); -void S_MusicShutdown(void); -void S_MusicStartup(void); -void S_MusicVolume(int32_t volume); void S_RestartMusic(void); void S_PauseMusic(bool paused); void S_PauseSounds(bool paused);