diff --git a/Frameworks/OpenMPT/OpenMPT/Makefile b/Frameworks/OpenMPT/OpenMPT/Makefile index 34d317460..68453c066 100644 --- a/Frameworks/OpenMPT/OpenMPT/Makefile +++ b/Frameworks/OpenMPT/OpenMPT/Makefile @@ -218,7 +218,28 @@ LIBOPENMPT_SO_VERSION=$(LIBOPENMPT_LTVER_CURRENT) # host setup -ifeq ($(OS),Windows_NT) +ifneq ($(MSYSTEM)x,x) + +HOST=unix +HOST_FLAVOUR= + +TOOLCHAIN_SUFFIX= + +CPPCHECK = cppcheck + +MKDIR_P = mkdir -p +RM = rm -f +RMTREE = rm -rf +INSTALL = install +INSTALL_MAKE_DIR = install -d +INSTALL_DIR = cp -r -v +FIXPATH = $1 + +HOST_FLAVOUR=MSYS2 + +NUMTHREADS:=$(shell nproc) + +else ifeq ($(OS),Windows_NT) HOST=windows HOST_FLAVOUR= @@ -1662,7 +1683,7 @@ endif svn export ./libopenmpt/doc/xmp-openmpt.txt bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/XMPlay/xmp-openmpt.txt --native-eol CRLF cp bin/xmp-openmpt.dll bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/XMPlay/xmp-openmpt.dll mkdir -p bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/Winamp - svn export ./libopenmpt/doc/xmp-openmpt.txt bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/Winamp/in_openmpt.txt --native-eol CRLF + svn export ./libopenmpt/doc/in_openmpt.txt bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/Winamp/in_openmpt.txt --native-eol CRLF cp bin/in_openmpt.dll bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/Winamp/in_openmpt.dll cd bin/dist-retro-win9x/libopenmpt-$(DIST_LIBOPENMPT_VERSION)/ && ../../../build/tools/7zip/7z a -tzip -mx=9 ../libopenmpt-$(DIST_LIBOPENMPT_VERSION).bin.retro.win9x.zip * diff --git a/Frameworks/OpenMPT/OpenMPT/build/dist.mk b/Frameworks/OpenMPT/OpenMPT/build/dist.mk index 6dcd9c64a..8c2e81db1 100644 --- a/Frameworks/OpenMPT/OpenMPT/build/dist.mk +++ b/Frameworks/OpenMPT/OpenMPT/build/dist.mk @@ -1,4 +1,4 @@ -MPT_SVNVERSION=17274 -MPT_SVNURL=https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.6.3 -MPT_SVNDATE=2022-04-24T13:18:24.140099Z +MPT_SVNVERSION=17506 +MPT_SVNURL=https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.6.4 +MPT_SVNDATE=2022-06-12T13:42:37.263635Z diff --git a/Frameworks/OpenMPT/OpenMPT/build/make/config-defaults.mk b/Frameworks/OpenMPT/OpenMPT/build/make/config-defaults.mk index 3b44f6c66..bc765dfe4 100644 --- a/Frameworks/OpenMPT/OpenMPT/build/make/config-defaults.mk +++ b/Frameworks/OpenMPT/OpenMPT/build/make/config-defaults.mk @@ -9,6 +9,26 @@ include build/make/config-clang.mk DYNLINK=0 SHARED_SONAME=0 +else ifeq ($(HOST_FLAVOUR),MSYS2) + +ifeq ($(MSYSTEM),MINGW64) +WINDOWS_ARCH=amd64 +include build/make/config-mingw-w64.mk +else ifeq ($(MSYSTEM),MINGW32) +WINDOWS_ARCH=x86 +include build/make/config-mingw-w64.mk +else ifeq ($(MSYSTEM),UCRT64) +WINDOWS_ARCH=amd64 +include build/make/config-mingw-w64.mk +else ifeq ($(MSYSTEM),CLANG64) +WINDOWS_ARCH=amd64 +MINGW_COMPILER=clang +include build/make/config-mingw-w64.mk +else +WINDOWS_ARCH=x86 +include build/make/config-mingw-w64.mk +endif + else ifeq ($(HOST_FLAVOUR),LINUX) include build/make/config-gcc.mk diff --git a/Frameworks/OpenMPT/OpenMPT/build/make/config-mingw-w64.mk b/Frameworks/OpenMPT/OpenMPT/build/make/config-mingw-w64.mk new file mode 100644 index 000000000..e0ab794c5 --- /dev/null +++ b/Frameworks/OpenMPT/OpenMPT/build/make/config-mingw-w64.mk @@ -0,0 +1,118 @@ + +ifeq ($(WINDOWS_ARCH),) +MINGW_ARCH = i686 +else ifeq ($(WINDOWS_ARCH),x86) +MINGW_ARCH = i686 +else ifeq ($(WINDOWS_ARCH),amd64) +MINGW_ARCH = x86_64 +#else ifeq ($(WINDOWS_ARCH),arm) +#MINGW_ARCH = +#else ifeq ($(WINDOWS_ARCH),arm64) +#MINGW_ARCH = +else +$(error unknown WINDOWS_ARCH) +endif + +CC = $(MINGW_ARCH)-w64-mingw32-gcc$(MINGW_FLAVOUR) +CXX = $(MINGW_ARCH)-w64-mingw32-g++$(MINGW_FLAVOUR) +LD = $(MINGW_ARCH)-w64-mingw32-g++$(MINGW_FLAVOUR) +AR = $(MINGW_ARCH)-w64-mingw32-ar$(MINGW_FLAVOUR) + +CXXFLAGS_STDCXX = -std=c++17 -fexceptions -frtti +CFLAGS_STDC = -std=c99 +CXXFLAGS += $(CXXFLAGS_STDCXX) +CFLAGS += $(CFLAGS_STDC) + +CPPFLAGS += +CXXFLAGS += -municode -mconsole -mthreads +CFLAGS += -municode -mconsole -mthreads +LDFLAGS += +LDLIBS += -lm -lole32 -lrpcrt4 -lwinmm +ARFLAGS := rcs + +PC_LIBS_PRIVATE += -lole32 -lrpcrt4 + +ifeq ($(WINDOWS_FAMILY),) +# nothing +else ifeq ($(WINDOWS_FAMILY),desktop-app) +# nothing +else ifeq ($(WINDOWS_FAMILY),app) +CPPFLAGS += -DWINAPI_FAMILY=2 +OPENMPT123=0 +else ifeq ($(WINDOWS_FAMILY),phone-app) +CPPFLAGS += -DWINAPI_FAMILY=3 +OPENMPT123=0 +else ifeq ($(WINDOWS_FAMILY),pc-app) +CPPFLAGS += -DWINAPI_FAMILY=2 +OPENMPT123=0 +else +$(error unknown WINDOWS_FAMILY) +endif + +ifeq ($(WINDOWS_VERSION),) +# nothing +else ifeq ($(WINDOWS_VERSION),win95) +CPPFLAGS += -D_WIN32_WINDOWS=0x0400 +else ifeq ($(WINDOWS_VERSION),win98) +CPPFLAGS += -D_WIN32_WINDOWS=0x0410 +else ifeq ($(WINDOWS_VERSION),winme) +CPPFLAGS += -D_WIN32_WINDOWS=0x0490 +else ifeq ($(WINDOWS_VERSION),winnt4) +CPPFLAGS += -D_WIN32_WINNT=0x0400 +else ifeq ($(WINDOWS_VERSION),win2000) +CPPFLAGS += -D_WIN32_WINNT=0x0500 +else ifeq ($(WINDOWS_VERSION),winxp) +CPPFLAGS += -D_WIN32_WINNT=0x0501 +else ifeq ($(WINDOWS_VERSION),winxp64) +CPPFLAGS += -D_WIN32_WINNT=0x0502 +else ifeq ($(WINDOWS_VERSION),winvista) +CPPFLAGS += -DNTDDI_VERSION=0x06000000 +else ifeq ($(WINDOWS_VERSION),win7) +CPPFLAGS += -DNTDDI_VERSION=0x06010000 +else ifeq ($(WINDOWS_VERSION),win8) +CPPFLAGS += -DNTDDI_VERSION=0x06020000 +else ifeq ($(WINDOWS_VERSION),win8.1) +CPPFLAGS += -DNTDDI_VERSION=0x06030000 +else ifeq ($(WINDOWS_VERSION),win10) +CPPFLAGS += -DNTDDI_VERSION=0x0A000000 +else +$(error unknown WINDOWS_VERSION) +endif + +ifeq ($(MINGW_COMPILER),clang) +include build/make/warnings-clang.mk +else +include build/make/warnings-gcc.mk +endif + +EXESUFFIX=.exe +SOSUFFIX=.dll +SOSUFFIXWINDOWS=1 + +DYNLINK=0 +SHARED_LIB=1 +STATIC_LIB=0 +SHARED_SONAME=0 + +ifeq ($(HOST_FLAVOUR),MSYS2) + +else + +IS_CROSS=1 + +NO_ZLIB=1 +NO_LTDL=1 +NO_DL=1 +NO_MPG123=1 +NO_OGG=1 +NO_VORBIS=1 +NO_VORBISFILE=1 +NO_PORTAUDIO=1 +NO_PORTAUDIOCPP=1 +NO_PULSEAUDIO=1 +NO_SDL=1 +NO_SDL2=1 +NO_SNDFILE=1 +NO_FLAC=1 + +endif diff --git a/Frameworks/OpenMPT/OpenMPT/build/svn_version/svn_version.h b/Frameworks/OpenMPT/OpenMPT/build/svn_version/svn_version.h index ae191d5d3..0ec192ca5 100644 --- a/Frameworks/OpenMPT/OpenMPT/build/svn_version/svn_version.h +++ b/Frameworks/OpenMPT/OpenMPT/build/svn_version/svn_version.h @@ -1,10 +1,10 @@ #pragma once -#define OPENMPT_VERSION_SVNVERSION "17274" -#define OPENMPT_VERSION_REVISION 17274 +#define OPENMPT_VERSION_SVNVERSION "17506" +#define OPENMPT_VERSION_REVISION 17506 #define OPENMPT_VERSION_DIRTY 0 #define OPENMPT_VERSION_MIXEDREVISIONS 0 -#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.6.3" -#define OPENMPT_VERSION_DATE "2022-04-24T13:18:24.140099Z" +#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.6.4" +#define OPENMPT_VERSION_DATE "2022-06-12T13:42:37.263635Z" #define OPENMPT_VERSION_IS_PACKAGE 1 diff --git a/Frameworks/OpenMPT/OpenMPT/common/BuildSettings.h b/Frameworks/OpenMPT/OpenMPT/common/BuildSettings.h index d0081b9d6..bc6249f30 100644 --- a/Frameworks/OpenMPT/OpenMPT/common/BuildSettings.h +++ b/Frameworks/OpenMPT/OpenMPT/common/BuildSettings.h @@ -500,7 +500,9 @@ // windows.h excludes #define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines +#ifndef NOMINMAX #define NOMINMAX // Macros min(a,b) and max(a,b) +#endif #define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc. #define NOCOMM // COMM driver routines #define NOKANJI // Kanji support stuff. diff --git a/Frameworks/OpenMPT/OpenMPT/common/versionNumber.h b/Frameworks/OpenMPT/OpenMPT/common/versionNumber.h index 1c6c3c779..feb182c95 100644 --- a/Frameworks/OpenMPT/OpenMPT/common/versionNumber.h +++ b/Frameworks/OpenMPT/OpenMPT/common/versionNumber.h @@ -17,7 +17,7 @@ OPENMPT_NAMESPACE_BEGIN // Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 #define VER_MAJOR 30 -#define VER_MINOR 04 +#define VER_MINOR 05 #define VER_MINORMINOR 00 OPENMPT_NAMESPACE_END diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/changelog.md b/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/changelog.md index 013130d17..c4082a4a0 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/changelog.md +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/changelog.md @@ -5,6 +5,21 @@ Changelog {#changelog} For fully detailed change log, please see the source repository directly. This is just a high-level summary. +### libopenmpt 0.6.4 (2022-06-12) + + * [**Bug**] openmpt123: Linking failed when using Autotools build system + targeting MinGW. + * [**Bug**] tests: Linking failed when using Autotools build system targeting + MinGW. + * [**Bug**] examples: Linking failed when using Autotools build system + targeting MinGW. + + * [**Change**] Support for mingw-std-threads when building for MinGW targets + is now deprecated because this is not supported for GCC 11 or later (see + ). + + * Ping-pong sample loops sometimes stopped playing at the end of the loop. + ### libopenmpt 0.6.3 (2022-04-24) * Pitch / Pan Separation and Random Variation instrument properties were not diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/dependencies.md b/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/dependencies.md index 8dc9dfc31..ab5c257b7 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/dependencies.md +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/dox/dependencies.md @@ -23,8 +23,7 @@ Dependencies * **GCC 8.1** or higher * **Clang 7** or higher * **MinGW-W64 8.1** or higher (it is recommended to preferably use - posix threading model as opposed to win32 threading model, or at least - have mingw-std-threads available otherwise) + posix threading model as opposed to win32 threading model) * **emscripten 1.39.1** or higher * **DJGPP GCC 8.1** or higher * any other **C++17 compliant** compiler diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/in_openmpt.cpp b/Frameworks/OpenMPT/OpenMPT/libopenmpt/in_openmpt.cpp index 49ccbf349..b40159552 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/in_openmpt.cpp +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/in_openmpt.cpp @@ -34,7 +34,9 @@ #if defined(MPT_WITH_MFC) #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS // Avoid binary bloat from linking unused MFC controls #endif // MPT_WITH_MFC +#ifndef NOMINMAX #define NOMINMAX +#endif #if defined(MPT_WITH_MFC) #include #include diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_impl.cpp b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_impl.cpp index 82d99b5ce..45aa54e43 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_impl.cpp +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_impl.cpp @@ -87,8 +87,12 @@ MPT_WARNING("Warning: libopenmpt for WinRT is built with reduced functionality. MPT_WARNING("Warning: libopenmpt built in non thread-safe mode because mutexes are not supported by the C++ standard library available.") #endif // MPT_MUTEX_NONE -#if (defined(__MINGW32__) || defined(__MINGW64__)) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(MPT_WITH_MINGWSTDTHREADS) -MPT_WARNING("Warning: Building libopenmpt with MinGW-w64 without std::thread support is not recommended and is deprecated. Please use MinGW-w64 with posix threading model (as opposed to win32 threading model), or build with mingw-std-threads.") +#if (defined(__MINGW32__) || defined(__MINGW64__)) && !defined(_GLIBCXX_HAS_GTHREADS) +#if defined(MPT_WITH_MINGWSTDTHREADS) +MPT_WARNING("Warning: Building with mingw-std-threads is deprecated because this is not supported with GCC 11 or later.") +#else // !MINGWSTDTHREADS +MPT_WARNING("Warning: Platform (Windows) supports multi-threading, however the toolchain (MinGW/GCC) does not. The resulting libopenmpt may not be thread-safe. This is a MinGW/GCC issue. You can avoid this warning by using a MinGW toolchain built with posix threading model as opposed to win32 threading model.") +#endif // MINGWSTDTHREADS #endif // MINGW #if MPT_CLANG_AT_LEAST(5,0,0) && MPT_CLANG_BEFORE(11,0,0) && defined(__powerpc__) && !defined(__powerpc64__) @@ -99,8 +103,7 @@ MPT_WARNING("Warning: libopenmpt is known to trigger bad code generation with Cl #if defined(MPT_ASSERT_HANDLER_NEEDED) && !defined(ENABLE_TESTS) -MPT_NOINLINE void AssertHandler(const mpt::source_location &loc, const char *expr, const char *msg) -{ +MPT_NOINLINE void AssertHandler(const mpt::source_location &loc, const char *expr, const char *msg) { if(msg) { mpt::log::GlobalLogger().SendLogMessage(loc, LogError, "ASSERT", MPT_USTRING("ASSERTION FAILED: ") + mpt::ToUnicode(mpt::CharsetSource, msg) + MPT_USTRING(" (") + mpt::ToUnicode(mpt::CharsetSource, expr) + MPT_USTRING(")") diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.h b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.h index 7252b81e8..0d90c07ff 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.h +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.h @@ -21,7 +21,7 @@ /*! \brief libopenmpt minor version number */ #define OPENMPT_API_VERSION_MINOR 6 /*! \brief libopenmpt patch version number */ -#define OPENMPT_API_VERSION_PATCH 3 +#define OPENMPT_API_VERSION_PATCH 4 /*! \brief libopenmpt pre-release tag */ #define OPENMPT_API_VERSION_PREREL "" /*! \brief libopenmpt pre-release flag */ diff --git a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.mk b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.mk index 6ef0d5f99..2e1f2e152 100644 --- a/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.mk +++ b/Frameworks/OpenMPT/OpenMPT/libopenmpt/libopenmpt_version.mk @@ -1,8 +1,8 @@ LIBOPENMPT_VERSION_MAJOR=0 LIBOPENMPT_VERSION_MINOR=6 -LIBOPENMPT_VERSION_PATCH=3 +LIBOPENMPT_VERSION_PATCH=4 LIBOPENMPT_VERSION_PREREL= LIBOPENMPT_LTVER_CURRENT=3 -LIBOPENMPT_LTVER_REVISION=3 +LIBOPENMPT_LTVER_REVISION=4 LIBOPENMPT_LTVER_AGE=3 diff --git a/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123.cpp b/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123.cpp index a10ef828b..e5c979366 100644 --- a/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123.cpp +++ b/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123.cpp @@ -1057,6 +1057,7 @@ void render_loop( commandlineflags & flags, Tmod & mod, double & duration, texto if ( multiline ) { lines += 1; + // cppcheck-suppress identicalInnerCondition if ( flags.show_ui ) { lines += 1; } @@ -1174,7 +1175,7 @@ void render_loop( commandlineflags & flags, Tmod & mod, double & duration, texto cpu /= ( static_cast( count ) ) / static_cast( flags.samplerate ); double mix = ( static_cast( count ) ) / static_cast( flags.samplerate ); cpu_smooth = ( 1.0 - mix ) * cpu_smooth + mix * cpu; - sprintf( cpu_str, "%.2f%%", cpu_smooth * 100.0 ); + std::snprintf( cpu_str, 64, "%.2f%%", cpu_smooth * 100.0 ); } } diff --git a/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123_allegro42.hpp b/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123_allegro42.hpp index c0f33481c..a0979eaac 100644 --- a/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123_allegro42.hpp +++ b/Frameworks/OpenMPT/OpenMPT/openmpt123/openmpt123_allegro42.hpp @@ -30,7 +30,7 @@ namespace openmpt123 { struct allegro42_exception : public exception { static std::string error_to_string() { try { - return allegro_error ? std::string( allegro_error ) : std::string(); + return std::string( allegro_error ); } catch ( const std::bad_alloc & ) { return std::string(); } diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/Fastmix.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/Fastmix.cpp index 65f768ec7..8ae5a0640 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/Fastmix.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/Fastmix.cpp @@ -190,12 +190,21 @@ struct MixLoopState // Part 2: Compute how many samples we can render until we reach the end of sample / loop boundary / etc. SamplePosition nPos = chn.position; - // too big increment, and/or too small loop length - if (nPos.GetInt() < nLoopStart) + const SmpLength nPosInt = nPos.GetUInt(); + if(nPos.GetInt() < nLoopStart) { - if (nPos.IsNegative() || nInc.IsNegative()) return 0; + // too big increment, and/or too small loop length + if(nPos.IsNegative() || nInc.IsNegative()) + return 0; + } else + { + // Not testing for equality since we might be going backwards from the very end of the sample + if(nPosInt > chn.nLength) + return 0; + // If going forwards and we're preceisely at the end, there's no point in going further + if(nPosInt == chn.nLength && nInc.IsPositive()) + return 0; } - if (nPos.IsNegative() || nPos.GetUInt() >= chn.nLength) return 0; uint32 nSmpCount = nSamples; SamplePosition nInv = nInc; if (nInc.IsNegative()) @@ -206,7 +215,6 @@ struct MixLoopState SamplePosition incSamples = nInc * (nSamples - 1); int32 nPosDest = (nPos + incSamples).GetInt(); - const SmpLength nPosInt = nPos.GetUInt(); const bool isAtLoopStart = (nPosInt >= chn.nLoopStart && nPosInt < chn.nLoopStart + InterpolationLookaheadBufferSize); if(!isAtLoopStart) { @@ -217,7 +225,7 @@ struct MixLoopState bool checkDest = true; if(lookaheadPointer != nullptr) { - if(nPos.GetUInt() >= lookaheadStart) + if(nPosInt >= lookaheadStart) { #if 0 const uint32 oldCount = nSmpCount; diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/Load_dsym.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/Load_dsym.cpp index aabbea905..d883def96 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/Load_dsym.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/Load_dsym.cpp @@ -245,7 +245,7 @@ bool CSoundFile::ReadDSym(FileReader &file, ModLoadingFlags loadFlags) ChnSettings[chn].nPan = (((chn & 3) == 1) || ((chn & 3) == 2)) ? 64 : 192; } - uint8 sampleNameLength[64]; + uint8 sampleNameLength[64] = {}; for(SAMPLEINDEX smp = 1; smp <= m_nSamples; smp++) { Samples[smp].Initialize(MOD_TYPE_MOD); diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/Load_mdl.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/Load_mdl.cpp index 7215dc8c9..243756201 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/Load_mdl.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/Load_mdl.cpp @@ -371,12 +371,10 @@ static bool ImportMDLCommands(ModCommand &m, uint8 vol, uint8 e1, uint8 e2, uint // Almost as easy e2 = e1; p2 = p1; - e1 = CMD_NONE; } else if(e1 == e2 && e1 != CMD_S3MCMDEX) { // Digitrakker processes the effects left-to-right, so if both effects are the same, the // second essentially overrides the first. - e1 = CMD_NONE; } else if(!vol) { lostCommand |= (ModCommand::TwoRegularCommandsToMPT(e1, p1, e2, p2).first != CMD_NONE); @@ -389,6 +387,7 @@ static bool ImportMDLCommands(ModCommand &m, uint8 vol, uint8 e1, uint8 e2, uint std::swap(e1, e2); std::swap(p1, p2); } + lostCommand = true; } m.command = e2; diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.cpp index d5095f50b..f55aaa150 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.cpp @@ -305,6 +305,25 @@ void ModInstrument::Sanitize(MODTYPE modType) } +std::map ModInstrument::CanConvertToDefaultNoteMap() const +{ + std::map transposeMap; + for(size_t i = 0; i < std::size(NoteMap); i++) + { + if(Keyboard[i] == 0) + continue; + if(!NoteMap[i] || NoteMap[i] == (i + 1)) + continue; + + const int8 relativeNote = static_cast(NoteMap[i] - (i + NOTE_MIN)); + if(transposeMap.count(Keyboard[i]) && transposeMap[Keyboard[i]] != relativeNote) + return {}; + transposeMap[Keyboard[i]] = relativeNote; + } + return transposeMap; +} + + void ModInstrument::Transpose(int8 amount) { for(auto ¬e : NoteMap) diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.h b/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.h index 68af431b2..2c04fa769 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.h +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/ModInstrument.h @@ -17,6 +17,7 @@ #include "Snd_defs.h" #include "openmpt/base/FlagSet.hpp" #include "../common/misc_util.h" +#include #include OPENMPT_NAMESPACE_BEGIN @@ -26,7 +27,7 @@ struct ModChannel; // Instrument Nodes struct EnvelopeNode { - using tick_t = uint16 ; + using tick_t = uint16; using value_t = uint8; tick_t tick = 0; // Envelope node position (x axis) @@ -133,12 +134,13 @@ struct ModInstrument // Reset note mapping (i.e. every note is mapped to itself) void ResetNoteMap() { - for(size_t n = 0; n < std::size(NoteMap); n++) - { - NoteMap[n] = static_cast(n + 1); - } + std::iota(NoteMap.begin(), NoteMap.end(), static_cast(NOTE_MIN)); } + // If the instrument has a non-default note mapping and can be simplified to use the default note mapping by transposing samples, + // the list of samples that would need to be transposed and the corresponding transpose values are returned - otherwise an empty map. + std::map CanConvertToDefaultNoteMap() const; + // Transpose entire note mapping by given number of semitones void Transpose(int8 amount); diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/Sndfile.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/Sndfile.cpp index efe00452d..e3c87cd71 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/Sndfile.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/Sndfile.cpp @@ -2045,6 +2045,7 @@ void TempoSwing::Normalize() sum += i; } sum /= size(); + MPT_ASSERT(sum > 0); // clang-analyzer false-positive int64 remain = Unity * size(); for(auto &i : *this) { diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/modcommand.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/modcommand.cpp index 467e2e4c2..5f5f98b22 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/modcommand.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/modcommand.cpp @@ -557,17 +557,27 @@ void ModCommand::Convert(MODTYPE fromType, MODTYPE toType, const CSoundFile &snd { switch(command) { - case CMD_TONEPORTAVOL: // lacks memory -> 500 is the same as 300 - if(param == 0x00) command = CMD_TONEPORTAMENTO; + case CMD_TONEPORTAVOL: // lacks memory -> 500 is the same as 300 + if(param == 0x00) + command = CMD_TONEPORTAMENTO; break; - case CMD_VIBRATOVOL: // lacks memory -> 600 is the same as 400 - if(param == 0x00) command = CMD_VIBRATO; + case CMD_VIBRATOVOL: // lacks memory -> 600 is the same as 400 + if(param == 0x00) + command = CMD_VIBRATO; break; - case CMD_MODCMDEX: // This would turn into "Set Active Macro", so let's better remove it + case CMD_PORTAMENTOUP: // lacks memory -> remove + case CMD_PORTAMENTODOWN: + case CMD_VOLUMESLIDE: + if(param == 0x00) + command = CMD_NONE; + break; + + case CMD_MODCMDEX: // This would turn into "Set Active Macro", so let's better remove it case CMD_S3MCMDEX: - if((param & 0xF0) == 0xF0) command = CMD_NONE; + if((param & 0xF0) == 0xF0) + command = CMD_NONE; break; } } // End if(oldTypeIsMOD && newTypeIsXM) diff --git a/Frameworks/OpenMPT/OpenMPT/soundlib/plugins/dmo/Gargle.cpp b/Frameworks/OpenMPT/OpenMPT/soundlib/plugins/dmo/Gargle.cpp index 1f9115a66..91f5e145f 100644 --- a/Frameworks/OpenMPT/OpenMPT/soundlib/plugins/dmo/Gargle.cpp +++ b/Frameworks/OpenMPT/OpenMPT/soundlib/plugins/dmo/Gargle.cpp @@ -180,7 +180,7 @@ CString Gargle::GetParamDisplay(PlugParamIndex param) uint32 Gargle::RateInHertz() const { - return mpt::saturate_round(m_param[kGargleRate] * 999.0f) + 1; + return static_cast(mpt::round(std::clamp(m_param[kGargleRate], 0.0f, 1.0f) * 999.0f)) + 1; } diff --git a/Frameworks/OpenMPT/OpenMPT/src/mpt/audio/span.hpp b/Frameworks/OpenMPT/OpenMPT/src/mpt/audio/span.hpp index 5d159f7ee..5653f8d8f 100644 --- a/Frameworks/OpenMPT/OpenMPT/src/mpt/audio/span.hpp +++ b/Frameworks/OpenMPT/OpenMPT/src/mpt/audio/span.hpp @@ -5,10 +5,9 @@ +#include "mpt/base/macros.hpp" #include "mpt/base/namespace.hpp" -#include - #include #include diff --git a/Frameworks/OpenMPT/OpenMPT/src/mpt/base/constexpr_throw.hpp b/Frameworks/OpenMPT/OpenMPT/src/mpt/base/constexpr_throw.hpp index d01651da5..961268f24 100644 --- a/Frameworks/OpenMPT/OpenMPT/src/mpt/base/constexpr_throw.hpp +++ b/Frameworks/OpenMPT/OpenMPT/src/mpt/base/constexpr_throw.hpp @@ -8,6 +8,8 @@ #include "mpt/base/detect.hpp" #include "mpt/base/namespace.hpp" +#include + namespace mpt { diff --git a/Frameworks/OpenMPT/OpenMPT/src/mpt/base/detect_compiler.hpp b/Frameworks/OpenMPT/OpenMPT/src/mpt/base/detect_compiler.hpp index 7424386dd..aeed0896e 100644 --- a/Frameworks/OpenMPT/OpenMPT/src/mpt/base/detect_compiler.hpp +++ b/Frameworks/OpenMPT/OpenMPT/src/mpt/base/detect_compiler.hpp @@ -50,7 +50,9 @@ #elif defined(_MSC_VER) #define MPT_COMPILER_MSVC 1 -#if (_MSC_VER >= 1931) +#if (_MSC_VER >= 1932) +#define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2022, 2) +#elif (_MSC_VER >= 1931) #define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2022, 1) #elif (_MSC_VER >= 1930) #define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2022, 0)