From 352365189f089dec1a89d86361237c31279c998d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Sep 2019 02:10:00 +0200 Subject: [PATCH] - moved the main music classes to ZMusic What's left is the CD-Audio playback and some global functions. --- libraries/zmusic/CMakeLists.txt | 4 ++++ libraries/zmusic/mididevices/mididevice.h | 2 -- .../zmusic/musicformats/music_midi.cpp | 23 +++++++++---------- .../zmusic}/musicformats/music_stream.cpp | 0 src/CMakeLists.txt | 2 -- 5 files changed, 15 insertions(+), 16 deletions(-) rename src/sound/musicformats/music_midistream.cpp => libraries/zmusic/musicformats/music_midi.cpp (98%) rename {src/sound => libraries/zmusic}/musicformats/music_stream.cpp (100%) diff --git a/libraries/zmusic/CMakeLists.txt b/libraries/zmusic/CMakeLists.txt index 4e75ac2565..aaa7db2742 100644 --- a/libraries/zmusic/CMakeLists.txt +++ b/libraries/zmusic/CMakeLists.txt @@ -49,6 +49,7 @@ file( GLOB HEADER_FILES zmusic/*.h mididevices/*.h midisources/*.h + musicformats/*.h decoder/*.h streamsources/*.h thirdparty/*.h @@ -76,6 +77,8 @@ add_library( zmusic STATIC streamsources/music_libsndfile.cpp streamsources/music_opl.cpp streamsources/music_xa.cpp + musicformats/music_stream.cpp + musicformats/music_midi.cpp decoder/sounddecoder.cpp decoder/sndfile_decoder.cpp decoder/mpg123_decoder.cpp @@ -87,6 +90,7 @@ target_link_libraries( zmusic ) source_group("MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mididevices/.+") source_group("MIDI Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/midisources/.+") +source_group("Music Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/musicformats/.+") source_group("Public Interface" 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/.+") diff --git a/libraries/zmusic/mididevices/mididevice.h b/libraries/zmusic/mididevices/mididevice.h index 5cda680179..80dff086ea 100644 --- a/libraries/zmusic/mididevices/mididevice.h +++ b/libraries/zmusic/mididevices/mididevice.h @@ -4,8 +4,6 @@ #include "zmusic/midiconfig.h" #include "zmusic/mididefs.h" -#include "mididevices/mididevice.h" - void TimidityPP_Shutdown(); typedef void(*MidiCallback)(void *); diff --git a/src/sound/musicformats/music_midistream.cpp b/libraries/zmusic/musicformats/music_midi.cpp similarity index 98% rename from src/sound/musicformats/music_midistream.cpp rename to libraries/zmusic/musicformats/music_midi.cpp index d22a397b7b..909281f994 100644 --- a/src/sound/musicformats/music_midistream.cpp +++ b/libraries/zmusic/musicformats/music_midi.cpp @@ -34,7 +34,7 @@ // HEADER FILES ------------------------------------------------------------ - +#include #include "zmusic/musinfo.h" #include "mididevices/mididevice.h" #include "midisources/midisource.h" @@ -125,7 +125,7 @@ protected: EMidiDevice DeviceType; bool CallbackIsThreaded; int LoopLimit; - FString Args; + std::string Args; std::unique_ptr source; }; @@ -255,15 +255,15 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate) switch (devtype) { case MDEV_GUS: - dev = CreateTimidityMIDIDevice(Args, samplerate); + dev = CreateTimidityMIDIDevice(Args.c_str(), samplerate); break; case MDEV_ADL: - dev = CreateADLMIDIDevice(Args); + dev = CreateADLMIDIDevice(Args.c_str()); break; case MDEV_OPN: - dev = CreateOPNMIDIDevice(Args); + dev = CreateOPNMIDIDevice(Args.c_str()); break; case MDEV_MMAPI: @@ -275,19 +275,19 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate) // Intentional fall-through for non-Windows systems. case MDEV_FLUIDSYNTH: - dev = CreateFluidSynthMIDIDevice(samplerate, Args); + dev = CreateFluidSynthMIDIDevice(samplerate, Args.c_str()); break; case MDEV_OPL: - dev = CreateOplMIDIDevice(Args); + dev = CreateOplMIDIDevice(Args.c_str()); break; case MDEV_TIMIDITY: - dev = CreateTimidityPPMIDIDevice(Args, samplerate); + dev = CreateTimidityPPMIDIDevice(Args.c_str(), samplerate); break; case MDEV_WILDMIDI: - dev = CreateWildMIDIDevice(Args, samplerate); + dev = CreateWildMIDIDevice(Args.c_str(), samplerate); break; default: @@ -783,8 +783,7 @@ int MIDIStreamer::FillBuffer(int buffer_num, int max_events, uint32_t max_time) int i; uint32_t *events = Events[buffer_num], *max_event_p; - uint32_t tot_time = 0; - uint32_t time = 0; + // The final event is for a NOP to hold the delay from the last event. max_event_p = events + (max_events - 1) * 3; @@ -999,4 +998,4 @@ void MIDIDumpWave(MIDISource* source, EMidiDevice devtype, const char *devarg, c MIDIStreamer me(devtype, devarg); me.SetMIDISource(source); me.DumpWave(outname, subsong, samplerate); -} \ No newline at end of file +} diff --git a/src/sound/musicformats/music_stream.cpp b/libraries/zmusic/musicformats/music_stream.cpp similarity index 100% rename from src/sound/musicformats/music_stream.cpp rename to libraries/zmusic/musicformats/music_stream.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62379c016c..a4b148eb40 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1161,8 +1161,6 @@ set (PCH_SOURCES sound/backend/i_sound.cpp sound/music/music_config.cpp sound/musicformats/music_cd.cpp - sound/musicformats/music_midistream.cpp - sound/musicformats/music_stream.cpp rendering/swrenderer/textures/r_swtexture.cpp rendering/swrenderer/textures/warptexture.cpp rendering/swrenderer/textures/swcanvastexture.cpp