libopenmpt  0.2.7299-autotools
cross-platform C++ and C library to decode tracked music files
openmpt Namespace Reference

Namespaces

 ext
 
 string
 

Classes

class  exception
 
class  module
 
class  module_ext
 

Functions

LIBOPENMPT_CXX_API std::uint32_t get_library_version ()
 Get the libopenmpt version number. More...
 
LIBOPENMPT_CXX_API std::uint32_t get_core_version ()
 Get the core version number. More...
 
LIBOPENMPT_CXX_API std::vector< std::string > get_supported_extensions ()
 Get a list of supported file extensions. More...
 
LIBOPENMPT_CXX_API bool is_extension_supported (const std::string &extension)
 Query whether a file extension is supported. More...
 
LIBOPENMPT_CXX_API double could_open_propability (std::istream &stream, double effort=1.0, std::ostream &log=std::clog)
 Roughly scan the input stream to find out whether libopenmpt might be able to open it. More...
 

Function Documentation

§ could_open_propability()

LIBOPENMPT_CXX_API double openmpt::could_open_propability ( std::istream &  stream,
double  effort = 1.0,
std::ostream &  log = std::clog 
)

Roughly scan the input stream to find out whether libopenmpt might be able to open it.

Parameters
streamInput stream to scan.
effortEffort to make when validating stream. Effort 0.0 does not even look at stream at all and effort 1.0 completely loads the file from stream. A lower effort requires less data to be loaded but only gives a rough estimate answer. Use an effort of 0.25 to only verify the header data of the module file.
logLog where warning and errors are written.
Returns
Probability between 0.0 and 1.0.
Remarks
openmpt::could_open_propability() can return any value between 0.0 and 1.0. Only 0.0 and 1.0 are definitive answers, all values in between are just estimates. In general, any return value >0.0 means that you should try loading the file, and any value below 1.0 means that loading may fail. If you want a threshold above which you can be reasonably sure that libopenmpt will be able to load the file, use >=0.5. If you see the need for a threshold below which you could reasonably outright reject a file, use <0.25 (Note: Such a threshold for rejecting on the lower end is not recommended, but may be required for better integration into some other framework's probe scoring.).
openmpt::could_open_propability() expects the complete file data to be eventually available to it, even if it is asked to just parse the header. Verification will be unreliable (both false positives and false negatives), if you pretend that the file is just some few bytes of initial data threshold in size. In order to really just access the first bytes of a file, check in your std::istream implementation whether data or seeking is requested beyond your initial data threshold, and in that case, return an error. openmpt::could_open_propability() will treat this as any other I/O error and return 0.0. You must not expect the correct result in this case. You instead must remember that it asked for more data than you currently want to provide to it and treat this situation as if openmpt::could_open_propability() returned 0.5.
See also
File I/O

§ get_core_version()

LIBOPENMPT_CXX_API std::uint32_t openmpt::get_core_version ( )

Get the core version number.

Return the OpenMPT core version number.

Returns
The value represents (majormajor << 24 + major << 16 + minor << 8 + minorminor).

§ get_library_version()

LIBOPENMPT_CXX_API std::uint32_t openmpt::get_library_version ( )

Get the libopenmpt version number.

Returns the libopenmpt version number.

Returns
The value represents (major << 24 + minor << 16 + revision).

§ get_supported_extensions()

LIBOPENMPT_CXX_API std::vector<std::string> openmpt::get_supported_extensions ( )

Get a list of supported file extensions.

Returns
The list of extensions supported by this libopenmpt build. The extensions are returned lower-case without a leading dot.

§ is_extension_supported()

LIBOPENMPT_CXX_API bool openmpt::is_extension_supported ( const std::string &  extension)

Query whether a file extension is supported.

Parameters
extensionfile extension to query without a leading dot. The case is ignored.
Returns
true if the extension is supported by libopenmpt, false otherwise.