diff --git a/libraries/zmusic/zmusic/zmusic.h b/libraries/zmusic/zmusic/zmusic.h index 309a3f26b..4847ae81f 100644 --- a/libraries/zmusic/zmusic/zmusic.h +++ b/libraries/zmusic/zmusic/zmusic.h @@ -149,10 +149,11 @@ void SetWgOpn(const void* data, unsigned len); // Set DMXGUS data for running the GUS synth in actual GUS mode. void SetDmxGus(const void* data, unsigned len); -// These exports is needed by the MIDI dumpers which need to remain on the client side. +// These exports are needed by the MIDI dumpers which need to remain on the client side. class MIDISource; // abstract for the client EMIDIType IdentifyMIDIType(uint32_t *id, int size); MIDISource *CreateMIDISource(const uint8_t *data, size_t length, EMIDIType miditype); +void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); class MusInfo; // Configuration interface. The return value specifies if a music restart is needed. diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 15e994a9d..506cbf30e 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -51,6 +51,7 @@ #include "teaminfo.h" #include "r_data/sprites.h" #include "atterm.h" +#include "zmusic/zmusic.h" void ClearSaveGames(); diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index b9f30cdd4..9a547aaa1 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -69,7 +69,6 @@ #include "p_effect.h" #include "r_utility.h" #include "a_morph.h" -#include "i_music.h" #include "thingdef.h" #include "g_levellocals.h" #include "actorinlines.h" diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index b8ccdbbcd..d21fe0394 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -46,7 +46,6 @@ #include "a_weapons.h" #include "d_player.h" #include "p_setup.h" -#include "i_music.h" #include "am_map.h" #include "v_video.h" #include "gi.h" diff --git a/src/sound/backend/oalsound.cpp b/src/sound/backend/oalsound.cpp index 3236b2b32..39674b9a9 100644 --- a/src/sound/backend/oalsound.cpp +++ b/src/sound/backend/oalsound.cpp @@ -41,7 +41,6 @@ #include "c_dispatch.h" #include "v_text.h" #include "i_module.h" -#include "i_music.h" #include "cmdlib.h" #include "menu/menu.h" #include "zmusic/sounddecoder.h" diff --git a/src/sound/music/i_music.cpp b/src/sound/music/i_music.cpp index 0ef50443d..dd7f02d32 100644 --- a/src/sound/music/i_music.cpp +++ b/src/sound/music/i_music.cpp @@ -45,17 +45,19 @@ #include "c_dispatch.h" #include "templates.h" #include "stats.h" +#include "c_cvars.h" #include "c_console.h" #include "vm.h" #include "v_text.h" +#include "i_sound.h" #include "i_soundfont.h" #include "s_music.h" +#include "doomstat.h" #include "zmusic/zmusic.h" #include "zmusic/musinfo.h" #include "streamsources/streamsource.h" #include "filereadermusicinterface.h" #include "../libraries/zmusic/midisources/midisource.h" -#include "../libraries/dumb/include/dumb.h" #define GZIP_ID1 31 #define GZIP_ID2 139 @@ -68,9 +70,9 @@ #define GZIP_FNAME 8 #define GZIP_FCOMMENT 16 -extern int MUSHeaderSearch(const uint8_t *head, int len); + void I_InitSoundFonts(); -extern "C" void dumb_exit(); + extern MusPlayingInfo mus_playing; EXTERN_CVAR (Int, snd_samplerate) @@ -80,7 +82,6 @@ static bool MusicDown = true; static bool ungzip(uint8_t *data, int size, std::vector &newdata); -MusInfo *currSong; int nomusic = 0; //========================================================================== @@ -275,16 +276,14 @@ void I_ShutdownMusic(bool onexit) if (MusicDown) return; MusicDown = true; - if (currSong) + if (mus_playing.handle) { S_StopMusic (true); - assert (currSong == nullptr); + assert (mus_playing.handle == nullptr); } if (onexit) { - // free static data in the backends. - TimidityPP_Shutdown(); - dumb_exit(); + ZMusic_Shutdown(); } } @@ -294,7 +293,7 @@ void I_ShutdownMusic(bool onexit) // //========================================================================== -MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *device) +MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args) { MusInfo *info = nullptr; StreamSource *streamsource = nullptr; @@ -357,14 +356,13 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi return nullptr; } - EMidiDevice devtype = device == nullptr ? MDEV_DEFAULT : (EMidiDevice)device->device; #ifndef _WIN32 // non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS - if (devtype == MDEV_MMAPI) - devtype = MDEV_SNDSYS; + if (device == MDEV_MMAPI) + device = MDEV_SNDSYS; #endif - info = CreateMIDIStreamer(source, devtype, device != nullptr ? device->args.GetChars() : ""); + info = CreateMIDIStreamer(source, device, Args? Args : ""); } // Check for CDDA "format" @@ -546,15 +544,6 @@ static bool ungzip(uint8_t *data, int complen, std::vector &newdata) // //========================================================================== -void I_UpdateMusic() -{ - if (currSong != nullptr) - { - currSong->Update(); - } -} - - void I_SetRelativeVolume(float vol) { relative_volume = (float)vol; diff --git a/src/sound/music/i_music.h b/src/sound/music/i_music.h index c2639b2f0..54502461b 100644 --- a/src/sound/music/i_music.h +++ b/src/sound/music/i_music.h @@ -34,10 +34,6 @@ #ifndef __I_MUSIC_H__ #define __I_MUSIC_H__ -#include "doomdef.h" -#include "zmusic/mididefs.h" -#include "i_soundinternal.h" - class FileReader; struct FOptionValues; @@ -47,17 +43,11 @@ struct FOptionValues; void I_InitMusic (); void I_ShutdownMusic (bool onexit = false); void I_BuildMIDIMenuList (FOptionValues *); -void I_UpdateMusic (); // Volume. void I_SetRelativeVolume(float); void I_SetMusicVolume (double volume); -// Registers a song handle to song data. -class MusInfo; -struct MidiDeviceSetting; -MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *device); -MusInfo *I_RegisterCDSong (int track, int cdid = 0); extern int nomusic; diff --git a/src/sound/music/i_musicinterns.h b/src/sound/music/i_musicinterns.h index 95686ef70..c316ba27d 100644 --- a/src/sound/music/i_musicinterns.h +++ b/src/sound/music/i_musicinterns.h @@ -1,42 +1,32 @@ +#include #include #include -#include "c_cvars.h" -#include "i_sound.h" -#include "i_music.h" -#include "s_sound.h" -#include "files.h" -#include "zmusic/midiconfig.h" -#include "zmusic/mididefs.h" - -#include "zmusic/..//mididevices/mididevice.h" // this is still needed... - -void I_InitMusicWin32 (); +#include "zmusic/zmusic.h" class MIDISource; class MIDIDevice; class OPLmusicFile; - - -// Data interface - -// Module played via foo_dumb ----------------------------------------------- - class StreamSource; - -// stream song ------------------------------------------ +class MusInfo; MusInfo *OpenStreamSong(StreamSource *source); const char *GME_CheckFormat(uint32_t header); MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader); MusInfo* CD_OpenSong(int track, int id); MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args); -void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); -// -------------------------------------------------------------------------- +// Registers a song handle to song data. -extern MusInfo *currSong; -void MIDIDeviceChanged(int newdev, bool force = false); +MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args); +MusInfo *I_RegisterCDSong (int track, int cdid = 0); -EXTERN_CVAR (Float, snd_mastervolume) -EXTERN_CVAR (Float, snd_musicvolume) +void TimidityPP_Shutdown(); +extern "C" void dumb_exit(); + +inline void ZMusic_Shutdown() +{ + // free static data in the backends. + TimidityPP_Shutdown(); + dumb_exit(); +} diff --git a/src/sound/music/music_config.cpp b/src/sound/music/music_config.cpp index ac538c412..2531be803 100644 --- a/src/sound/music/music_config.cpp +++ b/src/sound/music/music_config.cpp @@ -33,7 +33,9 @@ ** */ -#include "i_musicinterns.h" +#include +#include +#include #include "c_cvars.h" #include "s_music.h" #include "zmusic/zmusic.h" diff --git a/src/sound/music/music_midi_base.cpp b/src/sound/music/music_midi_base.cpp index e335461ff..6d08fe0e7 100644 --- a/src/sound/music/music_midi_base.cpp +++ b/src/sound/music/music_midi_base.cpp @@ -38,7 +38,6 @@ #include #endif -#include "i_musicinterns.h" #include "c_dispatch.h" #include "v_text.h" diff --git a/src/sound/s_music.cpp b/src/sound/s_music.cpp index cf052f8bc..d0fc7a800 100644 --- a/src/sound/s_music.cpp +++ b/src/sound/s_music.cpp @@ -89,6 +89,8 @@ #include "filereadermusicinterface.h" #include "zmusic/musinfo.h" +#include "i_musicinterns.h" + // MACROS ------------------------------------------------------------------ @@ -269,17 +271,18 @@ void S_ResumeMusic () void S_UpdateMusic () { - I_UpdateMusic(); - - // [RH] Update music and/or playlist. IsPlaying() must be called - // to attempt to reconnect to broken net streams and to advance the - // playlist when the current song finishes. - if (mus_playing.handle != nullptr && - !mus_playing.handle->IsPlaying() && - PlayList) + if (mus_playing.handle != nullptr) { - PlayList->Advance(); - S_ActivatePlayList(false); + mus_playing.handle->Update(); + + // [RH] Update music and/or playlist. IsPlaying() must be called + // to attempt to reconnect to broken net streams and to advance the + // playlist when the current song finishes. + if (!mus_playing.handle->IsPlaying() && PlayList) + { + PlayList->Advance(); + S_ActivatePlayList(false); + } } } @@ -540,7 +543,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) try { auto mreader = new FileReaderMusicInterface(reader); - mus_playing.handle = I_RegisterSong(mreader, devp); + mus_playing.handle = I_RegisterSong(mreader, devp? (EMidiDevice)devp->device : MDEV_DEFAULT, devp? devp->args.GetChars() : ""); } catch (const std::runtime_error& err) {