You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(10) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(2) |
May
(10) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(4) |
Aug
(6) |
Sep
(2) |
Oct
(9) |
Nov
(1) |
Dec
(4) |
2009 |
Jan
(9) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
(6) |
Jun
(18) |
Jul
(33) |
Aug
(39) |
Sep
(33) |
Oct
(24) |
Nov
(23) |
Dec
(22) |
2010 |
Jan
(29) |
Feb
(32) |
Mar
(51) |
Apr
(17) |
May
(31) |
Jun
(21) |
Jul
(32) |
Aug
(28) |
Sep
(35) |
Oct
(27) |
Nov
(11) |
Dec
(13) |
2011 |
Jan
(14) |
Feb
(13) |
Mar
(27) |
Apr
(27) |
May
(28) |
Jun
(20) |
Jul
(43) |
Aug
(52) |
Sep
(66) |
Oct
(61) |
Nov
(11) |
Dec
(8) |
2012 |
Jan
(20) |
Feb
(30) |
Mar
(38) |
Apr
(21) |
May
(33) |
Jun
(21) |
Jul
(25) |
Aug
(9) |
Sep
(24) |
Oct
(42) |
Nov
(27) |
Dec
(41) |
2013 |
Jan
(20) |
Feb
(35) |
Mar
(156) |
Apr
(298) |
May
(258) |
Jun
(201) |
Jul
(105) |
Aug
(60) |
Sep
(193) |
Oct
(245) |
Nov
(280) |
Dec
(194) |
2014 |
Jan
(63) |
Feb
(202) |
Mar
(200) |
Apr
(23) |
May
(53) |
Jun
(105) |
Jul
(18) |
Aug
(26) |
Sep
(110) |
Oct
(187) |
Nov
(97) |
Dec
(74) |
2015 |
Jan
(45) |
Feb
(55) |
Mar
(116) |
Apr
(116) |
May
(193) |
Jun
(164) |
Jul
(50) |
Aug
(111) |
Sep
(98) |
Oct
(71) |
Nov
(103) |
Dec
(63) |
2016 |
Jan
(33) |
Feb
(101) |
Mar
(182) |
Apr
(139) |
May
(140) |
Jun
(103) |
Jul
(165) |
Aug
(286) |
Sep
(208) |
Oct
(127) |
Nov
(97) |
Dec
(54) |
2017 |
Jan
(64) |
Feb
(335) |
Mar
(202) |
Apr
(212) |
May
(139) |
Jun
(127) |
Jul
(294) |
Aug
(154) |
Sep
(170) |
Oct
(152) |
Nov
(156) |
Dec
(62) |
2018 |
Jan
(168) |
Feb
(237) |
Mar
(196) |
Apr
(174) |
May
(174) |
Jun
(161) |
Jul
(127) |
Aug
(88) |
Sep
(149) |
Oct
(66) |
Nov
(52) |
Dec
(135) |
2019 |
Jan
(146) |
Feb
(126) |
Mar
(104) |
Apr
(58) |
May
(60) |
Jun
(28) |
Jul
(197) |
Aug
(129) |
Sep
(141) |
Oct
(148) |
Nov
(63) |
Dec
(100) |
2020 |
Jan
(74) |
Feb
(37) |
Mar
(59) |
Apr
(154) |
May
(194) |
Jun
(133) |
Jul
(313) |
Aug
(197) |
Sep
(49) |
Oct
(162) |
Nov
(143) |
Dec
(57) |
2021 |
Jan
(120) |
Feb
(107) |
Mar
(314) |
Apr
(157) |
May
(524) |
Jun
(169) |
Jul
(72) |
Aug
(133) |
Sep
(135) |
Oct
(146) |
Nov
(198) |
Dec
(325) |
2022 |
Jan
(409) |
Feb
(249) |
Mar
(138) |
Apr
(95) |
May
(102) |
Jun
(221) |
Jul
(66) |
Aug
(120) |
Sep
(192) |
Oct
(131) |
Nov
(53) |
Dec
(171) |
2023 |
Jan
(357) |
Feb
(82) |
Mar
(168) |
Apr
(218) |
May
(196) |
Jun
(86) |
Jul
(115) |
Aug
(49) |
Sep
(190) |
Oct
(102) |
Nov
(45) |
Dec
(76) |
2024 |
Jan
(86) |
Feb
(50) |
Mar
(324) |
Apr
(209) |
May
(197) |
Jun
(232) |
Jul
(194) |
Aug
(247) |
Sep
(219) |
Oct
(266) |
Nov
(328) |
Dec
(304) |
2025 |
Jan
(191) |
Feb
(115) |
Mar
(137) |
Apr
(32) |
May
(126) |
Jun
(403) |
Jul
(213) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sv...@op...> - 2024-10-28 14:06:23
|
Author: manx Date: Mon Oct 28 15:06:12 2024 New Revision: 22018 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22018 Log: [Doc] libopenmpt: Update changelog. Modified: branches/OpenMPT-1.29/libopenmpt/dox/changelog.md Modified: branches/OpenMPT-1.29/libopenmpt/dox/changelog.md ============================================================================== --- branches/OpenMPT-1.29/libopenmpt/dox/changelog.md Mon Oct 28 15:06:08 2024 (r22017) +++ branches/OpenMPT-1.29/libopenmpt/dox/changelog.md Mon Oct 28 15:06:12 2024 (r22018) @@ -7,7 +7,7 @@ ### libopenmpt 0.5.35-pre - * mpg123: Update to v1.32.8 (2024-10-26). + * mpg123: Update to v1.32.9-dev+r5448 (2024-10-28). ### libopenmpt 0.5.34 (2024-10-26) |
From: <sv...@op...> - 2024-10-28 14:06:18
|
Author: manx Date: Mon Oct 28 15:06:04 2024 New Revision: 22016 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22016 Log: [Doc] libopenmpt: Update changelog. Modified: branches/OpenMPT-1.31/doc/libopenmpt/changelog.md Modified: branches/OpenMPT-1.31/doc/libopenmpt/changelog.md ============================================================================== --- branches/OpenMPT-1.31/doc/libopenmpt/changelog.md Mon Oct 28 15:04:48 2024 (r22015) +++ branches/OpenMPT-1.31/doc/libopenmpt/changelog.md Mon Oct 28 15:06:04 2024 (r22016) @@ -7,7 +7,7 @@ ### libopenmpt 0.7.12-pre - * mpg123: Update to v1.32.8 (2024-10-26). + * mpg123: Update to v1.32.9-dev+r5448 (2024-10-28). ### libopenmpt 0.7.11 (2024-10-26) |
From: <sv...@op...> - 2024-10-28 14:06:17
|
Author: manx Date: Mon Oct 28 15:06:08 2024 New Revision: 22017 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22017 Log: [Doc] libopenmpt: Update changelog. Modified: branches/OpenMPT-1.30/libopenmpt/dox/changelog.md Modified: branches/OpenMPT-1.30/libopenmpt/dox/changelog.md ============================================================================== --- branches/OpenMPT-1.30/libopenmpt/dox/changelog.md Mon Oct 28 15:06:04 2024 (r22016) +++ branches/OpenMPT-1.30/libopenmpt/dox/changelog.md Mon Oct 28 15:06:08 2024 (r22017) @@ -7,7 +7,7 @@ ### libopenmpt 0.6.21-pre - * mpg123: Update to v1.32.8 (2024-10-26). + * mpg123: Update to v1.32.9-dev+r5448 (2024-10-28). ### libopenmpt 0.6.20 (2024-10-26) |
Author: manx Date: Mon Oct 28 15:04:48 2024 New Revision: 22015 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22015 Log: Merged revision(s) 21998, 22007 from trunk/OpenMPT: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. ........ [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). ........ Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/include/mpg123/OpenMPT.txt branches/OpenMPT-1.28/include/mpg123/src/compat/compat.c branches/OpenMPT-1.28/include/mpg123/src/compat/compat.h branches/OpenMPT-1.28/include/mpg123/src/include/mpg123.h branches/OpenMPT-1.28/include/mpg123/src/libmpg123/lfs_wrap.c branches/OpenMPT-1.28/include/mpg123/src/version.h Modified: branches/OpenMPT-1.28/include/mpg123/OpenMPT.txt ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/OpenMPT.txt Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/OpenMPT.txt Mon Oct 28 15:04:48 2024 (r22015) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/MSVC++/config.h` has been added for MSVC builds. * `ports/Xcode/config.h` has been retained from older versions. Modified: branches/OpenMPT-1.28/include/mpg123/src/compat/compat.c ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/src/compat/compat.c Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/src/compat/compat.c Mon Oct 28 15:04:48 2024 (r22015) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: branches/OpenMPT-1.28/include/mpg123/src/compat/compat.h ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/src/compat/compat.h Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/src/compat/compat.h Mon Oct 28 15:04:48 2024 (r22015) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: branches/OpenMPT-1.28/include/mpg123/src/include/mpg123.h ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/src/include/mpg123.h Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/src/include/mpg123.h Mon Oct 28 15:04:48 2024 (r22015) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: branches/OpenMPT-1.28/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:04:48 2024 (r22015) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,13 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } - return lseek(ioh->fd, (off_t)offset, whence); + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -861,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -902,7 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: branches/OpenMPT-1.28/include/mpg123/src/version.h ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/src/version.h Mon Oct 28 15:04:23 2024 (r22014) +++ branches/OpenMPT-1.28/include/mpg123/src/version.h Mon Oct 28 15:04:48 2024 (r22015) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |
From: <sv...@op...> - 2024-10-28 14:04:30
|
Author: manx Date: Mon Oct 28 15:04:23 2024 New Revision: 22014 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22014 Log: Merged revision(s) 22006 from trunk/OpenMPT: [Fix] mpg123: Enable setmode(). We are not using that code path, but it is required for generally correct Windows/DOS support. ........ Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/include/mpg123/ports/MSVC++/config.h Modified: branches/OpenMPT-1.28/include/mpg123/ports/MSVC++/config.h ============================================================================== --- branches/OpenMPT-1.28/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:03:35 2024 (r22013) +++ branches/OpenMPT-1.28/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:04:23 2024 (r22014) @@ -33,6 +33,9 @@ #define strcasecmp _strcmpi #define strncasecmp _strnicmp +/* Windows/DOS */ +#define HAVE__SETMODE + /* Features */ /* #define LFS_LARGEFILE_64 1 */ |
Author: manx Date: Mon Oct 28 15:03:35 2024 New Revision: 22013 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22013 Log: Merged revision(s) 21998, 22007 from trunk/OpenMPT: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. ........ [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). ........ Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c branches/OpenMPT-1.29/include/mpg123/src/version.h Modified: branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt Mon Oct 28 15:03:35 2024 (r22013) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/makefile/config.h` has been added for plain `Makefile` builds. * `ports/MSVC++/config.h` has been added for MSVC builds. Modified: branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c Mon Oct 28 15:03:35 2024 (r22013) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h Mon Oct 28 15:03:35 2024 (r22013) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h Mon Oct 28 15:03:35 2024 (r22013) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:03:35 2024 (r22013) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,13 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } - return lseek(ioh->fd, (off_t)offset, whence); + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -861,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -902,7 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: branches/OpenMPT-1.29/include/mpg123/src/version.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/version.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/version.h Mon Oct 28 15:03:35 2024 (r22013) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |
From: <sv...@op...> - 2024-10-28 14:03:10
|
Author: manx Date: Mon Oct 28 15:02:59 2024 New Revision: 22012 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22012 Log: Merged revision(s) 22006 from trunk/OpenMPT: [Fix] mpg123: Enable setmode(). We are not using that code path, but it is required for generally correct Windows/DOS support. ........ Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/include/mpg123/ports/MSVC++/config.h branches/OpenMPT-1.29/include/mpg123/ports/makefile/config.h Modified: branches/OpenMPT-1.29/include/mpg123/ports/MSVC++/config.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:02:36 2024 (r22011) +++ branches/OpenMPT-1.29/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:02:59 2024 (r22012) @@ -33,6 +33,9 @@ #define strcasecmp _strcmpi #define strncasecmp _strnicmp +/* Windows/DOS */ +#define HAVE__SETMODE + /* Features */ /* #define LFS_LARGEFILE_64 1 */ Modified: branches/OpenMPT-1.29/include/mpg123/ports/makefile/config.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/ports/makefile/config.h Mon Oct 28 15:02:36 2024 (r22011) +++ branches/OpenMPT-1.29/include/mpg123/ports/makefile/config.h Mon Oct 28 15:02:59 2024 (r22012) @@ -33,6 +33,13 @@ #define SIZEOF_OFF_T 8 #endif +/* Windows/DOS */ +#if defined(__DJGPP__) +#define HAVE_SETMODE +#elif defined(_WIN32) +#define HAVE__SETMODE +#endif + /* Features */ /* #define LFS_LARGEFILE_64 1 */ |
Author: manx Date: Mon Oct 28 15:02:36 2024 New Revision: 22011 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22011 Log: Merged revision(s) 21998, 22007 from trunk/OpenMPT: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. ........ [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/include/mpg123/OpenMPT.txt branches/OpenMPT-1.30/include/mpg123/src/compat/compat.c branches/OpenMPT-1.30/include/mpg123/src/compat/compat.h branches/OpenMPT-1.30/include/mpg123/src/include/mpg123.h branches/OpenMPT-1.30/include/mpg123/src/libmpg123/lfs_wrap.c branches/OpenMPT-1.30/include/mpg123/src/version.h Modified: branches/OpenMPT-1.30/include/mpg123/OpenMPT.txt ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/OpenMPT.txt Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/OpenMPT.txt Mon Oct 28 15:02:36 2024 (r22011) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/makefile/config.h` has been added for plain `Makefile` builds. * `ports/MSVC++/config.h` has been added for MSVC builds. Modified: branches/OpenMPT-1.30/include/mpg123/src/compat/compat.c ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/src/compat/compat.c Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/src/compat/compat.c Mon Oct 28 15:02:36 2024 (r22011) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: branches/OpenMPT-1.30/include/mpg123/src/compat/compat.h ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/src/compat/compat.h Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/src/compat/compat.h Mon Oct 28 15:02:36 2024 (r22011) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: branches/OpenMPT-1.30/include/mpg123/src/include/mpg123.h ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/src/include/mpg123.h Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/src/include/mpg123.h Mon Oct 28 15:02:36 2024 (r22011) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: branches/OpenMPT-1.30/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:02:36 2024 (r22011) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,13 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } - return lseek(ioh->fd, (off_t)offset, whence); + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -861,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -902,7 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: branches/OpenMPT-1.30/include/mpg123/src/version.h ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/src/version.h Mon Oct 28 15:02:11 2024 (r22010) +++ branches/OpenMPT-1.30/include/mpg123/src/version.h Mon Oct 28 15:02:36 2024 (r22011) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |
From: <sv...@op...> - 2024-10-28 14:02:23
|
Author: manx Date: Mon Oct 28 15:02:11 2024 New Revision: 22010 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22010 Log: Merged revision(s) 22006 from trunk/OpenMPT: [Fix] mpg123: Enable setmode(). We are not using that code path, but it is required for generally correct Windows/DOS support. ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/include/mpg123/ports/MSVC++/config.h branches/OpenMPT-1.30/include/mpg123/ports/makefile/config.h Modified: branches/OpenMPT-1.30/include/mpg123/ports/MSVC++/config.h ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:01:51 2024 (r22009) +++ branches/OpenMPT-1.30/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:02:11 2024 (r22010) @@ -33,6 +33,9 @@ #define strcasecmp _strcmpi #define strncasecmp _strnicmp +/* Windows/DOS */ +#define HAVE__SETMODE + /* Features */ /* #define LFS_LARGEFILE_64 1 */ Modified: branches/OpenMPT-1.30/include/mpg123/ports/makefile/config.h ============================================================================== --- branches/OpenMPT-1.30/include/mpg123/ports/makefile/config.h Mon Oct 28 15:01:51 2024 (r22009) +++ branches/OpenMPT-1.30/include/mpg123/ports/makefile/config.h Mon Oct 28 15:02:11 2024 (r22010) @@ -35,6 +35,13 @@ #define SIZEOF_OFF_T 8 #endif +/* Windows/DOS */ +#if defined(__DJGPP__) +#define HAVE_SETMODE +#elif defined(_WIN32) +#define HAVE__SETMODE +#endif + /* Features */ /* #define LFS_LARGEFILE_64 1 */ |
Author: manx Date: Mon Oct 28 15:01:51 2024 New Revision: 22009 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22009 Log: Merged revision(s) 21998, 22007 from trunk/OpenMPT: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. ........ [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/include/mpg123/OpenMPT.txt branches/OpenMPT-1.31/include/mpg123/src/compat/compat.c branches/OpenMPT-1.31/include/mpg123/src/compat/compat.h branches/OpenMPT-1.31/include/mpg123/src/include/mpg123.h branches/OpenMPT-1.31/include/mpg123/src/libmpg123/lfs_wrap.c branches/OpenMPT-1.31/include/mpg123/src/version.h Modified: branches/OpenMPT-1.31/include/mpg123/OpenMPT.txt ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/OpenMPT.txt Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/OpenMPT.txt Mon Oct 28 15:01:51 2024 (r22009) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/makefile/config.h` has been added for plain `Makefile` builds. * `ports/MSVC++/config.h` has been added for MSVC builds. Modified: branches/OpenMPT-1.31/include/mpg123/src/compat/compat.c ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/src/compat/compat.c Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/src/compat/compat.c Mon Oct 28 15:01:51 2024 (r22009) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: branches/OpenMPT-1.31/include/mpg123/src/compat/compat.h ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/src/compat/compat.h Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/src/compat/compat.h Mon Oct 28 15:01:51 2024 (r22009) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: branches/OpenMPT-1.31/include/mpg123/src/include/mpg123.h ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/src/include/mpg123.h Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/src/include/mpg123.h Mon Oct 28 15:01:51 2024 (r22009) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: branches/OpenMPT-1.31/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:01:51 2024 (r22009) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,13 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } - return lseek(ioh->fd, (off_t)offset, whence); + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -861,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -902,7 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: branches/OpenMPT-1.31/include/mpg123/src/version.h ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/src/version.h Mon Oct 28 15:00:50 2024 (r22008) +++ branches/OpenMPT-1.31/include/mpg123/src/version.h Mon Oct 28 15:01:51 2024 (r22009) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |
From: <sv...@op...> - 2024-10-28 14:01:02
|
Author: manx Date: Mon Oct 28 15:00:50 2024 New Revision: 22008 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22008 Log: Merged revision(s) 22006 from trunk/OpenMPT: [Fix] mpg123: Enable setmode(). We are not using that code path, but it is required for generally correct Windows/DOS support. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/include/mpg123/ports/MSVC++/config.h branches/OpenMPT-1.31/include/mpg123/ports/makefile/config.h Modified: branches/OpenMPT-1.31/include/mpg123/ports/MSVC++/config.h ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:00:22 2024 (r22007) +++ branches/OpenMPT-1.31/include/mpg123/ports/MSVC++/config.h Mon Oct 28 15:00:50 2024 (r22008) @@ -33,6 +33,9 @@ #define strcasecmp _strcmpi #define strncasecmp _strnicmp +/* Windows/DOS */ +#define HAVE__SETMODE + /* Features */ /* #define LFS_LARGEFILE_64 1 */ Modified: branches/OpenMPT-1.31/include/mpg123/ports/makefile/config.h ============================================================================== --- branches/OpenMPT-1.31/include/mpg123/ports/makefile/config.h Mon Oct 28 15:00:22 2024 (r22007) +++ branches/OpenMPT-1.31/include/mpg123/ports/makefile/config.h Mon Oct 28 15:00:50 2024 (r22008) @@ -35,6 +35,13 @@ #define SIZEOF_OFF_T 8 #endif +/* Windows/DOS */ +#if defined(__DJGPP__) +#define HAVE_SETMODE +#elif defined(_WIN32) +#define HAVE__SETMODE +#endif + /* Features */ /* #define LFS_LARGEFILE_64 1 */ |
From: <sv...@op...> - 2024-10-28 14:00:30
|
Author: manx Date: Mon Oct 28 15:00:22 2024 New Revision: 22007 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22007 Log: [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt trunk/OpenMPT/include/mpg123/src/compat/compat.c trunk/OpenMPT/include/mpg123/src/compat/compat.h trunk/OpenMPT/include/mpg123/src/include/mpg123.h trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c trunk/OpenMPT/include/mpg123/src/version.h Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt ============================================================================== --- trunk/OpenMPT/include/mpg123/OpenMPT.txt Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/OpenMPT.txt Mon Oct 28 15:00:22 2024 (r22007) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/makefile/config.h` has been added for plain `Makefile` builds. * `ports/MSVC++/config.h` has been added for MSVC builds. @@ -6,9 +6,6 @@ * `ports/Xcode/config.h` has been modified to let the build system set `OPT_*`. * `ports/Xcode/config.h` has been modified to `#define HAVE_DIRENT_H`. - * `src/libmpg123/lfs_wrap.c` has been modified to work-around - <https://sourceforge.net/p/mpg123/bugs/373/> ("weird LNK4286 warning when - building against ARM64EC UCRT for lseek"). * Modifications are marked by `// OpenMPT` or `/* OpenMPT */`. * Obviously, unnecessary folders and files have been removed. * For building, premake is used to generate Visual Studio project files. Modified: trunk/OpenMPT/include/mpg123/src/compat/compat.c ============================================================================== --- trunk/OpenMPT/include/mpg123/src/compat/compat.c Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/src/compat/compat.c Mon Oct 28 15:00:22 2024 (r22007) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: trunk/OpenMPT/include/mpg123/src/compat/compat.h ============================================================================== --- trunk/OpenMPT/include/mpg123/src/compat/compat.h Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/src/compat/compat.h Mon Oct 28 15:00:22 2024 (r22007) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: trunk/OpenMPT/include/mpg123/src/include/mpg123.h ============================================================================== --- trunk/OpenMPT/include/mpg123/src/include/mpg123.h Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/src/include/mpg123.h Mon Oct 28 15:00:22 2024 (r22007) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:00:22 2024 (r22007) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,17 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } -#if defined(_UCRT) /* OpenMPT */ - return _lseek(ioh->fd, (off_t)offset, whence); /* OpenMPT */ -#else /* OpenMPT */ - return lseek(ioh->fd, (off_t)offset, whence); -#endif /* OpenMPT */ + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -865,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -906,11 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; -#if defined(_UCRT) /* OpenMPT */ - ioh->r_lseek = r_lseek != NULL ? r_lseek : _lseek; /* OpenMPT */ -#else /* OpenMPT */ - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; -#endif /* OpenMPT */ + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: trunk/OpenMPT/include/mpg123/src/version.h ============================================================================== --- trunk/OpenMPT/include/mpg123/src/version.h Mon Oct 28 14:56:27 2024 (r22006) +++ trunk/OpenMPT/include/mpg123/src/version.h Mon Oct 28 15:00:22 2024 (r22007) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |
From: <sv...@op...> - 2024-10-28 13:56:40
|
Author: manx Date: Mon Oct 28 14:56:27 2024 New Revision: 22006 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22006 Log: [Fix] mpg123: Enable setmode(). We are not using that code path, but it is required for generally correct Windows/DOS support. Modified: trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h trunk/OpenMPT/include/mpg123/ports/makefile/config.h Modified: trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h ============================================================================== --- trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h Sun Oct 27 22:31:29 2024 (r22005) +++ trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h Mon Oct 28 14:56:27 2024 (r22006) @@ -33,6 +33,9 @@ #define strcasecmp _strcmpi #define strncasecmp _strnicmp +/* Windows/DOS */ +#define HAVE__SETMODE + /* Features */ /* #define LFS_LARGEFILE_64 1 */ Modified: trunk/OpenMPT/include/mpg123/ports/makefile/config.h ============================================================================== --- trunk/OpenMPT/include/mpg123/ports/makefile/config.h Sun Oct 27 22:31:29 2024 (r22005) +++ trunk/OpenMPT/include/mpg123/ports/makefile/config.h Mon Oct 28 14:56:27 2024 (r22006) @@ -35,6 +35,13 @@ #define SIZEOF_OFF_T 8 #endif +/* Windows/DOS */ +#if defined(__DJGPP__) +#define HAVE_SETMODE +#elif defined(_WIN32) +#define HAVE__SETMODE +#endif + /* Features */ /* #define LFS_LARGEFILE_64 1 */ |
From: <sv...@op...> - 2024-10-27 21:31:41
|
Author: sagamusix Date: Sun Oct 27 22:31:29 2024 New Revision: 22005 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22005 Log: [Fix] Comments tab: Avoid warning in non-UNICODE builds. Modified: trunk/OpenMPT/mptrack/view_com.cpp Modified: trunk/OpenMPT/mptrack/view_com.cpp ============================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp Sun Oct 27 16:49:28 2024 (r22004) +++ trunk/OpenMPT/mptrack/view_com.cpp Sun Oct 27 22:31:29 2024 (r22005) @@ -278,7 +278,7 @@ if(m_editLabel && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) { m_editLabel = false; - m_ItemList.CancelEditLabel(); + m_ItemList.SetFocus(); return TRUE; } |
From: <sv...@op...> - 2024-10-27 15:49:40
|
Author: sagamusix Date: Sun Oct 27 16:49:28 2024 New Revision: 22004 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22004 Log: [Imp] S3M: Fingerprint early Schism Tracker versions, as found in some 2007-ish S3Ms by Platonist. Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp Sun Oct 27 14:15:50 2024 (r22003) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp Sun Oct 27 16:49:28 2024 (r22004) @@ -232,6 +232,15 @@ m_nMinPeriod = 64; m_nMaxPeriod = 32767; + ReadOrderFromFile<uint8>(Order(), file, fileHeader.ordNum, 0xFF, 0xFE); + + // Read sample header offsets + std::vector<uint16le> sampleOffsets; + file.ReadVector(sampleOffsets, fileHeader.smpNum); + // Read pattern offsets + std::vector<uint16le> patternOffsets; + file.ReadVector(patternOffsets, fileHeader.patNum); + // ST3 ignored Zxx commands, so if we find that a file was made with ST3, we should erase all MIDI macros. bool keepMidiMacros = false; @@ -241,6 +250,7 @@ bool isST3 = false; bool isSchism = false; const bool usePanningTable = fileHeader.usePanningTable == S3MFileHeader::idPanning; + const bool offsetsAreCanonical = !patternOffsets.empty() && !sampleOffsets.empty() && patternOffsets[0] > sampleOffsets[0]; const int32 schismDateVersion = SchismTrackerEpoch + ((fileHeader.cwtv == 0x4FFF) ? fileHeader.reserved2 : (fileHeader.cwtv - 0x4050)); switch(fileHeader.cwtv & S3MFileHeader::trackerMask) { @@ -252,18 +262,25 @@ if(!memcmp(&fileHeader.reserved2, "SCLUB2.0", 8)) { madeWithTracker = UL_("Sound Club 2"); - } else if(fileHeader.cwtv == S3MFileHeader::trkST3_20 && fileHeader.special == 0 && (fileHeader.ordNum & 0x0F) == 0 && fileHeader.ultraClicks == 0 && (fileHeader.flags & ~0x50) == 0 && usePanningTable) + } else if(fileHeader.cwtv == S3MFileHeader::trkST3_20 && fileHeader.special == 0 && (fileHeader.ordNum & 0x01) == 0 && fileHeader.ultraClicks == 0 && (fileHeader.flags & ~0x50) == 0 && usePanningTable && offsetsAreCanonical) { - // MPT and OpenMPT before 1.17.03.02 - Simply keep default (filter) MIDI macros - if((fileHeader.masterVolume & 0x80) != 0) + // Canonical offset check avoids mis-detection of an automatic conversion of Vic's "Paper" demo track + if((fileHeader.ordNum & 0x0F) == 0) { - m_dwLastSavedWithVersion = MPT_V("1.16"); - madeWithTracker = UL_("ModPlug Tracker / OpenMPT 1.17"); - } else + // MPT and OpenMPT before 1.17.03.02 - Simply keep default (filter) MIDI macros + if((fileHeader.masterVolume & 0x80) != 0) + { + m_dwLastSavedWithVersion = MPT_V("1.16"); + madeWithTracker = UL_("ModPlug Tracker / OpenMPT 1.17"); + } else + { + // MPT 1.0 alpha5 doesn't set the stereo flag, but MPT 1.0 alpha6 does. + m_dwLastSavedWithVersion = MPT_V("1.00.00.A0"); + madeWithTracker = UL_("ModPlug Tracker 1.0 alpha"); + } + } else if((fileHeader.masterVolume & 0x80) != 0) { - // MPT 1.0 alpha5 doesn't set the stereo flag, but MPT 1.0 alpha6 does. - m_dwLastSavedWithVersion = MPT_V("1.00.00.A0"); - madeWithTracker = UL_("ModPlug Tracker 1.0 alpha"); + madeWithTracker = UL_("Schism Tracker"); } keepMidiMacros = true; nonCompatTracker = true; @@ -308,7 +325,7 @@ madeWithTracker = UL_("Impulse Tracker 1.03"); // Could also be 1.02, maybe? I don't have that one else madeWithTracker = GetImpulseTrackerVersion(fileHeader.cwtv, 0); - + if(fileHeader.cwtv >= S3MFileHeader::trkIT2_07 && fileHeader.reserved3 != 0) { // Starting from version 2.07, IT stores the total edit time of a module in the "reserved" field @@ -498,15 +515,6 @@ } } - ReadOrderFromFile<uint8>(Order(), file, fileHeader.ordNum, 0xFF, 0xFE); - - // Read sample header offsets - std::vector<uint16le> sampleOffsets; - file.ReadVector(sampleOffsets, fileHeader.smpNum); - // Read pattern offsets - std::vector<uint16le> patternOffsets; - file.ReadVector(patternOffsets, fileHeader.patNum); - // Read extended channel panning if(usePanningTable) { @@ -522,6 +530,7 @@ if(GetNumChannels() < 32 && m_dwLastSavedWithVersion == MPT_V("1.16")) { // MPT 1.0 alpha 6 up to 1.16.203 set the panning bit for all channels, regardless of whether they are used or not. + // Note: Schism Tracker fixed the same bug in git commit f21fe8bcae8b6dde2df27ede4ac9fe563f91baff if(hasChannelsWithoutPanning) m_modFormat.madeWithTracker = UL_("ModPlug Tracker 1.16 / OpenMPT 1.17"); else |
From: <sv...@op...> - 2024-10-27 13:15:57
|
Author: sagamusix Date: Sun Oct 27 14:15:50 2024 New Revision: 22003 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22003 Log: Merged revision(s) 22001-22002 from trunk/OpenMPT: [Imp] MOD: When converting sample to MOD, zero the lower 4 bits, as they won't be saved anyway. [Imp] MOD: Improve handling of tranpose = -1 / finetune = 0 case when converting sample from another format. ........ [Fix] MIDI recording: Velocity amplification only worked for integer multiples of 100% (https://bugs.openmpt.org/view.php?id=1835). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/mptrack/Mpt_midi.cpp branches/OpenMPT-1.31/soundlib/ModSample.cpp Modified: branches/OpenMPT-1.31/mptrack/Mpt_midi.cpp ============================================================================== --- branches/OpenMPT-1.31/mptrack/Mpt_midi.cpp Sun Oct 27 13:24:18 2024 (r22002) +++ branches/OpenMPT-1.31/mptrack/Mpt_midi.cpp Sun Oct 27 14:15:50 2024 (r22003) @@ -29,21 +29,20 @@ //Get Midi message(dwParam1), apply MIDI settings having effect on volume, and return //the volume value [0, 256]. In addition value -1 is used as 'use default value'-indicator. -int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, const BYTE midivolume) +int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, uint8 midiChannelVolume) { int nVol = MIDIEvents::GetDataByte2FromEvent(dwParam1); if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) { - nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8; - nVol *= TrackerSettings::Instance().midiVelocityAmp / 100; + if(!(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL)) + midiChannelVolume = 127; + nVol = Util::muldivr_unsigned(CDLSBank::DLSMidiVolumeToLinear(nVol), TrackerSettings::Instance().midiVelocityAmp * midiChannelVolume, 100 * 127 * 256); Limit(nVol, 1, 256); - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) - nVol = static_cast<int>((midivolume / 127.0) * nVol); } else { // Case: No velocity record. if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) - nVol = 4*((midivolume+1)/2); + nVol = (midiChannelVolume + 1) * 2; else //Use default volume nVol = -1; } Modified: branches/OpenMPT-1.31/soundlib/ModSample.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/ModSample.cpp Sun Oct 27 13:24:18 2024 (r22002) +++ branches/OpenMPT-1.31/soundlib/ModSample.cpp Sun Oct 27 14:15:50 2024 (r22003) @@ -41,6 +41,13 @@ nC5Speed = Util::muldivr_unsigned(nC5Speed, 8363, 8287); FrequencyToTranspose(); } + if(toType == MOD_TYPE_MOD) + { + if(RelativeTone == -1 && nFineTune == 0) + nFineTune = -128; + RelativeTone = 0; + nFineTune &= ~0x0F; + } // No ping-pong loop, panning and auto-vibrato for MOD / S3M samples if(toType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) @@ -51,8 +58,6 @@ nVibRate = 0; nVibSweep = 0; nVibType = VIB_SINE; - - RelativeTone = 0; } // No global volume / sustain loops for MOD/S3M/XM @@ -85,7 +90,6 @@ LimitMax(nVibRate, uint8(63)); } - // Autovibrato sweep setting is inverse in XM (0 = "no sweep") and IT (0 = "no vibrato") if(((fromType & MOD_TYPE_XM) && (toType & (MOD_TYPE_IT | MOD_TYPE_MPT))) || ((toType & MOD_TYPE_XM) && (fromType & (MOD_TYPE_IT | MOD_TYPE_MPT)))) { |
From: <sv...@op...> - 2024-10-27 12:24:32
|
Author: sagamusix Date: Sun Oct 27 13:24:18 2024 New Revision: 22002 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22002 Log: [Fix] MIDI recording: Velocity amplification only worked for integer multiples of 100% (https://bugs.openmpt.org/view.php?id=1835). Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp Sun Oct 27 13:15:28 2024 (r22001) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp Sun Oct 27 13:24:18 2024 (r22002) @@ -33,21 +33,20 @@ //Get Midi message(dwParam1), apply MIDI settings having effect on volume, and return //the volume value [0, 256]. In addition value -1 is used as 'use default value'-indicator. -int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, const BYTE midivolume) +int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, uint8 midiChannelVolume) { int nVol = MIDIEvents::GetDataByte2FromEvent(dwParam1); if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) { - nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8; - nVol *= TrackerSettings::Instance().midiVelocityAmp / 100; + if(!(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL)) + midiChannelVolume = 127; + nVol = Util::muldivr_unsigned(CDLSBank::DLSMidiVolumeToLinear(nVol), TrackerSettings::Instance().midiVelocityAmp * midiChannelVolume, 100 * 127 * 256); Limit(nVol, 1, 256); - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) - nVol = static_cast<int>((midivolume / 127.0) * nVol); } else { // Case: No velocity record. if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) - nVol = 4*((midivolume+1)/2); + nVol = (midiChannelVolume + 1) * 2; else //Use default volume nVol = -1; } |
From: <sv...@op...> - 2024-10-27 12:15:41
|
Author: sagamusix Date: Sun Oct 27 13:15:28 2024 New Revision: 22001 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22001 Log: [Imp] MOD: When converting sample to MOD, zero the lower 4 bits, as they won't be saved anyway. [Imp] MOD: Improve handling of tranpose = -1 / finetune = 0 case when converting sample from another format. Modified: trunk/OpenMPT/soundlib/ModSample.cpp Modified: trunk/OpenMPT/soundlib/ModSample.cpp ============================================================================== --- trunk/OpenMPT/soundlib/ModSample.cpp Sun Oct 27 13:14:11 2024 (r22000) +++ trunk/OpenMPT/soundlib/ModSample.cpp Sun Oct 27 13:15:28 2024 (r22001) @@ -42,6 +42,13 @@ nC5Speed = Util::muldivr_unsigned(nC5Speed, 8363, 8287); FrequencyToTranspose(); } + if(toType == MOD_TYPE_MOD) + { + if(RelativeTone == -1 && nFineTune == 0) + nFineTune = -128; + RelativeTone = 0; + nFineTune &= ~0x0F; + } // No ping-pong loop, panning and auto-vibrato for MOD / S3M samples if(toType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) @@ -52,8 +59,6 @@ nVibRate = 0; nVibSweep = 0; nVibType = VIB_SINE; - - RelativeTone = 0; } // No global volume / sustain loops for MOD/S3M/XM @@ -86,7 +91,6 @@ LimitMax(nVibRate, uint8(63)); } - // Autovibrato sweep setting is inverse in XM (0 = "no sweep") and IT (0 = "no vibrato") if(((fromType & MOD_TYPE_XM) && (toType & (MOD_TYPE_IT | MOD_TYPE_MPT))) || ((toType & MOD_TYPE_XM) && (fromType & (MOD_TYPE_IT | MOD_TYPE_MPT)))) { |
From: <sv...@op...> - 2024-10-27 12:14:26
|
Author: sagamusix Date: Sun Oct 27 13:14:11 2024 New Revision: 22000 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22000 Log: [Imp] Comments tab: Allow name label editing to be cancelled (what a boring commit 22000 \o/) Modified: trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/mptrack/view_com.h Modified: trunk/OpenMPT/mptrack/view_com.cpp ============================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp Sun Oct 27 12:01:51 2024 (r21999) +++ trunk/OpenMPT/mptrack/view_com.cpp Sun Oct 27 13:14:11 2024 (r22000) @@ -275,6 +275,13 @@ { if(pMsg) { + if(m_editLabel && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) + { + m_editLabel = false; + m_ItemList.CancelEditLabel(); + return TRUE; + } + if((pMsg->message == WM_SYSKEYUP) || (pMsg->message == WM_KEYUP) || (pMsg->message == WM_SYSKEYDOWN) || (pMsg->message == WM_KEYDOWN)) { @@ -568,6 +575,7 @@ CEdit *editCtrl = m_ItemList.GetEditControl(); if(editCtrl) { + m_editLabel = true; const CModSpecifications &specs = GetDocument()->GetSoundFile().GetModSpecifications(); const auto maxStrLen = (m_nListId == IDC_LIST_SAMPLES) ? specs.sampleNameLengthMax : specs.instrNameLengthMax; editCtrl->LimitText(maxStrLen); @@ -576,9 +584,16 @@ } -void CViewComments::OnEndLabelEdit(LPNMHDR pnmhdr, LRESULT *) +void CViewComments::OnEndLabelEdit(LPNMHDR pnmhdr, LRESULT *result) { CMainFrame::GetInputHandler()->Bypass(false); + if(!m_editLabel) + { + *result = FALSE; + return; + } + m_editLabel = false; + LV_DISPINFO &lvDispInfo = *reinterpret_cast<LV_DISPINFO *>(pnmhdr); LV_ITEM &lvItem = lvDispInfo.item; CModDoc *pModDoc = GetDocument(); Modified: trunk/OpenMPT/mptrack/view_com.h ============================================================================== --- trunk/OpenMPT/mptrack/view_com.h Sun Oct 27 12:01:51 2024 (r21999) +++ trunk/OpenMPT/mptrack/view_com.h Sun Oct 27 13:14:11 2024 (r22000) @@ -34,6 +34,7 @@ ModCommand::NOTE m_lastNote = NOTE_NONE; CHANNELINDEX m_noteChannel = CHANNELINDEX_INVALID; INSTRUMENTINDEX m_noteInstr = INSTRUMENTINDEX_INVALID; + bool m_editLabel = false; public: void RecalcLayout(); |
From: <sv...@op...> - 2024-10-27 11:01:58
|
Author: sagamusix Date: Sun Oct 27 12:01:51 2024 New Revision: 21999 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21999 Log: [Imp] Effect info: Show effective spead of EFx command in parentheses. Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp ============================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp Sun Oct 27 07:57:48 2024 (r21998) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp Sun Oct 27 12:01:51 2024 (r21999) @@ -917,7 +917,7 @@ if((param & 0x0F) == 0) s = _T("Stop"); else - s.Format(_T("Speed %d"), param & 0x0F); + s.Format(_T("Speed %d (%d)"), param & 0x0F, ModEFxTable[param & 0x0F]); } else { // macro |
From: <sv...@op...> - 2024-10-27 06:57:59
|
Author: manx Date: Sun Oct 27 07:57:48 2024 New Revision: 21998 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21998 Log: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt ============================================================================== --- trunk/OpenMPT/include/mpg123/OpenMPT.txt Sun Oct 27 01:45:44 2024 (r21997) +++ trunk/OpenMPT/include/mpg123/OpenMPT.txt Sun Oct 27 07:57:48 2024 (r21998) @@ -6,6 +6,9 @@ * `ports/Xcode/config.h` has been modified to let the build system set `OPT_*`. * `ports/Xcode/config.h` has been modified to `#define HAVE_DIRENT_H`. + * `src/libmpg123/lfs_wrap.c` has been modified to work-around + <https://sourceforge.net/p/mpg123/bugs/373/> ("weird LNK4286 warning when + building against ARM64EC UCRT for lseek"). * Modifications are marked by `// OpenMPT` or `/* OpenMPT */`. * Obviously, unnecessary folders and files have been removed. * For building, premake is used to generate Visual Studio project files. Modified: trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c Sun Oct 27 01:45:44 2024 (r21997) +++ trunk/OpenMPT/include/mpg123/src/libmpg123/lfs_wrap.c Sun Oct 27 07:57:48 2024 (r21998) @@ -761,7 +761,11 @@ errno = EOVERFLOW; return -1; } +#if defined(_UCRT) /* OpenMPT */ + return _lseek(ioh->fd, (off_t)offset, whence); /* OpenMPT */ +#else /* OpenMPT */ return lseek(ioh->fd, (off_t)offset, whence); +#endif /* OpenMPT */ #endif } @@ -902,7 +906,11 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; +#if defined(_UCRT) /* OpenMPT */ + ioh->r_lseek = r_lseek != NULL ? r_lseek : _lseek; /* OpenMPT */ +#else /* OpenMPT */ ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; +#endif /* OpenMPT */ } /* The real reader replacement will happen while opening. */ |
From: <sv...@op...> - 2024-10-26 23:45:52
|
Author: sagamusix Date: Sun Oct 27 01:45:44 2024 New Revision: 21997 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21997 Log: [Imp] Stream Export: Remember Normalize and Clear Plugin Buffer choices across runs. Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp Sun Oct 27 01:30:39 2024 (r21996) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp Sun Oct 27 01:45:44 2024 (r21997) @@ -125,7 +125,7 @@ { DialogBase::OnInitDialog(); - CheckDlgButton(IDC_CHECK5, BST_UNCHECKED); // Normalize + CheckDlgButton(IDC_CHECK5, m_Settings.normalize ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CHECK3, BST_CHECKED); // Cue points CheckDlgButton(IDC_CHECK4, BST_UNCHECKED); @@ -183,7 +183,7 @@ { GetDlgItem(IDC_GIVEPLUGSIDLETIME)->EnableWindow(TRUE); GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(TRUE); - CheckDlgButton(IDC_RENDERSILENCE, BST_CHECKED); + CheckDlgButton(IDC_RENDERSILENCE, m_Settings.silencePlugBuffers ? BST_CHECKED : BST_UNCHECKED); break; } } @@ -726,7 +726,8 @@ m_Settings.repeatCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE)); m_Settings.normalize = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED; - m_Settings.silencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED; + if(GetDlgItem(IDC_RENDERSILENCE)->IsWindowEnabled()) + m_Settings.silencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED; m_Settings.outputToSample = IsDlgButtonChecked(IDC_RADIO5) != BST_UNCHECKED; m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) != BST_UNCHECKED; if (m_bGivePlugsIdleTime) Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Sun Oct 27 01:30:39 2024 (r21996) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Sun Oct 27 01:45:44 2024 (r21997) @@ -1678,7 +1678,10 @@ CWaveConvert wsdlg(pMainFrm, nMinOrder, nMaxOrder, m_SndFile.Order().GetLengthTailTrimmed() - 1, m_SndFile, encFactories); { BypassInputHandler bih; - if (wsdlg.DoModal() != IDOK) return; + wsdlg.m_Settings.normalize = TrackerSettings::Instance().ExportNormalize; + wsdlg.m_Settings.silencePlugBuffers = TrackerSettings::Instance().ExportClearPluginBuffers; + if (wsdlg.DoModal() != IDOK) + return; } EncoderFactoryBase *encFactory = wsdlg.m_Settings.GetEncoderFactory(); @@ -1690,10 +1693,13 @@ .DefaultFilename(GetPathNameMpt().GetFilenameBase() + P_(".") + extension) .ExtensionFilter(encFactory->GetTraits().fileDescription + U_(" (*.") + extension.ToUnicode() + U_(")|*.") + extension.ToUnicode() + U_("||")) .WorkingDirectory(TrackerSettings::Instance().PathExport.GetWorkingDir()); - if(!wsdlg.m_Settings.outputToSample && !dlg.Show()) return; + if(!wsdlg.m_Settings.outputToSample && !dlg.Show()) + return; // will set default dir here because there's no setup option for export dir yet (feel free to add one...) TrackerSettings::Instance().PathExport.SetDefaultDir(dlg.GetWorkingDirectory(), true); + TrackerSettings::Instance().ExportNormalize = wsdlg.m_Settings.normalize; + TrackerSettings::Instance().ExportClearPluginBuffers = wsdlg.m_Settings.silencePlugBuffers; mpt::PathString drive, dir, name, ext; dlg.GetFirstFile().SplitPath(nullptr, &drive, &dir, &name, &ext); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp ============================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp Sun Oct 27 01:30:39 2024 (r21996) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp Sun Oct 27 01:45:44 2024 (r21997) @@ -296,6 +296,8 @@ // Export , ExportDefaultToSoundcardSamplerate(conf, U_("Export"), U_("DefaultToSoundcardSamplerate"), true) , ExportStreamEncoderSettings(conf, U_("Export")) + , ExportNormalize(conf, U_("Export"), U_("Normalize"), false) + , ExportClearPluginBuffers(conf, U_("Export"), U_("ClearPluginBuffers"), true) // Components , ComponentsLoadOnStartup(conf, U_("Components"), U_("LoadOnStartup"), ComponentManagerSettingsDefault().LoadOnStartup()) , ComponentsKeepLoaded(conf, U_("Components"), U_("KeepLoaded"), ComponentManagerSettingsDefault().KeepLoaded()) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h ============================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h Sun Oct 27 01:30:39 2024 (r21996) +++ trunk/OpenMPT/mptrack/TrackerSettings.h Sun Oct 27 01:45:44 2024 (r21997) @@ -827,6 +827,8 @@ Setting<bool> ExportDefaultToSoundcardSamplerate; StreamEncoderSettingsConf ExportStreamEncoderSettings; + Setting<bool> ExportNormalize; + Setting<bool> ExportClearPluginBuffers; // Components |
From: <sv...@op...> - 2024-10-26 23:30:51
|
Author: sagamusix Date: Sun Oct 27 01:30:39 2024 New Revision: 21996 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21996 Log: [Imp] Resampling Dialog: Add an option to change notes in MOD format to compensate for the change in middle-C Frequency (https://forum.openmpt.org/index.php?topic=7245.0). Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/tracklib/SampleEdit.cpp trunk/OpenMPT/tracklib/SampleEdit.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp Sun Oct 27 01:30:39 2024 (r21996) @@ -1793,7 +1793,7 @@ } const uint32 oldRate = sample.GetSampleRate(m_sndFile.GetType()); - CResamplingDlg dlg(this, oldRate, TrackerSettings::Instance().sampleEditorDefaultResampler, first != last); + CResamplingDlg dlg(this, oldRate, TrackerSettings::Instance().sampleEditorDefaultResampler, first != last, m_sndFile.GetBestSaveFormat() == MOD_TYPE_MOD); if(dlg.DoModal() != IDOK) return; @@ -1808,12 +1808,12 @@ newFreq = sampleFreq / 2; else if(newFreq == sampleFreq) continue; - ApplyResample(smp, newFreq, dlg.GetFilter(), first != last, dlg.UpdatePatternCommands()); + ApplyResample(smp, newFreq, dlg.GetFilter(), first != last, dlg.UpdatePatternCommands(), dlg.UpdatePatternNotes()); } } -void CCtrlSamples::ApplyResample(SAMPLEINDEX smp, uint32 newRate, ResamplingMode mode, bool ignoreSelection, bool updatePatternCommands) +void CCtrlSamples::ApplyResample(SAMPLEINDEX smp, uint32 newRate, ResamplingMode mode, bool ignoreSelection, bool updatePatternCommands, bool updatePatternNotes) { BeginWaitCursor(); @@ -1848,7 +1848,7 @@ { m_modDoc.PrepareUndoForAllPatterns(false, "Resample (Adjust Offsets)"); }; - SmpLength newSelEnd = SampleEdit::Resample(sample, selection.nStart, selection.nEnd, newRate, mode, m_sndFile, updatePatternCommands, prepareSampleUndoFunc, preparePatternUndoFunc); + SmpLength newSelEnd = SampleEdit::Resample(sample, selection.nStart, selection.nEnd, newRate, mode, m_sndFile, updatePatternCommands, updatePatternNotes, prepareSampleUndoFunc, preparePatternUndoFunc); if(!newSelEnd) { MessageBeep(MB_ICONWARNING); @@ -1857,7 +1857,7 @@ } SetModified(smp, SampleHint().Info().Data(), smp == m_nSample, true); - if(updatePatternCommands) + if(updatePatternCommands || updatePatternNotes) { m_modDoc.UpdateAllViews(nullptr, PatternHint().Data(), this); } Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h ============================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h Sun Oct 27 01:30:39 2024 (r21996) @@ -77,7 +77,7 @@ void RemoveDCOffset(bool allSamples); void ApplyAmplify(const double amp, const double fadeInStart, const double fadeOutEnd, const bool fadeIn, const bool fadeOut, const Fade::Law fadeLaw); - void ApplyResample(SAMPLEINDEX smp, uint32 newRate, ResamplingMode mode, bool ignoreSelection = false, bool updatePatternCommands = false); + void ApplyResample(SAMPLEINDEX smp, uint32 newRate, ResamplingMode mode, bool ignoreSelection = false, bool updatePatternCommands = false, bool updatePatternNotes = false); SampleSelectionPoints GetSelectionPoints(); void SetSelectionPoints(SmpLength nStart, SmpLength nEnd); Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp ============================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp Sun Oct 27 01:30:39 2024 (r21996) @@ -790,18 +790,20 @@ CResamplingDlg::ResamplingOption CResamplingDlg::m_lastChoice = CResamplingDlg::Upsample; uint32 CResamplingDlg::m_lastFrequency = 0; -bool CResamplingDlg::m_updatePatterns = false; +bool CResamplingDlg::m_updatePatternCommands = false; +bool CResamplingDlg::m_updatePatternNotes = false; BEGIN_MESSAGE_MAP(CResamplingDlg, DialogBase) ON_EN_SETFOCUS(IDC_EDIT1, &CResamplingDlg::OnFocusEdit) END_MESSAGE_MAP() -CResamplingDlg::CResamplingDlg(CWnd *parent, uint32 frequency, ResamplingMode srcMode, bool resampleAll) +CResamplingDlg::CResamplingDlg(CWnd *parent, uint32 frequency, ResamplingMode srcMode, bool resampleAll, bool allowAdjustNotes) : DialogBase{IDD_RESAMPLE, parent} , m_srcMode{srcMode} , m_frequency{frequency} , m_resampleAll{resampleAll} + , m_allowAdjustNotes{allowAdjustNotes} { } @@ -848,7 +850,9 @@ } cbnResampling->SetRedraw(TRUE); - CheckDlgButton(IDC_CHECK1, m_updatePatterns ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECK1, m_updatePatternCommands ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECK2, (m_updatePatternNotes && m_allowAdjustNotes) ? BST_CHECKED : BST_UNCHECKED); + GetDlgItem(IDC_CHECK2)->EnableWindow(m_allowAdjustNotes ? TRUE : FALSE); return TRUE; } @@ -883,7 +887,8 @@ CComboBox *cbnResampling = static_cast<CComboBox *>(GetDlgItem(IDC_COMBO_FILTER)); m_srcMode = static_cast<ResamplingMode>(cbnResampling->GetItemData(cbnResampling->GetCurSel())); - m_updatePatterns = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; + m_updatePatternCommands = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; + m_updatePatternNotes = IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED; DialogBase::OnOK(); } Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.h ============================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.h Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.h Sun Oct 27 01:30:39 2024 (r21996) @@ -224,17 +224,20 @@ protected: ResamplingMode m_srcMode; uint32 m_frequency; - bool m_resampleAll; + const bool m_resampleAll; + const bool m_allowAdjustNotes; static uint32 m_lastFrequency; static ResamplingOption m_lastChoice; - static bool m_updatePatterns; + static bool m_updatePatternCommands; + static bool m_updatePatternNotes; public: - CResamplingDlg(CWnd *parent, uint32 frequency, ResamplingMode srcMode, bool resampleAll); + CResamplingDlg(CWnd *parent, uint32 frequency, ResamplingMode srcMode, bool resampleAll, bool allowAdjustNotes); uint32 GetFrequency() const { return m_frequency; } ResamplingMode GetFilter() const { return m_srcMode; } static ResamplingOption GetResamplingOption() { return m_lastChoice; } - static bool UpdatePatternCommands() { return m_updatePatterns; } + static bool UpdatePatternCommands() { return m_updatePatternCommands; } + static bool UpdatePatternNotes() { return m_updatePatternNotes; } protected: BOOL OnInitDialog() override; Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/mptrack/mptrack.rc Sun Oct 27 01:30:39 2024 (r21996) @@ -371,7 +371,7 @@ CTEXT "",IDC_SCANTEXT,6,7,306,20,SS_NOPREFIX END -IDD_RESAMPLE DIALOGEX 0, 0, 197, 110 +IDD_RESAMPLE DIALOGEX 0, 0, 197, 122 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Resample" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -388,6 +388,7 @@ DEFPUSHBUTTON "&OK",IDOK,138,6,50,14 PUSHBUTTON "&Cancel",IDCANCEL,138,24,50,14 CONTROL "&Adjust Offset Commands in Patterns",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,90,133,10 + CONTROL "Adjust &Notes in Patterns",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,105,94,10 END IDD_WECLOME DIALOGEX 0, 0, 257, 266 @@ -809,7 +810,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 190 TOPMARGIN, 7 - BOTTOMMARGIN, 103 + BOTTOMMARGIN, 115 END IDD_WECLOME, DIALOG Modified: trunk/OpenMPT/tracklib/SampleEdit.cpp ============================================================================== --- trunk/OpenMPT/tracklib/SampleEdit.cpp Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/tracklib/SampleEdit.cpp Sun Oct 27 01:30:39 2024 (r21996) @@ -12,6 +12,7 @@ #include "SampleEdit.h" #include "../soundlib/AudioCriticalSection.h" #include "../soundlib/MixFuncTable.h" +#include "../soundlib/mod_specifications.h" #include "../soundlib/modsmp_ctrl.h" #include "../soundlib/SampleCopy.h" #include "../soundlib/Sndfile.h" @@ -830,7 +831,7 @@ // Resample using given resampling method (SRCMODE_DEFAULT = r8brain). // Returns end point of resampled data, or 0 on failure. -SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc) +SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, bool updatePatternNotes, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc) { if(!smp.HasSampleData() || smp.uFlags[CHN_ADLIB] || start >= end) return 0; @@ -1013,15 +1014,15 @@ LimitMax(point, newTotalLength); } + const SAMPLEINDEX sampleIndex = static_cast<SAMPLEINDEX>(std::distance(&sndFile.GetSample(0), &smp)); + bool patternUndoCreated = false; if(updatePatternCommands) { - const SAMPLEINDEX sample = static_cast<SAMPLEINDEX>(std::distance(&sndFile.GetSample(0), &smp)); - bool patternUndoCreated = false; sndFile.Patterns.ForEachModCommand([&](ModCommand &m) { if(m.command != CMD_OFFSET && m.command != CMD_REVERSEOFFSET && m.command != CMD_OFFSETPERCENTAGE) return; - if(sndFile.GetSampleIndex(m.note, m.instr) != sample) + if(sndFile.GetSampleIndex(m.note, m.instr) != sampleIndex) return; SmpLength point = m.param * 256u; @@ -1051,10 +1052,50 @@ }); } - if(!partialResample && sndFile.GetType() != MOD_TYPE_MOD) + const double transpose = 12.0 * std::log(static_cast<double>(newRate) / oldRate) / std::log(2.0); + int noteAdjust = mpt::saturate_round<int>(transpose); + if(updatePatternNotes && noteAdjust != 0) { - smp.nC5Speed = newRate; - smp.FrequencyToTranspose(); + sndFile.Patterns.ForEachModCommand([&](ModCommand &m) + { + if(!m.IsNote()) + return; + if(sndFile.GetSampleIndex(m.note, m.instr) != sampleIndex) + return; + + const auto newNote = static_cast<ModCommand::NOTE>(Clamp(m.note + noteAdjust, sndFile.GetModSpecifications().noteMin, sndFile.GetModSpecifications().noteMax)); + if(m.note == newNote) + return; + + if(!patternUndoCreated) + { + patternUndoCreated = true; + preparePatternUndoFunc(); + } + m.note = newNote; + }); + } + + if(!partialResample || updatePatternNotes) + { + if (sndFile.GetBestSaveFormat() == MOD_TYPE_MOD) + { + int finetuneAdjust = smp.nFineTune / 16 + mpt::saturate_round<int>((transpose - noteAdjust) * 8.0); + if(finetuneAdjust >= 8) + { + finetuneAdjust -= 16; + noteAdjust++; + } else if(finetuneAdjust < -8) + { + finetuneAdjust += 16; + noteAdjust--; + } + smp.nFineTune = MOD2XMFineTune(finetuneAdjust); + } else + { + smp.nC5Speed = newRate; + smp.FrequencyToTranspose(); + } } smp.ReplaceWaveform(newSample, newTotalLength, sndFile); Modified: trunk/OpenMPT/tracklib/SampleEdit.h ============================================================================== --- trunk/OpenMPT/tracklib/SampleEdit.h Sun Oct 27 00:19:04 2024 (r21995) +++ trunk/OpenMPT/tracklib/SampleEdit.h Sun Oct 27 01:30:39 2024 (r21996) @@ -96,7 +96,7 @@ // Resample using given resampling method (SRCMODE_DEFAULT = r8brain). // Returns end point of resampled data, or 0 on failure. -SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc); +SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, bool updatePatternNotes, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc); } // namespace SampleEdit |
From: <sv...@op...> - 2024-10-26 22:19:17
|
Author: sagamusix Date: Sun Oct 27 00:19:04 2024 New Revision: 21995 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21995 Log: [New] Stream Export: Allow easier export of all sub-songs (https://bugs.openmpt.org/view.php?id=1515). [Imp] Stream Export: Repeat count can now also be set when exporting an order list selection, or selecting multiple sub-songs. Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mod2wave.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp Sun Oct 27 00:19:04 2024 (r21995) @@ -12,6 +12,7 @@ #include "mod2wave.h" #include "Dlsbank.h" #include "Mainfrm.h" +#include "Moddoc.h" #include "Mpdlgs.h" #include "Mptrack.h" #include "Reporting.h" @@ -56,21 +57,22 @@ // CWaveConvert - setup for converting a wave file BEGIN_MESSAGE_MAP(CWaveConvert, DialogBase) - ON_COMMAND(IDC_CHECK2, &CWaveConvert::OnCheckTimeLimit) - ON_COMMAND(IDC_CHECK4, &CWaveConvert::OnCheckChannelMode) - ON_COMMAND(IDC_CHECK6, &CWaveConvert::OnCheckInstrMode) - ON_COMMAND(IDC_RADIO1, &CWaveConvert::UpdateDialog) - ON_COMMAND(IDC_RADIO2, &CWaveConvert::UpdateDialog) - ON_COMMAND(IDC_RADIO3, &CWaveConvert::UpdateDialog) - ON_COMMAND(IDC_RADIO4, &CWaveConvert::OnExportModeChanged) - ON_COMMAND(IDC_RADIO5, &CWaveConvert::OnExportModeChanged) - ON_COMMAND(IDC_PLAYEROPTIONS, &CWaveConvert::OnPlayerOptions) - ON_CBN_SELCHANGE(IDC_COMBO5, &CWaveConvert::OnFileTypeChanged) - ON_CBN_SELCHANGE(IDC_COMBO1, &CWaveConvert::OnSamplerateChanged) - ON_CBN_SELCHANGE(IDC_COMBO4, &CWaveConvert::OnChannelsChanged) - ON_CBN_SELCHANGE(IDC_COMBO6, &CWaveConvert::OnDitherChanged) - ON_CBN_SELCHANGE(IDC_COMBO2, &CWaveConvert::OnFormatChanged) - ON_CBN_SELCHANGE(IDC_COMBO9, &CWaveConvert::OnSampleSlotChanged) + ON_COMMAND(IDC_CHECK2, &CWaveConvert::OnCheckTimeLimit) + ON_COMMAND(IDC_CHECK4, &CWaveConvert::OnCheckChannelMode) + ON_COMMAND(IDC_CHECK6, &CWaveConvert::OnCheckInstrMode) + ON_COMMAND(IDC_RADIO1, &CWaveConvert::UpdateDialog) + ON_COMMAND(IDC_RADIO2, &CWaveConvert::UpdateDialog) + ON_COMMAND(IDC_RADIO3, &CWaveConvert::UpdateDialog) + ON_COMMAND(IDC_RADIO4, &CWaveConvert::OnExportModeChanged) + ON_COMMAND(IDC_RADIO5, &CWaveConvert::OnExportModeChanged) + ON_COMMAND(IDC_PLAYEROPTIONS, &CWaveConvert::OnPlayerOptions) + ON_CBN_SELCHANGE(IDC_COMBO5, &CWaveConvert::OnFileTypeChanged) + ON_CBN_SELCHANGE(IDC_COMBO1, &CWaveConvert::OnSamplerateChanged) + ON_CBN_SELCHANGE(IDC_COMBO4, &CWaveConvert::OnChannelsChanged) + ON_CBN_SELCHANGE(IDC_COMBO6, &CWaveConvert::OnDitherChanged) + ON_CBN_SELCHANGE(IDC_COMBO2, &CWaveConvert::OnFormatChanged) + ON_CBN_SELCHANGE(IDC_COMBO9, &CWaveConvert::OnSampleSlotChanged) + ON_EN_CHANGE(IDC_EDIT12, &CWaveConvert::OnSubsongChanged) END_MESSAGE_MAP() @@ -78,24 +80,23 @@ : DialogBase(IDD_WAVECONVERT, parent) , m_Settings(theApp.GetSettings(), encFactories) , m_SndFile(sndFile) + , m_subSongs{sndFile.GetAllSubSongs()} + , m_nNumOrders{numOrders} { - ASSERT(!encFactories.empty()); + MPT_ASSERT(!encFactories.empty()); encTraits = m_Settings.GetTraits(); - m_bGivePlugsIdleTime = false; if(minOrder != ORDERINDEX_INVALID && maxOrder != ORDERINDEX_INVALID) { // render selection m_Settings.minOrder = minOrder; m_Settings.maxOrder = maxOrder; } - m_Settings.repeatCount = 1; - m_Settings.minSequence = m_Settings.maxSequence = m_SndFile.Order.GetCurrentSequenceIndex(); - m_nNumOrders = numOrders; - - m_dwSongLimit = 0; } +CWaveConvert::~CWaveConvert() {} + + void CWaveConvert::DoDataExchange(CDataExchange *pDX) { DialogBase::DoDataExchange(pDX); @@ -107,8 +108,7 @@ DDX_Control(pDX, IDC_SPIN3, m_SpinMinOrder); DDX_Control(pDX, IDC_SPIN4, m_SpinMaxOrder); DDX_Control(pDX, IDC_SPIN5, m_SpinLoopCount); - DDX_Control(pDX, IDC_SPIN6, m_SpinMinSequence); - DDX_Control(pDX, IDC_SPIN7, m_SpinMaxSequence); + DDX_Control(pDX, IDC_SPIN6, m_SpinSubsongIndex); DDX_Control(pDX, IDC_COMBO9, m_CbnSampleSlot); DDX_Control(pDX, IDC_COMBO3, m_CbnGenre); @@ -131,8 +131,9 @@ CheckDlgButton(IDC_CHECK4, BST_UNCHECKED); CheckDlgButton(IDC_CHECK6, BST_UNCHECKED); + // Export limits const bool selection = (m_Settings.minOrder != ORDERINDEX_INVALID && m_Settings.maxOrder != ORDERINDEX_INVALID); - CheckRadioButton(IDC_RADIO1, IDC_RADIO3, selection ? IDC_RADIO2 : IDC_RADIO1); + CheckRadioButton(IDC_RADIO1, IDC_RADIO3, selection ? IDC_RADIO2 : IDC_RADIO3); if(selection) { SetDlgItemInt(IDC_EDIT3, m_Settings.minOrder); @@ -141,17 +142,18 @@ m_SpinMinOrder.SetRange32(0, m_nNumOrders); m_SpinMaxOrder.SetRange32(0, m_nNumOrders); - const SEQUENCEINDEX numSequences = m_SndFile.Order.GetNumSequences(); - const BOOL enableSeq = numSequences > 1 ? TRUE : FALSE; - GetDlgItem(IDC_RADIO3)->EnableWindow(enableSeq); - m_SpinMinSequence.SetRange32(1, numSequences); - m_SpinMaxSequence.SetRange32(1, numSequences); - SetDlgItemInt(IDC_EDIT12, m_Settings.minSequence + 1); - SetDlgItemInt(IDC_EDIT13, m_Settings.maxSequence + 1); - SetDlgItemInt(IDC_EDIT5, m_Settings.repeatCount, FALSE); m_SpinLoopCount.SetRange32(1, int16_max); + m_SpinSubsongIndex.SetRange32(1, static_cast<int>(m_subSongs.size())); + SetDlgItemInt(IDC_EDIT12, static_cast<UINT>(m_selectedSong + 1), FALSE); + if(m_subSongs.size() <= 1) + { + GetDlgItem(IDC_RADIO3)->SetWindowText(_T("&Entire Song")); + GetDlgItem(IDC_RADIO1)->EnableWindow(FALSE); + } + UpdateSubsongName(); + FillFileTypes(); FillSamplerates(); FillChannels(); @@ -181,6 +183,7 @@ { GetDlgItem(IDC_GIVEPLUGSIDLETIME)->EnableWindow(TRUE); GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(TRUE); + CheckDlgButton(IDC_RENDERSILENCE, BST_CHECKED); break; } } @@ -203,6 +206,7 @@ CheckRadioButton(IDC_RADIO4, IDC_RADIO5, m_Settings.outputToSample ? IDC_RADIO5 : IDC_RADIO4); UpdateDialog(); + return TRUE; } @@ -238,8 +242,8 @@ DWORD_PTR dwFormat = m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel()); Encoder::Mode mode = (Encoder::Mode)((dwFormat >> 24) & 0xff); - CheckDlgButton(IDC_CHECK3, encTraits->canCues?encSettings.Cues?TRUE:FALSE:FALSE); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), encTraits->canCues?TRUE:FALSE); + CheckDlgButton(IDC_CHECK3, (encTraits->canCues && encSettings.Cues) ? BST_CHECKED : BST_UNCHECKED); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), encTraits->canCues ? TRUE : FALSE); const BOOL canTags = encTraits->canTags ? TRUE : FALSE; CheckDlgButton(IDC_CHECK7, encSettings.Tags ? canTags : FALSE); @@ -565,6 +569,26 @@ } +void CWaveConvert::OnSubsongChanged() +{ + BOOL ok = FALSE; + const auto newSubSong = std::clamp(static_cast<size_t>(GetDlgItemInt(IDC_EDIT12, &ok, FALSE)), size_t(1), m_subSongs.size()) - 1; + if(m_selectedSong == newSubSong || !ok) + return; + m_selectedSong = newSubSong; + UpdateSubsongName(); +} + + +void CWaveConvert::UpdateSubsongName() +{ + const auto subsongText = GetDlgItem(IDC_SUBSONG); + if(subsongText == nullptr || m_selectedSong >= m_subSongs.size()) + return; + subsongText->SetWindowText(m_SndFile.GetpModDoc()->FormatSubsongName(m_subSongs[m_selectedSong]).c_str()); +} + + void CWaveConvert::UpdateDialog() { CheckDlgButton(IDC_CHECK2, (m_dwSongLimit) ? BST_CHECKED : 0); @@ -578,15 +602,8 @@ m_SpinMinOrder.EnableWindow(sel == IDC_RADIO2); m_SpinMaxOrder.EnableWindow(sel == IDC_RADIO2); - GetDlgItem(IDC_EDIT5)->EnableWindow(sel == IDC_RADIO1); - m_SpinLoopCount.EnableWindow(sel == IDC_RADIO1); - - const SEQUENCEINDEX numSequences = m_SndFile.Order.GetNumSequences(); - const BOOL enableSeq = (numSequences > 1 && sel == IDC_RADIO3) ? TRUE : FALSE; - GetDlgItem(IDC_EDIT12)->EnableWindow(enableSeq); - GetDlgItem(IDC_EDIT13)->EnableWindow(enableSeq); - m_SpinMinSequence.EnableWindow(enableSeq); - m_SpinMaxSequence.EnableWindow(enableSeq); + GetDlgItem(IDC_EDIT12)->EnableWindow(sel == IDC_RADIO1); + m_SpinSubsongIndex.EnableWindow(sel == IDC_RADIO1); // No free slots => Cannot do instrument- or channel-based export to sample BOOL canDoMultiExport = (IsDlgButtonChecked(IDC_RADIO4) != BST_UNCHECKED /* normal export */ || m_CbnSampleSlot.GetItemData(0) == 0 /* "free slot" is in list */) ? TRUE : FALSE; @@ -691,6 +708,7 @@ if(selection) { // Play selection + m_subSongs.clear(); m_Settings.minOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT3, NULL, FALSE)); m_Settings.maxOrder = static_cast<ORDERINDEX>(GetDlgItemInt(IDC_EDIT4, NULL, FALSE)); if(m_Settings.minOrder > m_Settings.maxOrder) @@ -699,16 +717,11 @@ { m_Settings.minOrder = m_Settings.maxOrder = ORDERINDEX_INVALID; } - if(IsDlgButtonChecked(IDC_RADIO3)) + if(IsDlgButtonChecked(IDC_RADIO1)) { - const UINT maxSequence = m_SndFile.Order.GetNumSequences(); - m_Settings.minSequence = static_cast<SEQUENCEINDEX>(std::clamp(GetDlgItemInt(IDC_EDIT12, NULL, FALSE), 1u, maxSequence) - 1u); - m_Settings.maxSequence = static_cast<SEQUENCEINDEX>(std::clamp(GetDlgItemInt(IDC_EDIT13, NULL, FALSE), 1u, maxSequence) - 1u); - if(m_Settings.minSequence > m_Settings.maxSequence) - std::swap(m_Settings.minSequence, m_Settings.maxSequence); - } else - { - m_Settings.minSequence = m_Settings.maxSequence = m_SndFile.Order.GetCurrentSequenceIndex(); + // Specific subsong + size_t subsong = std::clamp(static_cast<size_t>(GetDlgItemInt(IDC_EDIT12, nullptr, FALSE)), size_t(1), m_subSongs.size()) - 1; + m_subSongs = {m_subSongs[subsong]}; } m_Settings.repeatCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE)); @@ -883,12 +896,6 @@ , EncoderName(conf, U_("Export"), U_("Encoder"), U_("")) , EncoderIndex(FindEncoder(EncoderName)) , storedTags(conf) - , repeatCount(0) - , minOrder(ORDERINDEX_INVALID), maxOrder(ORDERINDEX_INVALID) - , sampleSlot(0) - , normalize(false) - , silencePlugBuffers(false) - , outputToSample(false) { Tags.encoder = Version::Current().GetOpenMPTVersionString(); for(const auto & factory : EncoderFactories) @@ -1063,38 +1070,31 @@ // Calculate maximum samples uint64 max = m_dwSongLimit ? ullMaxSamples : uint64_max; - // Reset song position tracking - m_SndFile.ResetPlayPos(); m_SndFile.m_PlayState.m_flags.reset(SONG_PATTERNLOOP); ORDERINDEX startOrder = 0; - GetLengthTarget target; + double duration = m_subSong.duration; if(m_Settings.minOrder != ORDERINDEX_INVALID && m_Settings.maxOrder != ORDERINDEX_INVALID) { - m_SndFile.SetRepeatCount(0); startOrder = m_Settings.minOrder; ORDERINDEX endOrder = m_Settings.maxOrder; while(!m_SndFile.Order().IsValidPat(endOrder) && endOrder > startOrder) { endOrder--; } + GetLengthTarget target; if(m_SndFile.Order().IsValidPat(endOrder)) { target = GetLengthTarget(endOrder, m_SndFile.Patterns[m_SndFile.Order()[endOrder]].GetNumRows() - 1); } target.StartPos(m_SndFile.Order.GetCurrentSequenceIndex(), startOrder, 0); - m_SndFile.m_nMaxOrderPosition = endOrder + 1; - } else - { - m_SndFile.SetRepeatCount(std::max(0, m_Settings.repeatCount - 1)); + m_SndFile.m_restartOverridePos = m_Settings.minOrder; + m_SndFile.m_maxOrderPosition = endOrder + 1; + duration = m_SndFile.GetLength(eNoAdjust, target).front().duration; } - uint64 l = mpt::saturate_round<uint64>(m_SndFile.GetLength(eNoAdjust, target).front().duration * samplerate * (1 + m_SndFile.GetRepeatCount())); - - m_SndFile.SetCurrentOrder(startOrder); - m_SndFile.GetLength(eAdjust, GetLengthTarget(startOrder, 0)); // adjust playback variables / visited rows vector - m_SndFile.m_PlayState.m_nCurrentOrder = startOrder; - - if (l < max) max = l; + m_SndFile.SetRepeatCount(std::max(0, m_Settings.repeatCount - 1)); + uint64 l = mpt::saturate_round<uint64>(duration * samplerate * (1 + m_SndFile.GetRepeatCount())); + LimitMax(max, l); SetRange(0, max); EnableTaskbarProgress(); @@ -1105,17 +1105,20 @@ // Process the conversion - // For calculating the remaining time - auto dwStartTime = timeGetTime(), prevTime = dwStartTime; - uint32 timeRemaining = 0; - - uint64 bytesWritten = 0; - auto mainFrame = CMainFrame::GetMainFrame(); mainFrame->PauseMod(); - m_SndFile.m_PlayState.m_flags.reset(SONG_STEP | SONG_PATTERNLOOP); + + // Reset song position tracking + m_SndFile.ResetPlayPos(); + m_SndFile.GetLength(eAdjust, GetLengthTarget(m_subSong.startOrder, m_subSong.startRow).StartPos(m_subSong.sequence, 0, 0)); + m_SndFile.m_PlayState.m_flags.reset(); + mainFrame->InitRenderer(&m_SndFile); + // For calculating the remaining time + auto dwStartTime = timeGetTime(), prevTime = dwStartTime; + uint32 timeRemaining = 0; + uint64 bytesWritten = 0; while(true) { UINT lRead = 0; @@ -1262,7 +1265,7 @@ } } - m_SndFile.m_nMaxOrderPosition = 0; + m_SndFile.m_restartOverridePos = m_SndFile.m_maxOrderPosition = 0; mainFrame->StopRenderer(&m_SndFile); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Sun Oct 27 00:19:04 2024 (r21995) @@ -1759,23 +1759,33 @@ int oldRepeat = m_SndFile.GetRepeatCount(); const SEQUENCEINDEX currentSeq = m_SndFile.Order.GetCurrentSequenceIndex(); - for(SEQUENCEINDEX seq = wsdlg.m_Settings.minSequence; seq <= wsdlg.m_Settings.maxSequence; seq++) + if(wsdlg.m_subSongs.empty()) { - m_SndFile.Order.SetSequence(seq); + // Render selection + SubSong subsong{}; + subsong.sequence = currentSeq; + subsong.startOrder = wsdlg.m_Settings.minOrder; + wsdlg.m_subSongs.push_back(subsong); + } + for(size_t subsong = 0; subsong < wsdlg.m_subSongs.size(); subsong++) + { + const auto &song = wsdlg.m_subSongs[subsong]; mpt::ustring fileNameAdd; for(int i = 0; i < nRenderPasses; i++) { mpt::PathString thisName = fileName; CString caption = _T("file"); fileNameAdd.clear(); - if(wsdlg.m_Settings.minSequence != wsdlg.m_Settings.maxSequence) + if(wsdlg.m_subSongs.size() > 1) { - fileNameAdd = MPT_UFORMAT("-{}")(mpt::ufmt::dec0<2>(seq + 1)); - mpt::ustring seqName = m_SndFile.Order(seq).GetName(); + fileNameAdd = MPT_UFORMAT("-{}")(mpt::ufmt::dec0<2>(subsong + 1)); + mpt::ustring seqName = m_SndFile.Order(song.sequence).GetName(); if(!seqName.empty()) - { fileNameAdd += UL_("-") + seqName; - } + const auto startPattern = m_SndFile.Order(song.sequence).PatternAt(song.startOrder); + const auto orderName = startPattern ? startPattern->GetName() : std::string{}; + if(!orderName.empty()) + fileNameAdd += UL_("-") + mpt::ToUnicode(m_SndFile.GetCharsetInternal(), orderName); } // Channel mode @@ -1878,7 +1888,7 @@ } else { BypassInputHandler bih; - CDoWaveConvert dwcdlg(m_SndFile, f, caption, wsdlg.m_Settings, pMainFrm); + CDoWaveConvert dwcdlg(m_SndFile, f, caption, wsdlg.m_Settings, song, pMainFrm); dwcdlg.m_bGivePlugsIdleTime = wsdlg.m_bGivePlugsIdleTime; dwcdlg.m_dwSongLimit = wsdlg.m_dwSongLimit; cancel = dwcdlg.DoModal() != IDOK; Modified: trunk/OpenMPT/mptrack/mod2wave.h ============================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/mptrack/mod2wave.h Sun Oct 27 00:19:04 2024 (r21995) @@ -23,6 +23,7 @@ OPENMPT_NAMESPACE_BEGIN class CSoundFile; +struct SubSong; struct CWaveConvertSettings { @@ -35,14 +36,13 @@ StoredTags storedTags; FileTags Tags; - int repeatCount; - ORDERINDEX minOrder, maxOrder; - SAMPLEINDEX sampleSlot; - SEQUENCEINDEX minSequence, maxSequence; - - bool normalize : 1; - bool silencePlugBuffers : 1; - bool outputToSample : 1; + int repeatCount = 1; + ORDERINDEX minOrder = ORDERINDEX_INVALID, maxOrder = ORDERINDEX_INVALID; + SAMPLEINDEX sampleSlot = 0; + + bool normalize = false; + bool silencePlugBuffers = false; + bool outputToSample = false; std::size_t FindEncoder(const mpt::ustring &name) const; void SelectEncoder(std::size_t index); @@ -58,21 +58,29 @@ { public: CWaveConvertSettings m_Settings; - const Encoder::Traits *encTraits; CSoundFile &m_SndFile; - uint64 m_dwSongLimit; - ORDERINDEX m_nNumOrders; + uint64 m_dwSongLimit = 0; + std::vector<SubSong> m_subSongs; - CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnDither, m_CbnSampleFormat, m_CbnSampleSlot; - CSpinButtonCtrl m_SpinLoopCount, m_SpinMinOrder, m_SpinMaxOrder, m_SpinMinSequence, m_SpinMaxSequence; + bool m_bGivePlugsIdleTime = false; + bool m_bChannelMode = false; // Render by channel + bool m_bInstrumentMode = false; // Render by instrument + +private: + const Encoder::Traits *encTraits = nullptr; - bool m_bGivePlugsIdleTime; - bool m_bChannelMode; // Render by channel - bool m_bInstrumentMode; // Render by instrument + CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnDither, m_CbnSampleFormat, m_CbnSampleSlot; + CSpinButtonCtrl m_SpinLoopCount, m_SpinMinOrder, m_SpinMaxOrder, m_SpinSubsongIndex; CEdit m_EditTitle, m_EditAuthor, m_EditURL, m_EditAlbum, m_EditYear; CComboBox m_CbnGenre; CEdit m_EditGenre; + size_t m_selectedSong = 0; + const ORDERINDEX m_nNumOrders; + +public: + CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile &sndFile, const std::vector<EncoderFactoryBase *> &encFactories); + ~CWaveConvert(); private: void FillFileTypes(); @@ -87,14 +95,13 @@ void SaveEncoderSettings(); void SaveTags(); -public: - CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile &sndFile, const std::vector<EncoderFactoryBase*> &encFactories); - -public: + void UpdateSubsongName(); void UpdateDialog(); + BOOL OnInitDialog() override; void DoDataExchange(CDataExchange *pDX) override; void OnOK() override; + afx_msg void OnCheckTimeLimit(); afx_msg void OnCheckChannelMode(); afx_msg void OnCheckInstrMode(); @@ -103,9 +110,11 @@ afx_msg void OnChannelsChanged(); afx_msg void OnDitherChanged(); afx_msg void OnFormatChanged(); + afx_msg void OnSubsongChanged(); afx_msg void OnPlayerOptions(); afx_msg void OnExportModeChanged(); afx_msg void OnSampleSlotChanged(); + DECLARE_MESSAGE_MAP() }; @@ -113,23 +122,27 @@ class CDoWaveConvert: public CProgressDialog { public: - const CWaveConvertSettings &m_Settings; - CSoundFile &m_SndFile; - std::ostream &fileStream; - const CString &caption; - uint64 m_dwSongLimit; - bool m_bGivePlugsIdleTime; + uint64 m_dwSongLimit = 0; + bool m_bGivePlugsIdleTime = false; public: - CDoWaveConvert(CSoundFile &sndFile, std::ostream &f, const CString &caption, const CWaveConvertSettings &settings, CWnd *parent = NULL) + CDoWaveConvert(CSoundFile &sndFile, std::ostream &f, const CString &caption, const CWaveConvertSettings &settings, const SubSong &subSong, CWnd *parent = nullptr) : CProgressDialog(parent) , m_Settings(settings) , m_SndFile(sndFile) , fileStream(f) , caption(caption) - , m_dwSongLimit(0) + , m_subSong(subSong) { } + void Run() override; + +private: + const CWaveConvertSettings &m_Settings; + CSoundFile &m_SndFile; + std::ostream &fileStream; + const CString &caption; + const SubSong &m_subSong; }; Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/mptrack/mptrack.rc Sun Oct 27 00:19:04 2024 (r21995) @@ -1164,13 +1164,13 @@ LTEXT "50ms",IDC_STATIC,211,257,23,8 END -IDD_WAVECONVERT DIALOGEX 0, 0, 388, 239 +IDD_WAVECONVERT DIALOGEX 0, 0, 389, 290 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Export" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,270,216,50,14 - PUSHBUTTON "Cancel",IDCANCEL,330,216,50,14 + DEFPUSHBUTTON "&OK",IDOK,270,270,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,330,270,50,14 GROUPBOX "For&mat",IDC_STATIC,6,6,186,66 COMBOBOX IDC_COMBO5,12,18,174,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO1,12,36,54,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -1178,8 +1178,8 @@ COMBOBOX IDC_COMBO6,120,36,66,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO2,12,54,174,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP GROUPBOX "Render",IDC_STATIC,6,78,186,84 - PUSHBUTTON "Player &Options",IDC_PLAYEROPTIONS,12,90,60,14,BS_CENTER - CONTROL "&Channel mode (one file per channel)",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,108,174,12 + PUSHBUTTON "Pla&yer Options",IDC_PLAYEROPTIONS,12,90,60,14,BS_CENTER + CONTROL "C&hannel mode (one file per channel)",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,108,174,12 CONTROL "&Instrument mode (one file per instrument)",IDC_CHECK6, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,120,174,12 CONTROL "&Normalize Output",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,132,174,12 @@ -1190,44 +1190,43 @@ "Button",BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE | WS_TABSTOP,12,180,174,12 CONTROL "Clear plugin &buffers before exporting",IDC_RENDERSILENCE, "Button",BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE | WS_TABSTOP,12,192,174,12 - GROUPBOX "Limit",IDC_STATIC,198,6,186,84 + GROUPBOX "Limit",IDC_STATIC,198,6,186,126 CONTROL "Limit song &length to: (seconds)",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,18,114,10 EDITTEXT IDC_EDIT2,324,18,50,12,ES_AUTOHSCROLL - CONTROL "&Sequences",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,204,36,72,12 - CONTROL "Play &entire song",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,204,54,72,12 - CONTROL "From &position",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,204,73,72,12 - EDITTEXT IDC_EDIT12,276,36,36,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN6,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,300,41,11,11 - CTEXT "to",IDC_STATIC,318,36,8,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT13,330,36,36,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN7,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,354,41,11,11 - EDITTEXT IDC_EDIT5,276,54,36,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,300,60,11,11 - LTEXT "times",IDC_STATIC,319,55,59,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT3,276,73,36,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,300,78,11,11 - CTEXT "to",IDC_STATIC,318,73,8,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT4,330,73,36,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,354,78,11,11 - GROUPBOX "Tags",IDC_STATIC,198,96,186,114 - CONTROL "Incl&ude Song Information",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,108,174,10 - LTEXT "Title:",IDC_STATIC,204,122,17,8 - EDITTEXT IDC_EDIT11,240,120,138,12,ES_AUTOHSCROLL - LTEXT "Author:",IDC_STATIC,204,140,30,8 - EDITTEXT IDC_EDIT6,240,138,138,12,ES_AUTOHSCROLL - LTEXT "Album:",IDC_STATIC,204,158,30,8 - EDITTEXT IDC_EDIT7,240,156,138,12,ES_AUTOHSCROLL - LTEXT "URL:",IDC_STATIC,204,176,30,8 - EDITTEXT IDC_EDIT8,240,174,138,12,ES_AUTOHSCROLL - LTEXT "Genre:",IDC_STATIC,204,194,29,8 - EDITTEXT IDC_EDIT10,240,192,78,12,ES_AUTOHSCROLL - RTEXT "Year:",IDC_STATIC,324,194,18,8 - EDITTEXT IDC_EDIT9,348,192,30,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Export To:",IDC_STATIC,6,219,48,8 - CONTROL "&File",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,54,219,38,8 - CONTROL "S&le Slot",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,96,219,56,8 - COMBOBOX IDC_COMBO9,156,217,96,119,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_COMBO3,240,192,78,64,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Repea&t",IDC_STATIC,204,34,36,12,SS_CENTERIMAGE + EDITTEXT IDC_EDIT5,240,34,36,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,264,40,11,11 + LTEXT "times",IDC_STATIC,282,34,59,12,SS_CENTERIMAGE + CONTROL "All Sub Songs (S&eparate Files)",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,204,54,138,12 + CONTROL "&Sub Song:",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,204,72,72,12 + CONTROL "From &position",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,204,114,72,12 + EDITTEXT IDC_EDIT12,276,72,36,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN6,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,306,72,11,11 + CONTROL "",IDC_SUBSONG,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX | WS_GROUP,215,90,163,18 + EDITTEXT IDC_EDIT3,276,114,36,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,300,119,11,11 + CTEXT "to",IDC_STATIC,318,114,8,12,SS_CENTERIMAGE + EDITTEXT IDC_EDIT4,330,114,36,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,354,119,11,11 + GROUPBOX "Tags",IDC_STATIC,198,138,186,126 + CONTROL "Incl&ude Song Information",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,156,174,10 + LTEXT "Title:",IDC_STATIC,204,174,17,8 + EDITTEXT IDC_EDIT11,240,170,138,12,ES_AUTOHSCROLL + LTEXT "Author:",IDC_STATIC,204,190,30,8 + EDITTEXT IDC_EDIT6,240,190,138,12,ES_AUTOHSCROLL + LTEXT "Album:",IDC_STATIC,204,209,30,8 + EDITTEXT IDC_EDIT7,240,206,138,12,ES_AUTOHSCROLL + LTEXT "URL:",IDC_STATIC,204,226,30,8 + EDITTEXT IDC_EDIT8,240,225,138,12,ES_AUTOHSCROLL + LTEXT "Genre:",IDC_STATIC,204,244,29,8 + EDITTEXT IDC_EDIT10,240,242,78,12,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO3,240,242,78,64,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + RTEXT "Year:",IDC_STATIC,324,244,18,8 + EDITTEXT IDC_EDIT9,348,242,30,12,ES_AUTOHSCROLL | ES_NUMBER + GROUPBOX "Export To",IDC_STATIC,6,216,186,48 + CONTROL "&File",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,228,38,8 + CONTROL "Sampl&e Slot",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,246,56,8 + COMBOBOX IDC_COMBO9,72,243,114,119,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_PROGRESS DIALOGEX 0, 0, 220, 55 @@ -2329,8 +2328,8 @@ IDD_WAVECONVERT, DIALOG BEGIN - RIGHTMARGIN, 337 - BOTTOMMARGIN, 236 + RIGHTMARGIN, 338 + BOTTOMMARGIN, 287 END IDD_PROGRESS, DIALOG Modified: trunk/OpenMPT/soundlib/Sndfile.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/soundlib/Sndfile.cpp Sun Oct 27 00:19:04 2024 (r21995) @@ -695,7 +695,7 @@ if(UseFinetuneAndTranspose()) m_playBehaviour.reset(kPeriodsAreHertz); - m_nMaxOrderPosition = 0; + m_restartOverridePos = m_maxOrderPosition = 0; RecalculateSamplesPerTick(); Modified: trunk/OpenMPT/soundlib/Sndfile.h ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/soundlib/Sndfile.h Sun Oct 27 00:19:04 2024 (r21995) @@ -527,7 +527,7 @@ ResamplingMode m_nResampling; // Resampling mode (if overriding the globally set resampling) int32 m_nRepeatCount = 0; // -1 means repeat infinitely. - ORDERINDEX m_nMaxOrderPosition; + ORDERINDEX m_restartOverridePos = 0, m_maxOrderPosition = 0; std::vector<ModChannelSettings> ChnSettings; // Initial channels settings CPatternContainer Patterns; ModSequenceSet Order; // Pattern sequences (order lists) Modified: trunk/OpenMPT/soundlib/Sndmix.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp Sat Oct 26 22:21:46 2024 (r21994) +++ trunk/OpenMPT/soundlib/Sndmix.cpp Sun Oct 27 00:19:04 2024 (r21995) @@ -252,12 +252,6 @@ } else { // No new pattern data - #ifdef MODPLUG_TRACKER - if((m_nMaxOrderPosition) && (m_PlayState.m_nCurrentOrder >= m_nMaxOrderPosition)) - { - m_PlayState.m_flags.set(SONG_ENDREACHED); - } - #endif // MODPLUG_TRACKER if(IsRenderingToDisc()) { // Disable song fade when rendering or when requested in libopenmpt. @@ -462,15 +456,18 @@ // Check if pattern is valid if(!m_PlayState.m_flags[SONG_PATTERNLOOP]) { - m_PlayState.m_nPattern = (m_PlayState.m_nCurrentOrder < Order().size()) ? Order()[m_PlayState.m_nCurrentOrder] : PATTERNINDEX_INVALID; - if (m_PlayState.m_nPattern < Patterns.Size() && !Patterns[m_PlayState.m_nPattern].IsValid()) m_PlayState.m_nPattern = PATTERNINDEX_SKIP; - while (m_PlayState.m_nPattern >= Patterns.Size()) + const size_t songEnd = m_maxOrderPosition ? m_maxOrderPosition : Order().size(); + m_PlayState.m_nPattern = (m_PlayState.m_nCurrentOrder < songEnd) ? Order()[m_PlayState.m_nCurrentOrder] : PATTERNINDEX_INVALID; + if(m_PlayState.m_nPattern < Patterns.Size() && !Patterns[m_PlayState.m_nPattern].IsValid()) + m_PlayState.m_nPattern = PATTERNINDEX_SKIP; + + while(m_PlayState.m_nPattern >= Patterns.Size()) { // End of song? - if ((m_PlayState.m_nPattern == PATTERNINDEX_INVALID) || (m_PlayState.m_nCurrentOrder >= Order().size())) + if ((m_PlayState.m_nPattern == PATTERNINDEX_INVALID) || (m_PlayState.m_nCurrentOrder >= songEnd)) { - ORDERINDEX restartPosOverride = Order().GetRestartPos(); - if(restartPosOverride == 0 && m_PlayState.m_nCurrentOrder <= Order().size() && m_PlayState.m_nCurrentOrder > 0) + ORDERINDEX restartPosOverride = m_maxOrderPosition ? m_restartOverridePos : Order().GetRestartPos(); + if(restartPosOverride == 0 && m_PlayState.m_nCurrentOrder <= songEnd && m_PlayState.m_nCurrentOrder > 0) { // Subtune detection. Subtunes are separated by "---" order items, so if we're in a // subtune and there's no restart position, we go to the first order of the subtune @@ -564,10 +561,6 @@ m_PlayState.m_nPattern = PATTERNINDEX_SKIP; } m_PlayState.m_nNextOrder = m_PlayState.m_nCurrentOrder; - -#ifdef MODPLUG_TRACKER - if ((m_nMaxOrderPosition) && (m_PlayState.m_nCurrentOrder >= m_nMaxOrderPosition)) return false; -#endif // MODPLUG_TRACKER } // Weird stuff? |
From: <sv...@op...> - 2024-10-26 20:21:54
|
Author: sagamusix Date: Sat Oct 26 22:21:46 2024 New Revision: 21994 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21994 Log: [Imp] MIDI Export: Allow sub-songs to be exported to individual files (https://bugs.openmpt.org/view.php?id=1515). Modified: trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/OPLExport.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/mod2midi.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Sat Oct 26 22:21:46 2024 (r21994) @@ -2001,41 +2001,9 @@ void CModDoc::OnFileMidiConvert() { #ifndef NO_PLUGINS - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - - if ((!pMainFrm) || (!m_SndFile.GetType())) return; - - mpt::PathString filename = GetPathNameMpt().ReplaceExtension(P_(".mid")); - - FileDialog dlg = SaveFileDialog() - .DefaultExtension(U_("mid")) - .DefaultFilename(filename) - .ExtensionFilter(U_("MIDI Files (*.mid)|*.mid||")); - if(!dlg.Show()) return; - - CModToMidi mididlg(m_SndFile, pMainFrm); + CModToMidi mididlg(*this, CMainFrame::GetMainFrame()); BypassInputHandler bih; - if(mididlg.DoModal() == IDOK) - { - try - { - mpt::IO::SafeOutputFile sf(dlg.GetFirstFile(), std::ios::binary, mpt::IO::FlushModeFromBool(TrackerSettings::Instance().MiscFlushFileBuffersOnSave)); - mpt::IO::ofstream &f = sf; - f.exceptions(f.exceptions() | std::ios::badbit | std::ios::failbit); - - if(!f.good()) - { - Reporting::Error("Could not open file for writing. Is it open in another application?"); - return; - } - - CDoMidiConvert doconv(m_SndFile, f, mididlg.m_instrMap); - doconv.DoModal(); - } catch(const std::exception &) - { - Reporting::Error(_T("Error while writing file!")); - } - } + mididlg.DoModal(); #else Reporting::Error("In order to use MIDI export, OpenMPT must be built with plugin support."); #endif // NO_PLUGINS @@ -3076,6 +3044,20 @@ } +mpt::tstring CModDoc::FormatSubsongName(const SubSong &song) +{ + const auto sequenceName = m_SndFile.Order(song.sequence).GetName(); + const auto startPattern = m_SndFile.Order(song.sequence).PatternAt(song.startOrder); + const auto orderName = startPattern ? startPattern->GetName() : std::string{}; + return MPT_TFORMAT("Sequence {}{}\nOrder {} to {}{}")( + song.sequence + 1, + sequenceName.empty() ? mpt::tstring{} : MPT_TFORMAT(" ({})")(sequenceName), + song.startOrder, + song.endOrder, + orderName.empty() ? mpt::tstring{} : MPT_TFORMAT(" ({})")(mpt::ToWin(m_SndFile.GetCharsetInternal(), orderName))); +} + + void CModDoc::SafeFileClose() { // Verify that the main window has the focus. This saves us a lot of trouble because active modal dialogs cannot know if their pSndFile pointers are still valid. Modified: trunk/OpenMPT/mptrack/Moddoc.h ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/Moddoc.h Sat Oct 26 22:21:46 2024 (r21994) @@ -336,6 +336,8 @@ // [in] bIncludeIndex: True to include instrument index in front of the instrument name, false otherwise. CString GetPatternViewInstrumentName(INSTRUMENTINDEX nInstr, bool bEmptyInsteadOfNoName = false, bool bIncludeIndex = true) const; + mpt::tstring FormatSubsongName(const SubSong &song); + // Check if a given channel contains data. bool IsChannelUnused(CHANNELINDEX nChn) const; // Check whether a sample is used. Modified: trunk/OpenMPT/mptrack/OPLExport.cpp ============================================================================== --- trunk/OpenMPT/mptrack/OPLExport.cpp Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/OPLExport.cpp Sat Oct 26 22:21:46 2024 (r21994) @@ -454,17 +454,7 @@ const auto subsongText = GetDlgItem(IDC_SUBSONG); if(subsongText == nullptr || m_selectedSong >= m_subSongs.size()) return; - const auto &song = m_subSongs[m_selectedSong]; - const auto sequenceName = m_sndFile.Order(song.sequence).GetName(); - const auto startPattern = m_sndFile.Order(song.sequence).PatternAt(song.startOrder); - const auto orderName = startPattern ? startPattern->GetName() : std::string{}; - subsongText->SetWindowText(MPT_TFORMAT("Sequence {}{}\nOrder {} to {}{}")( - song.sequence + 1, - sequenceName.empty() ? mpt::tstring{} : MPT_TFORMAT(" ({})")(sequenceName), - song.startOrder, - song.endOrder, - orderName.empty() ? mpt::tstring{} : MPT_TFORMAT(" ({})")(mpt::ToWin(m_sndFile.GetCharsetInternal(), orderName))) - .c_str()); + subsongText->SetWindowText(m_modDoc.FormatSubsongName(m_subSongs[m_selectedSong]).c_str()); } void DoConversion(const mpt::PathString &fileName) @@ -512,11 +502,14 @@ const auto songIndexFmt = mpt::format_simple_spec<mpt::ustring>{}.Dec().FillNul().Width(1 + static_cast<int>(std::log10(m_subSongs.size()))); - size_t totalSamples = 0; + uint64 totalSamples = 0; for(size_t i = 0; i < m_subSongs.size() && !m_abort; i++) { const auto &song = m_subSongs[i]; + m_selectedSong = i; + UpdateSubsongName(); + m_sndFile.ResetPlayPos(); m_sndFile.GetLength(eAdjust, GetLengthTarget(song.startOrder, song.startRow).StartPos(song.sequence, 0, 0)); m_sndFile.m_PlayState.m_flags.reset(); Modified: trunk/OpenMPT/mptrack/mod2midi.cpp ============================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/mod2midi.cpp Sat Oct 26 22:21:46 2024 (r21994) @@ -10,17 +10,21 @@ #include "stdafx.h" #include "mod2midi.h" +#include "FileDialog.h" +#include "InputHandler.h" #include "Mainfrm.h" #include "Moddoc.h" #include "Mptrack.h" #include "Reporting.h" #include "resource.h" +#include "TrackerSettings.h" #include "../common/mptFileIO.h" #include "../common/mptStringBuffer.h" #include "../soundlib/plugins/PlugInterface.h" #include "../soundlib/plugins/PluginManager.h" #include "mpt/io/io.hpp" #include "mpt/io/io_stdstream.hpp" +#include "mpt/io_file/outputfile.hpp" #include <sstream> @@ -61,7 +65,7 @@ ModInstrument m_instr; const ModInstrument *const m_oldInstr; const CSoundFile &m_sndFile; - const GetLengthType &m_songLength; + const SubSong &m_subsongInfo; MidiTrack *const m_tempoTrack; // Pointer to tempo track, nullptr if this is the tempo track decltype(m_MidiCh) *m_lastMidiCh = nullptr; std::shared_ptr<MidiChannelState> m_channelState; @@ -119,11 +123,11 @@ operator ModInstrument& () { return m_instr; } - MidiTrack(VSTPluginLib &factory, CSoundFile &sndFile, const GetLengthType &songLength, SNDMIXPLUGIN &mixStruct, MidiTrack *tempoTrack, const mpt::ustring &name, const ModInstrument *oldInstr, bool overlappingInstruments) + MidiTrack(VSTPluginLib &factory, CSoundFile &sndFile, const SubSong &subsongInfo, SNDMIXPLUGIN &mixStruct, MidiTrack *tempoTrack, const mpt::ustring &name, const ModInstrument *oldInstr, bool overlappingInstruments) : IMidiPlugin(factory, sndFile, mixStruct) , m_oldInstr(oldInstr) , m_sndFile(sndFile) - , m_songLength(songLength) + , m_subsongInfo(subsongInfo) , m_tempoTrack(tempoTrack) , m_sampleRate(sndFile.GetSampleRate()) , m_overlappingInstruments(overlappingInstruments) @@ -208,7 +212,7 @@ mpt::IO::WriteRaw(f, msg, 9); } - if(!m_tempoTrack && !m_wroteLoopStart && m_sndFile.m_PlayState.m_nRow == m_songLength.restartRow && m_sndFile.m_PlayState.m_nCurrentOrder == m_songLength.restartOrder) + if(!m_tempoTrack && !m_wroteLoopStart && m_sndFile.m_PlayState.m_nRow == m_subsongInfo.loopStartRow && m_sndFile.m_PlayState.m_nCurrentOrder == m_subsongInfo.loopStartOrder) { WriteString(kCue, U_("loopStart")); m_wroteLoopStart = true; @@ -434,16 +438,16 @@ VSTPluginLib m_plugFactory; CSoundFile &m_sndFile; std::ostream &m_file; - const GetLengthType m_songLength; + const SubSong &m_subsongInfo; const bool m_wasInstrumentMode; public: - Conversion(CSoundFile &sndFile, const InstrMap &instrMap, std::ostream &file, bool overlappingInstruments, const GetLengthType &songLength) + Conversion(CSoundFile &sndFile, const InstrMap &instrMap, std::ostream &file, bool overlappingInstruments, const SubSong &subsongInfo) : m_oldInstruments(sndFile.GetNumInstruments()) , m_plugFactory(nullptr, true, {}, {}) , m_sndFile(sndFile) , m_file(file) - , m_songLength(songLength) + , m_subsongInfo(subsongInfo) , m_wasInstrumentMode(sndFile.GetNumInstruments() > 0) { m_oldPlugins.assign(std::begin(m_sndFile.m_MixPlugins), std::end(m_sndFile.m_MixPlugins)); @@ -458,7 +462,7 @@ } m_tracks.reserve(m_sndFile.GetNumInstruments() + 1); - MidiTrack &tempoTrack = *(new MidiTrack(m_plugFactory, m_sndFile, m_songLength, tempoTrackPlugin, nullptr, mpt::ToUnicode(m_sndFile.GetCharsetInternal(), m_sndFile.m_songName), nullptr, overlappingInstruments)); + MidiTrack &tempoTrack = *(new MidiTrack(m_plugFactory, m_sndFile, m_subsongInfo, tempoTrackPlugin, nullptr, mpt::ToUnicode(m_sndFile.GetCharsetInternal(), m_sndFile.m_songName), nullptr, overlappingInstruments)); tempoTrackPlugin.pMixPlugin = &tempoTrack; tempoTrack.WriteString(kText, mpt::ToUnicode(m_sndFile.GetCharsetInternal(), m_sndFile.m_songMessage.GetString())); tempoTrack.WriteString(kCopyright, m_sndFile.m_songArtist); @@ -475,7 +479,7 @@ SNDMIXPLUGIN &mixPlugin = m_sndFile.m_MixPlugins[nextPlug++]; ModInstrument *oldInstr = m_wasInstrumentMode ? m_oldInstruments[i - 1] : nullptr; - MidiTrack &midiInstr = *(new MidiTrack(m_plugFactory, m_sndFile, m_songLength, mixPlugin, &tempoTrack, m_wasInstrumentMode ? mpt::ToUnicode(m_sndFile.GetCharsetInternal(), oldInstr->name) : mpt::ToUnicode(m_sndFile.GetCharsetInternal(), m_sndFile.GetSampleName(i)), oldInstr, overlappingInstruments)); + MidiTrack &midiInstr = *(new MidiTrack(m_plugFactory, m_sndFile, m_subsongInfo, mixPlugin, &tempoTrack, m_wasInstrumentMode ? mpt::ToUnicode(m_sndFile.GetCharsetInternal(), oldInstr->name) : mpt::ToUnicode(m_sndFile.GetCharsetInternal(), m_sndFile.GetSampleName(i)), oldInstr, overlappingInstruments)); ModInstrument &instr = midiInstr; mixPlugin.pMixPlugin = &midiInstr; @@ -581,10 +585,11 @@ bool CModToMidi::s_overlappingInstruments = false; BEGIN_MESSAGE_MAP(CModToMidi, DialogBase) - ON_CBN_SELCHANGE(IDC_COMBO1, &CModToMidi::UpdateDialog) - ON_CBN_SELCHANGE(IDC_COMBO2, &CModToMidi::OnChannelChanged) - ON_CBN_SELCHANGE(IDC_COMBO3, &CModToMidi::OnProgramChanged) - ON_COMMAND(IDC_CHECK1, &CModToMidi::OnOverlapChanged) + ON_CBN_SELCHANGE(IDC_COMBO1, &CModToMidi::UpdateDialog) + ON_CBN_SELCHANGE(IDC_COMBO2, &CModToMidi::OnChannelChanged) + ON_CBN_SELCHANGE(IDC_COMBO3, &CModToMidi::OnProgramChanged) + ON_COMMAND(IDC_CHECK1, &CModToMidi::OnOverlapChanged) + ON_EN_CHANGE(IDC_EDIT1, &CModToMidi::OnSubsongChanged) ON_WM_VSCROLL() END_MESSAGE_MAP() @@ -599,14 +604,15 @@ } -CModToMidi::CModToMidi(CSoundFile &sndFile, CWnd *pWndParent) - : DialogBase(IDD_MOD2MIDI, pWndParent) - , m_sndFile(sndFile) - , m_instrMap((sndFile.GetNumInstruments() ? sndFile.GetNumInstruments() : sndFile.GetNumSamples()) + 1) +CModToMidi::CModToMidi(CModDoc &modDoc, CWnd *parent) + : CProgressDialog{parent, IDD_MOD2MIDI} + , m_modDoc{modDoc} + , m_instrMap((modDoc.GetNumInstruments() ? modDoc.GetNumInstruments() : modDoc.GetNumSamples()) + 1) + , m_subSongs{modDoc.GetSoundFile().GetAllSubSongs()} { - for (INSTRUMENTINDEX i = 1; i <= m_sndFile.GetNumInstruments(); i++) + for (INSTRUMENTINDEX i = 1; i <= modDoc.GetNumInstruments(); i++) { - ModInstrument *pIns = m_sndFile.Instruments[i]; + ModInstrument *pIns = modDoc.GetSoundFile().Instruments[i]; if(pIns != nullptr) { m_instrMap[i].channel = pIns->nMidiChannel; @@ -621,6 +627,9 @@ } +CModToMidi::~CModToMidi() {} + + BOOL CModToMidi::OnInitDialog() { CString s; @@ -632,25 +641,26 @@ m_SpinInstrument.SetPos(0); m_currentInstr = 1; m_CbnInstrument.SetRedraw(FALSE); - if(m_sndFile.GetNumInstruments()) + const CSoundFile &sndFile = m_modDoc.GetSoundFile(); + if(m_modDoc.GetNumInstruments()) { - for(INSTRUMENTINDEX nIns = 1; nIns <= m_sndFile.GetNumInstruments(); nIns++) + for(INSTRUMENTINDEX nIns = 1; nIns <= sndFile.GetNumInstruments(); nIns++) { - ModInstrument *pIns = m_sndFile.Instruments[nIns]; - if(pIns && m_sndFile.GetpModDoc()->IsInstrumentUsed(nIns, false)) + ModInstrument *pIns = sndFile.Instruments[nIns]; + if(pIns && m_modDoc.IsInstrumentUsed(nIns, false)) { - const CString name = m_sndFile.GetpModDoc()->GetPatternViewInstrumentName(nIns); + const CString name = m_modDoc.GetPatternViewInstrumentName(nIns); m_CbnInstrument.SetItemData(m_CbnInstrument.AddString(name), nIns); } } } else { - for(SAMPLEINDEX nSmp = 1; nSmp <= m_sndFile.GetNumSamples(); nSmp++) + for(SAMPLEINDEX nSmp = 1; nSmp <= sndFile.GetNumSamples(); nSmp++) { - if(m_sndFile.GetpModDoc()->IsSampleUsed(nSmp, false)) + if(m_modDoc.IsSampleUsed(nSmp, false)) { s.Format(_T("%02d: "), nSmp); - s += mpt::ToCString(m_sndFile.GetCharsetInternal(), m_sndFile.m_szNames[nSmp]); + s += mpt::ToCString(sndFile.GetCharsetInternal(), sndFile.m_szNames[nSmp]); m_CbnInstrument.SetItemData(m_CbnInstrument.AddString(s), nSmp); } } @@ -679,6 +689,21 @@ m_CbnProgram.SetCurSel(0); UpdateDialog(); CheckDlgButton(IDC_CHECK1, s_overlappingInstruments ? BST_CHECKED : BST_UNCHECKED); + + // Subsongs + CheckRadioButton(IDC_RADIO4, IDC_RADIO5, IDC_RADIO4); + + static_cast<CSpinButtonCtrl *>(GetDlgItem(IDC_SPIN2))->SetRange32(1, static_cast<int>(m_subSongs.size())); + SetDlgItemInt(IDC_EDIT1, static_cast<UINT>(m_selectedSong + 1), FALSE); + if(m_subSongs.size() <= 1) + { + const int controls[] = {IDC_RADIO4, IDC_RADIO5, IDC_EDIT1, IDC_SPIN2}; + for(int control : controls) + GetDlgItem(control)->EnableWindow(FALSE); + } + UpdateSubsongName(); + m_locked = false; + return TRUE; } @@ -687,6 +712,7 @@ { if(m_percussion == percussion) return; + const CSoundFile &sndFile = m_modDoc.GetSoundFile(); m_CbnProgram.SetRedraw(FALSE); m_CbnProgram.ResetContent(); if(percussion) @@ -697,7 +723,7 @@ ModCommand::NOTE note = i + 24; auto s = MPT_CFORMAT("{} ({}): {}")( note, - mpt::ToCString(m_sndFile.GetNoteName(note + NOTE_MIN)), + mpt::ToCString(sndFile.GetNoteName(note + NOTE_MIN)), mpt::ToCString(mpt::Charset::ASCII, szMidiPercussionNames[i])); m_CbnProgram.SetItemData(m_CbnProgram.AddString(s), note); } @@ -825,80 +851,167 @@ void CModToMidi::OnOK() { + bool ok = false; for(size_t i = 1; i < m_instrMap.size(); i++) { if(m_instrMap[i].channel != MidiNoChannel) { - DialogBase::OnOK(); + ok = true; + break; + } + } + + if (!ok) + { + auto choice = Reporting::Confirm(_T("No instruments have been selected for export. Would you still like to export the file?"), true, true); + if(choice != cnfYes) + { + if(choice == cnfNo) + OnCancel(); return; } } + + mpt::PathString filename = m_modDoc.GetPathNameMpt().ReplaceExtension(P_(".mid")); + FileDialog dlg = SaveFileDialog() + .DefaultExtension(U_("mid")) + .DefaultFilename(filename) + .ExtensionFilter(U_("MIDI Files (*.mid)|*.mid||")); + if(!dlg.Show()) + { + OnCancel(); + return; + } + m_conversionRunning = true; + DoConversion(dlg.GetFirstFile()); + + CProgressDialog::OnOK(); +} + - auto choice = Reporting::Confirm(_T("No instruments have been selected for export. Would you still like to export the file?"), true, true); - if(choice == cnfYes) - DialogBase::OnOK(); - else if(choice == cnfNo) +void CModToMidi::OnCancel() +{ + if(m_conversionRunning) + CProgressDialog::OnCancel(); + else DialogBase::OnCancel(); } -void CDoMidiConvert::Run() +void CModToMidi::OnSubsongChanged() { - CMainFrame::GetMainFrame()->PauseMod(m_sndFile.GetpModDoc()); + if(m_locked) + return; + CheckRadioButton(IDC_RADIO4, IDC_RADIO5, IDC_RADIO5); + BOOL ok = FALSE; + const auto newSubSong = std::clamp(static_cast<size_t>(GetDlgItemInt(IDC_EDIT1, &ok, FALSE)), size_t(1), m_subSongs.size()) - 1; + if(m_selectedSong == newSubSong || !ok) + return; + m_selectedSong = newSubSong; + UpdateSubsongName(); +} - const auto songLength = m_sndFile.GetLength(eNoAdjust).front(); - const double duration = songLength.duration; - const uint64 totalSamples = mpt::saturate_round<uint64>(duration * m_sndFile.m_MixerSettings.gdwMixingFreq); - SetRange(0, totalSamples); - auto conv = std::make_unique<MidiExport::Conversion>(m_sndFile, m_instrMap, m_file, CModToMidi::s_overlappingInstruments, songLength); +void CModToMidi::UpdateSubsongName() +{ + const auto subsongText = GetDlgItem(IDC_SUBSONG); + if(subsongText == nullptr || m_selectedSong >= m_subSongs.size()) + return; + subsongText->SetWindowText(m_modDoc.FormatSubsongName(m_subSongs[m_selectedSong]).c_str()); +} - auto startTime = timeGetTime(), prevTime = startTime; - m_sndFile.SetCurrentOrder(0); - m_sndFile.GetLength(eAdjust, GetLengthTarget(0, 0)); - m_sndFile.m_PlayState.m_flags.reset(SONG_PATTERNLOOP); - int oldRepCount = m_sndFile.GetRepeatCount(); - m_sndFile.SetRepeatCount(0); - m_sndFile.m_bIsRendering = true; +void CModToMidi::DoConversion(const mpt::PathString &fileName) +{ + if(IsDlgButtonChecked(IDC_RADIO5)) + m_subSongs = {m_subSongs[m_selectedSong]}; + + const int controls[] = {IDC_COMBO1, IDC_COMBO2, IDC_COMBO3, IDC_RADIO4, IDC_RADIO5, IDC_EDIT1, IDC_CHECK1, IDC_SPIN1, IDC_SPIN2, IDOK}; + for(int control : controls) + GetDlgItem(control)->EnableWindow(FALSE); + GetDlgItem(IDCANCEL)->SetFocus(); + + CSoundFile &sndFile = m_modDoc.GetSoundFile(); + SetRange(0, mpt::saturate_round<uint64>(std::accumulate(m_subSongs.begin(), m_subSongs.end(), 0.0, [](double acc, const auto &song) { return acc + song.duration; }) * sndFile.GetSampleRate())); + GetDlgItem(IDC_PROGRESS1)->ShowWindow(SW_SHOW); + + BypassInputHandler bih; + CMainFrame::GetMainFrame()->PauseMod(&m_modDoc); + + sndFile.m_bIsRendering = true; + + const auto origSequence = sndFile.Order.GetCurrentSequenceIndex(); + const auto origRepeatCount = sndFile.GetRepeatCount(); + sndFile.SetRepeatCount(0); EnableTaskbarProgress(); - MidiExport::DummyAudioTarget target; - UINT ok = IDOK; - const auto fmt = MPT_TFORMAT("Rendering file... ({}mn{}s, {}mn{}s remaining)"); - while(m_sndFile.Read(MIXBUFFERSIZE, target) > 0) + const auto songIndexFmt = mpt::format_simple_spec<mpt::ustring>{}.Dec().FillNul().Width(1 + static_cast<int>(std::log10(m_subSongs.size()))); + + uint64 totalSamples = 0; + for(size_t i = 0; i < m_subSongs.size() && !m_abort; i++) { - m_sndFile.ResetMixStat(); - auto currentTime = timeGetTime(); - if(currentTime - prevTime >= 16) + const auto &song = m_subSongs[i]; + + m_selectedSong = i; + UpdateSubsongName(); + + sndFile.ResetPlayPos(); + sndFile.GetLength(eAdjust, GetLengthTarget(song.startOrder, song.startRow).StartPos(song.sequence, 0, 0)); + sndFile.m_PlayState.m_flags.reset(); + + mpt::PathString currentFileName = fileName; + if(m_subSongs.size() > 1) + currentFileName = fileName.ReplaceExtension(mpt::PathString::FromNative(MPT_TFORMAT(" ({})")(mpt::ufmt::fmt(i + 1, songIndexFmt))) + fileName.GetFilenameExtension()); + mpt::IO::SafeOutputFile sf(currentFileName, std::ios::binary, mpt::IO::FlushModeFromBool(TrackerSettings::Instance().MiscFlushFileBuffersOnSave)); + mpt::IO::ofstream &f = sf; + + try { - prevTime = currentTime; - uint64 curSamples = m_sndFile.GetTotalSampleCount(); - uint32 curTime = static_cast<uint32>(curSamples / m_sndFile.m_MixerSettings.gdwMixingFreq); - uint32 timeRemaining = 0; - if(curSamples > 0 && curSamples < totalSamples) - { - timeRemaining = static_cast<uint32>(((currentTime - startTime) * (totalSamples - curSamples) / curSamples) / 1000u); - } - SetText(fmt(curTime / 60u, mpt::tfmt::dec0<2>(curTime % 60u), timeRemaining / 60u, mpt::tfmt::dec0<2>(timeRemaining % 60u)).c_str()); - SetProgress(curSamples); - ProcessMessages(); + if(!f) + throw std::exception{}; + f.exceptions(f.exceptions() | std::ios::badbit | std::ios::failbit); + + auto conv = std::make_unique<MidiExport::Conversion>(sndFile, m_instrMap, f, CModToMidi::s_overlappingInstruments, m_subSongs[i]); - if(m_abort) + MidiExport::DummyAudioTarget target; + const auto fmt = MPT_TFORMAT("Rendering file... ({}mn{}s, {}mn{}s remaining)"); + auto prevTime = timeGetTime(); + uint64 subsongSamples = 0; + while(!m_abort) { - ok = IDCANCEL; - break; + auto count = sndFile.Read(MIXBUFFERSIZE, target); + if(count == 0) + break; + + totalSamples += count; + subsongSamples += count; + sndFile.ResetMixStat(); + + auto currentTime = timeGetTime(); + if(currentTime - prevTime >= 16) + { + prevTime = currentTime; + auto timeSec = subsongSamples / sndFile.GetSampleRate(); + SetWindowText(MPT_TFORMAT("Exporting Song {} / {}... {}:{}:{}")(i + 1, m_subSongs.size(), timeSec / 3600, mpt::cfmt::dec0<2>((timeSec / 60) % 60), mpt::cfmt::dec0<2>(timeSec % 60)).c_str()); + + SetProgress(totalSamples); + ProcessMessages(); + } } + + conv->Finalise(); + } catch(const std::exception &) + { + Reporting::Error(MPT_UFORMAT("Unable to write to file {}!")(currentFileName)); + break; } } - conv->Finalise(); - - m_sndFile.m_bIsRendering = false; - m_sndFile.SetRepeatCount(oldRepCount); - - EndDialog(ok); + sndFile.SetRepeatCount(origRepeatCount); + sndFile.Order.SetSequence(origSequence); + sndFile.ResetPlayPos(); + sndFile.m_bIsRendering = false; } OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/mod2midi.h ============================================================================== --- trunk/OpenMPT/mptrack/mod2midi.h Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/mod2midi.h Sat Oct 26 22:21:46 2024 (r21994) @@ -19,7 +19,8 @@ OPENMPT_NAMESPACE_BEGIN -class CSoundFile; +class CModDoc; +struct SubSong; namespace MidiExport { @@ -32,23 +33,34 @@ } -class CModToMidi : public DialogBase +class CModToMidi : public CProgressDialog { protected: CComboBox m_CbnInstrument, m_CbnChannel, m_CbnProgram; CSpinButtonCtrl m_SpinInstrument; - CSoundFile &m_sndFile; + CModDoc &m_modDoc; + MidiExport::InstrMap m_instrMap; + std::vector<SubSong> m_subSongs; + size_t m_selectedSong = 0; size_t m_currentInstr = 1; bool m_percussion = false; + bool m_conversionRunning = false; + bool m_locked = true; public: - MidiExport::InstrMap m_instrMap; static bool s_overlappingInstruments; public: - CModToMidi(CSoundFile &sndFile, CWnd *pWndParent = nullptr); + CModToMidi(CModDoc &modDoc, CWnd *parent = nullptr); + ~CModToMidi(); protected: + void Run() override {}; + + void UpdateSubsongName(); + void DoConversion(const mpt::PathString &fileName); + void OnOK() override; + void OnCancel() override; BOOL OnInitDialog() override; void DoDataExchange(CDataExchange *pDX) override; void FillProgramBox(bool percussion); @@ -57,25 +69,9 @@ afx_msg void OnChannelChanged(); afx_msg void OnProgramChanged(); afx_msg void OnOverlapChanged(); - DECLARE_MESSAGE_MAP(); -}; - + afx_msg void OnSubsongChanged(); -class CDoMidiConvert: public CProgressDialog -{ -public: - CSoundFile &m_sndFile; - std::ostream &m_file; - const MidiExport::InstrMap &m_instrMap; - -public: - CDoMidiConvert(CSoundFile &sndFile, std::ostream &f, const MidiExport::InstrMap &instrMap, CWnd *parent = nullptr) - : CProgressDialog(parent) - , m_sndFile(sndFile) - , m_file(f) - , m_instrMap(instrMap) - { } - void Run() override; + DECLARE_MESSAGE_MAP(); }; Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Sat Oct 26 21:58:29 2024 (r21993) +++ trunk/OpenMPT/mptrack/mptrack.rc Sat Oct 26 22:21:46 2024 (r21994) @@ -2055,23 +2055,30 @@ CONTROL "Tree1",IDC_TREEDATA,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | WS_BORDER,0,135,85,131 END -IDD_MOD2MIDI DIALOGEX 0, 0, 257, 98 +IDD_MOD2MIDI DIALOGEX 0, 0, 267, 194 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "MIDI Conversion Setup" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,198,6,50,14 - PUSHBUTTON "Cancel",IDCANCEL,198,24,50,14 - GROUPBOX "",IDC_STATIC,6,6,184,72 - LTEXT "Instrument:",IDC_STATIC,12,18,67,8 + DEFPUSHBUTTON "&OK",IDOK,156,174,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,210,174,50,14 + GROUPBOX "Instruments",IDC_STATIC,6,6,252,90 + LTEXT "&Instrument:",IDC_STATIC,12,18,67,8 CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",0x0,12,28,11,12 - COMBOBOX IDC_COMBO1,25,28,158,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "MIDI Channel:",IDC_STATIC,12,48,46,8 - COMBOBOX IDC_COMBO2,12,58,66,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "MIDI Program / Percussion:",IDC_STATIC,83,48,97,8 - COMBOBOX IDC_COMBO3,83,58,100,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Allow instruments to overlap on same MIDI channel",IDC_CHECK1, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,84,246,10 + COMBOBOX IDC_COMBO1,25,28,221,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "MIDI &Channel:",IDC_STATIC,12,48,46,8 + COMBOBOX IDC_COMBO2,12,58,84,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "MIDI &Program / Percussion:",IDC_STATIC,102,48,97,8 + COMBOBOX IDC_COMBO3,102,58,144,114,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Allow instruments to overlap on same &MIDI channel",IDC_CHECK1, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,78,234,10 + GROUPBOX "Sub Songs",IDC_STATIC,6,102,252,66 + CONTROL "&All Sub Songs (Separate Files)",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,116,132,10 + CONTROL "&Sub Song:",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,130,54,10 + EDITTEXT IDC_EDIT1,66,129,54,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,126,126,11,14 + CONTROL "",IDC_SUBSONG,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX | WS_GROUP,23,145,223,18 + CONTROL "",IDC_PROGRESS1,"msctls_progress32",NOT WS_VISIBLE | WS_BORDER,6,174,144,14 END IDD_SAVEPRESET DIALOGEX 0, 0, 154, 58 @@ -2483,9 +2490,9 @@ IDD_MOD2MIDI, DIALOG BEGIN LEFTMARGIN, 4 - RIGHTMARGIN, 253 + RIGHTMARGIN, 263 TOPMARGIN, 4 - BOTTOMMARGIN, 94 + BOTTOMMARGIN, 190 END IDD_SAVEPRESET, DIALOG @@ -2704,6 +2711,11 @@ BEGIN 0 END + +IDD_MOD2MIDI AFX_DIALOG_LAYOUT +BEGIN + 0 +END #ifdef APSTUDIO_INVOKED |