Initial commit

This commit is contained in:
mxdyeah committed 2026-07-08 01:15:18 +08:00
commit acadc92e68
780 files changed
+468285

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
Contributing
============
OpenMPT, libopenmpt, openmpt123, xmp-openmpt and in_openmpt are developed in
the Subversion repository at
[https://source.openmpt.org/browse/openmpt/trunk/OpenMPT/](https://source.openmpt.org/browse/openmpt/trunk/OpenMPT/).
Patches can be provided either against this Subversion repository or against our
GitHub mirror at
[https://github.com/OpenMPT/openmpt/](https://github.com/OpenMPT/openmpt/).
We do not have a developer mailing list. Discussions about new features or
problems can happen at:
* [Issue Tracker](https://bugs.openmpt.org/), preferred for specific bug
reports or bug fixes and feature development discussion
* [Forum](https://forum.openmpt.org/), preferred for long-term discussion of
new features or specific questions about development
* [IRC channel (`Libera.Chat/#openmpt`)](ircs://irc.libera.chat:6697/#openmpt),
preferred for shorter questions
* [GitHub pull requests](https://github.com/OpenMPT/openmpt/pulls), please
only use for rather tiny fixes, see below
For patch submissions, please also see
[OpenMPT style guide](openmpt_styleguide.md) and
[libopenmpt style guide](libopenmpt_styleguide.md).
### Contributing via GitHub
As OpenMPT is developed in a Subversion repository and the GitHub repository is
just mirrored from that, we cannot directly take pull requests via GitHub. We
recognize that, especially for tiny bug fixes, the burden to choose a different
way than GitHub for contributing can be too high. Thus, we will of course react,
give feedback, and take patches also via GitHub pull requests. However, as the
GitHub repository is strictly downstream from our Subversion repository (and
this will not change, due to considerable complications when synchronizing this
two-way), we cannot directly merge pull requests on GitHub. We will merge
contributions to our Subversion repository, which will then in turn be mirrored
to GitHub automatically, after which we will close the pull request. Authorship
attribution in git relies on the email address used in the commit header, which
is not how it usually works in Subversion. We will thus add an additional line
to the commit message in the form of `Patch-by: John Doe <[email protected]>`. If
you prefer to be attributed with your nickname and/or without your email
address, that would also be fine for us.
File diff suppressed because it is too large. Load diff
+126
View File
@@ -0,0 +1,126 @@
Dependencies {#dependencies}
============
Dependencies
------------
### libopenmpt
* Supported compilers for building libopenmpt:
* **Microsoft Visual Studio 2019** or higher, running on a amd64 build
system (other target systems are supported)
Please note that we do not support building with a later Visual Studio
installation with an earlier compiler version. This is because, while
later Visual Studio versions allow installing earlier compilers to be
available via the later version's environment, in this configuration,
the earlier compiler will still use the later C and C++ runtime's
headers and implementation, which significantly increases the matrix of
possible configurations to test.
* **Microsoft Visual Studio 2017 XP targeting toolset**
* **GCC 7.1** or higher
* **Clang 6** or higher
* **MinGW-W64 7.1 (posix threading model)** or higher
* **MinGW-W64 13.1 (mcfgthread threading model)** or higher
* **MinGW-W64 7.1 (win32 threading model)** up to
**MinGW-W64 13.0 (win32 threading model)**
* **emscripten 3.1.51** or higher
* **DJGPP GCC 7.1** or higher
* any other **C++23, C++20, or C++17 compliant** compiler
libopenmpt makes the following assumptions about the C++ implementation
used for building:
* `std::numeric_limits<unsigned char>::digits == 8` (enforced by
static_assert)
* existence of `std::uintptr_t` (enforced by static_assert)
* in C++23/C++20 mode, `std::endian::little != std::endian::big`
(enforced by static_assert)
* `wchar_t` encoding is either UTF-16 or UTF-32 (implicitly assumed)
* representation of basic source character set is ASCII (implicitly
assumed)
* representation of basic source character set is identical in char
and `wchar_t` (implicitly assumed)
libopenmpt does not rely on any specific implementation defined or
undefined behaviour (if it does, that's a bug in libopenmpt). In
particular:
* `char` can be `signed` or `unsigned`
* shifting signed values is implementation defined
* `signed` integer overflow is undefined
* `float` and `double` can be non-IEEE754
libopenmpt can optionally support certain incomplete C++
implementations:
* platforms without `wchar_t` support (like DJGPP)
* platforms without working `std::random_device` (like Emscripten when
running in `AudioWorkletProcessor` context)
* platforms without working `std::high_resolution_clock` (like
Emscripten when running in `AudioWorkletProcessor` context)
* Required compilers to use libopenmpt:
* Any **C89** / **C99** / **C11** / **C17** / **C23** compatible compiler
should work with the C API as long as a **C99** compatible **stdint.h**
is available.
* Any **C++23**, **C++20**, or **C++17** compatible compiler should work
with the C++ API.
* **J2B** support requires an inflate (deflate decompression) implementation:
* **zlib** (or **miniz** can be used internally)
* **MO3** support requires:
* **libmpg123 >= 1.14.0** (or **minimp3** can be used internally)
* **libogg**, **libvorbis**, and **libvorbisfile** (or **stb_vorbis** can
be used internally)
* Building on Unix-like systems requires:
* **GNU make**
* **pkg-config**
* The Autotools-based build system requires:
* **pkg-config 0.24** or higher
* **zlib**
* **doxygen**
### openmpt123
* Live sound output requires one of:
* **PulseAudio**
* **SDL 2**
* **PortAudio v19**
* **Win32**
* **liballegro 4.2** on DJGPP/DOS
Optional dependencies
---------------------
### libopenmpt
* **doxygen 1.8** or higher is required to build the documentation.
### openmpt123
* Rendering to PCM files can use:
* **FLAC 1.3** or higher
* **libsndfile**
* **Win32** for WAVE
* raw PCM has no external dependencies
* **help2man** is required to build the documentation.
Source packages
---------------
Building the source packages additionally requires:
* 7z (7-zip)
* autoconf
* autoconf-archive
* automake
* awk (mawk)
* git
* gzip
* help2man
* libtool
* subversion
* tar
* xpath (libxml-xpath-perl)
* zip
+283
View File
@@ -0,0 +1,283 @@
Getting Started {#gettingstarted}
===============
How to compile
--------------
### libopenmpt and openmpt123
- Autotools
Grab a `libopenmpt-VERSION-autotools.tar.gz` tarball.
./configure
make
make check
sudo make install
Cross-compilation is generally supported (although only tested for
targetting MinGW-w64).
Note that some MinGW-w64 distributions come with the `win32` threading model
enabled by default instead of the `posix` threading model. The `win32`
threading model lacks proper support for C++11 `<thread>` and `<mutex>` as
well as thread-safe magic statics. It is recommended to use the `posix`
threading model for libopenmpt for this reason. On Debian, the appropriate
configure command is
`./configure --host=x86_64-w64-mingw32 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix`
for 64bit, or
`./configure --host=i686-w64-mingw32 CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix`
for 32bit. Other MinGW-w64 distributions may differ.
- Visual Studio:
- You will find solutions for Visual Studio in the matching
`build/vsVERSIONwinWINDOWSVERSION/` folder.
Minimal projects that target Windows 10 UWP are available in
`build/vsVERSIONuwp/`.
Most projects are supported with any of the mentioned Visual Studio
verions, with the following exceptions:
- in_openmpt: Requires Visual Studio with MFC.
- xmp-openmpt: Requires Visual Studio with MFC.
- libopenmpt requires the compile host system to be amd64 or ARM64 when
building with Visual Studio.
- In order to build libopenmpt for Windows XP, the Visual Studio 2017 XP
targeting toolset as well as the Windows 8.1 SDK need to be installed.
The SDK is optionally included with Visual Studio 2017, but must be
separately installed with later Visual Studio versions.
The Windows 8.1 SDK is available from
<https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/>
or directly from
<https://download.microsoft.com/download/B/0/C/B0C80BA3-8AD6-4958-810B-6882485230B5/standalonesdk/sdksetup.exe>
.
- You will need the Winamp 5 SDK and the XMPlay SDK if you want to
compile the plugins for these 2 players. They can be downloaded
automatically on Windows 7 or later by just running the
`build/download_externals.cmd` script.
If you do not want to or cannot use this script, you may follow these
manual steps instead:
- Winamp 5 SDK:
To build libopenmpt as a winamp input plugin, copy the contents of
`WA5.55_SDK.exe` to include/winamp/.
Please visit
[winamp.com](http://wiki.winamp.com/wiki/Plug-in_Developer) to
download the SDK.
You can disable in_openmpt in the solution configuration.
- XMPlay SDK:
To build libopenmpt with XMPlay input plugin support, copy the
contents of xmp-sdk.zip into include/xmplay/.
Please visit [un4seen.com](https://www.un4seen.com/xmplay.html) to
download the SDK.
You can disable xmp-openmpt in the solution configuration.
- Makefile
The makefile supports different build environments and targets via the
`CONFIG=` parameter directly to the make invocation.
Use `make CONFIG=$newconfig clean` when switching between different configs
because the makefile cleans only intermediates and target that are active
for the current config and no configuration state is kept around across
invocations.
- native build:
Simply run
make
which will try to guess the compiler based on your operating system.
- gcc or clang (on Unix-like systems, including Mac OS X with MacPorts,
and Haiku (32-bit Hybrid and 64-bit)):
The Makefile requires pkg-config for native builds.
For sound output in openmpt123, PortAudio or SDL is required.
openmpt123 can optionally use libflac and libsndfile to render PCM
files to disk.
When you want to use gcc, run:
make CONFIG=gcc
When you want to use clang, it is recommended to do:
make CONFIG=clang
- MinGW-w64:
make CONFIG=mingw-w64 \
MINGW_FLAVOUR=[|-posix|-win32] \
WINDOWS_ARCH=[x86|amd64] \
WINDOWS_FAMILY=[|desktop-app|app|phone-app|pc-app] \
WINDOWS_VERSION=[win95|win98|winme|winnt4|win2000|winxp|winxp64|winvista|win7|win8|win8.1|win10]
- emscripten (on Unix-like systems):
Run:
# generates WebAssembly with JavaScript fallback
make CONFIG=emscripten EMSCRIPTEN_TARGET=all
or
# generates WebAssembly
make CONFIG=emscripten EMSCRIPTEN_TARGET=wasm
or
# generates JavaScript with compatibility for older VMs
make CONFIG=emscripten EMSCRIPTEN_TARGET=js
Running the test suite on the command line is also supported by using
node.js. Depending on how your distribution calls the `node.js` binary,
you might have to edit `build/make/config-emscripten.mk`.
- DJGPP / DOS
Cross-compilation from Linux systems is supported with DJGPP GCC via
make CONFIG=djgpp
`openmpt123` can use liballegro 4.2 for sound output on DJGPP/DOS.
liballegro needs to be downloaded into the `libopenmpt` source tree.
./build/download_externals.sh # download liballegro source
make CONFIG=djgpp USE_ALLEGRO42=1
- afl++:
To compile libopenmpt with fuzzing instrumentation using afl++, run:
make CONFIG=afl
For more detailed instructions, read `contrib/fuzzing/readme.md`.
- other compilers:
To compile libopenmpt with other compliant compilers, run:
make CONFIG=generic
The `Makefile` supports some customizations. You might want to read the top
which should get you some possible make settings, like e.g.
`make DYNLINK=0` or similar. Cross compiling or different compiler would
best be implemented via new `config-*.mk` files.
The `Makefile` also supports building doxygen documentation by using
make doc
Binaries and documentation can be installed systen-wide with
make PREFIX=/yourprefix install
make PREFIX=/yourprefix install-doc
Some systems (i.e. Linux) require running
sudo ldconfig
in order for the system linker to be able to pick up newly installed
libraries.
`PREFIX` defaults to `/usr/local`. A `DESTDIR=` parameter is also
supported.
- Android NDK
See `build/android_ndk/README.AndroidNDK.txt`.
### Building libopenmpt with any other build system
libopenmpt is very simple to build with any build system of your choice. The
only required information is listed below. We currently only support building
libopenmpt itself this way, but the test suite and openmpt123 may follow later.
- language:
- C++17 / C++20 / C++23
- defines:
- LIBOPENMPT_BUILD
- private include directories:
- .
- common
- src
- files:
- common/*.cpp
- sounddsp/*.cpp
- soundlib/*.cpp
- soundlib/plugins/*.cpp
- soundlib/plugins/dmo/*.cpp
- libopenmpt/*.cpp
- public include directories:
- .
- public header files:
- libopenmpt/libopenmpt.h
- libopenmpt/libopenmpt.hpp
- libopenmpt/libopenmpt_config.h
- libopenmpt/libopenmpt_ext.h
- libopenmpt/libopenmpt_ext.hpp
- libopenmpt/libopenmpt_version.h
- libopenmpt/libopenmpt_stream_callbacks_buffer.h
- libopenmpt/libopenmpt_stream_callbacks_fd.h
- libopenmpt/libopenmpt_stream_callbacks_file_mingw.h
- libopenmpt/libopenmpt_stream_callbacks_file_msvcrt.h
- libopenmpt/libopenmpt_stream_callbacks_file_posix.h
- libopenmpt/libopenmpt_stream_callbacks_file_posix_lfs64.h
- dependencies:
- zlib:
- pkg-config
- zlib
- defines
- MPT_WITH_ZLIB
- libmpg123:
- pkg-config
- mpg123
- defines
- MPT_WITH_MPG123
- libogg:
- pkg-config
- ogg
- defines
- MPT_WITH_OGG
- libvorbis:
- pkg-config
- vorbis
- defines
- MPT_WITH_VORBIS
- libvorbisfile:
- pkg-config
- vorbisfile
- defines
- MPT_WITH_VORBISFILE
- dll:
- build:
- defines
- LIBOPENMPT_BUILD_DLL
- use:
- defines
- LIBOPENMPT_USE_DLL
+43
View File
@@ -0,0 +1,43 @@
/*!
* \mainpage Contents
*
* libopenmpt is a cross-platform C++ and C library to decode <a href="https://en.wikipedia.org/wiki/Module_file">tracked music files (modules)</a> into a raw PCM audio stream.
*
* libopenmpt is based on the player code of the OpenMPT project (Open ModPlug Tracker, <a href="https://openmpt.org/">https://openmpt.org/</a>)
*
* \section toc Contents
* - \ref md_README "README"
* - \ref dependencies "Dependencies"
* - \ref gettingstarted "Getting Started"
* - \ref packaging "Packaging"
* - \ref md_doc_contributing "Contributing"
* - \ref md_doc_libopenmpt_styleguide "libopenmpt Style Guide"
* - \ref md_doc_openmpt_styleguide "OpenMPT Style Guide"
* - \ref tests "Tests"
* - \ref changelog "Changelog"
* - \ref md_doc_module_formats "Implementing new Module Formats"
* - <a href="https://bugs.openmpt.org/">Issue Tracker</a>
* \subsection toc_apis APIs
* - libopenmpt
* - \ref libopenmpt "Common Details"
* - libopenmpt C++
* - \ref libopenmpt_cpp_overview "Overview"
* - \ref libopenmpt_cpp "Details"
* - libopenmpt C
* - \ref libopenmpt_c_overview "Overview"
* - \ref libopenmpt_c "Details"
* - libopenmpt_ext C++
* - \ref libopenmpt_ext_cpp_overview "Overview"
* - \ref libopenmpt_ext_cpp "Details"
* - libopenmpt_ext C
* - \ref libopenmpt_ext_c_overview "Overview"
* - \ref libopenmpt_ext_c "Details"
*
* \section toc_website Website
* https://lib.openmpt.org/
*
* \section toc_license License
* \include LICENSE
*
*/
+38
View File
@@ -0,0 +1,38 @@
Packaging {#packaging}
=========
Packaging
---------
### Packaging recommendations for distribution package maintainers
* libopenmpt (since 0.3) uses SemVer 2.0.0 versioning. See
[semver.org](https://semver.org/spec/v2.0.0.html). Clause 4 is ignored for
libopenmpt, which means that libopenmpt will also provide API/ABI
compatibility semantics for pre-1.0.0 versions as required by SemVer 2.0.0
only for post-1.0.0 versions. The SemVer versioning scheme is incompatible
with Debian/Ubuntu package versions, however it can easily be processed to
be compatible by replacing '-' (hyphen) with '~' (tilde). It is recommended
that you use this exact transformation if required.
* Use the autotools source package.
* Use the default set of dependencies required by the autotools package.
* Read \ref libopenmpt_c_staticlinking and thus possibly pass
`CXXSTDLIB_PCLIBSPRIVATE` variable to `configure` if appropriate and/or
desired.
* Run the test suite in your build process.
* Send any build system improvement patches upstream.
* Do not include the libmodplug emulation layer in the default libopenmpt
binary package. Either do not package it at all, or provide a separate
package named libopenmpt-modplug or libmodplug-openmpt (or similar), which
depends on libopenmpt, provides libmodplug, and conflicts with original
libmodplug.
* Split openmpt123 into its own binary package because it has more
dependencies than libopenmpt itself.
* Consider providing an additional openmpt123 package (in addition to the
default openmpt123 package with all audio output drivers), built with fewer
audio output drivers so it does not transitively depend on X11. Name that
package and its executable openmpt123-nox (or whatever else may be common
practice in your distribution).
+44
View File
@@ -0,0 +1,44 @@
Tests {#tests}
=====
libopenmpt provides some basic unit tests that check the platform for general
sanity and do some basic internal functionality testing. The test suite
requires a special libopenmpt build that includes file saving functionality
which is not included in normal builds. This is handled by all provided build
systems automatically.
### Running Tests
#### On Unix-like systems
Compile with
make $YOURMAKEOPTIONS clean
make $YOURMAKEOPTIONS
and run
make $YOURMAKEOPTIONS check
As the build system retains no state between make invocations, you have to
provide your make options on every make invocation.
#### Autotools-based build system
./configure
make check
#### On Windows
Using Visual Studio 20??, compile
build\vs20??\libopenmpt_test.sln
and run
bin\$ARCH\libopenmpt_test.exe
from the root of the source tree.
+104
View File
@@ -0,0 +1,104 @@
libopenmpt Style Guide
======================
### libopenmpt
**Note:**
**This applies to `libopenmpt/` and `openmpt123/` directories only.**
**Use OpenMPT style otherwise.**
The code generally tries to follow these conventions, but they are not
strictly enforced and there are valid reasons to diverge from these
conventions. Using common sense is recommended.
- In general, the most important thing is to keep style consistent with
directly surrounding code.
- Use C++ std types when possible, prefer `std::size_t` and `std::int32_t`
over `long` or `int`. Do not use C99 std types (e.g. no pure `int32_t`)
- Qualify namespaces explicitly, do not use `using`.
Members of `namespace openmpt` can be named without full namespace
qualification.
- Prefer the C++ version in `namespace std` if the same functionality is
provided by the C standard library as well. Also, include the C++
version of C standard library headers (e.g. use `<cstdio>` instead of
`<stdio.h>`.
- Do not use ANY locale-dependant C functions. For locale-dependant C++
functionaly (especially iostream), always imbue the
`std::locale::classic()` locale.
- Prefer kernel_style_names over CamelCaseNames.
- If a folder (or one of its parent folders) contains .clang-format,
use clang-format v3.5 for indenting C++ and C files, otherwise:
- `{` are placed at the end of the opening line.
- Enclose even single statements in curly braces.
- Avoid placing single statements on the same line as the `if`.
- Opening parentheses are separated from keywords with a space.
- Opening parentheses are not separated from function names.
- Place spaces around operators and inside parentheses.
- Align `:` and `,` when inheriting or initializing members in a
constructor.
- The pointer `*` is separated from both the type and the variable name.
- Use tabs for identation, spaces for formatting.
Tabs should only appear at the very beginning of a line.
Do not assume any particular width of the TAB character. If width is
important for formatting reasons, use spaces.
- Use empty lines at will.
- API documentation is done with doxygen.
Use general C doxygen for the C API.
Use QT-style doxygen for the C++ API.
#### libopenmpt indentation example
~~~~{.cpp}
namespace openmpt {
// This is totally meaningless code and just illustrates indentation.
class foo
: public base
, public otherbase
{
private:
std::int32_t x;
std::int16_t y;
public:
foo()
: x(0)
, y(-1)
{
return;
}
int bar() const;
}; // class foo
int foo::bar() const {
for ( int i = 0; i < 23; ++i ) {
switch ( x ) {
case 2:
something( y );
break;
default:
something( ( y - 1 ) * 2 );
break;
}
}
if ( x == 12 ) {
return -1;
} else if ( x == 42 ) {
return 1;
}
return 42;
}
} // namespace openmpt
~~~~
+110
View File
@@ -0,0 +1,110 @@
Adding support for new module formats
=====================================
This document describes the basics of writing a new module loader and related
work that has to be done. We will not discuss in detail how to write the loader,
have a look at existing loaders to get an idea how they work in general.
General hints
-------------
* We strive for quality over quantity. The goal is not to support as many module
formats as possible, but to support them as well as possible.
* Write defensive code. Guard against out-of-bound values, division by zero and
similar stuff. libopenmpt is constantly fuzz-tested to catch any crashes, but
of course we want our code to be reliable from the start.
* Every format should have its own `MODTYPE` flag, unless it can be reasonably
represented as a subset of another format (like Ice Tracker ICE files being
a subset of ProTracker MOD).
* When reading binary structs from the file, use our data types with defined
endianness, which can be found in `common/Endianness.h`:
* Big-Endian: (u)int8/16/24/32/64be, float32be, float64be
* Little-Endian: (u)int8/16/24/32/64le, float32le, float64le
Entire structs containing integers with defined endianness can be read in one
go if they are tagged with `MPT_BINARY_STRUCT` (see existing loaders for an
example).
* `CSoundFile::ChnSettings` **MUST NOT** be resized after a pattern has been
created, as existing patterns will be interpreted incorrectly. For module
formats that support per-pattern channel amounts, the maximum number of
channels must be determined beforehand.
* Strings can be safely handled using:
* `FileReader::ReadString` and friends for reading them directly from a file
* `mpt::String::ReadBuf` for reading them from a struct or char array
These functions take care of string padding (zero / space padding) and will
avoid reading past the end of the string if there is no terminating null
character.
* Do not use non-const static variables in your loader. Loaders need to be
thread-safe for libopenmpt.
* `FileReader` instances may be used to treat a portion of a file as its own
independent file (through `FileReader::ReadChunk`). This can be useful with
"embedded files" such as WAV or Ogg samples (see MO3 or SymMOD for examples).
Container formats such as UMX are another good example for this usage.
* Samples *either* use middle-C frequency *or* finetune + transpose. For the few
weird formats that use both, it may make sense to translate everything into
middle-C frequency.
* Add the new `MODTYPE` to `CSoundFile::UseFinetuneAndTranspose` if applicable,
and see if any effect handlers in `soundlib/Snd_fx.cpp` need to know the new
`MODTYPE`.
* Do not rely on hard-coded magic numbers. For example, when comparing if an
index is valid for a given array, do not hard-code the array size but rather
use `std::size` (or `mpt::array_size` in contexts where `std::size` is not
usable) or, for ensuring that char arrays are null-terminated,
`mpt::String::SetNullTerminator`. Similarly, do not assume any specific
quantities for OpenMPT's constants like MAX_SAMPLES, MAX_PATTERN_ROWS, etc.
These may change at any time.
* Pay attention to off-by-one errors when comparing against MAX_SAMPLES and
MAX_INSTRUMENTS, since sample and instrument numbers are 1-based. Prefer using
`CSoundFile::CanAddMoreSamples` and `CSoundFile::CanAddMoreInstruments` to
check if a given amount of samples or instruments can be added to the file
rather than doing the calculations yourself.
* Placement of the loader function in the `ModuleFormatLoaders` array in
Sndfile.cpp depends on various factors. In general, module formats that have
very bad magic numbers (and thus might cause other formats to get
mis-interpreted) should be placed at the bottom of the list. Two notable
examples are 669 files, where the first two bytes of the file are "if"
(which may e.g. cause a song title starting with if ..." in various other
formats to be interpreted as a 669 module), and of course
Ultimate SoundTracker modules, which have no magic bytes at all.
* Avoid use of functions tagged with `[[deprecated]]`.
Probing
-------
libopenmpt provides fast probing functions that can be used by library users
to quickly check if a file is most likely playable with libopenmpt, even if only
a fraction of the file is available (e.g. when streaming from the internet).
In order to satisfy these requirements, probing functions should do as little
work as possible (e.g. only parse the header of the file), but as much as
required to tell with some certainty that the file is really of a certain mod
format. However, probing functions should not rely on having access to more than
the first `CSoundFile::ProbeRecommendedSize` bytes of the file.
* Probing functions **must not** allocate any memory on the heap.
* Probing functions **must not** return ProbeFailure or ProbeWantMoreData for
any file that would normally be accepted by the loader. In particular, this
means that any header checks must not be any more aggressive than they would
be in the real loader (hence it is a good idea to not copy-paste this code but
rather put it in a reusable function), and the minimum additional size passed
to `CSoundFile::ProbeAdditionalSize` must not be higher than the biggest size
that would cause a hard failure (i.e. returning `false`) in the module loader.
* Probing functions **may** return ProbeSuccess for files that would be rejected
by a loader after a more thorough inspection. For example, probing functions
do not need to verify that all required chunks of an IFF-like file format are
actually present, if the header makes it obvious enough that the file is
highly likely to be a module.
Adding loader to the build systems and various other locations
--------------------------------------------------------------
Apart from writing the module loader itself, there are a couple of other places
that need to be updated:
* Add loader file to `build/android_ndk/Android.mk`.
* Add loader file to `build/autotools/Makefile.am`.
* Run `build/regenerate_vs_projects.sh` / `build/regenerate_vs_projects.cmd`
(depending on your platform)
* Add file extension to `installer/filetypes-*.iss`.
* Add file extension to `CTrackApp::OpenModulesDialog` in `mptrack/Mptrack.cpp`
as required (e.g. if it's a compressed container format or if it's relevant
enough to be mentioned).
* Add format information to `soundlib/Tables.cpp`.
* Add magic bytes to `contrib/fuzzing/all_formats.dict`.
+35
View File
@@ -0,0 +1,35 @@
OpenMPT Style Guide
===================
### OpenMPT
**Note:**
**This applies to all source code *except* for `libopenmpt/` and `openmpt123/`**
**directories.**
**Use libopenmpt style otherwise.**
(see below for an example)
* Place curly braces at the beginning of the line, not at the end
* Generally make use of the custom index types like `SAMPLEINDEX` or
`ORDERINDEX` when referring to samples, orders, etc.
* When changing playback behaviour, make sure that you use the function
`CSoundFile::IsCompatibleMode()` so that modules made with previous versions
of MPT still sound correct (if the change is extremely small, this might be
unnecessary)
* `CamelCase` function and variable names are preferred.
#### OpenMPT code example
~~~~{.cpp}
void Foo::Bar(int foobar)
{
while(true)
{
// some code
}
}
~~~~