From 859028b35a6fb6123bb02d1e2f0ac4e52dea0d34 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Sep 2019 13:33:09 +0200 Subject: [PATCH] - moved the stream sources to zmusic project. --- libraries/zmusic/CMakeLists.txt | 9 ++++- .../zmusic/streamsources}/music_dumb.cpp | 2 +- .../zmusic/streamsources}/music_gme.cpp | 0 .../streamsources}/music_libsndfile.cpp | 1 + .../zmusic/streamsources}/music_opl.cpp | 6 +-- .../zmusic/streamsources}/music_xa.cpp | 3 +- libraries/zmusic/streamsources/streamsource.h | 39 +++++++++++++++++++ libraries/zmusic/zmusic/mididefs.h | 2 + src/CMakeLists.txt | 8 +--- src/sound/music/i_music.cpp | 1 + src/sound/music/i_musicinterns.h | 6 --- src/sound/musicformats/music_stream.cpp | 2 +- 12 files changed, 59 insertions(+), 20 deletions(-) rename {src/sound/musicformats => libraries/zmusic/streamsources}/music_dumb.cpp (99%) rename {src/sound/musicformats => libraries/zmusic/streamsources}/music_gme.cpp (100%) rename {src/sound/musicformats => libraries/zmusic/streamsources}/music_libsndfile.cpp (99%) rename {src/sound/musicformats => libraries/zmusic/streamsources}/music_opl.cpp (96%) rename {src/sound/musicformats => libraries/zmusic/streamsources}/music_xa.cpp (99%) create mode 100644 libraries/zmusic/streamsources/streamsource.h diff --git a/libraries/zmusic/CMakeLists.txt b/libraries/zmusic/CMakeLists.txt index 65fdc1dae..b2b0a78e0 100644 --- a/libraries/zmusic/CMakeLists.txt +++ b/libraries/zmusic/CMakeLists.txt @@ -38,7 +38,7 @@ elseif( FLUIDSYNTH_FOUND ) endif() -include_directories( "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" ) +include_directories( "../libraries/dumb/include" "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" ) if (WIN32) set( PLAT_WIN32_SOURCES @@ -50,6 +50,7 @@ file( GLOB HEADER_FILES mididevices/*.h midisources/*.h decoder/*.h + streamsources/*.h thirdparty/*.h ) add_library( zmusic STATIC @@ -70,6 +71,11 @@ add_library( zmusic STATIC midisources/midisource_smf.cpp midisources/midisource_hmi.cpp midisources/midisource_xmi.cpp + streamsources/music_dumb.cpp + streamsources/music_gme.cpp + streamsources/music_libsndfile.cpp + streamsources/music_opl.cpp + streamsources/music_xa.cpp decoder/sounddecoder.cpp decoder/sndfile_decoder.cpp decoder/mpg123_decoder.cpp @@ -82,4 +88,5 @@ source_group("MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mid source_group("MIDI Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/midisources/.+") source_group("MIDI Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/zmusic/.+") source_group("Sound Decoding" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/decoder/.+") +source_group("Stream Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/streamsources/.+") source_group("Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/.+") diff --git a/src/sound/musicformats/music_dumb.cpp b/libraries/zmusic/streamsources/music_dumb.cpp similarity index 99% rename from src/sound/musicformats/music_dumb.cpp rename to libraries/zmusic/streamsources/music_dumb.cpp index ff1a59808..54721fa03 100644 --- a/src/sound/musicformats/music_dumb.cpp +++ b/libraries/zmusic/streamsources/music_dumb.cpp @@ -45,7 +45,7 @@ #undef CDECL // w32api's windef.h defines this #include "../dumb/include/dumb.h" #include "../dumb/include/internal/it.h" -#include "m_swap.h" +#include "zmusic/m_swap.h" #include "zmusic/mididefs.h" #include "zmusic/midiconfig.h" #include "../../libraries/music_common/fileio.h" diff --git a/src/sound/musicformats/music_gme.cpp b/libraries/zmusic/streamsources/music_gme.cpp similarity index 100% rename from src/sound/musicformats/music_gme.cpp rename to libraries/zmusic/streamsources/music_gme.cpp diff --git a/src/sound/musicformats/music_libsndfile.cpp b/libraries/zmusic/streamsources/music_libsndfile.cpp similarity index 99% rename from src/sound/musicformats/music_libsndfile.cpp rename to libraries/zmusic/streamsources/music_libsndfile.cpp index a367174d5..d96824323 100644 --- a/src/sound/musicformats/music_libsndfile.cpp +++ b/libraries/zmusic/streamsources/music_libsndfile.cpp @@ -35,6 +35,7 @@ // HEADER FILES ------------------------------------------------------------ #include +#include #include "streamsource.h" #include "zmusic/sounddecoder.h" diff --git a/src/sound/musicformats/music_opl.cpp b/libraries/zmusic/streamsources/music_opl.cpp similarity index 96% rename from src/sound/musicformats/music_opl.cpp rename to libraries/zmusic/streamsources/music_opl.cpp index 4bf7cd07a..856c16bf1 100644 --- a/src/sound/musicformats/music_opl.cpp +++ b/libraries/zmusic/streamsources/music_opl.cpp @@ -32,9 +32,9 @@ */ #include "streamsource.h" -#include "../libraries/oplsynth/oplsynth/opl.h" -#include "../libraries/oplsynth/oplsynth/opl_mus_player.h" -#include "../libraries/music_common/fileio.h" +#include "oplsynth/opl.h" +#include "oplsynth/opl_mus_player.h" +#include "../../libraries/music_common/fileio.h" #include "zmusic/midiconfig.h" diff --git a/src/sound/musicformats/music_xa.cpp b/libraries/zmusic/streamsources/music_xa.cpp similarity index 99% rename from src/sound/musicformats/music_xa.cpp rename to libraries/zmusic/streamsources/music_xa.cpp index 0d77ce86e..45f2d6614 100644 --- a/src/sound/musicformats/music_xa.cpp +++ b/libraries/zmusic/streamsources/music_xa.cpp @@ -1,5 +1,6 @@ +#include #include "streamsource.h" -#include "../libraries/music_common/fileio.h" +#include "../../libraries/music_common/fileio.h" /** * PlayStation XA (ADPCM) source support for MultiVoc diff --git a/libraries/zmusic/streamsources/streamsource.h b/libraries/zmusic/streamsources/streamsource.h new file mode 100644 index 000000000..4b01579c4 --- /dev/null +++ b/libraries/zmusic/streamsources/streamsource.h @@ -0,0 +1,39 @@ +#pragma once + +// Anything streamed to the sound system as raw wave data, except MIDIs -------------------- + +#include +#include "zmusic/mididefs.h" // for StreamSourceInfo +#include "zmusic/midiconfig.h" + +class StreamSource +{ +protected: + bool m_Looping = true; + int m_OutputRate; + +public: + + StreamSource (int outputRate) { m_OutputRate = outputRate; } + virtual ~StreamSource () {} + virtual void SetPlayMode(bool looping) { m_Looping = looping; } + virtual bool Start() { return true; } + virtual bool SetPosition(unsigned position) { return false; } + virtual bool SetSubsong(int subsong) { return false; } + virtual bool GetData(void *buffer, size_t len) = 0; + virtual SoundStreamInfo GetFormat() { return {65536, m_OutputRate, 2 }; } // Default format is: System's output sample rate, 32 bit float, stereo + virtual std::string GetStats() { return ""; } + virtual void ChangeSettingInt(const char *name, int value) { } + virtual void ChangeSettingNum(const char *name, double value) { } + virtual void ChangeSettingString(const char *name, const char *value) { } + +protected: + StreamSource() = default; +}; + + +StreamSource *MOD_OpenSong(MusicIO::FileInterface* reader, DumbConfig* config, int samplerate); +StreamSource* GME_OpenSong(MusicIO::FileInterface* reader, const char* fmt, float stereo_depth, int sample_rate); +StreamSource *SndFile_OpenSong(MusicIO::FileInterface* fr); +StreamSource* XA_OpenSong(MusicIO::FileInterface* reader); +StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config); diff --git a/libraries/zmusic/zmusic/mididefs.h b/libraries/zmusic/zmusic/mididefs.h index 67c4f1d09..a42e22eaf 100644 --- a/libraries/zmusic/zmusic/mididefs.h +++ b/libraries/zmusic/zmusic/mididefs.h @@ -1,5 +1,7 @@ #pragma once +#include + enum { MAX_MIDI_EVENTS = 128 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c26e33ef..f339654f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -463,7 +463,7 @@ set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_L if (HAVE_VULKAN) set( ZDOOM_LIBS ${ZDOOM_LIBS} "glslang" "SPIRV" "OGLCompiler") endif() -include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" ) +include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" ) if( ${HAVE_VM_JIT} ) add_definitions( -DHAVE_VM_JIT ) @@ -1161,13 +1161,8 @@ set (PCH_SOURCES sound/backend/i_sound.cpp sound/music/midi_cvars.cpp sound/musicformats/music_cd.cpp - sound/musicformats/music_dumb.cpp - sound/musicformats/music_gme.cpp - sound/musicformats/music_libsndfile.cpp sound/musicformats/music_midistream.cpp - sound/musicformats/music_opl.cpp sound/musicformats/music_stream.cpp - sound/musicformats/music_xa.cpp rendering/swrenderer/textures/r_swtexture.cpp rendering/swrenderer/textures/warptexture.cpp rendering/swrenderer/textures/swcanvastexture.cpp @@ -1288,7 +1283,6 @@ include_directories( . rendering rendering/vulkan/thirdparty ../libraries/gdtoa - ../libraries/dumb/include ../libraries/glslang/glslang/Public ../libraries/glslang/spirv ${CMAKE_BINARY_DIR}/libraries/gdtoa diff --git a/src/sound/music/i_music.cpp b/src/sound/music/i_music.cpp index c1cbcc0f8..395b43a40 100644 --- a/src/sound/music/i_music.cpp +++ b/src/sound/music/i_music.cpp @@ -47,6 +47,7 @@ #include "stats.h" #include "vm.h" #include "s_music.h" +#include "streamsources/streamsource.h" #include "filereadermusicinterface.h" #include "../libraries/zmusic/midisources/midisource.h" #include "../libraries/dumb/include/dumb.h" diff --git a/src/sound/music/i_musicinterns.h b/src/sound/music/i_musicinterns.h index 68e537561..7c9a3b5f9 100644 --- a/src/sound/music/i_musicinterns.h +++ b/src/sound/music/i_musicinterns.h @@ -152,12 +152,6 @@ void Dumb_SetupConfig(DumbConfig* config); class StreamSource; -StreamSource *MOD_OpenSong(MusicIO::FileInterface* reader, DumbConfig* config, int samplerate); -StreamSource* GME_OpenSong(MusicIO::FileInterface* reader, const char* fmt, float stereo_depth, int sample_rate); -StreamSource *SndFile_OpenSong(MusicIO::FileInterface* fr); -StreamSource* XA_OpenSong(MusicIO::FileInterface* reader); -StreamSource* OPL_OpenSong(MusicIO::FileInterface* reader, OPLConfig *config); - // stream song ------------------------------------------ MusInfo *OpenStreamSong(StreamSource *source); diff --git a/src/sound/musicformats/music_stream.cpp b/src/sound/musicformats/music_stream.cpp index fdfaa52b2..3b6b16c32 100644 --- a/src/sound/musicformats/music_stream.cpp +++ b/src/sound/musicformats/music_stream.cpp @@ -33,7 +33,7 @@ */ #include "i_musicinterns.h" -#include "streamsource.h" +#include "streamsources/streamsource.h" class StreamSong : public MusInfo {