Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package zmusic for openSUSE:Factory checked in at 2022-06-24 08:45:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/zmusic (Old) and /work/SRC/openSUSE:Factory/.zmusic.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "zmusic" Fri Jun 24 08:45:56 2022 rev:6 rq:984770 version:1.1.9 Changes: -------- --- /work/SRC/openSUSE:Factory/zmusic/zmusic.changes 2021-06-01 10:40:13.465095256 +0200 +++ /work/SRC/openSUSE:Factory/.zmusic.new.1548/zmusic.changes 2022-06-24 08:46:05.055191177 +0200 @@ -1,0 +2,17 @@ +Thu Jun 23 21:46:14 UTC 2022 - Jan Engelhardt <jeng...@inai.de> + +- Update to release 1.1.9 + * Improve ALSA MIDI backend: No longer exclude builtin MIDI + passthrough ports + * Add handling for KeyPress events and avoid calling + snd_seq_sync_output_queue twice + * Add a 32-bit float sample type + * Add a new ZMusic_GetStreamInfoEx function + * Implement ZMusic_GetStreamInfo using GetStreamInfoEx + * Better handle various formats in SndFileSong + * Handle non-int16 samples in dumb_decode_vorbis + * Add missing GetStreamInfoEx for CDSong + * Fixes for gus and wildmidi emulation - fixed gus emulation + not working with DMXGUS and DMXGUSC lump + +------------------------------------------------------------------- Old: ---- ZMusic-1.1.8.tar.gz New: ---- ZMusic-1.1.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ zmusic.spec ++++++ --- /var/tmp/diff_new_pack.GLcKTe/_old 2022-06-24 08:46:05.627191817 +0200 +++ /var/tmp/diff_new_pack.GLcKTe/_new 2022-06-24 08:46:05.631191822 +0200 @@ -1,7 +1,7 @@ # # spec file for package zmusic # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: zmusic -Version: 1.1.8 +Version: 1.1.9 Release: 0 Summary: ZDoom component library for music handling License: GPL-3.0-only ++++++ ZMusic-1.1.8.tar.gz -> ZMusic-1.1.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/CMakeLists.txt new/ZMusic-1.1.9/CMakeLists.txt --- old/ZMusic-1.1.8/CMakeLists.txt 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/CMakeLists.txt 2022-06-06 18:09:47.000000000 +0200 @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13...3.19) project(ZMusic - VERSION 1.1.8 + VERSION 1.1.9 LANGUAGES C CXX ) @@ -12,12 +12,28 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) -# If building standalone give the user the option to build shared or static. -# Otherwise the vendoring project should set the variable. if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + # This project is being built standalone + + # Give user option to build shared or static option(BUILD_SHARED_LIBS "Build shared libraries" ON) -elseif(NOT DEFINED BUILD_SHARED_LIBS) - set(BUILD_SHARED_LIBS ON) + + # Enable install rules + set(ZMUSIC_INSTALL ON) +else() + # This project is being vendored by another project, set option default if + # the parent project doesn't provide them. + + if(NOT DEFINED BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ON) + endif() + + # Although install rules can be avoided with EXCLUDE_FROM_ALL on + # add_subdirectory, the EXPORT rules may place certain usage requirements on + # targets shared between the two projects. + if(NOT DEFINED ZMUSIC_INSTALL) + set(ZMUSIC_INSTALL OFF) + endif() endif() if(NOT CMAKE_BUILD_TYPE) @@ -110,10 +126,12 @@ ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake ) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic - COMPONENT devel -) +if(ZMUSIC_INSTALL) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic + COMPONENT devel + ) +endif() if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CPACK_PACKAGE_CONTACT "First Last <exam...@example.com>" CACHE STRING "Contact info for archive maintainer.") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/README.md new/ZMusic-1.1.9/README.md --- old/ZMusic-1.1.8/README.md 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/README.md 2022-06-06 18:09:47.000000000 +0200 @@ -9,8 +9,8 @@ git clone https://github.com/coelckers/ZMusic.git mkdir ZMusic/build cd ZMusic/build -cmake .. -DCMAKE_BUILD_TYPE=Release -cmake . --build +cmake -DCMAKE_BUILD_TYPE=Release .. +cmake --build . ``` On Unix/Linux you may also supply `sudo make install` in the build folder to push the compiled library directly into the file system so that it can be found by the previously mentioned projects. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/cmake/ZUtility.cmake new/ZMusic-1.1.9/cmake/ZUtility.cmake --- old/ZMusic-1.1.8/cmake/ZUtility.cmake 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/cmake/ZUtility.cmake 2022-06-06 18:09:47.000000000 +0200 @@ -120,10 +120,18 @@ endif() endfunction() -function(use_fast_math Tgt) - if(MSVC) - set_property( TARGET "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "/fp:fast" ) - elseif(ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE) - set_property( TARGET "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "-ffast-math" "-ffp-contract=fast" ) - endif() +function(use_fast_math) + foreach(Tgt IN LISTS ARGN) + if(TARGET Tgt) + set(TgtType TARGET) + else() + set(TgtType SOURCE) + endif() + + if(MSVC) + set_property("${TgtType}" "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "/fp:fast") + elseif(COMPILER_IS_GNUCXX_COMPATIBLE) + set_property("${TgtType}" "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "-ffast-math" "-ffp-contract=fast") + endif() + endforeach() endfunction() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/include/zmusic.h new/ZMusic-1.1.9/include/zmusic.h --- old/ZMusic-1.1.8/include/zmusic.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/include/zmusic.h 2022-06-06 18:09:47.000000000 +0200 @@ -67,7 +67,8 @@ typedef enum SampleType_ { SampleType_UInt8, - SampleType_Int16 + SampleType_Int16, + SampleType_Float32 } SampleType; typedef enum ChannelConfig_ @@ -76,6 +77,15 @@ ChannelConfig_Stereo } ChannelConfig; +typedef struct SoundStreamInfoEx_ +{ + int mBufferSize; // If mBufferSize is 0, the song doesn't use streaming but plays through a different interface. + int mSampleRate; + SampleType mSampleType; + ChannelConfig mChannelConfig; +} SoundStreamInfoEx; + + typedef enum EIntConfigKey_ { zmusic_adl_chips_count, @@ -264,14 +274,14 @@ #ifndef ZMUSIC_INTERNAL -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(ZMUSIC_STATIC) #define DLL_IMPORT _declspec(dllimport) -#else // !_MSC_VER +#else #define DLL_IMPORT -#endif // _MSC_VER +#endif // Note that the internal 'class' definitions are not C compatible! -typedef struct { int zm1; } *ZMusic_MidiSource; -typedef struct { int zm2; } *ZMusic_MusicStream; +typedef struct _ZMusic_MidiSource_Struct { int zm1; } *ZMusic_MidiSource; +typedef struct _ZMusic_MusicStream_Struct { int zm2; } *ZMusic_MusicStream; struct SoundDecoder; #endif @@ -319,6 +329,7 @@ DLL_IMPORT void ZMusic_VolumeChanged(ZMusic_MusicStream song); DLL_IMPORT zmusic_bool ZMusic_WriteSMF(ZMusic_MidiSource source, const char* fn, int looplimit); DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, SoundStreamInfo *info); + DLL_IMPORT void ZMusic_GetStreamInfoEx(ZMusic_MusicStream song, SoundStreamInfoEx *info); // Configuration interface. The return value specifies if a music restart is needed. // RealValue should be written back to the CVAR or whatever other method the client uses to store configuration state. DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); @@ -406,6 +417,7 @@ typedef void (*pfn_ZMusic_VolumeChanged)(ZMusic_MusicStream song); typedef zmusic_bool (*pfn_ZMusic_WriteSMF)(ZMusic_MidiSource source, const char* fn, int looplimit); typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, SoundStreamInfo *info); +typedef void (*pfn_ZMusic_GetStreamInfoEx)(ZMusic_MusicStream song, SoundStreamInfoEx *info); typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EStringConfigKey key, ZMusic_MusicStream song, const char* value); @@ -419,4 +431,4 @@ -#endif \ No newline at end of file +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/CMakeLists.txt new/ZMusic-1.1.9/source/CMakeLists.txt --- old/ZMusic-1.1.8/source/CMakeLists.txt 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/CMakeLists.txt 2022-06-06 18:09:47.000000000 +0200 @@ -152,13 +152,14 @@ # Although zmusic-obj puts the public include directory in our private include # list, we need to add it to the interface include directories for consumers. -target_include_directories(zmusic INTERFACE $<INSTALL_INTERFACE:include>) -target_include_directories(zmusiclite INTERFACE $<INSTALL_INTERFACE:include>) +target_include_directories(zmusic INTERFACE $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${ZMusic_SOURCE_DIR}/include>) +target_include_directories(zmusiclite INTERFACE $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${ZMusic_SOURCE_DIR}/include>) target_link_libraries_hidden(zmusic zmusic-obj adl oplsynth opn timidity timidityplus wildmidi) target_link_libraries_hidden(zmusiclite zmusic-obj) -target_compile_definitions(zmusiclite PRIVATE ZMUSIC_LITE=1) +target_compile_definitions(zmusic PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:zmusic,TYPE>,STATIC_LIBRARY>:ZMUSIC_STATIC>) +target_compile_definitions(zmusiclite PRIVATE ZMUSIC_LITE=1 PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:zmusiclite,TYPE>,STATIC_LIBRARY>:ZMUSIC_STATIC>) set_target_properties(zmusic zmusiclite PROPERTIES @@ -168,37 +169,39 @@ SOVERSION ${PROJECT_VERSION_MAJOR} ) -install(TARGETS zmusic EXPORT ZMusicFullTargets -PUBLIC_HEADER - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - COMPONENT devel -LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT full - NAMELINK_COMPONENT devel -) - -install(TARGETS zmusiclite EXPORT ZMusicLiteTargets -PUBLIC_HEADER - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - COMPONENT devel -LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT lite - NAMELINK_COMPONENT devel -) - -install(EXPORT ZMusicFullTargets - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic" - NAMESPACE ZMusic:: - COMPONENT devel -) - -install(EXPORT ZMusicLiteTargets - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic" - NAMESPACE ZMusic:: - COMPONENT devel -) +if(ZMUSIC_INSTALL) + install(TARGETS zmusic EXPORT ZMusicFullTargets + PUBLIC_HEADER + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT devel + LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT full + NAMELINK_COMPONENT devel + ) + + install(TARGETS zmusiclite EXPORT ZMusicLiteTargets + PUBLIC_HEADER + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT devel + LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT lite + NAMELINK_COMPONENT devel + ) + + install(EXPORT ZMusicFullTargets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic" + NAMESPACE ZMusic:: + COMPONENT devel + ) + + install(EXPORT ZMusicLiteTargets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic" + NAMESPACE ZMusic:: + COMPONENT devel + ) +endif() if( MSVC ) option( ZMUSIC_GENERATE_MAPFILE "Generate .map file for debugging." OFF ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/decoder/sounddecoder.cpp new/ZMusic-1.1.9/source/decoder/sounddecoder.cpp --- old/ZMusic-1.1.8/source/decoder/sounddecoder.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/decoder/sounddecoder.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -105,13 +105,53 @@ } decoder->getInfo(&srate, &chans, &type); - if (chans != ChannelConfig_Mono || type != SampleType_Int16) + if (chans != ChannelConfig_Mono) { delete decoder; return samples; } - decoder->read((char*)samples, outlen); + if(type == SampleType_Int16) + decoder->read((char*)samples, outlen); + else if(type == SampleType_Float32) + { + constexpr size_t tempsize = 1024; + float temp[tempsize]; + size_t spos = 0; + + outlen /= sizeof(short); + int done = 0; + while(done < outlen) + { + size_t got = decoder->read((char*)temp, tempsize * sizeof(float)) / sizeof(float); + for(size_t i = 0;i < got;++i) + { + float s = temp[i] * 32768.0f; + samples[spos++] = (s > 32767.0f) ? 32767 : (s < -32768.0f) ? -32768 : (short)s; + } + if(got < tempsize) + break; + done += got; + } + } + else if(type == SampleType_UInt8) + { + constexpr size_t tempsize = 1024; + uint8_t temp[tempsize]; + size_t spos = 0; + + outlen /= sizeof(short); + int done = 0; + while(done < outlen) + { + size_t got = decoder->read((char*)temp, tempsize); + for(size_t i = 0;i < got;++i) + samples[spos++] = (short)((temp[i]-128) * 256); + if(got < tempsize) + break; + done += got; + } + } delete decoder; return samples; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/mididevice.h new/ZMusic-1.1.9/source/mididevices/mididevice.h --- old/ZMusic-1.1.8/source/mididevices/mididevice.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/mididevice.h 2022-06-06 18:09:47.000000000 +0200 @@ -51,7 +51,7 @@ virtual std::string GetStats(); virtual int GetDeviceType() const { return MDEV_DEFAULT; } virtual bool CanHandleSysex() const { return true; } - virtual SoundStreamInfo GetStreamInfo() const; + virtual SoundStreamInfoEx GetStreamInfoEx() const; protected: MidiCallback Callback; @@ -81,7 +81,7 @@ virtual int Open() override; virtual bool ServiceStream(void* buff, int numbytes); int GetSampleRate() const { return SampleRate; } - SoundStreamInfo GetStreamInfo() const override; + SoundStreamInfoEx GetStreamInfoEx() const override; protected: double Tempo; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_alsa_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_alsa_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_alsa_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_alsa_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -50,7 +50,6 @@ enum class EventType { Null, - Delay, Action }; @@ -160,7 +159,7 @@ snd_seq_port_info_set_port(pinfo, IntendedPortId); snd_seq_port_info_set_port_specified(pinfo, 1); - snd_seq_port_info_set_name(pinfo, "GZDoom Music"); + snd_seq_port_info_set_name(pinfo, "ZMusic Program Music"); snd_seq_port_info_set_capability(pinfo, 0); snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION); @@ -172,7 +171,7 @@ if (QueueId < 0) { - QueueId = snd_seq_alloc_named_queue(sequencer.handle, "GZDoom Queue"); + QueueId = snd_seq_alloc_named_queue(sequencer.handle, "ZMusic Program Queue"); } if (!Connected) { @@ -290,8 +289,8 @@ return EventType::Action; case MIDI_POLYPRESS: - // FIXME: Seems to be missing in the Alsa sequencer implementation - break; + snd_seq_ev_set_keypress(&state.data, channel, parm1, parm2); + return EventType::Action; case MIDI_CTRLCHANGE: snd_seq_ev_set_controller(&state.data, channel, parm1, parm2); @@ -315,8 +314,10 @@ break; } } - // We didn't really recognize the event, treat it as a delay - return EventType::Delay; + // We didn't really recognize the event, treat it as a NOP + state.data.type = SND_SEQ_EVENT_NONE; + snd_seq_ev_set_fixed(&state.data); + return EventType::Action; } void AlsaMIDIDevice::SetExit(bool exit) { @@ -374,13 +375,6 @@ continue; } - // chomp delays as they come... - if(type == EventType::Delay) { - buffer_ticks += event.ticks; - Position += event.size_of; - continue; - } - // Figure out if we should sleep (the event is too far in the future for us to care), and for how long int next_event_tick = buffer_ticks + event.ticks; int queue_tick = snd_seq_queue_status_get_tick_time(status); @@ -433,7 +427,6 @@ snd_seq_drain_output(sequencer.handle); snd_seq_sync_output_queue(sequencer.handle); } - snd_seq_sync_output_queue(sequencer.handle); snd_seq_stop_queue(sequencer.handle, QueueId, NULL); snd_seq_drain_output(sequencer.handle); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_alsa_state.cpp new/ZMusic-1.1.9/source/mididevices/music_alsa_state.cpp --- old/ZMusic-1.1.8/source/mididevices/music_alsa_state.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_alsa_state.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -67,7 +67,7 @@ if(error) { return false; } - error = snd_seq_set_client_name(handle, "GZDoom"); + error = snd_seq_set_client_name(handle, "ZMusic Program"); if(error) { snd_seq_close(handle); handle = nullptr; @@ -131,11 +131,7 @@ while (snd_seq_query_next_client(handle, cinfo) >= 0) { snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); - // Ignore 'ALSA oddities' that we don't want to use int clientID = snd_seq_client_info_get_client(cinfo); - if(clientID < 16) { - continue; - } snd_seq_port_info_set_port(pinfo, -1); // enumerate ports diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_base_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_base_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_base_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_base_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -172,11 +172,11 @@ //========================================================================== // -// MIDIDevice :: GetStreamInfo +// MIDIDevice :: GetStreamInfoEx // //========================================================================== -SoundStreamInfo MIDIDevice::GetStreamInfo() const +SoundStreamInfoEx MIDIDevice::GetStreamInfoEx() const { - return { 0, 0, 0 }; // i.e. do not use streaming. + return {}; // i.e. do not use streaming. } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_fluidsynth_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_fluidsynth_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_fluidsynth_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_fluidsynth_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -257,7 +257,8 @@ int FluidSynthMIDIDevice::OpenRenderer() { - fluid_synth_system_reset(FluidSynth); + // Send MIDI system reset command (big red 'panic' button), turns off notes, resets controllers and restores initial basic channel configuration. + //fluid_synth_system_reset(FluidSynth); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_softsynth_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_softsynth_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_softsynth_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_softsynth_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -88,18 +88,19 @@ //========================================================================== // -// SoftSynthMIDIDevice :: GwrStreamInfo +// SoftSynthMIDIDevice :: GetStreamInfoEx // //========================================================================== -SoundStreamInfo SoftSynthMIDIDevice::GetStreamInfo() const +SoundStreamInfoEx SoftSynthMIDIDevice::GetStreamInfoEx() const { int chunksize = (SampleRate / StreamBlockSize) * 4; if (!isMono) { chunksize *= 2; } - return { chunksize, SampleRate, isMono? 1:2 }; + return { chunksize, SampleRate, SampleType_Float32, + isMono ? ChannelConfig_Mono : ChannelConfig_Stereo }; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_timidity_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_timidity_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_timidity_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_timidity_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -94,42 +94,44 @@ void TimidityMIDIDevice::LoadInstruments() { - if (gusConfig.dmxgus.size()) + if (gusConfig.reader) { // Check if we got some GUS data before using it. - std::string ultradir = getenv("ULTRADIR"); - if (ultradir.length() || gusConfig.gus_patchdir.length() != 0) + std::string ultradir; + const char *ret = getenv("ULTRADIR"); + if (ret) ultradir = std::string(ret); + // The GUS put its patches in %ULTRADIR%/MIDI so we can try that + if (ultradir.length()) { - auto psreader = new MusicIO::FileSystemSoundFontReader(""); - - // The GUS put its patches in %ULTRADIR%/MIDI so we can try that - if (ultradir.length()) - { - ultradir += "/midi"; - psreader->add_search_path(ultradir.c_str()); - } - // Load DMXGUS lump and patches from gus_patchdir - if (gusConfig.gus_patchdir.length() != 0) psreader->add_search_path(gusConfig.gus_patchdir.c_str()); - - gusConfig.instruments.reset(new Timidity::Instruments(psreader)); - bool success = gusConfig.instruments->LoadDMXGUS(gusConfig.gus_memsize, (const char*)gusConfig.dmxgus.data(), gusConfig.dmxgus.size()) >= 0; - - gusConfig.dmxgus.clear(); - - if (success) - { - gusConfig.loadedConfig = "DMXGUS"; - return; - } + ultradir += "/midi"; + gusConfig.reader->add_search_path(ultradir.c_str()); } - gusConfig.loadedConfig = ""; - gusConfig.instruments.reset(); - throw std::runtime_error("Unable to initialize DMXGUS for GUS MIDI device"); + // Load DMXGUS lump and patches from gus_patchdir + if (gusConfig.gus_patchdir.length() != 0) gusConfig.reader->add_search_path(gusConfig.gus_patchdir.c_str()); + + gusConfig.instruments.reset(new Timidity::Instruments(gusConfig.reader)); + gusConfig.loadedConfig = gusConfig.readerName; } - else if (gusConfig.reader) + + if (gusConfig.instruments == nullptr) + { + throw std::runtime_error("No instruments set for GUS device"); + } + + if (gusConfig.gus_dmxgus && gusConfig.dmxgus.size()) + { + bool success = gusConfig.instruments->LoadDMXGUS(gusConfig.gus_memsize, (const char*)gusConfig.dmxgus.data(), gusConfig.dmxgus.size()) >= 0; + gusConfig.reader = nullptr; + + if (!success) + { + gusConfig.instruments.reset(); + gusConfig.loadedConfig = ""; + throw std::runtime_error("Unable to initialize DMXGUS for GUS MIDI device"); + } + } + else { - gusConfig.loadedConfig = gusConfig.readerName; - gusConfig.instruments.reset(new Timidity::Instruments(gusConfig.reader)); bool err = gusConfig.instruments->LoadConfig() < 0; gusConfig.reader = nullptr; @@ -140,10 +142,6 @@ throw std::runtime_error("Unable to initialize instruments for GUS MIDI device"); } } - else if (gusConfig.instruments == nullptr) - { - throw std::runtime_error("No instruments set for GUS device"); - } } //========================================================================== @@ -257,20 +255,11 @@ bool GUS_SetupConfig(const char* args) { - gusConfig.reader = nullptr; - if ((gusConfig.gus_dmxgus && *args == 0) || !stricmp(args, "DMXGUS")) - { - if (stricmp(gusConfig.loadedConfig.c_str(), "DMXGUS") == 0) return false; // aleady loaded - if (gusConfig.dmxgus.size() > 0) - { - gusConfig.readerName = "DMXGUS"; - return true; - } - } if (*args == 0) args = gusConfig.gus_config.c_str(); - if (stricmp(gusConfig.loadedConfig.c_str(), args) == 0) return false; // aleady loaded + if (gusConfig.gus_dmxgus && *args == 0) args = "DMXGUS"; + //if (stricmp(gusConfig.loadedConfig.c_str(), args) == 0) return false; // aleady loaded - MusicIO::SoundFontReaderInterface* reader = MusicIO::ClientOpenSoundFont(args, SF_GUS | SF_SF2); + MusicIO::SoundFontReaderInterface* reader = MusicIO::ClientOpenSoundFont(args, SF_GUS); if (!reader && MusicIO::fileExists(args)) { auto f = MusicIO::utf8_fopen(args, "rb"); @@ -286,6 +275,11 @@ if (!reader) reader = new MusicIO::FileSystemSoundFontReader(args, true); } + if (!reader && gusConfig.gus_dmxgus) + { + reader = new MusicIO::FileSystemSoundFontReader(args, true); + } + if (reader == nullptr) { char error[80]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/mididevices/music_wildmidi_mididevice.cpp new/ZMusic-1.1.9/source/mididevices/music_wildmidi_mididevice.cpp --- old/ZMusic-1.1.8/source/mididevices/music_wildmidi_mididevice.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/mididevices/music_wildmidi_mididevice.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -87,15 +87,7 @@ { wildMidiConfig.loadedConfig = wildMidiConfig.readerName; wildMidiConfig.instruments.reset(new WildMidi::Instruments(wildMidiConfig.reader, SampleRate)); - bool success = wildMidiConfig.instruments->LoadConfig(wildMidiConfig.readerName.c_str()); wildMidiConfig.reader = nullptr; - - if (!success) - { - wildMidiConfig.instruments.reset(); - wildMidiConfig.loadedConfig = ""; - throw std::runtime_error("Unable to initialize instruments for WildMidi device"); - } } else if (wildMidiConfig.instruments == nullptr) { @@ -104,7 +96,9 @@ instruments = wildMidiConfig.instruments; if (instruments->LoadConfig(nullptr) < 0) { - throw std::runtime_error("Unable to load instruments set for WildMidi device"); + wildMidiConfig.instruments.reset(); + wildMidiConfig.loadedConfig = ""; + throw std::runtime_error("Unable to initialize instruments for WildMidi device"); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/musicformats/music_cd.cpp new/ZMusic-1.1.9/source/musicformats/music_cd.cpp --- old/ZMusic-1.1.8/source/musicformats/music_cd.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/musicformats/music_cd.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -52,6 +52,7 @@ void Resume(); void Stop(); bool IsPlaying(); + SoundStreamInfoEx GetStreamInfoEx() const override { return {}; } bool IsValid() const { return m_Inited; } protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/musicformats/music_midi.cpp new/ZMusic-1.1.9/source/musicformats/music_midi.cpp --- old/ZMusic-1.1.8/source/musicformats/music_midi.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/musicformats/music_midi.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -87,7 +87,7 @@ int ServiceEvent(); void SetMIDISource(MIDISource* _source); bool ServiceStream(void* buff, int len) override; - SoundStreamInfo GetStreamInfo() const override; + SoundStreamInfoEx GetStreamInfoEx() const override; int GetDeviceType() const override; @@ -446,10 +446,10 @@ } } -SoundStreamInfo MIDIStreamer::GetStreamInfo() const +SoundStreamInfoEx MIDIStreamer::GetStreamInfoEx() const { - if (MIDI) return MIDI->GetStreamInfo(); - else return { 0, 0, 0 }; + if (MIDI) return MIDI->GetStreamInfoEx(); + else return {}; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/musicformats/music_stream.cpp new/ZMusic-1.1.9/source/musicformats/music_stream.cpp --- old/ZMusic-1.1.8/source/musicformats/music_stream.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/musicformats/music_stream.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -54,7 +54,7 @@ void ChangeSettingNum(const char *name, double value) override { if (m_Source) m_Source->ChangeSettingNum(name, value); } void ChangeSettingString(const char *name, const char *value) override { if(m_Source) m_Source->ChangeSettingString(name, value); } bool ServiceStream(void* buff, int len) override; - SoundStreamInfo GetStreamInfo() const override { return m_Source->GetFormat(); } + SoundStreamInfoEx GetStreamInfoEx() const override { return m_Source->GetFormatEx(); } protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/music_dumb.cpp new/ZMusic-1.1.9/source/streamsources/music_dumb.cpp --- old/ZMusic-1.1.8/source/streamsources/music_dumb.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/music_dumb.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -64,7 +64,7 @@ //bool SetPosition(int ms); bool SetSubsong(int subsong) override; bool Start() override; - SoundStreamInfo GetFormat() override; + SoundStreamInfoEx GetFormatEx() override; void ChangeSettingNum(const char* setting, double val) override; std::string GetStats() override; @@ -1030,13 +1030,13 @@ //========================================================================== // -// DumbSong GetFormat +// DumbSong GetFormatEx // //========================================================================== -SoundStreamInfo DumbSong::GetFormat() +SoundStreamInfoEx DumbSong::GetFormatEx() { - return { 32*1024, srate, 2 }; + return { 32*1024, srate, SampleType_Float32, ChannelConfig_Stereo }; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/music_gme.cpp new/ZMusic-1.1.9/source/streamsources/music_gme.cpp --- old/ZMusic-1.1.8/source/streamsources/music_gme.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/music_gme.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -57,7 +57,7 @@ void ChangeSettingNum(const char *name, double val) override; std::string GetStats() override; bool GetData(void *buffer, size_t len) override; - SoundStreamInfo GetFormat() override; + SoundStreamInfoEx GetFormatEx() override; protected: Music_Emu *Emu; @@ -167,9 +167,9 @@ } -SoundStreamInfo GMESong::GetFormat() +SoundStreamInfoEx GMESong::GetFormatEx() { - return { 32*1024, SampleRate, -2 }; + return { 32*1024, SampleRate, SampleType_Int16, ChannelConfig_Stereo }; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/music_libsndfile.cpp new/ZMusic-1.1.9/source/streamsources/music_libsndfile.cpp --- old/ZMusic-1.1.8/source/streamsources/music_libsndfile.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/music_libsndfile.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -50,14 +50,13 @@ SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass); ~SndFileSong(); std::string GetStats() override; - SoundStreamInfo GetFormat() override; + SoundStreamInfoEx GetFormatEx() override; bool GetData(void *buffer, size_t len) override; protected: SoundDecoder *Decoder; - int Channels; - int SampleRate; - + unsigned int FrameSize; + uint32_t Loop_Start; uint32_t Loop_End; @@ -434,25 +433,30 @@ SndFileSong::SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass) { - ChannelConfig iChannels; - SampleType Type; - - decoder->getInfo(&SampleRate, &iChannels, &Type); + ChannelConfig chanconf; + SampleType stype; + int srate; - if (!startass) loop_start = Scale(loop_start, SampleRate, 1000); - if (!endass) loop_end = Scale(loop_end, SampleRate, 1000); + decoder->getInfo(&srate, &chanconf, &stype); + + if (!startass) loop_start = Scale(loop_start, srate, 1000); + if (!endass) loop_end = Scale(loop_end, srate, 1000); const uint32_t sampleLength = (uint32_t)decoder->getSampleLength(); Loop_Start = loop_start; Loop_End = sampleLength == 0 ? loop_end : std::min<uint32_t>(loop_end, sampleLength); Decoder = decoder; - Channels = iChannels == ChannelConfig_Stereo? 2:1; + FrameSize = ZMusic_ChannelCount(chanconf) * ZMusic_SampleTypeSize(stype); } -SoundStreamInfo SndFileSong::GetFormat() +SoundStreamInfoEx SndFileSong::GetFormatEx() { - // deal with this once the configuration is handled better. - return { 64/*snd_streambuffersize*/ * 1024, SampleRate, -Channels }; + ChannelConfig chanconf; + SampleType stype; + int srate; + + Decoder->getInfo(&srate, &chanconf, &stype); + return { 64/*snd_streambuffersize*/ * 1024, srate, stype, chanconf }; } //========================================================================== @@ -479,14 +483,17 @@ { char out[80]; - size_t SamplePos; + ChannelConfig chanconf; + SampleType stype; + int srate; + Decoder->getInfo(&srate, &chanconf, &stype); - SamplePos = Decoder->getSampleOffset(); - int time = int (SamplePos / SampleRate); + size_t SamplePos = Decoder->getSampleOffset(); + int time = int (SamplePos / srate); snprintf(out, 80, "Track: %s, %dHz Time: %02d:%02d", - Channels == 2? "Stereo" : "Mono", SampleRate, + ZMusic_ChannelConfigName(chanconf), srate, time/60, time % 60); return out; @@ -503,7 +510,7 @@ char *buff = (char*)vbuff; size_t currentpos = Decoder->getSampleOffset(); - size_t framestoread = len / (Channels*2); + size_t framestoread = len / FrameSize; bool err = false; if (!m_Looping) { @@ -515,7 +522,7 @@ } if (currentpos + framestoread > maxpos) { - size_t got = Decoder->read(buff, (maxpos - currentpos) * Channels * 2); + size_t got = Decoder->read(buff, (maxpos - currentpos) * FrameSize); memset(buff + got, 0, len - got); } else @@ -532,7 +539,7 @@ // Loop can be very short, make sure the current position doesn't exceed it if (currentpos < Loop_End) { - size_t endblock = (Loop_End - currentpos) * Channels * 2; + size_t endblock = (Loop_End - currentpos) * FrameSize; size_t endlen = Decoder->read(buff, endblock); // Even if zero bytes was read give it a chance to start from the beginning diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/music_opl.cpp new/ZMusic-1.1.9/source/streamsources/music_opl.cpp --- old/ZMusic-1.1.8/source/streamsources/music_opl.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/music_opl.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -54,7 +54,7 @@ ~OPLMUSSong (); bool Start() override; void ChangeSettingInt(const char *name, int value) override; - SoundStreamInfo GetFormat() override; + SoundStreamInfoEx GetFormatEx() override; protected: bool GetData(void *buffer, size_t len) override; @@ -93,10 +93,11 @@ // //========================================================================== -SoundStreamInfo OPLMUSSong::GetFormat() +SoundStreamInfoEx OPLMUSSong::GetFormatEx() { int samples = int(OPL_SAMPLE_RATE / 14); - return { samples * 4, int(OPL_SAMPLE_RATE), current_opl_core == 0? 1:2 }; + return { samples * 4, int(OPL_SAMPLE_RATE), SampleType_Float32, + current_opl_core == 0? ChannelConfig_Mono:ChannelConfig_Stereo }; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/music_xa.cpp new/ZMusic-1.1.9/source/streamsources/music_xa.cpp --- old/ZMusic-1.1.8/source/streamsources/music_xa.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/music_xa.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -235,7 +235,7 @@ { public: XASong(MusicIO::FileInterface *readr); - SoundStreamInfo GetFormat() override; + SoundStreamInfoEx GetFormatEx() override; bool Start() override; bool GetData(void *buffer, size_t len) override; @@ -260,10 +260,10 @@ getNextXABlock(&xad, false); } -SoundStreamInfo XASong::GetFormat() +SoundStreamInfoEx XASong::GetFormatEx() { auto SampleRate = xad.blockIs18K? 18900 : 37800; - return { 64*1024, SampleRate, 2}; + return { 64*1024, SampleRate, SampleType_Float32, ChannelConfig_Stereo }; } //========================================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/streamsources/streamsource.h new/ZMusic-1.1.9/source/streamsources/streamsource.h --- old/ZMusic-1.1.8/source/streamsources/streamsource.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/streamsources/streamsource.h 2022-06-06 18:09:47.000000000 +0200 @@ -21,7 +21,7 @@ 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 SoundStreamInfoEx GetFormatEx() = 0; virtual std::string GetStats() { return ""; } virtual void ChangeSettingInt(const char *name, int value) { } virtual void ChangeSettingNum(const char *name, double value) { } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/zmusic/configuration.cpp new/ZMusic-1.1.9/source/zmusic/configuration.cpp --- old/ZMusic-1.1.8/source/zmusic/configuration.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/zmusic/configuration.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -503,7 +503,7 @@ case zmusic_gus_memsize: ChangeAndReturn(gusConfig.gus_memsize, value, pRealValue); - return devType() == MDEV_GUS && gusConfig.gus_dmxgus; + return devType() == MDEV_GUS; #endif #ifdef HAVE_TIMIDITY case zmusic_timidity_modulation_wheel: @@ -518,15 +518,15 @@ case zmusic_timidity_reverb: if (value < 0 || value > 4) value = 0; - else TimidityPlus_SetReverb(); local_timidity_reverb = value; + TimidityPlus_SetReverb(); if (pRealValue) *pRealValue = value; return false; case zmusic_timidity_reverb_level: if (value < 0 || value > 127) value = 0; - else TimidityPlus_SetReverb(); local_timidity_reverb_level = value; + TimidityPlus_SetReverb(); if (pRealValue) *pRealValue = value; return false; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/zmusic/fileio.h new/ZMusic-1.1.9/source/zmusic/fileio.h --- old/ZMusic-1.1.8/source/zmusic/fileio.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/zmusic/fileio.h 2022-06-06 18:09:47.000000000 +0200 @@ -320,7 +320,7 @@ std::string fullname; if (!fn) { - f = utf8_fopen(mBaseFile.c_str(), "rt"); + f = utf8_fopen(mBaseFile.c_str(), "rb"); fullname = mBaseFile; } else @@ -330,11 +330,11 @@ for(int i = (int)mPaths.size()-1; i>=0; i--) { fullname = mPaths[i] + fn; - f = utf8_fopen(fullname.c_str(), "rt"); - break; + f = utf8_fopen(fullname.c_str(), "rb"); + if (f) break; } } - if (!f) f = fopen(fn, "rt"); + if (!f) f = fopen(fn, "rb"); } if (!f) return nullptr; auto tf = new StdioFileReader; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/zmusic/musinfo.h new/ZMusic-1.1.9/source/zmusic/musinfo.h --- old/ZMusic-1.1.8/source/zmusic/musinfo.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/zmusic/musinfo.h 2022-06-06 18:09:47.000000000 +0200 @@ -31,7 +31,7 @@ virtual void ChangeSettingNum(const char* setting, double value) {} // " virtual void ChangeSettingString(const char* setting, const char* value) {} // " virtual bool ServiceStream(void *buff, int len) { return false; } - virtual SoundStreamInfo GetStreamInfo() const { return { 0,0,0 }; } + virtual SoundStreamInfoEx GetStreamInfoEx() const = 0; enum EState { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/zmusic/zmusic.cpp new/ZMusic-1.1.9/source/zmusic/zmusic.cpp --- old/ZMusic-1.1.8/source/zmusic/zmusic.cpp 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/zmusic/zmusic.cpp 2022-06-06 18:09:47.000000000 +0200 @@ -455,9 +455,32 @@ DLL_EXPORT void ZMusic_GetStreamInfo(MusInfo *song, SoundStreamInfo *fmt) { if (!fmt) return; + *fmt = {}; + + if (!song) + return; + + SoundStreamInfoEx fmtex; + { + std::lock_guard<FCriticalSection> lock(song->CritSec); + fmtex = song->GetStreamInfoEx(); + } + if (fmtex.mSampleRate > 0) + { + fmt->mBufferSize = fmtex.mBufferSize; + fmt->mSampleRate = fmtex.mSampleRate; + fmt->mNumChannels = ZMusic_ChannelCount(fmtex.mChannelConfig); + if (fmtex.mSampleType == SampleType_Int16) + fmt->mNumChannels *= -1; + } +} + +DLL_EXPORT void ZMusic_GetStreamInfoEx(MusInfo *song, SoundStreamInfoEx *fmt) +{ + if (!fmt) return; if (!song) *fmt = {}; std::lock_guard<FCriticalSection> lock(song->CritSec); - *fmt = song->GetStreamInfo(); + *fmt = song->GetStreamInfoEx(); } DLL_EXPORT void ZMusic_Close(MusInfo *song) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/source/zmusic/zmusic_internal.h new/ZMusic-1.1.9/source/zmusic/zmusic_internal.h --- old/ZMusic-1.1.8/source/zmusic/zmusic_internal.h 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/source/zmusic/zmusic_internal.h 2022-06-06 18:09:47.000000000 +0200 @@ -1,13 +1,13 @@ #pragma once #define ZMUSIC_INTERNAL -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(ZMUSIC_STATIC) #define DLL_EXPORT __declspec(dllexport) #define DLL_IMPORT __declspec(dllexport) // without this the compiler complains. -#else // !_MSC_VER +#else #define DLL_EXPORT #define DLL_IMPORT -#endif // _MSC_VER +#endif typedef class MIDISource *ZMusic_MidiSource; typedef class MusInfo *ZMusic_MusicStream; @@ -49,3 +49,34 @@ void ZMusic_Printf(int type, const char* msg, ...); + +inline uint8_t ZMusic_SampleTypeSize(SampleType stype) +{ + switch(stype) + { + case SampleType_UInt8: return sizeof(uint8_t); + case SampleType_Int16: return sizeof(int16_t); + case SampleType_Float32: return sizeof(float); + } + return 0; +} + +inline uint8_t ZMusic_ChannelCount(ChannelConfig chans) +{ + switch(chans) + { + case ChannelConfig_Mono: return 1; + case ChannelConfig_Stereo: return 2; + } + return 0; +} + +inline const char *ZMusic_ChannelConfigName(ChannelConfig chans) +{ + switch(chans) + { + case ChannelConfig_Mono: return "Mono"; + case ChannelConfig_Stereo: return "Stereo"; + } + return "(unknown)"; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ZMusic-1.1.8/thirdparty/CMakeLists.txt new/ZMusic-1.1.9/thirdparty/CMakeLists.txt --- old/ZMusic-1.1.8/thirdparty/CMakeLists.txt 2021-05-19 08:13:53.000000000 +0200 +++ new/ZMusic-1.1.9/thirdparty/CMakeLists.txt 2022-06-06 18:09:47.000000000 +0200 @@ -1,18 +1,20 @@ -option(FORCE_INTERNAL_ZLIB "Use internal zlib" OFF) -find_package(ZLIB QUIET) -if(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB) - message(STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIRS}") - set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_GLOBAL TRUE) - determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET ZLIB::ZLIB MODULE ZLIB) -else() - message(STATUS "Using internal zlib") - set(SKIP_INSTALL_ALL TRUE) # Avoid installing zlib alongside ZMusic - add_subdirectory(zlib) - add_library(ZLIB::ZLIB ALIAS z) +if(NOT TARGET ZLIB::ZLIB) + option(FORCE_INTERNAL_ZLIB "Use internal zlib" OFF) + find_package(ZLIB QUIET) + if(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB) + message(STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIRS}") + set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_GLOBAL TRUE) + determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET ZLIB::ZLIB MODULE ZLIB) + else() + message(STATUS "Using internal zlib") + set(SKIP_INSTALL_ALL TRUE) # Avoid installing zlib alongside ZMusic + add_subdirectory(zlib) + add_library(ZLIB::ZLIB ALIAS z) - # Setup variables for GME's CMakeLists - set(ZLIB_LIBRARY ZLIB::ZLIB) - get_property(ZLIB_INCLUDE_DIR TARGET ZLIB::ZLIB PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + # Setup variables for GME's CMakeLists + set(ZLIB_LIBRARY ZLIB::ZLIB) + get_property(ZLIB_INCLUDE_DIR TARGET ZLIB::ZLIB PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + endif() endif() # GME is not currently released in a way that's conducive to using as a system