libopenmpt  0.2.5787-autotools
cross-platform C++ and C library to decode tracked music files
libopenmpt C

Classes

struct  openmpt_stream_callbacks
 Stream callbacks. More...
 
struct  openmpt_module_initial_ctl
 

Macros

#define OPENMPT_STRING_LIBRARY_VERSION   "library_version"
 
#define OPENMPT_STRING_LIBRARY_FEATURES   "library_features"
 
#define OPENMPT_STRING_CORE_VERSION   "core_version"
 
#define OPENMPT_STRING_BUILD   "build"
 
#define OPENMPT_STRING_CREDITS   "credits"
 
#define OPENMPT_STRING_CONTACT   "contact"
 
#define OPENMPT_STRING_LICENSE   "license"
 
#define OPENMPT_STREAM_SEEK_SET   0
 
#define OPENMPT_STREAM_SEEK_CUR   1
 
#define OPENMPT_STREAM_SEEK_END   2
 
#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL   1
 Master Gain. More...
 
#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT   2
 Stereo Separation. More...
 
#define OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH   3
 Interpolation Filter. More...
 
#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH   4
 Volume Ramping Strength. More...
 
#define OPENMPT_MODULE_COMMAND_NOTE   0
 Parameter index to use with openmpt_module_get_pattern_row_channel_command, openmpt_module_format_pattern_row_channel_command and openmpt_module_highlight_pattern_row_channel_command. More...
 
#define OPENMPT_MODULE_COMMAND_INSTRUMENT   1
 
#define OPENMPT_MODULE_COMMAND_VOLUMEEFFECT   2
 
#define OPENMPT_MODULE_COMMAND_EFFECT   3
 
#define OPENMPT_MODULE_COMMAND_VOLUME   4
 
#define OPENMPT_MODULE_COMMAND_PARAMETER   5
 

Typedefs

typedef size_t(* openmpt_stream_read_func) (void *stream, void *dst, size_t bytes)
 Read bytes from stream. More...
 
typedef int(* openmpt_stream_seek_func) (void *stream, int64_t offset, int whence)
 Seek stream position. More...
 
typedef int64_t(* openmpt_stream_tell_func) (void *stream)
 Tell stream position. More...
 
typedef struct openmpt_stream_callbacks openmpt_stream_callbacks
 Stream callbacks. More...
 
typedef void(* openmpt_log_func) (const char *message, void *user)
 Logging function. More...
 
typedef struct openmpt_module openmpt_module
 Opaque type representing a libopenmpt module. More...
 
typedef struct openmpt_module_initial_ctl openmpt_module_initial_ctl
 

Functions

uint32_t openmpt_get_library_version (void)
 Get the libopenmpt version number. More...
 
uint32_t openmpt_get_core_version (void)
 Get the core version number. More...
 
void openmpt_free_string (const char *str)
 Free a string returned by libopenmpt. More...
 
const char * openmpt_get_string (const char *key)
 Get library related metadata. More...
 
const char * openmpt_get_supported_extensions (void)
 Get a list of supported file extensions. More...
 
int openmpt_is_extension_supported (const char *extension)
 Query whether a file extension is supported. More...
 
void openmpt_log_func_default (const char *message, void *user)
 Default logging function. More...
 
void openmpt_log_func_silent (const char *message, void *user)
 Silent logging function. More...
 
double openmpt_could_open_propability (openmpt_stream_callbacks stream_callbacks, void *stream, double effort, openmpt_log_func logfunc, void *user)
 Roughly scan the input stream to find out whether libopenmpt might be able to open it. More...
 
openmpt_moduleopenmpt_module_create (openmpt_stream_callbacks stream_callbacks, void *stream, openmpt_log_func logfunc, void *user, const openmpt_module_initial_ctl *ctls)
 Construct an openmpt_module. More...
 
openmpt_moduleopenmpt_module_create_from_memory (const void *filedata, size_t filesize, openmpt_log_func logfunc, void *user, const openmpt_module_initial_ctl *ctls)
 Construct an openmpt_module. More...
 
void openmpt_module_destroy (openmpt_module *mod)
 Unload a previously created openmpt_module from memory. More...
 
int openmpt_module_select_subsong (openmpt_module *mod, int32_t subsong)
 Select a subsong from a multi-song module. More...
 
int openmpt_module_set_repeat_count (openmpt_module *mod, int32_t repeat_count)
 Set Repeat Count. More...
 
int32_t openmpt_module_get_repeat_count (openmpt_module *mod)
 Get Repeat Count. More...
 
double openmpt_module_get_duration_seconds (openmpt_module *mod)
 approximate song duration More...
 
double openmpt_module_set_position_seconds (openmpt_module *mod, double seconds)
 Set approximate current song position. More...
 
double openmpt_module_get_position_seconds (openmpt_module *mod)
 Get current song position. More...
 
double openmpt_module_set_position_order_row (openmpt_module *mod, int32_t order, int32_t row)
 Set approximate current song position. More...
 
int openmpt_module_get_render_param (openmpt_module *mod, int param, int32_t *value)
 Get render parameter. More...
 
int openmpt_module_set_render_param (openmpt_module *mod, int param, int32_t value)
 Set render parameter. More...
 
const char * openmpt_module_get_metadata_keys (openmpt_module *mod)
 Get the list of supported metadata item keys. More...
 
const char * openmpt_module_get_metadata (openmpt_module *mod, const char *key)
 Get a metadata item value. More...
 
int32_t openmpt_module_get_current_speed (openmpt_module *mod)
 Get the current speed. More...
 
int32_t openmpt_module_get_current_tempo (openmpt_module *mod)
 Get the current tempo. More...
 
int32_t openmpt_module_get_current_order (openmpt_module *mod)
 Get the current order. More...
 
int32_t openmpt_module_get_current_pattern (openmpt_module *mod)
 Get the current pattern. More...
 
int32_t openmpt_module_get_current_row (openmpt_module *mod)
 Get the current row. More...
 
int32_t openmpt_module_get_current_playing_channels (openmpt_module *mod)
 Get the current amount of playing channels. More...
 
float openmpt_module_get_current_channel_vu_mono (openmpt_module *mod, int32_t channel)
 Get an approximate indication of the channel volume. More...
 
float openmpt_module_get_current_channel_vu_left (openmpt_module *mod, int32_t channel)
 Get an approximate indication of the channel volume on the front-left speaker. More...
 
float openmpt_module_get_current_channel_vu_right (openmpt_module *mod, int32_t channel)
 Get an approximate indication of the channel volume on the front-right speaker. More...
 
float openmpt_module_get_current_channel_vu_rear_left (openmpt_module *mod, int32_t channel)
 Get an approximate indication of the channel volume on the rear-left speaker. More...
 
float openmpt_module_get_current_channel_vu_rear_right (openmpt_module *mod, int32_t channel)
 Get an approximate indication of the channel volume on the rear-right speaker. More...
 
int32_t openmpt_module_get_num_subsongs (openmpt_module *mod)
 Get the number of subsongs. More...
 
int32_t openmpt_module_get_num_channels (openmpt_module *mod)
 Get the number of pattern channels. More...
 
int32_t openmpt_module_get_num_orders (openmpt_module *mod)
 Get the number of orders. More...
 
int32_t openmpt_module_get_num_patterns (openmpt_module *mod)
 Get the number of patterns. More...
 
int32_t openmpt_module_get_num_instruments (openmpt_module *mod)
 Get the number of instruments. More...
 
int32_t openmpt_module_get_num_samples (openmpt_module *mod)
 Get the number of samples. More...
 
const char * openmpt_module_get_subsong_name (openmpt_module *mod, int32_t index)
 Get a subsong name. More...
 
const char * openmpt_module_get_channel_name (openmpt_module *mod, int32_t index)
 Get a channel name. More...
 
const char * openmpt_module_get_order_name (openmpt_module *mod, int32_t index)
 Get an order name. More...
 
const char * openmpt_module_get_pattern_name (openmpt_module *mod, int32_t index)
 Get a pattern name. More...
 
const char * openmpt_module_get_instrument_name (openmpt_module *mod, int32_t index)
 Get an instrument name. More...
 
const char * openmpt_module_get_sample_name (openmpt_module *mod, int32_t index)
 Get a sample name. More...
 
int32_t openmpt_module_get_order_pattern (openmpt_module *mod, int32_t order)
 Get pattern at order position. More...
 
int32_t openmpt_module_get_pattern_num_rows (openmpt_module *mod, int32_t pattern)
 Get the number of rows in a pattern. More...
 
uint8_t openmpt_module_get_pattern_row_channel_command (openmpt_module *mod, int32_t pattern, int32_t row, int32_t channel, int command)
 Get raw pattern content. More...
 
const char * openmpt_module_format_pattern_row_channel_command (openmpt_module *mod, int32_t pattern, int32_t row, int32_t channel, int command)
 Get formatted (human-readable) pattern content. More...
 
const char * openmpt_module_highlight_pattern_row_channel_command (openmpt_module *mod, int32_t pattern, int32_t row, int32_t channel, int command)
 Get highlighting information for formatted pattern content. More...
 
const char * openmpt_module_format_pattern_row_channel (openmpt_module *mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad)
 Get formatted (human-readable) pattern content. More...
 
const char * openmpt_module_highlight_pattern_row_channel (openmpt_module *mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad)
 Get highlighting information for formatted pattern content. More...
 
const char * openmpt_module_get_ctls (openmpt_module *mod)
 Retrieve supported ctl keys. More...
 
const char * openmpt_module_ctl_get (openmpt_module *mod, const char *ctl)
 Get current ctl value. More...
 
int openmpt_module_ctl_set (openmpt_module *mod, const char *ctl, const char *value)
 Set ctl value. More...
 
size_t openmpt_module_read_mono (openmpt_module *mod, int32_t samplerate, size_t count, int16_t *mono)
 Render audio data. More...
 
size_t openmpt_module_read_stereo (openmpt_module *mod, int32_t samplerate, size_t count, int16_t *left, int16_t *right)
 Render audio data. More...
 
size_t openmpt_module_read_quad (openmpt_module *mod, int32_t samplerate, size_t count, int16_t *left, int16_t *right, int16_t *rear_left, int16_t *rear_right)
 Render audio data. More...
 
size_t openmpt_module_read_float_mono (openmpt_module *mod, int32_t samplerate, size_t count, float *mono)
 Render audio data. More...
 
size_t openmpt_module_read_float_stereo (openmpt_module *mod, int32_t samplerate, size_t count, float *left, float *right)
 Render audio data. More...
 
size_t openmpt_module_read_float_quad (openmpt_module *mod, int32_t samplerate, size_t count, float *left, float *right, float *rear_left, float *rear_right)
 Render audio data. More...
 
size_t openmpt_module_read_interleaved_stereo (openmpt_module *mod, int32_t samplerate, size_t count, int16_t *interleaved_stereo)
 Render audio data. More...
 
size_t openmpt_module_read_interleaved_quad (openmpt_module *mod, int32_t samplerate, size_t count, int16_t *interleaved_quad)
 Render audio data. More...
 
size_t openmpt_module_read_interleaved_float_stereo (openmpt_module *mod, int32_t samplerate, size_t count, float *interleaved_stereo)
 Render audio data. More...
 
size_t openmpt_module_read_interleaved_float_quad (openmpt_module *mod, int32_t samplerate, size_t count, float *interleaved_quad)
 Render audio data. More...
 

Detailed Description

Macro Definition Documentation

#define OPENMPT_MODULE_COMMAND_EFFECT   3
#define OPENMPT_MODULE_COMMAND_INSTRUMENT   1
#define OPENMPT_MODULE_COMMAND_NOTE   0

Parameter index to use with openmpt_module_get_pattern_row_channel_command, openmpt_module_format_pattern_row_channel_command and openmpt_module_highlight_pattern_row_channel_command.

#define OPENMPT_MODULE_COMMAND_PARAMETER   5
#define OPENMPT_MODULE_COMMAND_VOLUME   4
#define OPENMPT_MODULE_COMMAND_VOLUMEEFFECT   2
#define OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH   3

Interpolation Filter.

The related value represents the interpolation filter length used by the libopenmpt mixer.
The default value is 0, which indicates a recommended default value.
The supported value range is [0,inf). Values greater than the implementation limit are clamped to the maximum supported value.
Currently supported values:

  • 0: internal default
  • 1: no interpolation (zero order hold)
  • 2: linear interpolation
  • 4: cubic interpolation
  • 8: windowed sinc with 8 taps
#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL   1

Master Gain.

The related value represents a relative gain in milliBel.
The default value is 0.
The supported value range is unlimited.

#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT   2

Stereo Separation.

The related value represents the stereo separation generated by the libopenmpt mixer in percent.
The default value is 100.
The supported value range is [0,200].

#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH   4

Volume Ramping Strength.

The related value represents the amount of volume ramping done by the libopenmpt mixer.
The default value is -1, which indicates a recommended default value.
The meaningful value range is [-1..10].
A value of 0 completely disables volume ramping. This might cause clicks in sound output.
Higher values imply slower/softer volume ramps.

#define OPENMPT_STREAM_SEEK_CUR   1
#define OPENMPT_STREAM_SEEK_END   2
#define OPENMPT_STREAM_SEEK_SET   0
#define OPENMPT_STRING_BUILD   "build"

Return information about the current build (e.g. the build date or compiler used) from openmpt_get_string().

#define OPENMPT_STRING_CONTACT   "contact"

Return contact infromation about libopenmpt from openmpt_get_string().

#define OPENMPT_STRING_CORE_VERSION   "core_version"

Return a verbose OpenMPT core version string from openmpt_get_string().

#define OPENMPT_STRING_CREDITS   "credits"

Return all contributors from openmpt_get_string().

#define OPENMPT_STRING_LIBRARY_FEATURES   "library_features"

Return a verbose library features string from openmpt_get_string().

#define OPENMPT_STRING_LIBRARY_VERSION   "library_version"

Return a verbose library version string from openmpt_get_string().

#define OPENMPT_STRING_LICENSE   "license"

Return the libopenmpt license from openmpt_get_string().

Typedef Documentation

typedef void(* openmpt_log_func) (const char *message, void *user)

Logging function.

Parameters
messageUTF-8 encoded log message.
userUser context that was passed to openmpt_module_create(), openmpt_module_create_from_memory() or openmpt_could_open_propability().

Opaque type representing a libopenmpt module.

Stream callbacks.

Stream callbacks used by libopenmpt for stream operations.

typedef size_t(* openmpt_stream_read_func) (void *stream, void *dst, size_t bytes)

Read bytes from stream.

Read bytes data from stream to dst.

Parameters
streamStream to read data from
dstTarget where to copy data.
bytesNumber of bytes to read.
Returns
Number of bytes actually read and written to dst.
Return values
0End of stream or error.
typedef int(* openmpt_stream_seek_func) (void *stream, int64_t offset, int whence)

Seek stream position.

Seek to stream position offset at whence.

Parameters
streamStream to operate on.
offsetOffset to seek to.
whenceOPENMPT_STREAM_SEEK_SET, OPENMPT_STREAM_SEEK_CUR, OPENMPT_STREAM_SEEK_END. See C89 documentation.
Returns
Returns 0 on success.
Return values
0Success.
-1Failure. Position does not get updated.
typedef int64_t(* openmpt_stream_tell_func) (void *stream)

Tell stream position.

Tell position of stream.

Parameters
streamStream to operate on.
Returns
Current position in stream.
Return values
-1Failure. Position does not get updated.

Function Documentation

double openmpt_could_open_propability ( openmpt_stream_callbacks  stream_callbacks,
void *  stream,
double  effort,
openmpt_log_func  logfunc,
void *  user 
)

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

Parameters
stream_callbacksInput stream callback operations.
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.
logfuncLogging function where warning and errors are written.
userLogging function user context.
Returns
Propability between 0.0 and 1.0.
See also
openmpt_stream_callbacks
void openmpt_free_string ( const char *  str)

Free a string returned by libopenmpt.

Frees any string that got returned by libopenmpt.

uint32_t openmpt_get_core_version ( void  )

Get the core version number.

Return the OpenMPT core version number.

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

Get the libopenmpt version number.

Returns the libopenmpt version number.

Returns
The value represents (major << 24 + minor << 16 + revision).
const char* openmpt_get_string ( const char *  key)

Get library related metadata.

Parameters
keyKey to query.
Returns
A (possibly multi-line) string containing the queried information. If no information is available, the string is empty.
See also
OPENMPT_STRING_LIBRARY_VERSION
OPENMPT_STRING_CORE_VERSION
OPENMPT_STRING_BUILD
OPENMPT_STRING_CREDITS
OPENMPT_STRING_CONTACT
OPENMPT_STRING_LICENSE
const char* openmpt_get_supported_extensions ( void  )

Get a list of supported file extensions.

Returns
The semicolon-separated list of extensions supported by this libopenmpt build. The extensions are returned lower-case without a leading dot.
int openmpt_is_extension_supported ( const char *  extension)

Query whether a file extension is supported.

Parameters
extensionfile extension to query without a leading dot. The case is ignored.
Returns
1 if the extension is supported by libopenmpt, 0 otherwise.
void openmpt_log_func_default ( const char *  message,
void *  user 
)

Default logging function.

Default logging function that logs anything to stderr.

void openmpt_log_func_silent ( const char *  message,
void *  user 
)

Silent logging function.

Silent logging function that throws any log message away.

openmpt_module* openmpt_module_create ( openmpt_stream_callbacks  stream_callbacks,
void *  stream,
openmpt_log_func  logfunc,
void *  user,
const openmpt_module_initial_ctl ctls 
)

Construct an openmpt_module.

Parameters
stream_callbacksInput stream callback operations.
streamInput stream to load the module from.
logfuncLog 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.
userUser-defined data associated with this module. This value will be passed to the logging callback function (logfunc)
ctlsA map of initial ctl values, see openmpt_module_get_ctls.
Returns
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 succesfully.
See also
openmpt_stream_callbacks
openmpt_module* openmpt_module_create_from_memory ( const void *  filedata,
size_t  filesize,
openmpt_log_func  logfunc,
void *  user,
const openmpt_module_initial_ctl ctls 
)

Construct an openmpt_module.

Parameters
filedataData to load the module from.
filesizeAmount of data available.
logfuncLog 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.
userUser-defined data associated with this module. This value will be passed to the logging callback function (logfunc)
ctlsA map of initial ctl values, see openmpt_module_get_ctls.
Returns
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 succesfully.
const char* openmpt_module_ctl_get ( openmpt_module mod,
const char *  ctl 
)

Get current ctl value.

Parameters
modThe module handle to work on.
ctlThe ctl key whose value should be retrieved.
Returns
The associated ctl value, or NULL on failure.
See also
openmpt_module_get_ctls
int openmpt_module_ctl_set ( openmpt_module mod,
const char *  ctl,
const char *  value 
)

Set ctl value.

Parameters
modThe module handle to work on.
ctlThe ctl key whose value should be set.
valueThe value that should be set.
See also
openmpt_module_get_ctls
void openmpt_module_destroy ( openmpt_module mod)

Unload a previously created openmpt_module from memory.

Parameters
modThe module to unload.
const char* openmpt_module_format_pattern_row_channel ( openmpt_module mod,
int32_t  pattern,
int32_t  row,
int32_t  channel,
size_t  width,
int  pad 
)

Get formatted (human-readable) pattern content.

Parameters
modThe module handle to work on.
patternThe pattern whose data should be retrieved.
rowThe row from which the data should be retrieved.
channelThe channel from which the data should be retrieved.
widthThe maximum number of characters the string should contain. 0 means no limit.
padIf true, the string will be resized to the exact length provided in the width parameter.
Returns
The formatted pattern data at the given pattern position.
See also
openmpt_module_highlight_pattern_row_channel
const char* openmpt_module_format_pattern_row_channel_command ( openmpt_module mod,
int32_t  pattern,
int32_t  row,
int32_t  channel,
int  command 
)

Get formatted (human-readable) pattern content.

Parameters
modThe module handle to work on.
patternThe pattern whose data should be retrieved.
rowThe row from which the data should be retrieved.
channelThe channel from which the data should be retrieved.
commandThe cell index at which the data should be retrieved.
Returns
The formatted pattern data at the given pattern position. See openmpt_module_command_index
See also
openmpt_module_highlight_pattern_row_channel_command
const char* openmpt_module_get_channel_name ( openmpt_module mod,
int32_t  index 
)

Get a channel name.

Parameters
modThe module handle to work on.
indexThe channel whose name should be retreived
Returns
The channel name.
See also
openmpt_module_get_num_channels
const char* openmpt_module_get_ctls ( openmpt_module mod)

Retrieve supported ctl keys.

Parameters
modThe module handle to work on.
Returns
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_subsongs_init: Set to "1" to avoid pre-initializing subsongs. 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.
  • 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.
  • dither: 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
float openmpt_module_get_current_channel_vu_left ( openmpt_module mod,
int32_t  channel 
)

Get an approximate indication of the channel volume on the front-left speaker.

Parameters
modThe module handle to work on.
channelThe channel whose volume should be retrieved.
Returns
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 openmpt_module_get_current_channel_vu_mono ( openmpt_module mod,
int32_t  channel 
)

Get an approximate indication of the channel volume.

Parameters
modThe module handle to work on.
channelThe channel whose volume should be retrieved.
Returns
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 openmpt_module_get_current_channel_vu_rear_left ( openmpt_module mod,
int32_t  channel 
)

Get an approximate indication of the channel volume on the rear-left speaker.

Parameters
modThe module handle to work on.
channelThe channel whose volume should be retrieved.
Returns
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 openmpt_module_get_current_channel_vu_rear_right ( openmpt_module mod,
int32_t  channel 
)

Get an approximate indication of the channel volume on the rear-right speaker.

Parameters
modThe module handle to work on.
channelThe channel whose volume should be retrieved.
Returns
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 openmpt_module_get_current_channel_vu_right ( openmpt_module mod,
int32_t  channel 
)

Get an approximate indication of the channel volume on the front-right speaker.

Parameters
modThe module handle to work on.
channelThe channel whose volume should be retrieved.
Returns
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.
int32_t openmpt_module_get_current_order ( openmpt_module mod)

Get the current order.

Parameters
modThe module handle to work on.
Returns
The current order at which the module is being played back.
int32_t openmpt_module_get_current_pattern ( openmpt_module mod)

Get the current pattern.

Parameters
modThe module handle to work on.
Returns
The current pattern that is being played.
int32_t openmpt_module_get_current_playing_channels ( openmpt_module mod)

Get the current amount of playing channels.

Parameters
modThe module handle to work on.
Returns
The amount of sample channels that are currently being rendered.
int32_t openmpt_module_get_current_row ( openmpt_module mod)

Get the current row.

Parameters
modThe module handle to work on.
Returns
The current row at which the current pattern is being played.
int32_t openmpt_module_get_current_speed ( openmpt_module mod)

Get the current speed.

Parameters
modThe module handle to work on.
Returns
The current speed in ticks per row.
int32_t openmpt_module_get_current_tempo ( openmpt_module mod)

Get the current tempo.

Parameters
modThe module handle to work on.
Returns
The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used.
double openmpt_module_get_duration_seconds ( openmpt_module mod)

approximate song duration

Parameters
modThe module handle to work on.
Returns
Approximate duration of current subsong in seconds.
const char* openmpt_module_get_instrument_name ( openmpt_module mod,
int32_t  index 
)

Get an instrument name.

Parameters
modThe module handle to work on.
indexThe instrument whose name should be retreived
Returns
The instrument name.
See also
openmpt_module_get_num_instruments
const char* openmpt_module_get_metadata ( openmpt_module mod,
const char *  key 
)

Get a metadata item value.

Parameters
modThe module handle to work on.
keyMetadata 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_long: Tracker name associated with the module format (e.g. Impulse Tracker)
  • container: Container format the module file is embedded in, if any (e.g. umx)
  • container_long: Full container name if the module is embedded in a container (e.g. Unreal Music)
  • tracker: Tracker that was (most likely) used to save the module file, if known
  • artist: Author of the module
  • title: Module title
  • date: Date the module was last saved, in ISO-8601 format.
  • message: Song message. If the song message is empty or the module format does not support song messages, a list of instrument and sample names is returned instead.
  • message_raw: Song message. If the song message is empty or the module format does not support song messages, an empty string is returned.
  • warnings: A list of warnings that were generated while loading the module.
Returns
The associated value for key.
See also
openmpt_module_get_metadata_keys
const char* openmpt_module_get_metadata_keys ( openmpt_module mod)

Get the list of supported metadata item keys.

Parameters
modThe module handle to work on.
Returns
Metadata item keys supported by openmpt_module_get_metadata, as a semicolon-separated list.
See also
openmpt_module_get_metadata
int32_t openmpt_module_get_num_channels ( openmpt_module mod)

Get the number of pattern channels.

Parameters
modThe module handle to work on.
Returns
The number of pattern channels in the module. Not all channels do necessarily contain data.
int32_t openmpt_module_get_num_instruments ( openmpt_module mod)

Get the number of instruments.

Parameters
modThe module handle to work on.
Returns
The number of instrument slots in the module. Instruments are a layer on top of samples, and are not supported by all module formats.
int32_t openmpt_module_get_num_orders ( openmpt_module mod)

Get the number of orders.

Parameters
modThe module handle to work on.
Returns
The number of orders in the current sequence of the module.
int32_t openmpt_module_get_num_patterns ( openmpt_module mod)

Get the number of patterns.

Parameters
modThe module handle to work on.
Returns
The number of distinct patterns in the module.
int32_t openmpt_module_get_num_samples ( openmpt_module mod)

Get the number of samples.

Parameters
modThe module handle to work on.
Returns
The number of sample slots in the module.
int32_t openmpt_module_get_num_subsongs ( openmpt_module mod)

Get the number of subsongs.

Parameters
modThe module handle to work on.
Returns
The number of subsongs in the module. This includes any "hidden" songs (songs that share the same sequence, but start at different order indices) and "normal" subsongs or "sequences" (if the format supports them).
See also
openmpt_module_get_subsong_names, openmpt_module_select_subsong
const char* openmpt_module_get_order_name ( openmpt_module mod,
int32_t  index 
)

Get an order name.

Parameters
modThe module handle to work on.
indexThe order whose name should be retreived
Returns
The order name.
See also
openmpt_module_get_num_orders
int32_t openmpt_module_get_order_pattern ( openmpt_module mod,
int32_t  order 
)

Get pattern at order position.

Parameters
modThe module handle to work on.
orderThe order item whose pattern index should be retrieved.
Returns
The pattern index found at the given order position of the current sequence.
const char* openmpt_module_get_pattern_name ( openmpt_module mod,
int32_t  index 
)

Get a pattern name.

Parameters
modThe module handle to work on.
indexThe pattern whose name should be retreived
Returns
The pattern name.
See also
openmpt_module_get_num_patterns
int32_t openmpt_module_get_pattern_num_rows ( openmpt_module mod,
int32_t  pattern 
)

Get the number of rows in a pattern.

Parameters
modThe module handle to work on.
patternThe pattern whose row count should be retrieved.
Returns
The number of rows in the given pattern. If the pattern does not exist, 0 is returned.
uint8_t openmpt_module_get_pattern_row_channel_command ( openmpt_module mod,
int32_t  pattern,
int32_t  row,
int32_t  channel,
int  command 
)

Get raw pattern content.

Parameters
modThe module handle to work on.
patternThe pattern whose data should be retrieved.
rowThe row from which the data should be retrieved.
channelThe channel from which the data should be retrieved.
commandThe cell index at which the data should be retrieved. See openmpt_module_command_index
Returns
The internal, raw pattern data at the given pattern position.
double openmpt_module_get_position_seconds ( openmpt_module mod)

Get current song position.

Parameters
modThe module handle to work on.
Returns
Current song position in seconds.
See also
openmpt_module_set_position_seconds
int openmpt_module_get_render_param ( openmpt_module mod,
int  param,
int32_t *  value 
)

Get render parameter.

Parameters
modThe module handle to work on.
paramParameter to query. See openmpt_module_render_param.
valuePointer to the variable that receives the current value of the parameter.
Returns
1 on success, 0 on failure (invalid param or value is NULL).
See also
OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL
OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT
OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH
OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH
openmpt_module_set_render_param
int32_t openmpt_module_get_repeat_count ( openmpt_module mod)

Get Repeat Count.

Parameters
modThe module handle to work on.
Returns
Repeat Count
  • -1: repeat forever
  • 0: play once, repeat zero times (the default)
  • n>0: play once and repeat n times after that
See also
openmpt_module_set_repeat_count
const char* openmpt_module_get_sample_name ( openmpt_module mod,
int32_t  index 
)

Get a sample name.

Parameters
modThe module handle to work on.
indexThe sample whose name should be retreived
Returns
The sample name.
See also
openmpt_module_get_num_samples
const char* openmpt_module_get_subsong_name ( openmpt_module mod,
int32_t  index 
)

Get a subsong name.

Parameters
modThe module handle to work on.
indexThe subsong whose name should be retreived
Returns
The subsong name.
See also
openmpt_module_get_num_subsongs, openmpt_module_select_subsong
const char* openmpt_module_highlight_pattern_row_channel ( openmpt_module mod,
int32_t  pattern,
int32_t  row,
int32_t  channel,
size_t  width,
int  pad 
)

Get highlighting information for formatted pattern content.

Parameters
modThe module handle to work on.
patternThe pattern whose data should be retrieved.
rowThe row from which the data should be retrieved.
channelThe channel from which the data should be retrieved.
widthThe maximum number of characters the string should contain. 0 means no limit.
padIf true, the string will be resized to the exact length provided in the width parameter.
Returns
The highlighting string for the formatted pattern data as retrived by openmpt_module_format_pattern_row_channel at the given pattern position.
See also
openmpt_module_format_pattern_row_channel
const char* openmpt_module_highlight_pattern_row_channel_command ( openmpt_module mod,
int32_t  pattern,
int32_t  row,
int32_t  channel,
int  command 
)

Get highlighting information for formatted pattern content.

Parameters
modThe module handle to work on.
patternThe pattern whose data should be retrieved.
rowThe row from which the data should be retrieved.
channelThe channel from which the data should be retrieved.
commandThe cell index at which the data should be retrieved. See openmpt_module_command_index
Returns
The highlighting string for the formatted pattern data as retrived by openmpt_module_get_pattern_row_channel_command at the given pattern position.
Remarks
The returned string will map each character position of the string returned by openmpt_module_get_pattern_row_channel_command to a highlighting instruction. Possible highlighting characters are:
  • " " : empty/space
  • "." : empty/dot
  • "n" : generic note
  • "m" : special note
  • "i" : generic instrument
  • "u" : generic volume column effect
  • "v" : generic volume column parameter
  • "e" : generic effect column effect
  • "f" : generic effect column parameter
See also
openmpt_module_get_pattern_row_channel_command
size_t openmpt_module_read_float_mono ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
float *  mono 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
monoPointer to a buffer of at least count elements that receives the mono/center output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot.
size_t openmpt_module_read_float_quad ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
float *  left,
float *  right,
float *  rear_left,
float *  rear_right 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
leftPointer to a buffer of at least count elements that receives the left output.
rightPointer to a buffer of at least count elements that receives the right output.
rear_leftPointer to a buffer of at least count elements that receives the rear left output.
rear_rightPointer to a buffer of at least count elements that receives the rear right output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot.
size_t openmpt_module_read_float_stereo ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
float *  left,
float *  right 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
leftPointer to a buffer of at least count elements that receives the left output.
rightPointer to a buffer of at least count elements that receives the right output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot.
size_t openmpt_module_read_interleaved_float_quad ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
float *  interleaved_quad 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
interleaved_quadPointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR).
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot.
size_t openmpt_module_read_interleaved_float_stereo ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
float *  interleaved_stereo 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
interleaved_stereoPointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R).
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot.
size_t openmpt_module_read_interleaved_quad ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
int16_t *  interleaved_quad 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
interleaved_quadPointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR).
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
It is recommended to use the floating point API because of the greater dynamic range and no implied clipping.
size_t openmpt_module_read_interleaved_stereo ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
int16_t *  interleaved_stereo 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
interleaved_stereoPointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R).
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
It is recommended to use the floating point API because of the greater dynamic range and no implied clipping.
size_t openmpt_module_read_mono ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
int16_t *  mono 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
monoPointer to a buffer of at least count elements that receives the mono/center output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
It is recommended to use the floating point API because of the greater dynamic range and no implied clipping.
size_t openmpt_module_read_quad ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
int16_t *  left,
int16_t *  right,
int16_t *  rear_left,
int16_t *  rear_right 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
leftPointer to a buffer of at least count elements that receives the left output.
rightPointer to a buffer of at least count elements that receives the right output.
rear_leftPointer to a buffer of at least count elements that receives the rear left output.
rear_rightPointer to a buffer of at least count elements that receives the rear right output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
It is recommended to use the floating point API because of the greater dynamic range and no implied clipping.
size_t openmpt_module_read_stereo ( openmpt_module mod,
int32_t  samplerate,
size_t  count,
int16_t *  left,
int16_t *  right 
)

Render audio data.

Parameters
modThe module handle to work on.
samplerateSamplerate to render output. Should be in [8000,192000], but this is not enforced.
countNumber of audio frames to render per channel.
leftPointer to a buffer of at least count elements that receives the left output.
rightPointer to a buffer of at least count elements that receives the right output.
Returns
The number of frames actually rendered.
Return values
0The end of song has been reached.
Remarks
The output buffers are only written to up to the returned number of elements.
You can freely switch between any of these function if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module.
It is recommended to use the floating point API because of the greater dynamic range and no implied clipping.
int openmpt_module_select_subsong ( openmpt_module mod,
int32_t  subsong 
)

Select a subsong from a multi-song module.

Parameters
modThe module handle to work on.
subsongIndex of the subsong. -1 plays all subsongs consecutively.
Returns
1 on success, 0 on failure.
See also
openmpt_module_get_num_subsongs, openmpt_module_get_subsong_names
double openmpt_module_set_position_order_row ( openmpt_module mod,
int32_t  order,
int32_t  row 
)

Set approximate current song position.

If order or row are out of range, to position is not modified and the current position is returned.

Parameters
modThe module handle to work on.
orderPattern order number to seek to.
rowPattern row number to seek to.
Returns
Approximate new song position in seconds.
See also
openmpt_module_set_position_seconds
openmpt_module_get_position_seconds
double openmpt_module_set_position_seconds ( openmpt_module mod,
double  seconds 
)

Set approximate current song position.

Parameters
modThe module handle to work on.
secondsSeconds to seek to. If seconds is out of range, the position gets set to song start or end respectively.
Returns
Approximate new song position in seconds.
See also
openmpt_module_get_position_seconds
int openmpt_module_set_render_param ( openmpt_module mod,
int  param,
int32_t  value 
)

Set render parameter.

Parameters
modThe module handle to work on.
paramParameter to set. See openmpt_module_render_param.
valueThe value to set param to.
Returns
1 on success, 0 on failure (invalid param).
See also
OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL
OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT
OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH
OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH
openmpt_module_get_render_param
int openmpt_module_set_repeat_count ( openmpt_module mod,
int32_t  repeat_count 
)

Set Repeat Count.

Parameters
modThe module handle to work on.
repeat_countRepeat Count
  • -1: repeat forever
  • 0: play once, repeat zero times (the default)
  • n>0: play once and repeat n times after that
Returns
1 on success, 0 on failure.
See also
openmpt_module_get_repeat_count