libopenmpt  0.2.8414-autotools
cross-platform C++ and C library to decode tracked music files
libopenmpt.h
Go to the documentation of this file.
1 /*
2  * libopenmpt.h
3  * ------------
4  * Purpose: libopenmpt public c interface
5  * Notes : (currently none)
6  * Authors: OpenMPT Devs
7  * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
8  */
9 
10 #ifndef LIBOPENMPT_H
11 #define LIBOPENMPT_H
12 
13 #include "libopenmpt_config.h"
14 #include <stddef.h>
15 #include <stdint.h>
16 
132 #ifdef __cplusplus
133 extern "C" {
134 #endif
135 
141 LIBOPENMPT_API uint32_t openmpt_get_library_version(void);
142 
148 LIBOPENMPT_API uint32_t openmpt_get_core_version(void);
149 
151 #define OPENMPT_STRING_LIBRARY_VERSION LIBOPENMPT_DEPRECATED_STRING( "library_version" )
152 
153 #define OPENMPT_STRING_LIBRARY_FEATURES LIBOPENMPT_DEPRECATED_STRING( "library_features" )
154 
155 #define OPENMPT_STRING_CORE_VERSION LIBOPENMPT_DEPRECATED_STRING( "core_version" )
156 
157 #define OPENMPT_STRING_BUILD LIBOPENMPT_DEPRECATED_STRING( "build" )
158 
159 #define OPENMPT_STRING_CREDITS LIBOPENMPT_DEPRECATED_STRING( "credits" )
160 
161 #define OPENMPT_STRING_CONTACT LIBOPENMPT_DEPRECATED_STRING( "contact" )
162 
163 #define OPENMPT_STRING_LICENSE LIBOPENMPT_DEPRECATED_STRING( "license" )
164 
169 LIBOPENMPT_API void openmpt_free_string( const char * str );
170 
190 LIBOPENMPT_API const char * openmpt_get_string( const char * key );
191 
196 LIBOPENMPT_API const char * openmpt_get_supported_extensions(void);
197 
203 LIBOPENMPT_API int openmpt_is_extension_supported( const char * extension );
204 
206 #define OPENMPT_STREAM_SEEK_SET 0
207 
208 #define OPENMPT_STREAM_SEEK_CUR 1
209 
210 #define OPENMPT_STREAM_SEEK_END 2
211 
221 typedef size_t (*openmpt_stream_read_func)( void * stream, void * dst, size_t bytes );
222 
233 typedef int (*openmpt_stream_seek_func)( void * stream, int64_t offset, int whence );
234 
242 typedef int64_t (*openmpt_stream_tell_func)( void * stream );
243 
248 typedef struct openmpt_stream_callbacks {
249 
255 
262 
269 
271 
277 typedef void (*openmpt_log_func)( const char * message, void * user );
278 
283 LIBOPENMPT_API void openmpt_log_func_default( const char * message, void * user );
284 
289 LIBOPENMPT_API void openmpt_log_func_silent( const char * message, void * user );
290 
304 LIBOPENMPT_API double openmpt_could_open_propability( openmpt_stream_callbacks stream_callbacks, void * stream, double effort, openmpt_log_func logfunc, void * user );
305 
309 
311  const char * ctl;
312  const char * value;
314 
327 LIBOPENMPT_API openmpt_module * openmpt_module_create( openmpt_stream_callbacks stream_callbacks, void * stream, openmpt_log_func logfunc, void * user, const openmpt_module_initial_ctl * ctls );
328 
340 LIBOPENMPT_API 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 );
341 
346 LIBOPENMPT_API void openmpt_module_destroy( openmpt_module * mod );
347 
354 #define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1
355 
361 #define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2
362 
374 #define OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH 3
375 
383 #define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH 4
384 
391 #define OPENMPT_MODULE_COMMAND_NOTE 0
392 #define OPENMPT_MODULE_COMMAND_INSTRUMENT 1
393 #define OPENMPT_MODULE_COMMAND_VOLUMEEFFECT 2
394 #define OPENMPT_MODULE_COMMAND_EFFECT 3
395 #define OPENMPT_MODULE_COMMAND_VOLUME 4
396 #define OPENMPT_MODULE_COMMAND_PARAMETER 5
397 
407 LIBOPENMPT_API int openmpt_module_select_subsong( openmpt_module * mod, int32_t subsong );
418 LIBOPENMPT_API int openmpt_module_set_repeat_count( openmpt_module * mod, int32_t repeat_count );
428 LIBOPENMPT_API int32_t openmpt_module_get_repeat_count( openmpt_module * mod );
429 
435 LIBOPENMPT_API double openmpt_module_get_duration_seconds( openmpt_module * mod );
436 
444 LIBOPENMPT_API double openmpt_module_set_position_seconds( openmpt_module * mod, double seconds );
451 LIBOPENMPT_API double openmpt_module_get_position_seconds( openmpt_module * mod );
452 
463 LIBOPENMPT_API double openmpt_module_set_position_order_row( openmpt_module * mod, int32_t order, int32_t row );
464 
477 LIBOPENMPT_API int openmpt_module_get_render_param( openmpt_module * mod, int param, int32_t * value );
490 LIBOPENMPT_API int openmpt_module_set_render_param( openmpt_module * mod, int param, int32_t value );
491 
506 LIBOPENMPT_API size_t openmpt_module_read_mono( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * mono );
521 LIBOPENMPT_API size_t openmpt_module_read_stereo( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right );
538 LIBOPENMPT_API 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 );
552 LIBOPENMPT_API size_t openmpt_module_read_float_mono( openmpt_module * mod, int32_t samplerate, size_t count, float * mono );
567 LIBOPENMPT_API size_t openmpt_module_read_float_stereo( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right );
584 LIBOPENMPT_API 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 );
598 LIBOPENMPT_API size_t openmpt_module_read_interleaved_stereo( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * interleaved_stereo );
612 LIBOPENMPT_API size_t openmpt_module_read_interleaved_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * interleaved_quad );
626 LIBOPENMPT_API size_t openmpt_module_read_interleaved_float_stereo( openmpt_module * mod, int32_t samplerate, size_t count, float * interleaved_stereo );
640 LIBOPENMPT_API size_t openmpt_module_read_interleaved_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * interleaved_quad );
649 LIBOPENMPT_API const char * openmpt_module_get_metadata_keys( openmpt_module * mod );
669 LIBOPENMPT_API const char * openmpt_module_get_metadata( openmpt_module * mod, const char * key );
670 
676 LIBOPENMPT_API int32_t openmpt_module_get_current_speed( openmpt_module * mod );
682 LIBOPENMPT_API int32_t openmpt_module_get_current_tempo( openmpt_module * mod );
688 LIBOPENMPT_API int32_t openmpt_module_get_current_order( openmpt_module * mod );
694 LIBOPENMPT_API int32_t openmpt_module_get_current_pattern( openmpt_module * mod );
700 LIBOPENMPT_API int32_t openmpt_module_get_current_row( openmpt_module * mod );
706 LIBOPENMPT_API int32_t openmpt_module_get_current_playing_channels( openmpt_module * mod );
707 
715 LIBOPENMPT_API float openmpt_module_get_current_channel_vu_mono( openmpt_module * mod, int32_t channel );
723 LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel );
731 LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel );
739 LIBOPENMPT_API float openmpt_module_get_current_channel_vu_rear_left( openmpt_module * mod, int32_t channel );
747 LIBOPENMPT_API float openmpt_module_get_current_channel_vu_rear_right( openmpt_module * mod, int32_t channel );
748 
755 LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod );
762 LIBOPENMPT_API int32_t openmpt_module_get_num_channels( openmpt_module * mod );
768 LIBOPENMPT_API int32_t openmpt_module_get_num_orders( openmpt_module * mod );
774 LIBOPENMPT_API int32_t openmpt_module_get_num_patterns( openmpt_module * mod );
780 LIBOPENMPT_API int32_t openmpt_module_get_num_instruments( openmpt_module * mod );
786 LIBOPENMPT_API int32_t openmpt_module_get_num_samples( openmpt_module * mod );
787 
795 LIBOPENMPT_API const char * openmpt_module_get_subsong_name( openmpt_module * mod, int32_t index );
803 LIBOPENMPT_API const char * openmpt_module_get_channel_name( openmpt_module * mod, int32_t index );
811 LIBOPENMPT_API const char * openmpt_module_get_order_name( openmpt_module * mod, int32_t index );
819 LIBOPENMPT_API const char * openmpt_module_get_pattern_name( openmpt_module * mod, int32_t index );
827 LIBOPENMPT_API const char * openmpt_module_get_instrument_name( openmpt_module * mod, int32_t index );
835 LIBOPENMPT_API const char * openmpt_module_get_sample_name( openmpt_module * mod, int32_t index );
836 
843 LIBOPENMPT_API int32_t openmpt_module_get_order_pattern( openmpt_module * mod, int32_t order );
850 LIBOPENMPT_API int32_t openmpt_module_get_pattern_num_rows( openmpt_module * mod, int32_t pattern );
851 
861 LIBOPENMPT_API uint8_t openmpt_module_get_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command );
862 
873 LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command );
895 LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command );
896 
908 LIBOPENMPT_API 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 );
920 LIBOPENMPT_API 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 );
921 
941 LIBOPENMPT_API const char * openmpt_module_get_ctls( openmpt_module * mod );
949 LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl );
957 LIBOPENMPT_API int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value );
958 
959 /* remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR */
960 
961 #ifdef __cplusplus
962 }
963 #endif
964 
969 #endif /* LIBOPENMPT_H */
970 
int32_t openmpt_module_get_current_tempo(openmpt_module *mod)
Get the current tempo.
uint32_t openmpt_get_core_version(void)
Get the core version number.
size_t openmpt_module_read_stereo(openmpt_module *mod, int32_t samplerate, size_t count, int16_t *left, int16_t *right)
Render audio data.
const char * openmpt_get_string(const char *key)
Get library related metadata.
void openmpt_log_func_silent(const char *message, void *user)
Silent logging function.
int32_t openmpt_module_get_pattern_num_rows(openmpt_module *mod, int32_t pattern)
Get the number of rows in a pattern.
int openmpt_module_select_subsong(openmpt_module *mod, int32_t subsong)
Select a sub-song from a multi-song module.
size_t openmpt_module_read_float_stereo(openmpt_module *mod, int32_t samplerate, size_t count, float *left, float *right)
Render audio data.
struct openmpt_stream_callbacks openmpt_stream_callbacks
Stream callbacks.
int openmpt_module_get_render_param(openmpt_module *mod, int param, int32_t *value)
Get render parameter.
size_t openmpt_module_read_interleaved_float_stereo(openmpt_module *mod, int32_t samplerate, size_t count, float *interleaved_stereo)
Render audio data.
const char * ctl
Definition: libopenmpt.h:311
const char * openmpt_module_get_instrument_name(openmpt_module *mod, int32_t index)
Get an instrument name.
int openmpt_module_set_repeat_count(openmpt_module *mod, int32_t repeat_count)
Set Repeat Count.
void openmpt_free_string(const char *str)
Free a string returned by libopenmpt.
double openmpt_module_set_position_seconds(openmpt_module *mod, double seconds)
Set approximate current song position.
int32_t openmpt_module_get_current_pattern(openmpt_module *mod)
Get the current pattern.
openmpt_stream_tell_func tell
Tell callback.
Definition: libopenmpt.h:268
void(* openmpt_log_func)(const char *message, void *user)
Logging function.
Definition: libopenmpt.h:277
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.
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.
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.
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.
size_t openmpt_module_read_mono(openmpt_module *mod, int32_t samplerate, size_t count, int16_t *mono)
Render audio data.
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...
const char * openmpt_module_get_metadata(openmpt_module *mod, const char *key)
Get a metadata item value.
size_t openmpt_module_read_interleaved_quad(openmpt_module *mod, int32_t samplerate, size_t count, int16_t *interleaved_quad)
Render audio data.
const char * value
Definition: libopenmpt.h:312
int32_t openmpt_module_get_num_patterns(openmpt_module *mod)
Get the number of patterns.
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.
int32_t openmpt_module_get_repeat_count(openmpt_module *mod)
Get Repeat Count.
size_t openmpt_module_read_interleaved_stereo(openmpt_module *mod, int32_t samplerate, size_t count, int16_t *interleaved_stereo)
Render audio data.
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.
int(* openmpt_stream_seek_func)(void *stream, int64_t offset, int whence)
Seek stream position.
Definition: libopenmpt.h:233
struct openmpt_module openmpt_module
Opaque type representing a libopenmpt module.
Definition: libopenmpt.h:308
const char * openmpt_module_get_order_name(openmpt_module *mod, int32_t index)
Get an order name.
int openmpt_module_ctl_set(openmpt_module *mod, const char *ctl, const char *value)
Set ctl value.
struct openmpt_module_initial_ctl openmpt_module_initial_ctl
double openmpt_module_set_position_order_row(openmpt_module *mod, int32_t order, int32_t row)
Set approximate current song position.
const char * openmpt_module_get_metadata_keys(openmpt_module *mod)
Get the list of supported metadata item keys.
uint32_t openmpt_get_library_version(void)
Get the libopenmpt version number.
int openmpt_is_extension_supported(const char *extension)
Query whether a file extension is supported.
const char * openmpt_module_get_sample_name(openmpt_module *mod, int32_t index)
Get a sample name.
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.
Stream callbacks.
Definition: libopenmpt.h:248
int32_t openmpt_module_get_num_samples(openmpt_module *mod)
Get the number of samples.
double openmpt_module_get_position_seconds(openmpt_module *mod)
Get current song position.
int openmpt_module_set_render_param(openmpt_module *mod, int param, int32_t value)
Set render parameter.
int32_t openmpt_module_get_current_playing_channels(openmpt_module *mod)
Get the current amount of playing channels.
size_t openmpt_module_read_float_mono(openmpt_module *mod, int32_t samplerate, size_t count, float *mono)
Render audio data.
int32_t openmpt_module_get_current_order(openmpt_module *mod)
Get the current order.
size_t openmpt_module_read_interleaved_float_quad(openmpt_module *mod, int32_t samplerate, size_t count, float *interleaved_quad)
Render audio data.
const char * openmpt_module_ctl_get(openmpt_module *mod, const char *ctl)
Get current ctl value.
size_t(* openmpt_stream_read_func)(void *stream, void *dst, size_t bytes)
Read bytes from stream.
Definition: libopenmpt.h:221
const char * openmpt_module_get_channel_name(openmpt_module *mod, int32_t index)
Get a channel name.
int64_t(* openmpt_stream_tell_func)(void *stream)
Tell stream position.
Definition: libopenmpt.h:242
const char * openmpt_module_get_pattern_name(openmpt_module *mod, int32_t index)
Get a pattern name.
openmpt_stream_read_func read
Read callback.
Definition: libopenmpt.h:254
double openmpt_module_get_duration_seconds(openmpt_module *mod)
approximate song duration
const char * openmpt_module_get_subsong_name(openmpt_module *mod, int32_t index)
Get a sub-song name.
void openmpt_module_destroy(openmpt_module *mod)
Unload a previously created openmpt_module from memory.
int32_t openmpt_module_get_num_channels(openmpt_module *mod)
Get the number of pattern channels.
const char * openmpt_get_supported_extensions(void)
Get a list of supported file extensions.
int32_t openmpt_module_get_current_row(openmpt_module *mod)
Get the current row.
const char * openmpt_module_get_ctls(openmpt_module *mod)
Retrieve supported ctl keys.
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.
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.
int32_t openmpt_module_get_order_pattern(openmpt_module *mod, int32_t order)
Get pattern at order position.
float openmpt_module_get_current_channel_vu_mono(openmpt_module *mod, int32_t channel)
Get an approximate indication of the channel volume.
int32_t openmpt_module_get_num_orders(openmpt_module *mod)
Get the number of orders.
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.
openmpt_stream_seek_func seek
Seek callback.
Definition: libopenmpt.h:261
int32_t openmpt_module_get_num_instruments(openmpt_module *mod)
Get the number of instruments.
int32_t openmpt_module_get_num_subsongs(openmpt_module *mod)
Get the number of sub-songs.
Definition: libopenmpt.h:310
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.
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.
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.
void openmpt_log_func_default(const char *message, void *user)
Default logging function.
int32_t openmpt_module_get_current_speed(openmpt_module *mod)
Get the current speed.