diff --git a/README.md b/README.md index 64012b510..d1d13cd6e 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ - SDL2-Mixer (Linux/OS X only) - libupnp (Linux/OS X only) - libgme (Linux/OS X only) +- libopenmpt (Linux/OS X only) ## Compiling diff --git a/libs/libopenmpt/LICENSE.txt b/libs/libopenmpt/LICENSE.txt index e0f012166..0e7623eaa 100644 --- a/libs/libopenmpt/LICENSE.txt +++ b/libs/libopenmpt/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2004-2019, OpenMPT contributors +Copyright (c) 2004-2023, OpenMPT Project Developers and Contributors Copyright (c) 1997-2003, Olivier Lapicque All rights reserved. @@ -13,14 +13,13 @@ modification, are permitted provided that the following conditions are met: names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/libopenmpt/Licenses/License.Vorbis.txt b/libs/libopenmpt/Licenses/License.Vorbis.txt index 153b926a1..fb456a87b 100644 --- a/libs/libopenmpt/Licenses/License.Vorbis.txt +++ b/libs/libopenmpt/Licenses/License.Vorbis.txt @@ -1,4 +1,4 @@ -Copyright (c) 2002-2018 Xiph.org Foundation +Copyright (c) 2002-2020 Xiph.org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/libs/libopenmpt/Licenses/License.mpg123.Authors.txt b/libs/libopenmpt/Licenses/License.mpg123.Authors.txt index c1eac976d..f7a792a85 100644 --- a/libs/libopenmpt/Licenses/License.mpg123.Authors.txt +++ b/libs/libopenmpt/Licenses/License.mpg123.Authors.txt @@ -30,6 +30,9 @@ The creator: Michael Hipp (email: hippm@informatik.uni-tuebingen.de - please bot Contributions/ideas Thomas Orgis era (includes backports from mhipp trunk): +Dave Yeo : continued OS/2 fixing +madebr and manx: github mirror and CI +Vitaly Kirsanov : ports/cmake (optional CMake build) Won-Kyu Park : patch to get rid of asm textrels (x86 PIC) Michael Weiser : update of coreaudio output to AudioComponents API Bent Bisballe Nyeng : patch for MPG123_NO_PEEK_END and MPG123_FORCE_SEEKABLE @@ -165,7 +168,7 @@ Hur TaeSung : 'http accept' patch (from post-0.59 changes that yet have to go into new trunk:) Hans Schwengeler : audio_dec additions -Wojciech Barański's Mp3Play (check the tools folder): Mp3Play frontend +Wojciech BaraƱski's Mp3Play (check the tools folder): Mp3Play frontend Daniel Koukola: audio_oss.c patch Munechika SUMIKAWA : IPv6 TEMNOTA : HTTP,FTP patch/playlist fix diff --git a/libs/libopenmpt/Licenses/License.mpg123.txt b/libs/libopenmpt/Licenses/License.mpg123.txt index d7bb85fc3..14e14f01c 100644 --- a/libs/libopenmpt/Licenses/License.mpg123.txt +++ b/libs/libopenmpt/Licenses/License.mpg123.txt @@ -2,7 +2,7 @@ This is the file that contains the terms of use, copying, etc. for the mpg123 di Main message, to include in "About ..." boxes, etc: - Copyright (c) 1995-2013 by Michael Hipp and others, + Copyright (c) 1995-2020 by Michael Hipp and others, free software under the terms of the LGPL v2.1 There is an attempt to cover the actual list of authors in the AUTHORS file. diff --git a/libs/libopenmpt/Licenses/License.mpt.BSD-3-Clause.txt b/libs/libopenmpt/Licenses/License.mpt.BSD-3-Clause.txt new file mode 100644 index 000000000..0e7623eaa --- /dev/null +++ b/libs/libopenmpt/Licenses/License.mpt.BSD-3-Clause.txt @@ -0,0 +1,25 @@ +Copyright (c) 2004-2023, OpenMPT Project Developers and Contributors +Copyright (c) 1997-2003, Olivier Lapicque +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the OpenMPT project nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/libopenmpt/Licenses/License.mpt.BSL-1.0.txt b/libs/libopenmpt/Licenses/License.mpt.BSL-1.0.txt new file mode 100644 index 000000000..36b7cd93c --- /dev/null +++ b/libs/libopenmpt/Licenses/License.mpt.BSL-1.0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/libs/libopenmpt/Licenses/License.zlib.txt b/libs/libopenmpt/Licenses/License.zlib.txt index 51106de47..024b79d3d 100644 --- a/libs/libopenmpt/Licenses/License.zlib.txt +++ b/libs/libopenmpt/Licenses/License.zlib.txt @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.11 is a general purpose data compression library. All the code is +zlib 1.2.12 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -31,7 +31,7 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at http://marknelson.us/1997/01/01/zlib-engine/ . -The changes made in version 1.2.11 are documented in the file ChangeLog. +The changes made in version 1.2.12 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -84,7 +84,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2017 Jean-loup Gailly and Mark Adler + (C) 1995-2022 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -108,7 +108,10 @@ Copyright notice: If you use the zlib library in a product, we would appreciate *not* receiving lengthy legal documents to sign. The sources are provided for free but without warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. +Gailly and Mark Adler; it does not include third-party code. We make all +contributions to and distributions of this project solely in our personal +capacity, and are not conveying any rights to any intellectual property of +any third parties. If you redistribute modified sources, we would appreciate that you include in the file ChangeLog history information documenting your changes. Please read diff --git a/libs/libopenmpt/SRB2NOTE.md b/libs/libopenmpt/SRB2NOTE.md deleted file mode 100644 index 7eac9183b..000000000 --- a/libs/libopenmpt/SRB2NOTE.md +++ /dev/null @@ -1,54 +0,0 @@ -# libopenmpt mingw-w64 binary info - -Current built version as of 2019/09/27 is 0.4.7+r12088.pkg - -* mingw binaries (.dll): `bin/[x86 or x86_64]/mingw` -* mingw import libraries (.dll.a): `lib/[x86 or x86_64]/mingw` - -# Building libopenmpt with mingw-w64 - -libopenmpt must be built from the Makefile / Android dev package in the -[Downloads page](https://lib.openmpt.org/libopenmpt/download/#all-downloads) - -Use the mingw-w64 distributions from -[SourceForge](https://sourceforge.net/projects/mingw-w64/files/#readme). - -You can download the appropriate 7-zip archive, extract to a folder of -your choice, remove any existing mingw directories from your PATH, -then call `mingw32-make.exe` from its direct location. - -FOR LIBOPENMPT, YOU MUST USE A MINGW PACKAGE THAT SUPPORTS THE POSIX -THREADING MODEL! DO NOT COMPILE WITH A WIN32 THREADING MODEL! - -I use GCC 7.3.0: - -* [x86_64-posix-seh](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z) -* [i686-posix-dwarf](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-posix/dwarf/i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z) - -## x86 build instructions - -``` -set CFLAGS=-march=pentium -static-libgcc -set CXXFLAGS=-march=pentium -static-libgcc -static-libstdc++ -set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive - -cd [libopenmpt-make-src] -[x86-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win32 -``` - -`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the -`bin/` folder. - -## x86_64 build instructions - -``` -set CFLAGS=-march=nocona -static-libgcc -set CXXFLAGS=-march=nocona -static-libgcc -static-libstdc++ -set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive - -cd [libopenmpt-make-src] -[x86_64-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win64 -``` - -`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the -`bin/` folder. \ No newline at end of file diff --git a/libs/libopenmpt/bin/x86/libopenmpt.dll b/libs/libopenmpt/bin/x86/libopenmpt.dll index 8ad64fdfd..7fec7d99e 100644 Binary files a/libs/libopenmpt/bin/x86/libopenmpt.dll and b/libs/libopenmpt/bin/x86/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-mpg123.dll b/libs/libopenmpt/bin/x86/openmpt-mpg123.dll index b068ddd0c..54c4b9fce 100644 Binary files a/libs/libopenmpt/bin/x86/openmpt-mpg123.dll and b/libs/libopenmpt/bin/x86/openmpt-mpg123.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-ogg.dll b/libs/libopenmpt/bin/x86/openmpt-ogg.dll index a5b460063..f5e087421 100644 Binary files a/libs/libopenmpt/bin/x86/openmpt-ogg.dll and b/libs/libopenmpt/bin/x86/openmpt-ogg.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-vorbis.dll b/libs/libopenmpt/bin/x86/openmpt-vorbis.dll index 1ebed9b0e..0653f6f81 100644 Binary files a/libs/libopenmpt/bin/x86/openmpt-vorbis.dll and b/libs/libopenmpt/bin/x86/openmpt-vorbis.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-zlib.dll b/libs/libopenmpt/bin/x86/openmpt-zlib.dll index 41bc22d2f..01ba3ec89 100644 Binary files a/libs/libopenmpt/bin/x86/openmpt-zlib.dll and b/libs/libopenmpt/bin/x86/openmpt-zlib.dll differ diff --git a/libs/libopenmpt/bin/x86_64/libopenmpt.dll b/libs/libopenmpt/bin/x86_64/libopenmpt.dll index ffbb4b19a..1cdb0c567 100644 Binary files a/libs/libopenmpt/bin/x86_64/libopenmpt.dll and b/libs/libopenmpt/bin/x86_64/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll b/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll deleted file mode 100644 index 018ae8276..000000000 Binary files a/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll and /dev/null differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll b/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll index 9a0fca874..3ef350e0e 100644 Binary files a/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll and b/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll b/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll index 4bc1a336b..bc1f42cf3 100644 Binary files a/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll and b/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll b/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll index ebe8ef9b3..66b7be774 100644 Binary files a/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll and b/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll b/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll index 319b646ff..cd738be6b 100644 Binary files a/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll and b/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll differ diff --git a/libs/libopenmpt/changelog.md b/libs/libopenmpt/changelog.md index 0b7279558..460b157b6 100644 --- a/libs/libopenmpt/changelog.md +++ b/libs/libopenmpt/changelog.md @@ -5,95 +5,435 @@ Changelog {#changelog} For fully detailed change log, please see the source repository directly. This is just a high-level summary. -### libopenmpt 0.4.7 (2019-09-23) +### libopenmpt 0.7.2 (2023-06-18) - * [**Bug**] Compilation fix for various platforms that do not provide - `std::aligned_alloc` in C++17 mode. The problematic dependency has been - removed. This should fix build problems on MinGW, OpenBSD, Haiku, and others - for good. + * [**New**] MOD: Can now read modified 8-channel MOD files from the DOS game + Aleshar - The World Of Ice. - * J2B: Ignore notes with non-existing instrument (fixes Ending.j2b). + * [**Sec**] Possible out-of-bounds read or write when reading malformed MED + files. (r19389) - * mpg123: Update to v1.25.13 (2019-08-24). - * ogg: Update to v1.3.4. (2019-08-31). - * flac: Update to v1.3.3. (2019-08-04). + * [**Bug**] The C++ API failed to compile with Clang/Emscripten in some + situations due to a misplaced `[[deprecated]]`. + * [**Bug**] The Opal OPL3 emulator symbols were not namespaced properly. + * [**Bug**] Work-around for MSVC VS2022 17.6.0 ARM64 compiler bug. + * [**Bug**] `Makefile` `CONFIG=emscripten EMSCRIPTEN_PORTS=1` failed to + properly use `libogg` and `libvorbis` dependencies. -### libopenmpt 0.4.6 (2019-08-10) +### libopenmpt 0.7.1 (2023-05-07) - * [**Bug**] Compilation fix for OpenBSD. - * [**Bug**] Compilation fix for NO_PLUGINS being defined. + * [**Bug**] MSVC projects failed to build from the packaged source zip. - * in_openmpt: Correct documentation. `openmpt-mpg123.dll` must be placed into - the Winamp directory. + * IT: Improved fingerprinting of early ModPlug Tracker versions. + * XMF: Modules from Astroidea demos can now be read as well. - * Detect IT files unpacked with early UNMO3 versions. +### libopenmpt 0.7.0 (2023-04-30) - * mpg123: Update to v1.25.11 (2019-07-18). - * minimp3: Update to commit 977514a6dfc4960d819a103f43b358e58ac6c28f - (2019-07-24). - * miniz: Update to v2.1.0 (2019-05-05). - * stb_vorbis: Update to v1.17 (2019-08-09). + * [**New**] `667` files from Composer 667 are now supported. + * [**New**] `GTK` and `GT2` files from Gramouf Tracker are now supported. + * [**New**] Can now read a variant of the DSMI AMF format called DMF, as found + in various DOS games distributed by Webfoot (Tronic, H2O, PowBall, etc.). + * [**New**] `DSM` files from Dynamic Studio are now supported. + * [**New**] `XMF` files from the DOS game Imperium Galactica are now supported. + * [**New**] Can now read the hacked MOD format (`DMF`) from the game + "Apocalypse Abyss". + * [**New**] libopenmpt: New APIs for getting the current tempo as a floating + point value: `openmpt::module::get_current_tempo2()` (C++), and + `openmpt_module_get_current_tempo2()` (C). + * [**New**] C API: New stream callbacks for various platform extensions to the + C stdio interface: `openmpt_stream_get_file_posix_lfs64_callbacks()` in + `libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h` for explicit + `off64_t` on Posix systems, `openmpt_stream_get_file_posix_callbacks()` in + `libopenmpt/libopenmpt_stream_callbacks_file_posix.h` for `off_t` on Posix + systems, `openmpt_stream_get_file_msvcrt_callbacks()` in + `libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h` for 64bit file + support on Windows systems with the Microsoft C runtime, and + `openmpt_stream_get_file_mingw_callbacks()` in + `libopenmpt/libopenmpt_stream_callbacks_file_mingw.h` for 64bit file support + when targetting MinGW. The old `openmpt_stream_get_file_callbacks()` has + been deprecated in favour of a stricly standard conforming + `openmpt_stream_get_file_callbacks2()` in the same + `libopenmpt/libopenmpt_stream_callbacks_file.h` header. + `libopenmpt/libopenmpt.h` defines + `LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64`, + `LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX`, + `LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT`, and + `LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW` respectively in order to allow for + checking header availability. + * [**New**] C API: New stream callbacks for memory buffers. + `openmpt_stream_get_buffer_callbacks()` and `openmpt_stream_buffer_init()` + are deprecated. Use `openmpt_stream_get_buffer_callbacks2()` and + `openmpt_stream_buffer_init2()` instead. The new variants do not support + loading only a file prefix and checking for overflow any more. This was only + useful when using the old `openmpt_could_open_probability2()` style + interface from the libopenmpt 0.2 API, which has been superseded by + `openmpt_probe_file_header()`, + `openmpt_probe_file_header_without_filesize()`, and + `openmpt_probe_file_header_from_stream()` in libopenmpt 0.3.0. + * [**New**] libopenmpt_ext: New interface `interactive3` adding + `openmpt::ext::interactive3::set_current_tempo2()` (C++) and + `openmpt_module_ext_interface_interactive3.set_current_tempo2()` (C) which + allow setting non-integer tempo values. + * [**New**] New `Makefile` option `CONFIG=mingw-w64` which consolidates all + MinGW-w64 build configurations with the following options: + `MINGW_FLAVOUR=[|-posix|-win32]`, `WINDOWS_ARCH=[x86|amd64]`, + `WINDOWS_FAMILY=[|desktop-app|app|phone-app|pc-app]`, and + `WINDOWS_VERSION=[win95|win98|winme|winnt4|win2000|winxp|winxp64|winvista|win7|win8|win8.1|win10|win11]`. + * [**New**] New `Makefile` option `CONFIG=mingw` which consolidates all MinGW + build configurations with the following options: + `MINGW_FLAVOUR=[|-posix|-win32]`, and + `WINDOWS_VERSION=[win95|win98|winme|winnt4|win2000|winxp]`. + * [**New**] Building with MSYS2 is now fully supported for Makefile and + Autotools build systems. + * [**New**] `Makefile` `CONFIG=djgpp` now supports `CPU=` option to build + optimized for a particular CPU. See `build/make/config-djgpp.mk` for all + available options. `FLAVOURED_DIR=1` places the CPU-specific optimized + builds in separate folders below `bin/`. + * [**New**] Building with a MinGW32 CRTDLL toolchain is now supported via + `Makefile` option `CONFIG=mingw32crt`. + * [**New**] `Makefile` now uses `PKG_CONFIG` as path to `pkg-config`. + * [**New**] The C++ API is now also enabled for Emscripten builds by default. + * [**New**] Support for GCC 7 has been restored. + * [**New**] Support for Clang 6 has been restored. + * [**New**] Support for Android NDK 18 has been restored. + * [**New**] openmpt123: `--banner [0|1|2]` allows changing the openmpt123 + banner style to hidden, shown, or verbose, respectively. + * [**New**] openmpt123: `--assume-terminal` allows skipping the openmpt123 + terminal check, and thus allows running the UI with non-terminal stdin, + which can be useful for some very basic remote control functionality. -### libopenmpt 0.4.5 (2019-05-27) + * [**Change**] xmp-openmpt: The Amiga resampler emulation is now enabled by + default. + * [**Change**] in_openmpt: The Amiga resampler emulation is now enabled by + default. + * [**Change**] The official Windows builds (x86, amd64, arm, arm64) now + require Windows 10 21H2 (or later). The official legacy Windows builds + (x86-legacy, amd64-legacy) are unchanged and still require Windows 7 (or + later). + * [**Change**] `"date"` metadata will now exlude the UTC time zone signifier + `Z` if the precise time zone is unknown. + * [**Change**] ctl `seek.sync_samples` now defaults to 1. + * [**Change**] `Makefile` `CONFIG=generic` is gone. Please use + `CONFIG=standard` instead. + * [**Change**] `Makefile` `CONFIG=macosx` and `CONFIG=haiku` have been + removed. The OS is auto-detected. + * [**Change**] `Makefile` options `CONFIG=mingw64-win32`, + `CONFIG=mingw64-win64`, `CONFIG=mingw64-winrt-x86`, + `CONFIG=mingw64-winrt-amd64`, and `CONFIG=mingw-win9x` have been replaced by + `CONFIG=mingw-w64`, and `CONFIG=mingw`. + * [**Change**] Autotools now default to C++20 and only fall back to C++17 when + C++20 is not supported. + * [**Change**] `Makefile` now defaults to C++20 and only falls back to C++17 + when C++20 is not supported by the compiler. + * [**Change**] `Makefile` now defaults to C17 and only falls back to C11 when + C17 is not supported by the compiler. + * [**Change**] `Makefile` `CONFIG=djgpp` option `USE_ALLEGRO42` now + defaults to `1` and implies building a liballegro42 locally. This requires + executing `build/download_externals.sh` before building to download the + liballegro42 sources. + * [**Change**] in_openmpt: The Winamp input plugin in_openmpt is now + deprecated for use with the latest Winamp or WACUP releases. Please use the + native implementations available in Winamp >=5.9.0 or WACUP instead. This + does not mean that in_openmpt/in_mod will not receive further development, + it just means that the responsibility now lies with the player implementors + themselves. We will still maintain the status quo of our in_openmpt input + plugin for users of earlier Winamp version, or users on older systems, or + users of compatible players. + * [**Change**] The POSIX fd file callbacks implementation now handles `EINTR` + and retries the `read()` call. - * [**Sec**] Possible crash during playback due out-of-bounds read in XM and - MT2 files (r11608). + * [**Regression**] Full support for Visual Studio 2017 has been removed. We + still support targeting Windows XP with Visual Studio 2017. + * [**Regression**] Support for mingw-std-threads has been removed. If you + require a thread-safe libopenmpt, please build with POSIX threading model + and/or complain to MinGW/GCC about not properly supporting C++11 features in + 2023. + * [**Regression**] Support for Emscripten versions older than 3.1.1 has been + removed. + * [**Regression**] C API: `openmpt_stream_get_file_callbacks()` used to + provide 64bit file access on some platforms where long is 32bit. This never + worked reliably for all platforms though. The behaviour is now changed to + always stick to what standard C supports with `fseek` and `ftell`, where the + offset type is long. `openmpt_stream_get_file_callbacks()` is deprecated now + due to behavioral change. Please migrate to + `openmpt_stream_get_file_callbacks2()`. + * [**Regression**] Using the system-provided liballegro42 is no longer + supported. The option `BUNDLED_ALLEGRO42=1` does not exist any more. - * Breaking out of a sustain loop through Note-Off sometimes didn't continue in - the regular sample loop. - * Seeking did not stop notes playing with XM Key Off (Kxx) effect. + * Reduced aliasing when downsampling with the Sinc + Low-Pass resampler. + * The sample position is now rounded instead of truncated when resampling + without interpolation. + * Seeking with sample sync now supports portamento up / down commands as well + as IMF/ PTM note slides. Tone portamento is now synchronized correctly when + seeking in DBM, 669 and MED with fast slides (first tick of portamento was + previously not executed). + * The filter cutoff frequency is no longer rounded to integer frequency values. + * MED: Tempos higher than 255 BPM can now be imported in pattern data. + * MED: MMD1 files with more than 16 channels are now supported. + * ULT: Import 8-bit volume commands with full precision. + * IT: Initial "last note memory" of every channel is C-0, so a lone instrument + number without note triggers that note. + * S3M: Better approximation of old "stereo control" SAx command used in + Purple Motion's PANIC.S3M. + * S3M: In ScreamTracker 3.03 and later, OPL notes with tone portamento next to + them are delayed until the next row and then the new pitch is used instantly. + * MO3: Envelope sustain was not imported correctly if the source file was an + XM. + * MOD: Lone instrument number with retrigger effect swap sample immediately. + * Recalling a sample's default volume using an instrument number (as opposed + to regular volume commands) previously ramped the volume change smoothly + over a whole tick. Now the user-configured ramp settings are used instead + (as it would happen when using a volume command to achieve the same effect). -### libopenmpt 0.4.4 (2019-04-07) + * zlib: v1.2.12 (2022-03-27). + * mpg123: v1.31.3 (2023-03-19). + * ogg: v1.3.5 (2021-06-04). + * vorbis: v1.3.7 (2020-07-04). + * miniz: v2.2.0 (2021-06-27). + * minimp3: commit 50d2aaf360a53653b718fead8e258d654c3a7e41 (2021-11-27). + * stb_vorbis: v1.22 commit 5a0bb8b1c1b1ca3f4e2485f4114c1c8ea021b781 + (2021-07-12). + * FLAC: v1.4.2 (2022-10-22). + * PortAudio: v19.7.0 (2021-04-06). - * [**Bug**] Channel VU meters were swapped. +### libopenmpt 0.6.0 (2021-12-23) - * Startrekker: Clamp speed to 31 ticks per row. - * MTM: Ignore unused Exy commands on import. Command E5x (Set Finetune) is now - applied correctly. - * MOD: Sample swapping was always enabled since it has been separated from the - ProTracker 1/2 compatibility flag. Now it is always enabled for Amiga-style - modules and otherwise the old heuristic is used again. + * [**New**] `MUS` files from Psycho Pinball and Micro Machines 2 are now + supported. + * [**New**] `SymMOD` files created with Symphonie / Symphonie Pro are now + supported. + * [**New**] `FMT` files created with Davey W Taylor's FM Tracker are now + supported. + * [**New**] `DSYM` files created with Digital Symphony are now supported. + * [**New**] `STX` files (transitional format between Scream Tracker 2 and 3) + are now supported. + * [**New**] TakeTracker MODs with `TDZ1` to `TDZ3` magic bytes are now + supported. + * [**New**] openmpt123: openmpt123 will now expand file wildcards passed on + the command line in Windows when built with MSVC. + * [**New**] libopenmpt_ext: New interface `interactive2` adding + `openmpt::ext::interactive2::note_off()`, + `openmpt::ext::interactive2::note_fade()`, + `openmpt::ext::interactive2::set_channel_panning()`, + `openmpt::ext::interactive2::get_channel_panning()`, + `openmpt::ext::interactive2::set_note_finetune()`, and + `openmpt::ext::interactive2::get_note_finetune()` (C++) and + `openmpt_module_ext_interface_interactive2.note_off()`, + `openmpt_module_ext_interface_interactive2.note_fade()`, + `openmpt_module_ext_interface_interactive2.set_channel_panning()`, + `openmpt_module_ext_interface_interactive2.get_channel_panning()`, + `openmpt_module_ext_interface_interactive2.set_note_finetune()`, and + `openmpt_module_ext_interface_interactive2.get_note_finetune()` (C). + * [**New**] `Makefile` `CONFIG=emscripten` now supports + `EMSCRIPTEN_TARGET=audioworkletprocessor` which builds an ES6 module in + a single file with reduced dependencies suitable to be used in an + AudioWorkletProcessor. + * [**New**] `Makefile` `CONFIG=emscripten` now supports `EMSCRIPTEN_PORTS=1` + which uses dependencies (zlib, mp123, ogg, and vorbis) from Emscripten Ports + instead of using miniz, minimp3, and stb_vorbis locally or building zlib, + mp123, ogg, and vorbis locally. + * [**New**] `Makefile` `CONFIG=emscripten` and `CONFIG=djgpp` can now build + zlib, mpg123, and vorbis locally instead of only supporting miniz, minimp3, + and stb_vorbis via `ALLOW_LGPL=1`. - * stb_vorbis: Update to v1.16 (2019-03-05). + * [**Change**] `Makefile` `CONFIG=emscripten` now supports + `EMSCRIPTEN_TARGET=all` which provides WebAssembly as well as fallback to + JavaScript in a single build. + * [**Change**] openmpt123: DOS builds now use the Mercury fork of + `liballegro 4.2` for improved hardware compatibility. + * [**Change**] libopenmpt no longer generates internal interpolation tables on + library load time, but instead only on first module load time. -### libopenmpt 0.4.3 (2019-02-11) + * [**Regression**] `Makefile` `CONFIG=emscripten` does not support + `EMSCRIPTEN_TARGET=asmjs` or `EMSCRIPTEN_TARGET=asmjs128m` any more because + support has been removed from current Emscripten versions. + * [**Regression**] Support for GCC 7 has been removed. + * [**Regression**] Support for Clang 5, 6 has been removed. + * [**Regression**] Support for Emscripten versions older than 1.39.7 has been + removed. + * [**Regression**] Building with Android NDK older than NDK r19c is not + supported any more. - * [**Sec**] Possible crash due to null-pointer access when doing a portamento - from an OPL instrument to an empty instrument note map slot (r11348). + * libopenmpt can now detect infinite pattern loops and treats them as the song + end. This means that setting a repeat count other than -1 now always + guarantees that playback will eventually end. The song loop counter is + decremented each time it ends up at the start of the infinite loop, so the + song does not restart from the beginning even if the repeat count is not 0. + * `openmpt::module::set_position_seconds()` accuracy has been improved for + modules with pattern loops. + * Samples played at the wrong volume when rendering modules in mono. + * IT: Portamentos in files with Linear Slides disabled are now more accurate. + * IT: Pitch/Pan Separation was affected by note-off commands, and wasn't reset + by panning commands like in Impulse Tracker. + * IT: Even after libopenmpt 0.5.14 the filter reset logic was still not 100% + identical to Impulse Tracker: A note triggered on tick 0 of a row with a + Pattern Delay effect still caused the filter to be reset on repetitions of + that row even though the note wasn't retriggered. + * IT: Added read-only support for BeRoTracker commands 1 and 2 (equivalent to + XM commands K and L). + * XM: BeRoTracker saves smooth MIDI macros in a different way from OpenMPT. + This command is now imported correctly. + * XM: Emulate FT2 Tone Portamento quirk that inverts portamento direction + after the target was reached (if target note was higher than previous note). + * S3M files saved with Impulse Tracker and latest Schism Tracker now also + compute sample playback speed in Hertz. + * Depending on whether an S3M file was last saved in Scream Tracker with the + Sound Blaster or Gravis Ultrasound drivers loaded, different compatibility + flags are now applied. For files saved with the GUS, the sample volume + factor is now also ignored (fixes volume levels in S3Ms made on the GUS, in + particular if they use both samples and OPL instruments). + * S3M: Enforce the lower frequency bound. + * MOD: Loosened VBlank timing heuristics so that the original copy of + Guitar Slinger from Dizzy Tunes II plays correctly. + * FAR: Correct portamento depth is now used. + * DMF / IMF: Improved accuracy of finetune commands. + * MDL: Implemented finetune command. + * OKT: Various accuracy improvements such as: Sharing volume between mixed + channels, volume commands on mixed channels are permanent (not reset with + new notes), mixed channels do not support default sample volume, 7-bit + samples are actually supposed to be played as-is (not amplified to full + 8-bit range), reject speed command parameters >= 20. - * [**Bug**] libopenmpt did not compile on Apple platforms in C++17 mode. + * zlib: v1.2.11 (2017-01-15). + * mpg123: v1.29.3 (2021-12-11). + * ogg: v1.3.5 (2021-06-04). + * vorbis: v1.3.7 (2020-07-04). + * miniz: v2.2.0 (2021-06-27). + * minimp3: commit 50d2aaf360a53653b718fead8e258d654c3a7e41 (2021-11-27). + * stb_vorbis: v1.22 commit 5a0bb8b1c1b1ca3f4e2485f4114c1c8ea021b781 + (2021-07-12). + * FLAC: v1.3.3 (2019-08-04). + * PortAudio: v19.7.0 (2021-04-06). - * IT: Various fixes for note-off + instrument number in Old Effects mode. - * MO3: Import IT row highlights as written by MO3 2.4.1.2 or newer. Required - for modules using modern tempo mode. +### libopenmpt 0.5.0 (2020-05-24) - * miniz: Update to v2.0.8 (2018-09-19). - * stb_vorbis: Update to v1.15 (2019-02-07). + * [**New**] OggMod compressed FastTracker 2 XM (OXM) modules are now + supported. + * [**New**] The emulated Amiga type when Amiga resampler emulation is enabled + can now be selected via ctl `render.resampler.emulate_amiga_type`. Possible + values are: `"auto"`, `"a500"`, `"a1200"`, and an experimental option + `"unfiltered"`. + * [**New**] libopenmpt: New API `openmpt::module::get_current_estimated_bpm()` + (C++), and `openmpt_module_get_current_estimated_bpm()` (C) which provides + accurate beats per minute information for module formats with time signature + and an educated guess based on speed and tempo for others. + * [**New**] libopenmpt: New type-aware ctl APIs that do not require memory + allocations and are thus realtime-safe: + `openmpt::module::ctl_get_boolean()`, `openmpt::module::ctl_get_integer()`, + `openmpt::module::ctl_get_floatingpoint()`, + `openmpt::module::ctl_get_text()`, `openmpt::module::ctl_set_boolean()`, + `openmpt::module::ctl_set_integer()`, + `openmpt::module::ctl_set_floatingpoint()` (C++), and + `openmpt_module_ctl_get_boolean()`, `openmpt_module_ctl_get_integer()`, + `openmpt_module_ctl_get_floatingpoint()`, `openmpt_module_ctl_get_text()`, + `openmpt_module_ctl_set_boolean()`, `openmpt_module_ctl_set_integer()`, + `openmpt_module_ctl_set_floatingpoint()` (C). + * [**New**] libopenmpt C++ New API `openmpt::is_extension_supported2()` which + takes a `std::string_view` parameter instead of `std::string`. + * [**New**] libopenmpt C++: New API + `openmpt::module::module(std::vector data)`, + `openmpt::module::module(const std::byte * data, std::size_t size)`, + `openmpt::module::module(const std::byte * beg, const std::byte * end)`. + * [**New**] libopenmpt C++: New API + `openmpt::probe_file_header(flags, const std::byte * data, std::size_t size, filesize)`, + `openmpt::probe_file_header(flags, const std::byte * data, std::size_t size)`. + * [**New**] libopenmpt_ext C++: New API + `openmpt::module_ext::module_ext(std::vector data)`, + `openmpt::module_ext::module_ext(const std::byte * data, std::size_t size)`, + `openmpt::module_ext::module_ext(std::vector data)`, + `openmpt::module_ext::module_ext(const std::uint8_t * data, std::size_t size)`. -### libopenmpt 0.4.2 (2019-01-22) + * [**Change**] std::istream based file I/O has been speed up. + * [**Change**] Dependency on iconv on Linux has been removed. - * [**Sec**] DSM: Assertion failure during file parsing with debug STLs - (r11209). - * [**Sec**] J2B: Assertion failure during file parsing with debug STLs - (r11216). + * [**Regression**] libmodplug: The libmodplug emulation layer has been removed + from the libopenmpt tree. Please use the separate `libopenmpt-modplug` + package instead. + * [**Regression**] foo_openmpt: foo_openmpt is discontinued. Please use + Kode54's fork foo_openmpt54: + . + * [**Regression**] Support for building with C++11 or C++14 has been removed. + C++17 is now required to build libopenmpt. + * [**Regression**] Support for client code using C++11 or C++ 14 has been + removed. C++17 is now required to build libopenmpt client applications. + * [**Regression**] Support for Visual Studio 2015 has been removed. + * [**Regression**] Support for GCC 4.8, 4.9, 5, 6 has been removed. + * [**Regression**] Support for Clang 3.6, 3.7, 3.8, 3.9, 4 has been removed. + * [**Regression**] Support for Emscripten versions older than 1.39.1 has been + removed. + * [**Regression**] Building with Android NDK older than NDK r18b is not + supported any more. + * [**Regression**] openmpt123: Support for SDL1 (but not SDL2) output has been + removed. + * [**Regression**] openmpt123: Support for SDL2 older than 2.0.4 has been + removed. + * [**Regression**] Windows XP and Windows Vista are no longer supported. + * [**Regression**] It is no longer possible to optionally use iconv for + character set conversions. - * S3M: Allow volume change of OPL instruments after Note Cut. + * [**Bug**] openmpt123: openmpt123 now honors the current locale and outputs + text appropriately. + * [**Bug**] openmpt123: Piping text output to other than console window + targets on Windows has been fixed. -### libopenmpt 0.4.1 (2019-01-06) + * Greatly improved MED import. Synthesized instruments are still not supported + but support was added for: Multisampled instruments, delta samples, more + pattern commands, Hold and Decay, multiple songs and many other small + changes. + * Improved OPL channel allocation when more than 18 notes are active, so that + channels that have completely faded out are prioritized over channels that + have already been released but have not faded out yet. + * Interactively triggering an OPL instrument could cause the first pattern + channel to no longer be played back correctly. + * Fix some inaccuracies in OPL emulator. + * Fix overflow of OPL amplification happening at a synth volume level of 510. + * End-of-sample pop reduction of surround channels was applied to front + channels instead, causing a pop on the front channels instead of removing it + on the back channels. + * IT: Disable retrigger with short notes quirk for modules saved with + Chibi Tracker, as it does not implement that quirk. + * IT: Instrument and sample panning should not override channel panning for + following notes. + * IT: SBx is now prioritized over Bxx commands that are to the left of it. + * IT: Duplicate Check Type "Sample" should only be applied if the instruments + match, too. + * IT: Duplicate Check Type "Note" should compare pattern notes, but it was + comparing the new pattern note against the old translated note. + * IT: Various fixes for envelope resetting. + * IT / S3M: When combining SBx and EEx effects, don't skip the first row of + the loop like in FastTracker 2. + * S3M: Empty pattern commands now affect effect memory as well. + * S3M: Offset beyond loop end wraps around to loop start like in + Scream Tracker 3 + GUS (previously it just keep playing from the loop start, + which is neither what GUS nor Sound Blaster drivers do). + * S3M: Notes cannot be retriggered after they have been cut. + * S3M: Fix portamento after note cut (fixes antediluvian_song.s3m). + * S3M / MOD: Previous note offset is no longer used for retriggered notes if + there was no instrument number next to the Qxy effect. + * MOD: Sample swapping now also works if the sample that is being swapped from + does not loop. Swapping to a non-looped sample now stops playback once the + swapped-from sample reaches its (loop) end. + * MOD: Fix early song ending due to ProTracker pattern jump quirk + (EEx + Dxx on same row) if infinite looping is disabled. + Fixes Haunted Tracks.mod by Triace. + * MOD: Previous note offset is no longer used for retriggered notes if there + was no instrument number next to the E9x effect. + * MOD: Vibrato type "ramp down" was upside down. + * XM: If a file contains patterns longer than 1024 rows, they are now clamped + to 1024 rows instead of 64 rows. + * XM: Do not reset note-off status on portamento if there is no instrument + number. - * [**Bug**] Binaries compiled for winold (Windows XP, Vista, 7, for CPUs - without SSE2 support) did not actually work on CPUs without SSE2 support. - * [**Bug**] libmodplug: Public symbols of the C++ API had `visibility=hidden` - set on non-MSVC systems, which made them not publicly accessible. - * [**Bug**] Project files for Windows 10 desktop builds on ARM and ARM64 - (`build/vs2017win10`) were missing from Windows source package. - * [**Bug**] MSVC project files in Windows source package lacked additional - files required to build DLLs. - - * MO3: Apply playback changes based on "ModPlug-made" header flag. - - * minimp3: Update to commit e9df0760e94044caded36a55d70ab4152134adc5 - (2018-12-23). + * mpg123: v1.26rc3. + * ogg: v1.3.4. + * vorbis: v1.3.6. + * zlib: v1.2.11. + * minimp3: commit 55da78cbeea5fb6757f8df672567714e1e8ca3e9 (2020-03-04). + * stb_vorbis: v1.19 commit 37b9b20fdec06c75a0493e0bb59e2d0f288bfb51 + (2020-02-05). + * miniz: v2.1.0. + * FLAC: v1.3.3. + * PortAudio: commit 799a6834a58592eadc5712cba73b35956dc51579 (2020-03-26). ### libopenmpt 0.4.0 (2018-12-23) diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h index d41324885..912cf04da 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h @@ -559,27 +559,27 @@ LIBOPENMPT_API double openmpt_could_open_probability2( openmpt_stream_callbacks LIBOPENMPT_API size_t openmpt_probe_file_header_get_recommended_size(void); /*! Probe for module formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ -#define OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES 0x1ul +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES 0x1ull /*! Probe for module-specific container formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ -#define OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS 0x2ul +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS 0x2ull /*! Probe for the default set of formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ #define OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT ( OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES | OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS ) /*! Probe for no formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ -#define OPENMPT_PROBE_FILE_HEADER_FLAGS_NONE 0x0ul +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_NONE 0x0ull -/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +/*! Possible return values for openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(): The file will most likely be supported by libopenmpt. \since 0.3.0 */ #define OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS 1 -/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +/*! Possible return values for openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(): The file is not supported by libopenmpt. \since 0.3.0 */ #define OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE 0 -/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +/*! Possible return values for openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(): An answer could not be determined with the amount of data provided. \since 0.3.0 */ #define OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA (-1) -/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +/*! Possible return values for openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(): An internal error occurred. \since 0.3.0 */ #define OPENMPT_PROBE_FILE_HEADER_RESULT_ERROR (-255) /*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it * - * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param flags Bit mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. * \param data Beginning of the file data. * \param size Size of the beginning of the file data. * \param filesize Full size of the file data on disk. @@ -604,7 +604,7 @@ LIBOPENMPT_API size_t openmpt_probe_file_header_get_recommended_size(void); LIBOPENMPT_API int openmpt_probe_file_header( uint64_t flags, const void * data, size_t size, uint64_t filesize, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message ); /*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it * - * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param flags Bit mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. * \param data Beginning of the file data. * \param size Size of the beginning of the file data. * \param logfunc Logging function where warning and errors are written. May be NULL. @@ -630,7 +630,7 @@ LIBOPENMPT_API int openmpt_probe_file_header_without_filesize( uint64_t flags, c /*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it * - * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param flags Bit mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. * \param stream_callbacks Input stream callback operations. * \param stream Input stream to scan. * \param logfunc Logging function where warning and errors are written. May be NULL. @@ -670,7 +670,7 @@ typedef struct openmpt_module_initial_ctl { * \param stream Input stream to load the module from. * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. May be NULL. * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) - * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \param ctls An array of initial ctl and value pairs stored in \ref openmpt_module_initial_ctl, terminated by a pair of NULL and NULL. See \ref openmpt_module_get_ctls and \ref openmpt_module_ctl_set. * \return A pointer to the constructed openmpt_module, or NULL on failure. * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. * \sa openmpt_stream_callbacks @@ -689,7 +689,7 @@ LIBOPENMPT_API LIBOPENMPT_DEPRECATED openmpt_module * openmpt_module_create( ope * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. * \param error Pointer to an integer where an error may get stored. May be NULL. * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. - * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \param ctls An array of initial ctl and value pairs stored in \ref openmpt_module_initial_ctl, terminated by a pair of NULL and NULL. See \ref openmpt_module_get_ctls and \ref openmpt_module_ctl_set. * \return A pointer to the constructed openmpt_module, or NULL on failure. * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. * \sa openmpt_stream_callbacks @@ -704,7 +704,7 @@ LIBOPENMPT_API openmpt_module * openmpt_module_create2( openmpt_stream_callbacks * \param filesize Amount of data available. * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) - * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \param ctls An array of initial ctl and value pairs stored in \ref openmpt_module_initial_ctl, terminated by a pair of NULL and NULL. See \ref openmpt_module_get_ctls and \ref openmpt_module_ctl_set. * \return A pointer to the constructed openmpt_module, or NULL on failure. * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. * \sa \ref libopenmpt_c_fileio @@ -722,7 +722,7 @@ LIBOPENMPT_API LIBOPENMPT_DEPRECATED openmpt_module * openmpt_module_create_from * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. * \param error Pointer to an integer where an error may get stored. May be NULL. * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. - * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \param ctls An array of initial ctl and value pairs stored in \ref openmpt_module_initial_ctl, terminated by a pair of NULL and NULL. See \ref openmpt_module_get_ctls and \ref openmpt_module_ctl_set. * \return A pointer to the constructed openmpt_module, or NULL on failure. * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. * \sa \ref libopenmpt_c_fileio @@ -901,6 +901,7 @@ LIBOPENMPT_API int32_t openmpt_module_get_repeat_count( openmpt_module * mod ); * * \param mod The module handle to work on. * \return Approximate duration of current sub-song in seconds. + * \remarks The function may return infinity if the pattern data is too complex to evaluate. */ LIBOPENMPT_API double openmpt_module_get_duration_seconds( openmpt_module * mod ); @@ -1071,7 +1072,7 @@ LIBOPENMPT_API size_t openmpt_module_read_interleaved_stereo( openmpt_module * m * \param mod The module handle to work on. * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. * \param count Number of audio frames to render per channel. - * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved quad surround output in the order (L,R,RL,RR). * \return The number of frames actually rendered. * \retval 0 The end of song has been reached. * \remarks The output buffers are only written to up to the returned number of elements. @@ -1099,7 +1100,7 @@ LIBOPENMPT_API size_t openmpt_module_read_interleaved_float_stereo( openmpt_modu * \param mod The module handle to work on. * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. * \param count Number of audio frames to render per channel. - * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved quad surround output in the order (L,R,RL,RR). * \return The number of frames actually rendered. * \retval 0 The end of song has been reached. * \remarks The output buffers are only written to up to the returned number of elements. @@ -1122,7 +1123,7 @@ LIBOPENMPT_API const char * openmpt_module_get_metadata_keys( openmpt_module * m * \param mod The module handle to work on. * \param key Metadata item key to query. Use openmpt_module_get_metadata_keys to check for available keys. * Possible keys are: - * - type: Module format extension (e.g. it) + * - type: Module format extension (e.g. it) or another similar identifier for modules formats that typically do not use a file extension * - type_long: Format name associated with the module format (e.g. Impulse Tracker) * - originaltype: Module format extension (e.g. it) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) * - originaltype_long: Format name associated with the module format (e.g. Impulse Tracker) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) @@ -1140,6 +1141,14 @@ LIBOPENMPT_API const char * openmpt_module_get_metadata_keys( openmpt_module * m */ LIBOPENMPT_API const char * openmpt_module_get_metadata( openmpt_module * mod, const char * key ); +/*! Get the current estimated beats per minute (BPM). + * + * \param mod The module handle to work on. + * \remarks Many module formats lack time signature metadata. It is common that this estimate is off by a factor of two, but other multipliers are also possible. + * \remarks Due to the nature of how module tempo works, the estimate may change slightly after switching libopenmpt's output to a different sample rate. + * \return The current estimated BPM. + */ +LIBOPENMPT_API double openmpt_module_get_current_estimated_bpm( openmpt_module * mod ); /*! \brief Get the current speed * * \param mod The module handle to work on. @@ -1150,8 +1159,16 @@ LIBOPENMPT_API int32_t openmpt_module_get_current_speed( openmpt_module * mod ); * * \param mod The module handle to work on. * \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + * \deprecated Please use openmpt_module_get_current_tempo2(). */ -LIBOPENMPT_API int32_t openmpt_module_get_current_tempo( openmpt_module * mod ); +LIBOPENMPT_API LIBOPENMPT_DEPRECATED int32_t openmpt_module_get_current_tempo( openmpt_module * mod ); +/*! \brief Get the current tempo + * + * \param mod The module handle to work on. + * \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + * \since 0.7.0 + */ +LIBOPENMPT_API double openmpt_module_get_current_tempo2( openmpt_module * mod ); /*! \brief Get the current order * * \param mod The module handle to work on. @@ -1396,35 +1413,79 @@ LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmp * \param mod The module handle to work on. * \return A semicolon-separated list containing all supported ctl keys. * \remarks Currently supported ctl values are: - * - load.skip_samples: Set to "1" to avoid loading samples into memory - * - load.skip_patterns: Set to "1" to avoid loading patterns into memory - * - load.skip_plugins: Set to "1" to avoid loading plugins - * - load.skip_subsongs_init: Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. - * - seek.sync_samples: Set to "1" to sync sample playback when using openmpt_module_set_position_seconds or openmpt_module_set_position_order_row. - * - subsong: The current subsong. Setting it has identical semantics as openmpt_module_select_subsong(), getting it returns the currently selected subsong. - * - play.at_end: Chooses the behaviour when the end of song is reached: + * - load.skip_samples (boolean): Set to "1" to avoid loading samples into memory + * - load.skip_patterns (boolean): Set to "1" to avoid loading patterns into memory + * - load.skip_plugins (boolean): Set to "1" to avoid loading plugins + * - load.skip_subsongs_init (boolean): Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. + * - seek.sync_samples (boolean): Set to "0" to not sync sample playback when using openmpt_module_set_position_seconds or openmpt_module_set_position_order_row. + * - subsong (integer): The current subsong. Setting it has identical semantics as openmpt_module_select_subsong(), getting it returns the currently selected subsong. + * - play.at_end (text): Chooses the behaviour when the end of song is reached. The song end is considered to be reached after the number of reptitions set by openmpt_module_set_repeat_count was played, so if the song is set to repeat infinitely, its end is never considered to be reached. * - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. - * - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the song start or loop start. + * - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumsed from the song start). * - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. - * - play.tempo_factor: Set a floating point tempo factor. "1.0" is the default tempo. - * - play.pitch_factor: Set a floating point pitch factor. "1.0" is the default pitch. - * - render.resampler.emulate_amiga: Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. - * - render.opl.volume_factor: Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. - * - dither: Set the dither algorithm that is used for the 16 bit versions of openmpt_module_read. Supported values are: + * - play.tempo_factor (floatingpoint): Set a floating point tempo factor. "1.0" is the default tempo. + * - play.pitch_factor (floatingpoint): Set a floating point pitch factor. "1.0" is the default pitch. + * - render.resampler.emulate_amiga (boolean): Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. + * - render.resampler.emulate_amiga_type (string): Configures the filter type to use for the Amiga resampler. Supported values are: + * - "auto": Filter type is chosen by the library and might change. This is the default. + * - "a500": Amiga A500 filter. + * - "a1200": Amiga A1200 filter. + * - "unfiltered": BLEP synthesis without model-specific filters. The LED filter is ignored by this setting. This filter mode is considered to be experimental and might change in the future. + * - render.opl.volume_factor (floatingpoint): Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. + * - dither (integer): Set the dither algorithm that is used for the 16 bit versions of openmpt_module_read. Supported values are: * - 0: No dithering. * - 1: Default mode. Chosen by OpenMPT code, might change. * - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). * - 3: Rectangular, 1 bit depth, simple 1st order noise shaping */ LIBOPENMPT_API const char * openmpt_module_get_ctls( openmpt_module * mod ); + /*! \brief Get current ctl value * * \param mod The module handle to work on. * \param ctl The ctl key whose value should be retrieved. * \return The associated ctl value, or NULL on failure. * \sa openmpt_module_get_ctls + * \deprecated Please use openmpt_module_ctl_get_boolean(), openmpt_module_ctl_get_integer(), openmpt_module_ctl_get_floatingpoint(), or openmpt_module_ctl_get_text(). */ -LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl ); +LIBOPENMPT_API LIBOPENMPT_DEPRECATED const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl ); +/*! \brief Get current ctl boolean value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be retrieved. + * \return The associated ctl value, or NULL on failure. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int openmpt_module_ctl_get_boolean( openmpt_module * mod, const char * ctl ); +/*! \brief Get current ctl integer value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be retrieved. + * \return The associated ctl value, or NULL on failure. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int64_t openmpt_module_ctl_get_integer( openmpt_module * mod, const char * ctl ); +/*! \brief Get current ctl floatingpoint value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be retrieved. + * \return The associated ctl value, or NULL on failure. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API double openmpt_module_ctl_get_floatingpoint( openmpt_module * mod, const char * ctl ); +/*! \brief Get current ctl string value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be retrieved. + * \return The associated ctl value, or NULL on failure. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API const char * openmpt_module_ctl_get_text( openmpt_module * mod, const char * ctl ); + /*! \brief Set ctl value * * \param mod The module handle to work on. @@ -1432,8 +1493,49 @@ LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const * \param value The value that should be set. * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. * \sa openmpt_module_get_ctls + * \deprecated Please use openmpt_module_ctl_set_boolean(), openmpt_module_ctl_set_integer(), openmpt_module_ctl_set_floatingpoint(), or openmpt_module_ctl_set_text(). */ -LIBOPENMPT_API int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value ); +LIBOPENMPT_API LIBOPENMPT_DEPRECATED int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value ); +/*! \brief Set ctl boolean value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be set. + * \param value The value that should be set. + * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int openmpt_module_ctl_set_boolean( openmpt_module * mod, const char * ctl, int value ); +/*! \brief Set ctl integer value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be set. + * \param value The value that should be set. + * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int openmpt_module_ctl_set_integer( openmpt_module * mod, const char * ctl, int64_t value ); +/*! \brief Set ctl floatingpoint value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be set. + * \param value The value that should be set. + * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int openmpt_module_ctl_set_floatingpoint( openmpt_module * mod, const char * ctl, double value ); +/*! \brief Set ctl string value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be set. + * \param value The value that should be set. + * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. + * \sa openmpt_module_get_ctls + * \since 0.5.0 + */ +LIBOPENMPT_API int openmpt_module_ctl_set_text( openmpt_module * mod, const char * ctl, const char * value ); /* remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp index 55097f830..b35f42066 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp @@ -17,8 +17,10 @@ #include #include #include +#include #include +#include #include /*! @@ -101,7 +103,7 @@ * threads for internal use. * - You must ensure to only ever access a particular libopenmpt object via * non-const member functions from a single thread at a time. - * - You may access a particular libopenmpt objects concurrently from different + * - You may access a particular libopenmpt object concurrently from different * threads when using only const member functions from all threads. * - Consecutive accesses can happen from different threads. * - Different objects can be accessed concurrently from different threads. @@ -125,12 +127,12 @@ /*! \defgroup libopenmpt_cpp libopenmpt C++ */ +namespace openmpt { + /*! \addtogroup libopenmpt_cpp @{ */ -namespace openmpt { - #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4275) @@ -140,17 +142,17 @@ namespace openmpt { Base class used for all exceptions that are thrown by libopenmpt itself. Libopenmpt may additionally throw any exception thrown by the standard library which are all derived from std::exception. \sa \ref libopenmpt_cpp_error */ -class LIBOPENMPT_CXX_API exception : public std::exception { +class LIBOPENMPT_CXX_API_CLASS exception : public std::exception { private: char * text; public: - exception( const std::string & text ) noexcept; - exception( const exception & other ) noexcept; - exception( exception && other ) noexcept; - exception & operator = ( const exception & other ) noexcept; - exception & operator = ( exception && other ) noexcept; - virtual ~exception() noexcept; - const char * what() const noexcept override; + LIBOPENMPT_CXX_API_MEMBER exception( const std::string & text ) noexcept; + LIBOPENMPT_CXX_API_MEMBER exception( const exception & other ) noexcept; + LIBOPENMPT_CXX_API_MEMBER exception( exception && other ) noexcept; + LIBOPENMPT_CXX_API_MEMBER exception & operator = ( const exception & other ) noexcept; + LIBOPENMPT_CXX_API_MEMBER exception & operator = ( exception && other ) noexcept; + LIBOPENMPT_CXX_API_MEMBER virtual ~exception() noexcept; + LIBOPENMPT_CXX_API_MEMBER const char * what() const noexcept override; }; // class exception #if defined(_MSC_VER) #pragma warning(pop) @@ -174,19 +176,19 @@ LIBOPENMPT_CXX_API std::uint32_t get_core_version(); namespace string { //! Return a verbose library version string from openmpt::string::get(). \deprecated Please use `"library_version"` directly. -LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version"; +static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version"; //! Return a verbose library features string from openmpt::string::get(). \deprecated Please use `"library_features"` directly. -LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features"; +static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features"; //! Return a verbose OpenMPT core version string from openmpt::string::get(). \deprecated Please use `"core_version"` directly. -LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version"; +static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version"; //! Return information about the current build (e.g. the build date or compiler used) from openmpt::string::get(). \deprecated Please use `"build"` directly. -LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build"; +static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build"; //! Return all contributors from openmpt::string::get(). \deprecated Please use `"credits"` directly. -LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits"; +static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits"; //! Return contact information about libopenmpt from openmpt::string::get(). \deprecated Please use `"contact"` directly. -LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact"; +static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact"; //! Return the libopenmpt license from openmpt::string::get(). \deprecated Please use `"license"` directly. -LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license"; +static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license"; //! Get library related metadata. /*! @@ -231,8 +233,16 @@ LIBOPENMPT_CXX_API std::vector get_supported_extensions(); /*! \param extension file extension to query without a leading dot. The case is ignored. \return true if the extension is supported by libopenmpt, false otherwise. + \deprecated Please use openmpt::is_extension_supported2(). */ -LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension ); +LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension ); +//! Query whether a file extension is supported +/*! + \param extension file extension to query without a leading dot. The case is ignored. + \return true if the extension is supported by libopenmpt, false otherwise. + \since 0.5.0 +*/ +LIBOPENMPT_CXX_API bool is_extension_supported2( std::string_view extension ); //! Roughly scan the input stream to find out whether libopenmpt might be able to open it /*! @@ -251,9 +261,9 @@ LIBOPENMPT_CXX_API double could_open_probability( std::istream & stream, double //! Roughly scan the input stream to find out whether libopenmpt might be able to open it /*! - \deprecated Please use openmpt::module::could_open_probability(). + \deprecated Please use openmpt::could_open_probability(). */ -LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API LIBOPENMPT_DEPRECATED double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog ); +LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog ); //! Get recommended header size for successfull format probing /*! @@ -262,28 +272,59 @@ LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API LIBOPENMPT_DEPRECATED double could */ LIBOPENMPT_CXX_API std::size_t probe_file_header_get_recommended_size(); -//! Probe for module formats in openmpt::probe_file_header(). \since 0.3.0 -static const std::uint64_t probe_file_header_flags_modules = 0x1ul; +//! Probe for module formats in openmpt::probe_file_header(). \since 0.3.0 \deprecated Please use openmpt::probe_file_header_flags_modules2. +static const std::uint64_t probe_file_header_flags_modules LIBOPENMPT_ATTR_DEPRECATED = 0x1ull; -//! Probe for module-specific container formats in openmpt::probe_file_header(). \since 0.3.0 -static const std::uint64_t probe_file_header_flags_containers = 0x2ul; +//! Probe for module-specific container formats in openmpt::probe_file_header(). \since 0.3.0 \deprecated Please use openmpt::probe_file_header_flags_containers2. +static const std::uint64_t probe_file_header_flags_containers LIBOPENMPT_ATTR_DEPRECATED = 0x2ull; -//! Probe for the default set of formats in openmpt::probe_file_header(). \since 0.3.0 -static const std::uint64_t probe_file_header_flags_default = probe_file_header_flags_modules | probe_file_header_flags_containers; +//! Probe for the default set of formats in openmpt::probe_file_header(). \since 0.3.0 \deprecated Please use openmpt::probe_file_header_flags_default2. +static const std::uint64_t probe_file_header_flags_default LIBOPENMPT_ATTR_DEPRECATED = 0x1ull | 0x2ull; -//! Probe for no formats in openmpt::probe_file_header(). \since 0.3.0 -static const std::uint64_t probe_file_header_flags_none = 0x0ul; +//! Probe for no formats in openmpt::probe_file_header(). \since 0.3.0 \deprecated Please use openmpt::probe_file_header_flags_none2. +static const std::uint64_t probe_file_header_flags_none LIBOPENMPT_ATTR_DEPRECATED = 0x0ull; + +//! Possible values for openmpt::probe_file_header() flags parameter. \since 0.6.0 +enum probe_file_header_flags : std::uint64_t { + //! Probe for module formats in openmpt::probe_file_header(). \since 0.6.0 + probe_file_header_flags_modules2 = 0x1ull, + //! Probe for module-specific container formats in openmpt::probe_file_header(). \since 0.6.0 + probe_file_header_flags_containers2 = 0x2ull, + //! Probe for the default set of formats in openmpt::probe_file_header(). \since 0.6.0 + probe_file_header_flags_default2 = probe_file_header_flags_modules2 | probe_file_header_flags_containers2, + //! Probe for no formats in openmpt::probe_file_header(). \since 0.6.0 + probe_file_header_flags_none2 = 0x0ull +}; //! Possible return values for openmpt::probe_file_header(). \since 0.3.0 enum probe_file_header_result { + //! The file will most likely be supported by libopenmpt. \since 0.3.0 probe_file_header_result_success = 1, + //! The file is not supported by libopenmpt. \since 0.3.0 probe_file_header_result_failure = 0, + //! An answer could not be determined with the amount of data provided. \since 0.3.0 probe_file_header_result_wantmoredata = -1 }; //! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it /*! - \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param flags Bit mask of openmpt::probe_file_header_flags_modules2 and openmpt::probe_file_header_flags_containers2, or openmpt::probe_file_header_flags_default2. + \param data Beginning of the file data. + \param size Size of the beginning of the file data. + \param filesize Full size of the file data on disk. + \remarks It is recommended to provide openmpt::probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size and filesize to the file's size. + \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. + \retval probe_file_header_result_success The file will most likely be supported by libopenmpt. + \retval probe_file_header_result_failure The file is not supported by libopenmpt. + \retval probe_file_header_result_wantmoredata An answer could not be determined with the amount of data provided. + \sa openmpt::probe_file_header_get_recommended_size() + \sa openmpt::could_open_probability() + \since 0.5.0 +*/ +LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::byte * data, std::size_t size, std::uint64_t filesize ); +//! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it +/*! + \param flags Bit mask of openmpt::probe_file_header_flags_modules2 and openmpt::probe_file_header_flags_containers2, or openmpt::probe_file_header_flags_default2. \param data Beginning of the file data. \param size Size of the beginning of the file data. \param filesize Full size of the file data on disk. @@ -300,7 +341,23 @@ LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::uint8_ //! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it /*! - \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param flags Bit mask of openmpt::probe_file_header_flags_modules2 and openmpt::probe_file_header_flags_containers2, or openmpt::probe_file_header_flags_default2. + \param data Beginning of the file data. + \param size Size of the beginning of the file data. + \remarks It is recommended to use the overload of this function that also takes the filesize as parameter if at all possile. libopenmpt can provide more accurate answers if the filesize is known. + \remarks It is recommended to provide openmpt::probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size to the file's size. + \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. + \retval probe_file_header_result_success The file will most likely be supported by libopenmpt. + \retval probe_file_header_result_failure The file is not supported by libopenmpt. + \retval probe_file_header_result_wantmoredata An answer could not be determined with the amount of data provided. + \sa openmpt::probe_file_header_get_recommended_size() + \sa openmpt::could_open_probability() + \since 0.5.0 +*/ +LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::byte * data, std::size_t size ); +//! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it +/*! + \param flags Bit mask of openmpt::probe_file_header_flags_modules2 and openmpt::probe_file_header_flags_containers2, or openmpt::probe_file_header_flags_default2. \param data Beginning of the file data. \param size Size of the beginning of the file data. \remarks It is recommended to use the overload of this function that also takes the filesize as parameter if at all possile. libopenmpt can provide more accurate answers if the filesize is known. @@ -317,7 +374,7 @@ LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::uint8_ //! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it /*! - \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param flags Bit mask of openmpt::probe_file_header_flags_modules2 and openmpt::probe_file_header_flags_containers2, or openmpt::probe_file_header_flags_default2. \param stream Input stream to scan. \remarks stream is left in an unspecified state when this function returns. \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. @@ -340,7 +397,7 @@ typedef std::map< std::string, std::string > initial_ctls_map; } // namespace detail -class LIBOPENMPT_CXX_API module { +class LIBOPENMPT_CXX_API_CLASS module { friend class module_ext; @@ -411,21 +468,53 @@ public: /*! \param stream Input stream from which the module is loaded. After the constructor has finished successfully, the input position of stream is set to the byte after the last byte that has been read. If the constructor fails, the state of the input position of stream is undefined. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. - \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \param ctls A map of initial ctl values, see \ref openmpt::module::get_ctls and openmpt::module::ctl_set. \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see \ref openmpt::module::get_ctls and openmpt::module::ctl_set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param beg Begin of data to load the module from. + \param end End of data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see \ref openmpt::module::get_ctls and openmpt::module::ctl_set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER module( const std::byte * beg, const std::byte * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param size Amount of data available. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio + \since 0.5.0 */ - module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const std::byte * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see \ref openmpt::module::get_ctls and openmpt::module::ctl_set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + LIBOPENMPT_CXX_API_MEMBER module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param beg Begin of data to load the module from. \param end End of data to load the module from. @@ -435,7 +524,7 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param data Data to load the module from. \param size Amount of data available. @@ -445,7 +534,7 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. @@ -454,7 +543,7 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param beg Begin of data to load the module from. \param end End of data to load the module from. @@ -464,7 +553,7 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param data Data to load the module from. \param size Amount of data available. @@ -474,7 +563,7 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); /*! \param data Data to load the module from. \param size Amount of data available. @@ -484,8 +573,8 @@ public: \remarks The input data can be discarded after an openmpt::module has been constructed successfully. \sa \ref libopenmpt_cpp_fileio */ - module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); - virtual ~module(); + LIBOPENMPT_CXX_API_MEMBER module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER virtual ~module(); public: //! Select a sub-song from a multi-song module @@ -495,14 +584,14 @@ public: \sa openmpt::module::get_num_subsongs, openmpt::module::get_selected_subsong, openmpt::module::get_subsong_names \remarks Whether subsong -1 (all subsongs consecutively), subsong 0 or some other subsong is selected by default, is an implementation detail and subject to change. If you do not want to care about subsongs, it is recommended to just not call openmpt::module::select_subsong() at all. */ - void select_subsong( std::int32_t subsong ); + LIBOPENMPT_CXX_API_MEMBER void select_subsong( std::int32_t subsong ); //! Get currently selected sub-song from a multi-song module /*! \return Currently selected sub-song. -1 for all subsongs consecutively, 0 or greater for the current sub-song index. \sa openmpt::module::get_num_subsongs, openmpt::module::select_subsong, openmpt::module::get_subsong_names \since 0.3.0 */ - std::int32_t get_selected_subsong() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_selected_subsong() const; //! Set Repeat Count /*! \param repeat_count Repeat Count @@ -511,7 +600,7 @@ public: - n>0: play once and repeat n times after that \sa openmpt::module::get_repeat_count */ - void set_repeat_count( std::int32_t repeat_count ); + LIBOPENMPT_CXX_API_MEMBER void set_repeat_count( std::int32_t repeat_count ); //! Get Repeat Count /*! \return Repeat Count @@ -520,13 +609,14 @@ public: - n>0: play once and repeat n times after that \sa openmpt::module::set_repeat_count */ - std::int32_t get_repeat_count() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_repeat_count() const; //! Get approximate song duration /*! \return Approximate duration of current sub-song in seconds. + \remarks The function may return infinity if the pattern data is too complex to evaluate. */ - double get_duration_seconds() const; + LIBOPENMPT_CXX_API_MEMBER double get_duration_seconds() const; //! Set approximate current song position /*! @@ -534,13 +624,13 @@ public: \return Approximate new song position in seconds. \sa openmpt::module::get_position_seconds */ - double set_position_seconds( double seconds ); + LIBOPENMPT_CXX_API_MEMBER double set_position_seconds( double seconds ); //! Get current song position /*! \return Current song position in seconds. \sa openmpt::module::set_position_seconds */ - double get_position_seconds() const; + LIBOPENMPT_CXX_API_MEMBER double get_position_seconds() const; //! Set approximate current song position /*! @@ -551,7 +641,7 @@ public: \sa openmpt::module::set_position_seconds \sa openmpt::module::get_position_seconds */ - double set_position_order_row( std::int32_t order, std::int32_t row ); + LIBOPENMPT_CXX_API_MEMBER double set_position_order_row( std::int32_t order, std::int32_t row ); //! Get render parameter /*! @@ -561,7 +651,7 @@ public: \sa openmpt::module::render_param \sa openmpt::module::set_render_param */ - std::int32_t get_render_param( int param ) const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_render_param( int param ) const; //! Set render parameter /*! \param param Parameter to set. See openmpt::module::render_param. @@ -570,7 +660,7 @@ public: \sa openmpt::module::render_param \sa openmpt::module::get_render_param */ - void set_render_param( int param, std::int32_t value ); + LIBOPENMPT_CXX_API_MEMBER void set_render_param( int param, std::int32_t value ); /*@{*/ //! Render audio data @@ -585,7 +675,7 @@ public: \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -599,7 +689,7 @@ public: \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -615,7 +705,7 @@ public: \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -628,7 +718,7 @@ public: \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, float * mono ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, float * mono ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -642,7 +732,7 @@ public: \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -658,7 +748,7 @@ public: \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -671,12 +761,12 @@ public: \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. \param count Number of audio frames to render per channel. - \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved quad surround output in the order (L,R,RL,RR). \return The number of frames actually rendered. \retval 0 The end of song has been reached. \remarks The output buffers are only written to up to the returned number of elements. @@ -684,7 +774,7 @@ public: \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. @@ -697,12 +787,12 @@ public: \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo ); //! Render audio data /*! \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. \param count Number of audio frames to render per channel. - \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved quad surround output in the order (L,R,RL,RR). \return The number of frames actually rendered. \retval 0 The end of song has been reached. \remarks The output buffers are only written to up to the returned number of elements. @@ -710,7 +800,7 @@ public: \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. \sa \ref libopenmpt_cpp_outputformat */ - std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad ); + LIBOPENMPT_CXX_API_MEMBER std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad ); /*@}*/ //! Get the list of supported metadata item keys @@ -718,12 +808,12 @@ public: \return Metadata item keys supported by openmpt::module::get_metadata \sa openmpt::module::get_metadata */ - std::vector get_metadata_keys() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_metadata_keys() const; //! Get a metadata item value /*! \param key Metadata item key to query. Use openmpt::module::get_metadata_keys to check for available keys. Possible keys are: - - type: Module format extension (e.g. it) + - type: Module format extension (e.g. it) or another similar identifier for modules formats that typically do not use a file extension - type_long: Format name associated with the module format (e.g. Impulse Tracker) - originaltype: Module format extension (e.g. it) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) - originaltype_long: Format name associated with the module format (e.g. Impulse Tracker) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) @@ -739,38 +829,52 @@ public: \return The associated value for key. \sa openmpt::module::get_metadata_keys */ - std::string get_metadata( const std::string & key ) const; + LIBOPENMPT_CXX_API_MEMBER std::string get_metadata( const std::string & key ) const; + //! Get the current estimated beats per minute (BPM). + /*! + \remarks Many module formats lack time signature metadata. It is common that this estimate is off by a factor of two, but other multipliers are also possible. + \remarks Due to the nature of how module tempo works, the estimate may change slightly after switching libopenmpt's output to a different sample rate. + \return The current estimated BPM. + */ + LIBOPENMPT_CXX_API_MEMBER double get_current_estimated_bpm() const; //! Get the current speed /*! \return The current speed in ticks per row. */ - std::int32_t get_current_speed() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_speed() const; //! Get the current tempo /*! \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + \deprecated Please use openmpt::module::get_current_tempo2(). */ - std::int32_t get_current_tempo() const; + LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_tempo() const; + //! Get the current tempo + /*! + \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + \since 0.7.0 + */ + LIBOPENMPT_CXX_API_MEMBER double get_current_tempo2() const; //! Get the current order /*! \return The current order at which the module is being played back. */ - std::int32_t get_current_order() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_order() const; //! Get the current pattern /*! \return The current pattern that is being played. */ - std::int32_t get_current_pattern() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_pattern() const; //! Get the current row /*! \return The current row at which the current pattern is being played. */ - std::int32_t get_current_row() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_row() const; //! Get the current amount of playing channels. /*! \return The amount of sample channels that are currently being rendered. */ - std::int32_t get_current_playing_channels() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_current_playing_channels() const; //! Get an approximate indication of the channel volume. /*! @@ -778,119 +882,119 @@ public: \return The approximate channel volume. \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. */ - float get_current_channel_vu_mono( std::int32_t channel ) const; + LIBOPENMPT_CXX_API_MEMBER float get_current_channel_vu_mono( std::int32_t channel ) const; //! Get an approximate indication of the channel volume on the front-left speaker. /*! \param channel The channel whose volume should be retrieved. \return The approximate channel volume. \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. */ - float get_current_channel_vu_left( std::int32_t channel ) const; + LIBOPENMPT_CXX_API_MEMBER float get_current_channel_vu_left( std::int32_t channel ) const; //! Get an approximate indication of the channel volume on the front-right speaker. /*! \param channel The channel whose volume should be retrieved. \return The approximate channel volume. \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. */ - float get_current_channel_vu_right( std::int32_t channel ) const; + LIBOPENMPT_CXX_API_MEMBER float get_current_channel_vu_right( std::int32_t channel ) const; //! Get an approximate indication of the channel volume on the rear-left speaker. /*! \param channel The channel whose volume should be retrieved. \return The approximate channel volume. \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. */ - float get_current_channel_vu_rear_left( std::int32_t channel ) const; + LIBOPENMPT_CXX_API_MEMBER float get_current_channel_vu_rear_left( std::int32_t channel ) const; //! Get an approximate indication of the channel volume on the rear-right speaker. /*! \param channel The channel whose volume should be retrieved. \return The approximate channel volume. \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. */ - float get_current_channel_vu_rear_right( std::int32_t channel ) const; + LIBOPENMPT_CXX_API_MEMBER float get_current_channel_vu_rear_right( std::int32_t channel ) const; //! Get the number of sub-songs /*! \return The number of sub-songs in the module. This includes any "hidden" songs (songs that share the same sequence, but start at different order indices) and "normal" sub-songs or "sequences" (if the format supports them). \sa openmpt::module::get_subsong_names, openmpt::module::select_subsong, openmpt::module::get_selected_subsong */ - std::int32_t get_num_subsongs() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_subsongs() const; //! Get the number of pattern channels /*! \return The number of pattern channels in the module. Not all channels do necessarily contain data. \remarks The number of pattern channels is completely independent of the number of output channels. libopenmpt can render modules in mono, stereo or quad surround, but the choice of which of the three modes to use must not be made based on the return value of this function, which may be any positive integer amount. Only use this function for informational purposes. */ - std::int32_t get_num_channels() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_channels() const; //! Get the number of orders /*! \return The number of orders in the current sequence of the module. */ - std::int32_t get_num_orders() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_orders() const; //! Get the number of patterns /*! \return The number of distinct patterns in the module. */ - std::int32_t get_num_patterns() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_patterns() const; //! Get the number of instruments /*! \return The number of instrument slots in the module. Instruments are a layer on top of samples, and are not supported by all module formats. */ - std::int32_t get_num_instruments() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_instruments() const; //! Get the number of samples /*! \return The number of sample slots in the module. */ - std::int32_t get_num_samples() const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_num_samples() const; //! Get a list of sub-song names /*! \return All sub-song names. \sa openmpt::module::get_num_subsongs, openmpt::module::select_subsong, openmpt::module::get_selected_subsong */ - std::vector get_subsong_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_subsong_names() const; //! Get a list of channel names /*! \return All channel names. \sa openmpt::module::get_num_channels */ - std::vector get_channel_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_channel_names() const; //! Get a list of order names /*! \return All order names. \sa openmpt::module::get_num_orders */ - std::vector get_order_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_order_names() const; //! Get a list of pattern names /*! \return All pattern names. \sa openmpt::module::get_num_patterns */ - std::vector get_pattern_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_pattern_names() const; //! Get a list of instrument names /*! \return All instrument names. \sa openmpt::module::get_num_instruments */ - std::vector get_instrument_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_instrument_names() const; //! Get a list of sample names /*! \return All sample names. \sa openmpt::module::get_num_samples */ - std::vector get_sample_names() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_sample_names() const; //! Get pattern at order position /*! \param order The order item whose pattern index should be retrieved. \return The pattern index found at the given order position of the current sequence. */ - std::int32_t get_order_pattern( std::int32_t order ) const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_order_pattern( std::int32_t order ) const; //! Get the number of rows in a pattern /*! \param pattern The pattern whose row count should be retrieved. \return The number of rows in the given pattern. If the pattern does not exist, 0 is returned. */ - std::int32_t get_pattern_num_rows( std::int32_t pattern ) const; + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_pattern_num_rows( std::int32_t pattern ) const; //! Get raw pattern content /*! @@ -900,7 +1004,7 @@ public: \param command The cell index at which the data should be retrieved. See openmpt::module::command_index \return The internal, raw pattern data at the given pattern position. */ - std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + LIBOPENMPT_CXX_API_MEMBER std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; //! Get formatted (human-readable) pattern content /*! @@ -911,7 +1015,7 @@ public: \return The formatted pattern data at the given pattern position. See openmpt::module::command_index \sa openmpt::module::highlight_pattern_row_channel_command */ - std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + LIBOPENMPT_CXX_API_MEMBER std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; //! Get highlighting information for formatted pattern content /*! @@ -933,7 +1037,7 @@ public: - "f" : generic effect column parameter \sa openmpt::module::get_pattern_row_channel_command */ - std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + LIBOPENMPT_CXX_API_MEMBER std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; //! Get formatted (human-readable) pattern content /*! @@ -945,7 +1049,7 @@ public: \return The formatted pattern data at the given pattern position. \sa openmpt::module::highlight_pattern_row_channel */ - std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + LIBOPENMPT_CXX_API_MEMBER std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; //! Get highlighting information for formatted pattern content /*! \param pattern The pattern whose data should be retrieved. @@ -956,27 +1060,32 @@ public: \return The highlighting string for the formatted pattern data as retrieved by openmpt::module::format_pattern_row_channel at the given pattern position. \sa openmpt::module::format_pattern_row_channel */ - std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + LIBOPENMPT_CXX_API_MEMBER std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; //! Retrieve supported ctl keys /*! \return A vector containing all supported ctl keys. \remarks Currently supported ctl values are: - - load.skip_samples: Set to "1" to avoid loading samples into memory - - load.skip_patterns: Set to "1" to avoid loading patterns into memory - - load.skip_plugins: Set to "1" to avoid loading plugins - - load.skip_subsongs_init: Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. - - seek.sync_samples: Set to "1" to sync sample playback when using openmpt::module::set_position_seconds or openmpt::module::set_position_order_row. - - subsong: The current subsong. Setting it has identical semantics as openmpt::module::select_subsong(), getting it returns the currently selected subsong. - - play.at_end: Chooses the behaviour when the end of song is reached: + - load.skip_samples (boolean): Set to "1" to avoid loading samples into memory + - load.skip_patterns (boolean): Set to "1" to avoid loading patterns into memory + - load.skip_plugins (boolean): Set to "1" to avoid loading plugins + - load.skip_subsongs_init (boolean): Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. + - seek.sync_samples (boolean): Set to "0" to not sync sample playback when using openmpt::module::set_position_seconds or openmpt::module::set_position_order_row. + - subsong (integer): The current subsong. Setting it has identical semantics as openmpt::module::select_subsong(), getting it returns the currently selected subsong. + - play.at_end (text): Chooses the behaviour when the end of song is reached. The song end is considered to be reached after the number of reptitions set by openmpt::module::set_repeat_count was played, so if the song is set to repeat infinitely, its end is never considered to be reached. - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. - - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the song start or loop start. + - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumsed from the song start). - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. - - play.tempo_factor: Set a floating point tempo factor. "1.0" is the default tempo. - - play.pitch_factor: Set a floating point pitch factor. "1.0" is the default pitch. - - render.resampler.emulate_amiga: Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. - - render.opl.volume_factor: Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. - - dither: Set the dither algorithm that is used for the 16 bit versions of openmpt::module::read. Supported values are: + - play.tempo_factor (floatingpoint): Set a floating point tempo factor. "1.0" is the default tempo. + - play.pitch_factor (floatingpoint): Set a floating point pitch factor. "1.0" is the default pitch. + - render.resampler.emulate_amiga (boolean): Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. + - render.resampler.emulate_amiga_type (string): Configures the filter type to use for the Amiga resampler. Supported values are: + - "auto": Filter type is chosen by the library and might change. This is the default. + - "a500": Amiga A500 filter. + - "a1200": Amiga A1200 filter. + - "unfiltered": BLEP synthesis without model-specific filters. The LED filter is ignored by this setting. This filter mode is considered to be experimental and might change in the future. + - render.opl.volume_factor (floatingpoint): Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. + - dither (integer): Set the dither algorithm that is used for the 16 bit versions of openmpt::module::read. Supported values are: - 0: No dithering. - 1: Default mode. Chosen by OpenMPT code, might change. - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). @@ -984,32 +1093,103 @@ public: An exclamation mark ("!") or a question mark ("?") can be appended to any ctl key in order to influence the behaviour in case of an unknown ctl key. "!" causes an exception to be thrown; "?" causes the ctl to be silently ignored. In case neither is appended to the key name, unknown init_ctls are ignored by default and other ctls throw an exception by default. */ - std::vector get_ctls() const; + LIBOPENMPT_CXX_API_MEMBER std::vector get_ctls() const; //! Get current ctl value /*! \param ctl The ctl key whose value should be retrieved. \return The associated ctl value. \sa openmpt::module::get_ctls + \deprecated Please use openmpt::module::ctl_get_boolean(), openmpt::module::ctl_get_integer(), openmpt::module::ctl_get_floatingpoint(), or openmpt::module::ctl_get_text(). */ - std::string ctl_get( const std::string & ctl ) const; + LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API_MEMBER std::string ctl_get( const std::string & ctl ) const; + //! Get current ctl boolean value + /*! + \param ctl The ctl key whose value should be retrieved. + \return The associated ctl value. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER bool ctl_get_boolean( std::string_view ctl ) const; + //! Get current ctl integer value + /*! + \param ctl The ctl key whose value should be retrieved. + \return The associated ctl value. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER std::int64_t ctl_get_integer( std::string_view ctl ) const; + //! Get current ctl floatingpoint value + /*! + \param ctl The ctl key whose value should be retrieved. + \return The associated ctl value. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER double ctl_get_floatingpoint( std::string_view ctl ) const; + //! Get current ctl text value + /*! + \param ctl The ctl key whose value should be retrieved. + \return The associated ctl value. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER std::string ctl_get_text( std::string_view ctl ) const; + //! Set ctl value /*! \param ctl The ctl key whose value should be set. \param value The value that should be set. \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. \sa openmpt::module::get_ctls + \deprecated Please use openmpt::module::ctl_set_boolean(), openmpt::module::ctl_set_integer(), openmpt::module::ctl_set_floatingpoint(), or openmpt::module::ctl_set_text(). */ - void ctl_set( const std::string & ctl, const std::string & value ); + LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API_MEMBER void ctl_set( const std::string & ctl, const std::string & value ); + //! Set ctl boolean value + /*! + \param ctl The ctl key whose value should be set. + \param value The value that should be set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER void ctl_set_boolean( std::string_view ctl, bool value ); + //! Set ctl integer value + /*! + \param ctl The ctl key whose value should be set. + \param value The value that should be set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER void ctl_set_integer( std::string_view ctl, std::int64_t value ); + //! Set ctl floatingpoint value + /*! + \param ctl The ctl key whose value should be set. + \param value The value that should be set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER void ctl_set_floatingpoint( std::string_view ctl, double value ); + //! Set ctl text value + /*! + \param ctl The ctl key whose value should be set. + \param value The value that should be set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. + \sa openmpt::module::get_ctls + \since 0.5.0 + */ + LIBOPENMPT_CXX_API_MEMBER void ctl_set_text( std::string_view ctl, std::string_view value ); // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR }; // class module -} // namespace openmpt - /*! @} */ +} // namespace openmpt + #endif // LIBOPENMPT_HPP diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h index 0323ab1e0..ca77f596f 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h @@ -10,6 +10,8 @@ #ifndef LIBOPENMPT_CONFIG_H #define LIBOPENMPT_CONFIG_H +/* clang-format off */ + /*! \defgroup libopenmpt libopenmpt */ /*! \addtogroup libopenmpt @@ -22,11 +24,28 @@ #define LIBOPENMPT_CXX_API #undef LIBOPENMPT_CXX_API -/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_buffer.h exists. */ +/*! + @} +*/ + +/*! \addtogroup libopenmpt_c + @{ +*/ + +/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_buffer.h exists. + * \remarks + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_BUFFER) + * #include + * #endif + * \endcode + */ #define LIBOPENMPT_STREAM_CALLBACKS_BUFFER /*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_fd.h exists. - * \since 0.3 + * \since 0.3.0 * \remarks * Use the following to check for availability: * \code @@ -39,7 +58,7 @@ #define LIBOPENMPT_STREAM_CALLBACKS_FD /*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file.h exists. - * \since 0.3 + * \since 0.3.0 * \remarks * Use the following to check for availability: * \code @@ -51,6 +70,74 @@ */ #define LIBOPENMPT_STREAM_CALLBACKS_FILE + /*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file_mingw.h exists. + * \since 0.7.0 + * \remarks + * This macro does not determine if the interfaces required to use libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h are available. + * It is the libopenmpt user's responsibility to check for availability of the _off64_t, _ftelli64(), and _fseeki64(). + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW + + /*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h exists. + * \since 0.7.0 + * \remarks + * This macro does not determine if the interfaces required to use libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h are available. + * It is the libopenmpt user's responsibility to check for availability of the __int64, _ftelli64(), and _fseeki64(). + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT + + /*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file_posix.h exists. + * \since 0.7.0 + * \remarks + * This macro does not determine if the interfaces required to use libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h are available. + * It is the libopenmpt user's responsibility to check for availability of the _off_t, ftello(), and fseeko(). + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX + +/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h exists. + * \since 0.7.0 + * \remarks + * This macro does not determine if the interfaces required to use libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h are available. + * It is the libopenmpt user's responsibility to check for availability of the off64_t, ftello64(), and fseeko64(). + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64 + +/*! + @} +*/ + +/*! \addtogroup libopenmpt + @{ +*/ + #if defined(__DOXYGEN__) #define LIBOPENMPT_API_HELPER_EXPORT @@ -62,8 +149,15 @@ #define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) #define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport) -#define LIBOPENMPT_API_HELPER_PUBLIC -#define LIBOPENMPT_API_HELPER_LOCAL +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#ifdef __cplusplus +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS +#endif #elif defined(__EMSCRIPTEN__) @@ -72,6 +166,17 @@ #define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) __attribute__((used)) #define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) +#ifdef __cplusplus +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS __attribute__((visibility("hidden"))) +#define LIBOPENMPT_API_HELPER_EXPORT_MEMBER __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_IMPORT_MEMBER __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_PUBLIC_MEMBER __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_LOCAL_MEMBER __attribute__((visibility("hidden"))) +#endif + #elif (defined(__GNUC__) || defined(__clang__)) && defined(_WIN32) #define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) @@ -79,6 +184,13 @@ #define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) #define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) +#ifdef __cplusplus +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS __attribute__((visibility("hidden"))) +#endif + #elif defined(__GNUC__) || defined(__clang__) #define LIBOPENMPT_API_HELPER_EXPORT __attribute__((visibility("default"))) @@ -86,12 +198,28 @@ #define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) #define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) +#ifdef __cplusplus +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS __attribute__((visibility("hidden"))) +#endif + #elif defined(_WIN32) #define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) #define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport) -#define LIBOPENMPT_API_HELPER_PUBLIC -#define LIBOPENMPT_API_HELPER_LOCAL +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#ifdef __cplusplus + +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS + +#endif #else @@ -102,33 +230,71 @@ #endif +#ifdef __cplusplus + +#ifndef LIBOPENMPT_API_HELPER_EXPORT_CLASS +#define LIBOPENMPT_API_HELPER_EXPORT_CLASS +#endif +#ifndef LIBOPENMPT_API_HELPER_EXPORT_MEMBER +#define LIBOPENMPT_API_HELPER_EXPORT_MEMBER +#endif +#ifndef LIBOPENMPT_API_HELPER_IMPORT_CLASS +#define LIBOPENMPT_API_HELPER_IMPORT_CLASS +#endif +#ifndef LIBOPENMPT_API_HELPER_IMPORT_MEMBER +#define LIBOPENMPT_API_HELPER_IMPORT_MEMBER +#endif +#ifndef LIBOPENMPT_API_HELPER_PUBLIC_CLASS +#define LIBOPENMPT_API_HELPER_PUBLIC_CLASS +#endif +#ifndef LIBOPENMPT_API_HELPER_PUBLIC_MEMBER +#define LIBOPENMPT_API_HELPER_PUBLIC_MEMBER +#endif +#ifndef LIBOPENMPT_API_HELPER_LOCAL_CLASS +#define LIBOPENMPT_API_HELPER_LOCAL_CLASS +#endif +#ifndef LIBOPENMPT_API_HELPER_LOCAL_MEMBER +#define LIBOPENMPT_API_HELPER_LOCAL_MEMBER +#endif + +#endif + #if defined(LIBOPENMPT_BUILD_DLL) -#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_EXPORT +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_EXPORT #elif defined(LIBOPENMPT_USE_DLL) -#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_IMPORT +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_IMPORT #else -#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_PUBLIC #endif #ifdef __cplusplus -#define LIBOPENMPT_CXX_API LIBOPENMPT_API +#if defined(LIBOPENMPT_BUILD_DLL) +#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_EXPORT +#define LIBOPENMPT_CXX_API_CLASS LIBOPENMPT_API_HELPER_EXPORT_CLASS +#define LIBOPENMPT_CXX_API_MEMBER LIBOPENMPT_API_HELPER_EXPORT_MEMBER +#elif defined(LIBOPENMPT_USE_DLL) +#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_IMPORT +#define LIBOPENMPT_CXX_API_CLASS LIBOPENMPT_API_HELPER_IMPORT_CLASS +#define LIBOPENMPT_CXX_API_MEMBER LIBOPENMPT_API_HELPER_IMPORT_MEMBER +#else +#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_CXX_API_CLASS LIBOPENMPT_API_HELPER_PUBLIC_CLASS +#define LIBOPENMPT_CXX_API_MEMBER LIBOPENMPT_API_HELPER_PUBLIC_MEMBER +#endif #if defined(LIBOPENMPT_USE_DLL) #if defined(_MSC_VER) && !defined(_DLL) #error "C++ interface is disabled if libopenmpt is built as a DLL and the runtime is statically linked. This is not supported by microsoft and cannot possibly work. Ever." #undef LIBOPENMPT_CXX_API #define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL +#undef LIBOPENMPT_CXX_API_CLASS +#define LIBOPENMPT_CXX_API_CLASS LIBOPENMPT_API_HELPER_LOCAL_CLASS +#undef LIBOPENMPT_CXX_API_MEMBER +#define LIBOPENMPT_CXX_API_MEMBER LIBOPENMPT_API_HELPER_LOCAL_MEMBER #endif #endif -#if defined(__EMSCRIPTEN__) - -/* Only the C API is supported for emscripten. Disable the C++ API. */ -#undef LIBOPENMPT_CXX_API -#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL -#endif - #endif /*! @@ -148,6 +314,8 @@ #else #define LIBOPENMPT_DEPRECATED #endif +#else +#define LIBOPENMPT_DEPRECATED #endif #ifndef __cplusplus @@ -157,6 +325,18 @@ LIBOPENMPT_DEPRECATED static const int LIBOPENMPT_DEPRECATED_STRING_CONSTANT = 0 #else #define LIBOPENMPT_DEPRECATED_STRING( str ) str #endif +#else +#define LIBOPENMPT_DEPRECATED_STRING( str ) str +#endif + +#if defined(__STDC__) && (__STDC__ == 1) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#define LIBOPENMPT_C_INLINE inline +#else +#define LIBOPENMPT_C_INLINE +#endif +#else +#define LIBOPENMPT_C_INLINE #endif @@ -164,41 +344,20 @@ LIBOPENMPT_DEPRECATED static const int LIBOPENMPT_DEPRECATED_STRING_CONSTANT = 0 #ifdef __cplusplus -#ifndef LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED -/* handle known broken compilers here by defining LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED appropriately */ -#endif - #if defined(LIBOPENMPT_ASSUME_CPLUSPLUS) -#ifndef LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED -#define LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED LIBOPENMPT_ASSUME_CPLUSPLUS -#endif #endif #if !defined(LIBOPENMPT_NO_DEPRECATE) -#if defined(LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED) -#if (LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED >= 201402L) #define LIBOPENMPT_ATTR_DEPRECATED [[deprecated]] -#undef LIBOPENMPT_DEPRECATED -#define LIBOPENMPT_DEPRECATED #else #define LIBOPENMPT_ATTR_DEPRECATED #endif -#elif (__cplusplus >= 201402L) -#define LIBOPENMPT_ATTR_DEPRECATED [[deprecated]] -#undef LIBOPENMPT_DEPRECATED -#define LIBOPENMPT_DEPRECATED -#else -#define LIBOPENMPT_ATTR_DEPRECATED -#endif -#else -#undef LIBOPENMPT_DEPRECATED -#define LIBOPENMPT_DEPRECATED -#define LIBOPENMPT_ATTR_DEPRECATED -#endif #endif +/* clang-format on */ + #include "libopenmpt_version.h" #endif /* LIBOPENMPT_CONFIG_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h index e76f758de..5263c5bd9 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h @@ -162,8 +162,9 @@ typedef struct openmpt_module_ext_interface_interactive { * \return 1 on success, 0 on failure. * \remarks The tempo may be reset by pattern commands at any time. Use openmpt_module_ext_interface_interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. * \sa openmpt_module_get_current_tempo + * \deprecated Please use openmpt_module_ext_interface_interactive3::set_current_tempo2(). */ - int ( * set_current_tempo ) ( openmpt_module_ext * mod_ext, int32_t tempo ); + LIBOPENMPT_DEPRECATED int ( * set_current_tempo ) ( openmpt_module_ext * mod_ext, int32_t tempo ); /*! Set the current module tempo factor without affecting playback pitch * @@ -287,21 +288,128 @@ typedef struct openmpt_module_ext_interface_interactive { * \param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center. * \return The channel on which the note is played. This can pe be passed to openmpt_module_ext_interface_interactive::stop_note to stop the note. -1 means that no channel could be allocated and the note is not played. * \sa openmpt_module_ext_interface_interactive::stop_note + * \sa openmpt_module_ext_interface_interactive2::note_off + * \sa openmpt_module_ext_interface_interactive2::note_fade */ int32_t ( * play_note ) ( openmpt_module_ext * mod_ext, int32_t instrument, int32_t note, double volume, double panning ); /*! Stop the note playing on the specified channel * * \param mod_ext The module handle to work on. - * \param channel The channel on which the note should be stopped. + * \param channel The channel on which the note should be stopped. This is the value returned by a previous play_note call. * \return 1 on success, 0 on failure (channel out of range). * \sa openmpt_module_ext_interface_interactive::play_note + * \sa openmpt_module_ext_interface_interactive2::note_off + * \sa openmpt_module_ext_interface_interactive2::note_fade */ int ( * stop_note ) ( openmpt_module_ext * mod_ext, int32_t channel ); + } openmpt_module_ext_interface_interactive; +#ifndef LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE2 +#define LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE2 "interactive2" +#endif + +typedef struct openmpt_module_ext_interface_interactive2 { + //! Sends a key-off command for the note playing on the specified channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel on which the key-off event should be triggered. This is the value returned by a previous play_note call. + * \return 1 on success, 0 on failure (channel out of range). + * \remarks This method releases envelopes and sample sustain loops. If the sample has no sustain loop, or if the module does not use instruments, it does nothing. + * \sa openmpt_module_ext_interface_interactive::play_note + * \sa openmpt_module_ext_interface_interactive::stop_note + * \sa openmpt_module_ext_interface_interactive2::note_fade + * \since 0.6.0 + */ + int ( *note_off ) ( openmpt_module_ext * mod_ext, int32_t channel ); + + //! Sends a note fade command for the note playing on the specified channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel on which the note should be faded. This is the value returned by a previous play_note call. + * \return 1 on success, 0 on failure (channel out of range). + * \remarks This method uses the instrument's fade-out value. If the module does not use instruments, or the instrument's fade-out value is 0, it does nothing. + * \sa openmpt_module_ext_interface_interactive::play_note + * \sa openmpt_module_ext_interface_interactive::stop_note + * \sa openmpt_module_ext_interface_interactive2::note_fade + * \since 0.6.0 + */ + int ( *note_fade ) ( openmpt_module_ext * mod_ext, int32_t channel ); + + //! Set the current panning for a channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel that should be panned. This is the value returned by a previous play_note call. + * \param panning The panning position to set on the channel, in range [-1.0, 1.0], 0.0 is center. + * \return 1 on success, 0 on failure (channel out of range). + * \remarks This command affects subsequent notes played on the same channel, and may itself be overridden by subsequent panning commands encountered in the module itself. + * \sa openmpt_module_ext_interface_interactive2::get_channel_panning + * \since 0.6.0 + */ + int ( *set_channel_panning) ( openmpt_module_ext * mod_ext, int32_t channel, double panning ); + + //! Get the current panning position for a channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel whose panning should be retrieved. This is the value returned by a previous play_note call. + * \return The current channel panning, in range [-1.0, 1.0], 0.0 is center. + * \sa openmpt_module_ext_interface_interactive2::set_channel_panning + * \since 0.6.0 + */ + double (*get_channel_panning) ( openmpt_module_ext * mod_ext, int32_t channel ); + + //! Set the finetune for the currently playing note on a channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel whose finetune will be changed, in range [0, openmpt::module::get_num_channels()[ + * \param finetune The finetune to set on the channel, in range [-1.0, 1.0], 0.0 is center. + * \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + * \remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone. + * \remarks This command does not affect subsequent notes played on the same channel, but may itself be overridden by subsequent finetune commands encountered in the module itself. + * \sa openmpt_module_ext_interface_interactive2::get_note_finetune + * \since 0.6.0 + */ + int ( *set_note_finetune) ( openmpt_module_ext * mod_ext, int32_t channel, double finetune ); + + //! Get the finetune for the currently playing note on a channel + /*! + * \param mod_ext The module handle to work on. + * \param channel The channel whose finetune should be retrieved, in range [0, openmpt::module::get_num_channels()[ + * \return The current channel finetune, in range [-1.0, 1.0], 0.0 is center. + * \remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone. + * \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + * \sa openmpt_module_ext_interface_interactive2::set_note_finetune + * \since 0.6.0 + */ + double (*get_note_finetune) ( openmpt_module_ext * mod_ext, int32_t channel ); + +} openmpt_module_ext_interface_interactive2; + + + +#ifndef LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE3 +#define LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE3 "interactive3" +#endif + +typedef struct openmpt_module_ext_interface_interactive3 { + + /*! Set the current module tempo + * + * \param mod_ext The module handle to work on. + * \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + * \return 1 on success, 0 on failure. + * \remarks The tempo may be reset by pattern commands at any time. Use openmpt_module_ext_interface_interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + * \sa openmpt_module_get_current_tempo2 + */ + int ( * set_current_tempo2 ) ( openmpt_module_ext * mod_ext, double tempo ); + +} openmpt_module_ext_interface_interactive3; + + + /* add stuff here */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp index 686eaeeed..71524d2b6 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp @@ -26,28 +26,32 @@ /*! \defgroup libopenmpt_ext_cpp libopenmpt_ext C++ */ +namespace openmpt { + /*! \addtogroup libopenmpt_ext_cpp @{ */ -namespace openmpt { - class module_ext_impl; -class LIBOPENMPT_CXX_API module_ext : public module { +class LIBOPENMPT_CXX_API_CLASS module_ext : public module { private: module_ext_impl * ext_impl; private: // non-copyable - module_ext( const module_ext & ); - void operator = ( const module_ext & ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const module_ext & ); + LIBOPENMPT_CXX_API_MEMBER void operator = ( const module_ext & ); public: - module_ext( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); - module_ext( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); - module_ext( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); - module_ext( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); - virtual ~module_ext(); + LIBOPENMPT_CXX_API_MEMBER module_ext( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const std::byte * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER module_ext( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + LIBOPENMPT_CXX_API_MEMBER virtual ~module_ext(); public: @@ -69,12 +73,20 @@ public: \param interface_id The name of the extension interface to retrieve. \return The interface object. This may be a nullptr if the extension was not found. */ - void * get_interface( const std::string & interface_id ); + LIBOPENMPT_CXX_API_MEMBER void * get_interface( const std::string & interface_id ); }; // class module_ext +/*! + @} +*/ + namespace ext { +/*! \addtogroup libopenmpt_ext_cpp + @{ +*/ + #define LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(name) \ static const char name ## _id [] = # name ; \ class name; \ @@ -158,8 +170,9 @@ class interactive { \throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range. \remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. \sa openmpt::module::get_current_tempo + \deprecated Please use openmpt::ext::interactive3::set_current_tempo2(). */ - virtual void set_current_tempo( std::int32_t tempo ) = 0; + LIBOPENMPT_ATTR_DEPRECATED virtual void set_current_tempo( std::int32_t tempo ) = 0; //! Set the current module tempo factor without affecting playback pitch /*! @@ -190,6 +203,7 @@ class interactive { //! Gets the current module pitch factor /*! \return The current pitch factor. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the pitch is outside the specified range. \sa openmpt::ext::interactive::set_pitch_factor */ virtual double get_pitch_factor( ) const = 0; @@ -274,20 +288,129 @@ class interactive { \return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note. \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range. \sa openmpt::ext::interactive::stop_note + \sa openmpt::ext::interactive2::note_off + \sa openmpt::ext::interactive2::note_fade */ virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0; //! Stop the note playing on the specified channel /*! - \param channel The channel on which the note should be stopped. + \param channel The channel on which the note should be stopped. This is the value returned by a previous play_note call. \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. \sa openmpt::ext::interactive::play_note + \sa openmpt::ext::interactive2::note_off + \sa openmpt::ext::interactive2::note_fade */ virtual void stop_note( std::int32_t channel ) = 0; }; // class interactive +#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2 +#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2 +#endif + +LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive2) + +class interactive2 { + + LIBOPENMPT_EXT_CXX_INTERFACE(interactive2) + + //! Sends a key-off command for the note playing on the specified channel + /*! + \param channel The channel on which the key-off event should be triggered. This is the value returned by a previous play_note call. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \remarks This method releases envelopes and sample sustain loops. If the sample has no sustain loop, or if the module does not use instruments, it does nothing. + \sa openmpt::ext::interactive::play_note + \sa openmpt::ext::interactive::stop_note + \sa openmpt::ext::interactive2::note_fade + \since 0.6.0 + */ + virtual void note_off(int32_t channel ) = 0; + + //! Sends a note fade command for the note playing on the specified channel + /*! + \param channel The channel on which the note should be faded. This is the value returned by a previous play_note call. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \remarks This method uses the instrument's fade-out value. If the module does not use instruments, or the instrument's fade-out value is 0, it does nothing. + \sa openmpt::ext::interactive::play_note + \sa openmpt::ext::interactive::stop_note + \sa openmpt::ext::interactive2::note_off + \since 0.6.0 + */ + virtual void note_fade(int32_t channel) = 0; + + //! Set the current panning position for a channel + /*! + \param channel The channel whose panning will be changed, in range [0, openmpt::module::get_num_channels()[ + \param panning The panning position to set on the channel, in range [-1.0, 1.0], 0.0 is center. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \remarks This command affects subsequent notes played on the same channel, and may itself be overridden by subsequent panning commands encountered in the module itself. + \sa openmpt::ext::interactive2::get_channel_panning + \since 0.6.0 + */ + virtual void set_channel_panning(int32_t channel, double panning ) = 0; + + //! Get the current panning position for a channel + /*! + \param channel The channel whose panning should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel panning, in range [-1.0, 1.0], 0.0 is center. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive2::set_channel_panning + \since 0.6.0 + */ + virtual double get_channel_panning( int32_t channel ) = 0; + + //! Set the finetune for the currently playing note on a channel + /*! + \param channel The channel whose finetune will be changed, in range [0, openmpt::module::get_num_channels()[ + \param finetune The finetune to set on the channel, in range [-1.0, 1.0], 0.0 is center. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone. + \remarks This command does not affect subsequent notes played on the same channel, but may itself be overridden by subsequent finetune commands encountered in the module itself. + \sa openmpt::ext::interactive2::get_note_finetune + \since 0.6.0 + */ + virtual void set_note_finetune(int32_t channel, double finetune ) = 0; + + //! Get the finetune for the currently playing note on a channel + /*! + \param channel The channel whose finetune should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel finetune, in range [-1.0, 1.0], 0.0 is center. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone. + \sa openmpt::ext::interactive2::set_note_finetune + \since 0.6.0 + */ + virtual double get_note_finetune( int32_t channel ) = 0; + +}; // class interactive2 + + +#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3 +#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3 +#endif + +LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive3) + +class interactive3 { + + LIBOPENMPT_EXT_CXX_INTERFACE(interactive3) + + //! Set the current module tempo + /*! + \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range. + \remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + \sa openmpt::module::get_current_tempo2 + \since 0.7.0 + */ + virtual void set_current_tempo2( double tempo ) = 0; + +}; // class interactive3 + + + /* add stuff here */ @@ -295,12 +418,12 @@ class interactive { #undef LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE #undef LIBOPENMPT_EXT_CXX_INTERFACE -} // namespace ext - -} // namespace openmpt - /*! @} */ +} // namespace ext + +} // namespace openmpt + #endif // LIBOPENMPT_EXT_HPP diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h index 575049e4d..d6e03ff34 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h @@ -12,17 +12,6 @@ #include "libopenmpt.h" -/* The use of this header requires: - -#include -#if defined( LIBOPENMPT_STREAM_CALLBACKS_BUFFER ) -#include -#else -#error "libopenmpt too old." -#endif - -*/ - #include #include #include @@ -43,7 +32,7 @@ typedef struct openmpt_stream_buffer { int overflow; } openmpt_stream_buffer; -static size_t openmpt_stream_buffer_read_func( void * stream, void * dst, size_t bytes ) { +static LIBOPENMPT_C_INLINE size_t openmpt_stream_buffer_read_func( void * stream, void * dst, size_t bytes ) { openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; int64_t offset = 0; int64_t begpos = 0; @@ -87,7 +76,7 @@ static size_t openmpt_stream_buffer_read_func( void * stream, void * dst, size_t return bytes; } -static int openmpt_stream_buffer_seek_func( void * stream, int64_t offset, int whence ) { +static LIBOPENMPT_C_INLINE int openmpt_stream_buffer_seek_func( void * stream, int64_t offset, int whence ) { openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; int result = -1; if ( !s ) { @@ -142,7 +131,7 @@ static int openmpt_stream_buffer_seek_func( void * stream, int64_t offset, int w return result; } -static int64_t openmpt_stream_buffer_tell_func( void * stream ) { +static LIBOPENMPT_C_INLINE int64_t openmpt_stream_buffer_tell_func( void * stream ) { openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; if ( !s ) { return -1; @@ -150,7 +139,7 @@ static int64_t openmpt_stream_buffer_tell_func( void * stream ) { return s->file_pos; } -static void openmpt_stream_buffer_init( openmpt_stream_buffer * buffer, const void * file_data, int64_t file_size ) { +LIBOPENMPT_DEPRECATED static LIBOPENMPT_C_INLINE void openmpt_stream_buffer_init( openmpt_stream_buffer * buffer, const void * file_data, int64_t file_size ) { memset( buffer, 0, sizeof( openmpt_stream_buffer ) ); buffer->file_data = file_data; buffer->file_size = file_size; @@ -169,6 +158,7 @@ static void openmpt_stream_buffer_init( openmpt_stream_buffer * buffer, const vo /*! \brief Provide openmpt_stream_callbacks for in-memoy buffers * * Fills openmpt_stream_callbacks suitable for passing an in-memory buffer as a stream parameter to functions doing file input/output. + * A suitable openmpt_stream_buffer object may be initialized with openmpt_stream_buffer_init(). * * \remarks The stream argument must be passed as `(void*)(openmpt_stream_buffer*)stream_buffer`. * \sa \ref libopenmpt_c_fileio @@ -176,8 +166,10 @@ static void openmpt_stream_buffer_init( openmpt_stream_buffer * buffer, const vo * \sa openmpt_could_open_probability2 * \sa openmpt_probe_file_header_from_stream * \sa openmpt_module_create2 + * \sa openmpt_stream_buffer_init + * \deprecated Please use openmpt_stream_get_buffer_callbacks2(). */ -static openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks(void) { +LIBOPENMPT_DEPRECATED static LIBOPENMPT_C_INLINE openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks(void) { openmpt_stream_callbacks retval; memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); retval.read = openmpt_stream_buffer_read_func; @@ -186,6 +178,137 @@ static openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks(void) { return retval; } +typedef struct openmpt_stream_buffer2 { + const void * file_data; + int64_t file_size; + int64_t file_pos; +} openmpt_stream_buffer2; + +static size_t openmpt_stream_buffer_read_func2( void * stream, void * dst, size_t bytes ) { + openmpt_stream_buffer2 * s = (openmpt_stream_buffer2*)stream; + int64_t offset = 0; + int64_t begpos = 0; + int64_t endpos = 0; + if ( !s ) { + return 0; + } + offset = bytes; + begpos = s->file_pos; + endpos = s->file_pos; + endpos = (uint64_t)endpos + (uint64_t)offset; + if ( ( offset > 0 ) && !( (uint64_t)endpos > (uint64_t)begpos ) ) { + /* integer wrapped */ + return 0; + } + if ( bytes == 0 ) { + return 0; + } + if ( begpos >= s->file_size ) { + return 0; + } + if ( endpos > s->file_size ) { + /* clip to eof */ + bytes = bytes - (size_t)( endpos - s->file_size ); + endpos = endpos - ( endpos - s->file_size ); + } + memcpy( dst, (const char*)s->file_data + s->file_pos, bytes ); + s->file_pos = s->file_pos + bytes; + return bytes; +} + +static int openmpt_stream_buffer_seek_func2( void * stream, int64_t offset, int whence ) { + openmpt_stream_buffer2 * s = (openmpt_stream_buffer2*)stream; + int result = -1; + if ( !s ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + if ( offset < 0 ) { + return -1; + } + if ( offset > s->file_size ) { + return -1; + } + s->file_pos = offset; + result = 0; + break; + case OPENMPT_STREAM_SEEK_CUR: + do { + int64_t oldpos = s->file_pos; + int64_t pos = s->file_pos; + pos = (uint64_t)pos + (uint64_t)offset; + if ( ( offset > 0 ) && !( (uint64_t)pos > (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + if ( ( offset < 0 ) && !( (uint64_t)pos < (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + s->file_pos = pos; + } while(0); + result = 0; + break; + case OPENMPT_STREAM_SEEK_END: + if ( offset > 0 ) { + return -1; + } + do { + int64_t oldpos = s->file_pos; + int64_t pos = s->file_pos; + pos = s->file_size; + pos = (uint64_t)pos + (uint64_t)offset; + if ( ( offset < 0 ) && !( (uint64_t)pos < (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + s->file_pos = pos; + } while(0); + result = 0; + break; + } + return result; +} + +static int64_t openmpt_stream_buffer_tell_func2( void * stream ) { + openmpt_stream_buffer2 * s = (openmpt_stream_buffer2*)stream; + if ( !s ) { + return -1; + } + return s->file_pos; +} + +static void openmpt_stream_buffer_init2( openmpt_stream_buffer2 * buffer, const void * file_data, int64_t file_size ) { + memset( buffer, 0, sizeof( openmpt_stream_buffer2 ) ); + buffer->file_data = file_data; + buffer->file_size = file_size; + buffer->file_pos = 0; +} + +/*! \brief Provide openmpt_stream_callbacks for in-memoy buffers + * + * Fills openmpt_stream_callbacks suitable for passing an in-memory buffer as a stream parameter to functions doing file input/output. + * A suitable openmpt_stream_buffer2 object can be initialized with openmpt_stream_buffer_init2(). + * + * \remarks The stream argument must be passed as `(void*)(openmpt_stream_buffer2*)stream_buffer`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + * \sa openmpt_stream_buffer_init2 + * \since 0.7.0 + */ +static openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks2(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_buffer_read_func2; + retval.seek = openmpt_stream_buffer_seek_func2; + retval.tell = openmpt_stream_buffer_tell_func2; + return retval; +} + #ifdef __cplusplus } #endif @@ -195,4 +318,3 @@ static openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks(void) { */ #endif /* LIBOPENMPT_STREAM_CALLBACKS_BUFFER_H */ - diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h index 46b39f129..c0f80c3d9 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h @@ -12,6 +12,9 @@ #include "libopenmpt.h" +#ifndef _MSC_VER +#include +#endif #ifdef _MSC_VER #include #endif @@ -63,7 +66,9 @@ static size_t openmpt_stream_fd_read_func( void * stream, void * dst, size_t byt retval += ret_read; } #else - retval = read( fd, dst, bytes ); + do { + retval = read( fd, dst, bytes ); + } while ( ( retval == -1 ) && ( errno == EINTR ) ); #endif if ( retval <= 0 ) { return 0; @@ -98,4 +103,3 @@ static openmpt_stream_callbacks openmpt_stream_get_fd_callbacks(void) { */ #endif /* LIBOPENMPT_STREAM_CALLBACKS_FD_H */ - diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h index 643049153..a922d1539 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h @@ -12,13 +12,9 @@ #include "libopenmpt.h" -#include #include #include #include -#ifdef _MSC_VER -#include /* off_t */ -#endif /*! \addtogroup libopenmpt_c * @{ @@ -52,48 +48,38 @@ static int openmpt_stream_file_seek_func( void * stream, int64_t offset, int whe return -1; } switch ( whence ) { -#if defined(SEEK_SET) case OPENMPT_STREAM_SEEK_SET: fwhence = SEEK_SET; break; -#endif -#if defined(SEEK_CUR) case OPENMPT_STREAM_SEEK_CUR: fwhence = SEEK_CUR; break; -#endif -#if defined(SEEK_END) case OPENMPT_STREAM_SEEK_END: fwhence = SEEK_END; break; -#endif default: return -1; break; } - #if defined(_MSC_VER) - return _fseeki64( f, offset, fwhence ) ? -1 : 0; - #elif defined(_POSIX_SOURCE) && (_POSIX_SOURCE == 1) - return fseeko( f, offset, fwhence ) ? -1 : 0; - #else - return fseek( f, offset, fwhence ) ? -1 : 0; - #endif + if ( (long)offset != offset ) { + return -1; + } + return fseek( f, (long)offset, fwhence ) ? -1 : 0; } static int64_t openmpt_stream_file_tell_func( void * stream ) { FILE * f = 0; + long result = 0; int64_t retval = 0; f = (FILE*)stream; if ( !f ) { return -1; } - #if defined(_MSC_VER) - retval = _ftelli64( f ); - #elif defined(_POSIX_SOURCE) && (_POSIX_SOURCE == 1) - retval = ftello( f ); - #else - retval = ftell( f ); - #endif + result = ftell( f ); + if ( (int64_t)result != result ) { + return -1; + } + retval = (int64_t)result; if ( retval < 0 ) { return -1; } @@ -103,6 +89,9 @@ static int64_t openmpt_stream_file_tell_func( void * stream ) { /*! \brief Provide openmpt_stream_callbacks for standard C FILE objects * * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * Since 0.7.0, it does not try to use platform-specific file seeking any more, + * but sticks to standard C fseek/ftell only, which means on platforms where + * long is 32bit, there is no 64bit file access possible any more. * * \remarks The stream argument must be passed as `(void*)(FILE*)file`. * \sa \ref libopenmpt_c_fileio @@ -110,8 +99,37 @@ static int64_t openmpt_stream_file_tell_func( void * stream ) { * \sa openmpt_could_open_probability2 * \sa openmpt_probe_file_header_from_stream * \sa openmpt_module_create2 + * \sa openmpt_stream_get_file_callbacks2() + * \sa openmpt_stream_get_file_mingw_callbacks() + * \sa openmpt_stream_get_file_msvcrt_callbacks() + * \sa openmpt_stream_get_file_posix_callbacks() + * \sa openmpt_stream_get_file_posix_lfs64_callbacks() + * \deprecated Please use openmpt_stream_get_file_callbacks2(). */ -static openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { +LIBOPENMPT_DEPRECATED static LIBOPENMPT_C_INLINE openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_read_func; + retval.seek = openmpt_stream_file_seek_func; + retval.tell = openmpt_stream_file_tell_func; + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * This function uses the standard C fseek and ftell, thus platform-specific file size limits apply accordingly. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \remarks The provided callbacks are limited to handling files up to the size representable in the platform's long type. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + * \since 0.7.0 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_callbacks2(void) { openmpt_stream_callbacks retval; memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); retval.read = openmpt_stream_file_read_func; @@ -129,4 +147,3 @@ static openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { */ #endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_H */ - diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_mingw.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_mingw.h new file mode 100644 index 000000000..871af4dab --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_mingw.h @@ -0,0 +1,115 @@ +/* + * libopenmpt_stream_callbacks_file_mingw.h + * ---------------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW_H +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW_H + +#include "libopenmpt.h" + +#include +#include +#include + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +static size_t openmpt_stream_file_mingw_read_func( void * stream, void * dst, size_t bytes ) { + FILE * f = 0; + size_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return 0; + } + retval = fread( dst, 1, bytes, f ); + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +static int openmpt_stream_file_mingw_seek_func( void * stream, int64_t offset, int whence ) { + FILE * f = 0; + int fwhence = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + fwhence = SEEK_SET; + break; + case OPENMPT_STREAM_SEEK_CUR: + fwhence = SEEK_CUR; + break; + case OPENMPT_STREAM_SEEK_END: + fwhence = SEEK_END; + break; + default: + return -1; + break; + } + if ( (_off64_t)offset != offset ) { + return -1; + } + return fseeko64( f, (_off64_t)offset, fwhence ) ? -1 : 0; +} + +static int64_t openmpt_stream_file_mingw_tell_func( void * stream ) { + FILE * f = 0; + _off64_t result = 0; + int64_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + result = ftello64( f ); + if ( (int64_t)result != result ) { + return -1; + } + retval = (int64_t)result; + if ( retval < 0 ) { + return -1; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_mingw_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_mingw_read_func; + retval.seek = openmpt_stream_file_mingw_seek_func; + retval.tell = openmpt_stream_file_mingw_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_MINGW_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h new file mode 100644 index 000000000..d84dfc69b --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h @@ -0,0 +1,115 @@ +/* + * libopenmpt_stream_callbacks_file_msvcrt.h + * ----------------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT_H +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT_H + +#include "libopenmpt.h" + +#include +#include +#include + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +static size_t openmpt_stream_file_msvcrt_read_func( void * stream, void * dst, size_t bytes ) { + FILE * f = 0; + size_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return 0; + } + retval = fread( dst, 1, bytes, f ); + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +static int openmpt_stream_file_msvcrt_seek_func( void * stream, int64_t offset, int whence ) { + FILE * f = 0; + int fwhence = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + fwhence = SEEK_SET; + break; + case OPENMPT_STREAM_SEEK_CUR: + fwhence = SEEK_CUR; + break; + case OPENMPT_STREAM_SEEK_END: + fwhence = SEEK_END; + break; + default: + return -1; + break; + } + if ( (__int64)offset != offset ) { + return -1; + } + return _fseeki64( f, (__int64)offset, fwhence ) ? -1 : 0; +} + +static int64_t openmpt_stream_file_msvcrt_tell_func( void * stream ) { + FILE * f = 0; + __int64 result = 0; + int64_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + result = _ftelli64( f ); + if ( (int64_t)result != result ) { + return -1; + } + retval = (int64_t)result; + if ( retval < 0 ) { + return -1; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_msvcrt_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_msvcrt_read_func; + retval.seek = openmpt_stream_file_msvcrt_seek_func; + retval.tell = openmpt_stream_file_msvcrt_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_MSVCRT_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix.h new file mode 100644 index 000000000..a3d94ef61 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix.h @@ -0,0 +1,115 @@ +/* + * libopenmpt_stream_callbacks_file_posix.h + * ---------------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_H +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_H + +#include "libopenmpt.h" + +#include +#include +#include + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +static size_t openmpt_stream_file_posix_read_func( void * stream, void * dst, size_t bytes ) { + FILE * f = 0; + size_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return 0; + } + retval = fread( dst, 1, bytes, f ); + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +static int openmpt_stream_file_posix_seek_func( void * stream, int64_t offset, int whence ) { + FILE * f = 0; + int fwhence = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + fwhence = SEEK_SET; + break; + case OPENMPT_STREAM_SEEK_CUR: + fwhence = SEEK_CUR; + break; + case OPENMPT_STREAM_SEEK_END: + fwhence = SEEK_END; + break; + default: + return -1; + break; + } + if ( (off_t)offset != offset ) { + return -1; + } + return fseeko( f, (off_t)offset, fwhence ) ? -1 : 0; +} + +static int64_t openmpt_stream_file_posix_tell_func( void * stream ) { + FILE * f = 0; + off_t result = 0; + int64_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + result = ftello( f ); + if ( (int64_t)result != result ) { + return -1; + } + retval = (int64_t)result; + if ( retval < 0 ) { + return -1; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_posix_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_posix_read_func; + retval.seek = openmpt_stream_file_posix_seek_func; + retval.tell = openmpt_stream_file_posix_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h new file mode 100644 index 000000000..a5df246ee --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h @@ -0,0 +1,115 @@ +/* + * libopenmpt_stream_callbacks_file_posix_lfs64.h + * ---------------------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64_H +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64_H + +#include "libopenmpt.h" + +#include +#include +#include + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +static size_t openmpt_stream_file_posix_lfs64_read_func( void * stream, void * dst, size_t bytes ) { + FILE * f = 0; + size_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return 0; + } + retval = fread( dst, 1, bytes, f ); + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +static int openmpt_stream_file_posix_lfs64_seek_func( void * stream, int64_t offset, int whence ) { + FILE * f = 0; + int fwhence = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + fwhence = SEEK_SET; + break; + case OPENMPT_STREAM_SEEK_CUR: + fwhence = SEEK_CUR; + break; + case OPENMPT_STREAM_SEEK_END: + fwhence = SEEK_END; + break; + default: + return -1; + break; + } + if ( (off64_t)offset != offset ) { + return -1; + } + return fseeko64( f, (off64_t)offset, fwhence ) ? -1 : 0; +} + +static int64_t openmpt_stream_file_posix_lfs64_tell_func( void * stream ) { + FILE * f = 0; + off64_t result = 0; + int64_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + result = ftello64( f ); + if ( (int64_t)result != result ) { + return -1; + } + retval = (int64_t)result; + if ( retval < 0 ) { + return -1; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_posix_lfs64_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_posix_lfs64_read_func; + retval.seek = openmpt_stream_file_posix_lfs64_seek_func; + retval.tell = openmpt_stream_file_posix_lfs64_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_POSIX_LFS64_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h index 4bb90278c..6191fb5a1 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h @@ -10,6 +10,8 @@ #ifndef LIBOPENMPT_VERSION_H #define LIBOPENMPT_VERSION_H +/* clang-format off */ + /*! \addtogroup libopenmpt @{ */ @@ -17,9 +19,9 @@ /*! \brief libopenmpt major version number */ #define OPENMPT_API_VERSION_MAJOR 0 /*! \brief libopenmpt minor version number */ -#define OPENMPT_API_VERSION_MINOR 4 +#define OPENMPT_API_VERSION_MINOR 7 /*! \brief libopenmpt patch version number */ -#define OPENMPT_API_VERSION_PATCH 7 +#define OPENMPT_API_VERSION_PATCH 2 /*! \brief libopenmpt pre-release tag */ #define OPENMPT_API_VERSION_PREREL "" /*! \brief libopenmpt pre-release flag */ @@ -72,4 +74,6 @@ @} */ +/* clang-format on */ + #endif /* LIBOPENMPT_VERSION_H */ diff --git a/libs/libopenmpt/lib/x86/libopenmpt.lib b/libs/libopenmpt/lib/x86/libopenmpt.lib index c81c4c4ed..4ae31a98e 100644 Binary files a/libs/libopenmpt/lib/x86/libopenmpt.lib and b/libs/libopenmpt/lib/x86/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86_64/libopenmpt.lib b/libs/libopenmpt/lib/x86_64/libopenmpt.lib index 216d93b45..2b62077c9 100644 Binary files a/libs/libopenmpt/lib/x86_64/libopenmpt.lib and b/libs/libopenmpt/lib/x86_64/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a b/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a deleted file mode 100644 index c6eda119f..000000000 Binary files a/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a and /dev/null differ diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6043141b3..e492e2a5b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -913,6 +913,9 @@ void D_RegisterClientCommands(void) #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); CV_RegisterVar(&cv_amigafilter); +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + CV_RegisterVar(&cv_amigatype); +#endif #endif // FIXME: not to be here.. but needs be done for config loading diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9145a6ba9..4c291c62b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2282,7 +2282,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // From PrBoom: // -// e6y: Check whether the player can look beyond this line, rturns true if we can't +// e6y: Check whether the player can look beyond this line, returns true if we can't // boolean checkforemptylines = true; diff --git a/src/m_menu.c b/src/m_menu.c index 9b25cb7ab..091475764 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1413,7 +1413,11 @@ static menuitem_t OP_SoundAdvancedMenu[] = {IT_HEADER, NULL, "MOD", NULL, 10}, {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42} + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, +#endif + //{IT_STRING | IT_CVAR, NULL, "Dithering", &cv_mptdither, 82} }; #endif diff --git a/src/s_sound.c b/src/s_sound.c index 8627903d5..ff2009b5a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -53,6 +53,7 @@ CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}}; static void SetChannelsNum(void); static void Command_Tunes_f(void); static void Command_RestartAudio_f(void); +static void Command_RestartMusic_f(void); //mhhhm amiga type filters here i come uwu // Sound system toggles #ifndef NO_MIDI @@ -67,6 +68,9 @@ static void PlaySoundIfUnfocused_OnChange(void); #ifdef HAVE_OPENMPT static void ModFilter_OnChange(void); static void AmigaFilter_OnChange(void); +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 +static void AmigaType_OnChange(void); +#endif #endif // commands for music and sound servers @@ -142,6 +146,13 @@ consvar_t cv_modfilter = {"modfilter", "4", CV_SAVE|CV_CALL, interpolationfilter static CV_PossibleValue_t amigafilter_cons_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; consvar_t cv_amigafilter = {"amigafilter", "1", CV_SAVE|CV_CALL, amigafilter_cons_t, AmigaFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; + + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 +static CV_PossibleValue_t amigatype_cons_t[] = {{0, "auto"}, {1, "a500"}, {2, "a1200"}, {0, NULL}}; +consvar_t cv_amigatype = {"amigatype", "0", CV_SAVE|CV_CALL, amigatype_cons_t, AmigaType_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#endif + #endif #define S_MAX_VOLUME 127 @@ -306,6 +317,7 @@ void S_RegisterSoundStuff(void) COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); + COM_AddCommand("restartmusic", Command_RestartMusic_f); #if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff @@ -2032,6 +2044,24 @@ void S_Start(void) S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); } +void S_RestartMusic(void) +{ + S_StopMusic(); + I_ShutdownMusic(); + I_InitMusic(); + +#ifdef NO_MIDI + S_SetMusicVolume(cv_digmusicvolume.value, -1); +#else + S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value); +#endif + + if (Playing()) // Gotta make sure the player is in a level + P_RestoreMusic(&players[consoleplayer]); + else + S_ChangeMusicInternal("titles", looptitle); +} + static void Command_Tunes_f(void) { const char *tunearg; @@ -2136,6 +2166,11 @@ static void Command_RestartAudio_f(void) S_ChangeMusicInternal("titles", looptitle); } +static void Command_RestartMusic_f(void) //same as RestartAudio but only music gets restarted +{ + S_RestartMusic(); +} + void GameSounds_OnChange(void) { if (M_CheckParm("-nosound") || M_CheckParm("-noaudio")) @@ -2192,6 +2227,7 @@ void GameDigiMusic_OnChange(void) } } +#ifdef HAVE_OPENMPT void ModFilter_OnChange(void) { if (openmpt_mhandle) @@ -2205,6 +2241,18 @@ void AmigaFilter_OnChange(void) openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); } + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 +void AmigaType_OnChange(void) +{ + if (openmpt_mhandle) + openmpt_module_ctl_set_text(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigatype.string); + + S_RestartMusic(); //need to restart the music system or else it wont work +} +#endif +#endif + #ifndef NO_MIDI void GameMIDIMusic_OnChange(void) { diff --git a/src/s_sound.h b/src/s_sound.h index ee04ad4ad..6d9fed164 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -45,6 +45,9 @@ extern consvar_t cv_playsoundifunfocused; #ifdef HAVE_OPENMPT extern consvar_t cv_modfilter; extern consvar_t cv_amigafilter; +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 +extern consvar_t cv_amigatype; +#endif #endif extern consvar_t cv_music_resync_threshold; @@ -105,6 +108,9 @@ void S_StopSounds(void); void S_ClearSfx(void); void S_Start(void); +// Stops music and restarts it from same position. Used for instant applying changes to amiga filters. +void S_RestartMusic(void); + // // Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum. // diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 3e2df0067..b1259935c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1256,7 +1256,11 @@ boolean I_PlaySong(boolean looping) if (openmpt_mhandle) { openmpt_module_select_subsong(openmpt_mhandle, 0); + openmpt_module_ctl_set(openmpt_mhandle, "dither", "1"); openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_text(openmpt_mhandle, "render.resampler.emulate_amiga_type", cv_amigatype.string); +#endif openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); if (looping) openmpt_module_set_repeat_count(openmpt_mhandle, -1); // Always repeat diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index 2341a1494..b109aee8e 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -13,7 +13,7 @@ ifdef MINGW64 ifdef HAVE_OPENMPT LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt + LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64 -llibopenmpt endif SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main @@ -26,7 +26,7 @@ else ifdef HAVE_OPENMPT LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt + LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86 -llibopenmpt endif SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main