LMMS
Loading...
Searching...
No Matches
gme.h
Go to the documentation of this file.
1/* Game music emulator library C interface (also usable from C++) */
2
3/* Game_Music_Emu 0.6.2 */
4#ifndef GME_H
5#define GME_H
6
7#ifdef __cplusplus
8 extern "C" {
9#endif
10
11#define GME_VERSION 0x000602 /* 1 byte major, 1 byte minor, 1 byte patch-level */
12
13/* Error string returned by library functions, or NULL if no error (success) */
14typedef const char* gme_err_t;
15
16/* First parameter of most gme_ functions is a pointer to the Music_Emu */
17typedef struct Music_Emu Music_Emu;
18
19
20/******** Basic operations ********/
21
22/* Create emulator and load game music file/data into it. Sets *out to new emulator. */
23gme_err_t gme_open_file( const char path [], Music_Emu** out, int sample_rate );
24
25/* Number of tracks available */
26int gme_track_count( Music_Emu const* );
27
28/* Start a track, where 0 is the first track */
30
31/* Generate 'count' 16-bit signed samples info 'out'. Output is in stereo. */
33
34/* Finish using emulator and free memory */
35void gme_delete( Music_Emu* );
36
37
38/******** Track position/length ********/
39
40/* Set time to start fading track out. Once fade ends track_ended() returns true.
41Fade time can be changed while track is playing. */
42void gme_set_fade( Music_Emu*, int start_msec );
43
44/* True if a track has reached its end */
45int gme_track_ended( Music_Emu const* );
46
47/* Number of milliseconds (1000 = one second) played since beginning of track */
48int gme_tell( Music_Emu const* );
49
50/* Number of samples generated since beginning of track */
51int gme_tell_samples( Music_Emu const* );
52
53/* Seek to new time in track. Seeking backwards or far forward can take a while. */
54gme_err_t gme_seek( Music_Emu*, int msec );
55
56/* Equivalent to restarting track then skipping n samples */
58
59
60/******** Informational ********/
61
62/* If you only need track information from a music file, pass gme_info_only for
63sample_rate to open/load. */
64enum { gme_info_only = -1 };
65
66/* Most recent warning string, or NULL if none. Clears current warning after returning.
67Warning is also cleared when loading a file and starting a track. */
68const char* gme_warning( Music_Emu* );
69
70/* Load m3u playlist file (must be done after loading music) */
71gme_err_t gme_load_m3u( Music_Emu*, const char path [] );
72
73/* Clear any loaded m3u playlist and any internal playlist that the music format
74supports (NSFE for example). */
76
77/* Gets information for a particular track (length, name, author, etc.).
78Must be freed after use. */
79typedef struct gme_info_t gme_info_t;
80gme_err_t gme_track_info( Music_Emu const*, gme_info_t** out, int track );
81
82/* Frees track information */
84
86{
87 /* times in milliseconds; -1 if unknown */
88 int length; /* total length, if file specifies it */
89 int intro_length; /* length of song up to looping section */
90 int loop_length; /* length of looping section */
91
92 /* Length if available, otherwise intro_length+loop_length*2 if available,
93 otherwise a default of 150000 (2.5 minutes). */
95
96 int i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15; /* reserved */
97
98 /* empty string ("") if not available */
99 const char* system;
100 const char* game;
101 const char* song;
102 const char* author;
103 const char* copyright;
104 const char* comment;
105 const char* dumper;
106
107 const char *s7,*s8,*s9,*s10,*s11,*s12,*s13,*s14,*s15; /* reserved */
108};
109
110
111/******** Advanced playback ********/
112
113/* Adjust stereo echo depth, where 0.0 = off and 1.0 = maximum. Has no effect for
114GYM, SPC, and Sega Genesis VGM music */
115void gme_set_stereo_depth( Music_Emu*, double depth );
116
117/* Disable automatic end-of-track detection and skipping of silence at beginning
118if ignore is true */
120
121/* Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed.
122Track length as returned by track_info() assumes a tempo of 1.0. */
123void gme_set_tempo( Music_Emu*, double tempo );
124
125/* Number of voices used by currently loaded file */
126int gme_voice_count( Music_Emu const* );
127
128/* Name of voice i, from 0 to gme_voice_count() - 1 */
129const char* gme_voice_name( Music_Emu const*, int i );
130
131/* Mute/unmute voice i, where voice 0 is first voice */
132void gme_mute_voice( Music_Emu*, int index, int mute );
133
134/* Set muting state of all voices at once using a bit mask, where -1 mutes all
135voices, 0 unmutes them all, 0x01 mutes just the first voice, etc. */
136void gme_mute_voices( Music_Emu*, int muting_mask );
137
138/* Frequency equalizer parameters (see gme.txt) */
139/* Implementers: If modified, also adjust Music_Emu::make_equalizer as needed */
140typedef struct gme_equalizer_t
141{
142 double treble; /* -50.0 = muffled, 0 = flat, +5.0 = extra-crisp */
143 double bass; /* 1 = full bass, 90 = average, 16000 = almost no bass */
144
145 double d2,d3,d4,d5,d6,d7,d8,d9; /* reserved */
147
148/* Get current frequency equalizater parameters */
150
151/* Change frequency equalizer parameters */
153
154/* Enables/disables most accurate sound emulation options */
155void gme_enable_accuracy( Music_Emu*, int enabled );
156
157
158/******** Game music types ********/
159
160/* Music file type identifier. Can also hold NULL. */
161typedef const struct gme_type_t_* gme_type_t;
162
163/* Emulator type constants for each supported file type */
164extern const gme_type_t
176
177/* Type of this emulator */
179
180/* Pointer to array of all music types, with NULL entry at end. Allows a player linked
181to this library to support new music types without having to be updated. */
183
184/* Name of game system for this music file type */
185const char* gme_type_system( gme_type_t );
186
187/* True if this music file type supports multiple tracks */
189
190/* whether the pcm output retrieved by gme_play() will have all 8 voices rendered to their
191 * individual stereo channel or (if false) these voices get mixed into one single stereo channel
192 * @since 0.6.2 */
193int gme_multi_channel( Music_Emu const* );
194
195/******** Advanced file loading ********/
196
197/* Error returned if file type is not supported */
198extern const char* const gme_wrong_file_type;
199
200/* Same as gme_open_file(), but uses file data already in memory. Makes copy of data.
201 * The resulting Music_Emu object will be set to single channel mode. */
202gme_err_t gme_open_data( void const* data, long size, Music_Emu** out, int sample_rate );
203
204/* Determine likely game music type based on first four bytes of file. Returns
205string containing proper file suffix (i.e. "NSF", "SPC", etc.) or "" if
206file header is not recognized. */
207const char* gme_identify_header( void const* header );
208
209/* Get corresponding music type for file path or extension passed in. */
210gme_type_t gme_identify_extension( const char path_or_extension [] );
211
218const char* gme_type_extension( gme_type_t music_type );
219
220/* Determine file type based on file's extension or header (if extension isn't recognized).
221Sets *type_out to type, or 0 if unrecognized or error. */
222gme_err_t gme_identify_file( const char path [], gme_type_t* type_out );
223
224/* Create new emulator and set sample rate. Returns NULL if out of memory. If you only need
225track information, pass gme_info_only for sample_rate. */
226Music_Emu* gme_new_emu( gme_type_t, int sample_rate );
227
228/* Create new multichannel emulator and set sample rate. Returns NULL if out of memory.
229 * If you only need track information, pass gme_info_only for sample_rate.
230 * (see gme_multi_channel for more information on multichannel support)
231 * @since 0.6.2
232 */
234
235/* Load music file into emulator */
236gme_err_t gme_load_file( Music_Emu*, const char path [] );
237
238/* Load music file from memory into emulator. Makes a copy of data passed. */
239gme_err_t gme_load_data( Music_Emu*, void const* data, long size );
240
241/* Load music file using custom data reader function that will be called to
242read file data. Most emulators load the entire file in one read call. */
243typedef gme_err_t (*gme_reader_t)( void* your_data, void* out, int count );
244gme_err_t gme_load_custom( Music_Emu*, gme_reader_t, long file_size, void* your_data );
245
246/* Load m3u playlist file from memory (must be done after loading music) */
247gme_err_t gme_load_m3u_data( Music_Emu*, void const* data, long size );
248
249
250/******** User data ********/
251
252/* Set/get pointer to data you want to associate with this emulator.
253You can use this for whatever you want. */
254void gme_set_user_data( Music_Emu*, void* new_user_data );
255void* gme_user_data( Music_Emu const* );
256
257/* Register cleanup function to be called when deleting emulator, or NULL to
258clear it. Passes user_data to cleanup function. */
259typedef void (*gme_user_cleanup_t)( void* user_data );
261
262
263#ifdef __cplusplus
264 }
265#endif
266
267#endif
BLARGG_EXPORT gme_type_t const gme_ay_type
BLARGG_EXPORT gme_type_t const gme_gbs_type
Definition gme.h:166
register unsigned i
Definition inflate.c:1575
void gme_set_equalizer(Music_Emu *, gme_equalizer_t const *eq)
Definition gme.cpp:382
int gme_voice_count(Music_Emu const *)
Definition gme.cpp:372
void gme_set_user_data(Music_Emu *, void *new_user_data)
Definition gme.cpp:361
const char * gme_identify_header(void const *header)
Definition gme.cpp:70
const char *const gme_wrong_file_type
Definition Gme_File.cpp:21
void gme_ignore_silence(Music_Emu *, int ignore)
Definition gme.cpp:373
const char * gme_warning(Music_Emu *)
Definition gme.cpp:270
gme_err_t gme_start_track(Music_Emu *, int index)
Definition gme.cpp:364
void gme_free_info(gme_info_t *)
Definition gme.cpp:347
gme_err_t gme_seek_samples(Music_Emu *, int n)
Definition gme.cpp:371
const gme_type_t gme_nsfe_type
Definition gme.h:171
void gme_mute_voices(Music_Emu *, int muting_mask)
Definition gme.cpp:376
void gme_set_tempo(Music_Emu *, double tempo)
Definition gme.cpp:374
void(* gme_user_cleanup_t)(void *user_data)
Definition gme.h:259
void gme_set_user_cleanup(Music_Emu *, gme_user_cleanup_t func)
Definition gme.cpp:362
const gme_type_t gme_kss_type
Definition gme.h:169
const char * gme_type_system(gme_type_t)
Definition gme.cpp:404
gme_err_t gme_load_file(Music_Emu *, const char path[])
gme_err_t gme_open_file(const char path[], Music_Emu **out, int sample_rate)
gme_err_t gme_seek(Music_Emu *, int msec)
Definition gme.cpp:370
const struct gme_type_t_ * gme_type_t
Definition gme.h:161
int gme_tell_samples(Music_Emu const *)
Definition gme.cpp:369
gme_err_t gme_load_m3u(Music_Emu *, const char path[])
void gme_set_stereo_depth(Music_Emu *, double depth)
Definition gme.cpp:352
gme_err_t gme_open_data(void const *data, long size, Music_Emu **out, int sample_rate)
Definition gme.cpp:137
Music_Emu * gme_new_emu(gme_type_t, int sample_rate)
Definition gme.cpp:241
const gme_type_t gme_spc_type
Definition gme.h:173
void gme_enable_accuracy(Music_Emu *, int enabled)
Definition gme.cpp:377
const gme_type_t gme_sap_type
Definition gme.h:172
gme_err_t gme_load_m3u_data(Music_Emu *, void const *data, long size)
Definition M3u_Playlist.cpp:57
void gme_delete(Music_Emu *)
Definition gme.cpp:266
gme_err_t(* gme_reader_t)(void *your_data, void *out, int count)
Definition gme.h:243
Music_Emu * gme_new_emu_multi_channel(gme_type_t, int sample_rate)
Definition gme.cpp:246
gme_err_t gme_identify_file(const char path[], gme_type_t *type_out)
gme_err_t gme_track_info(Music_Emu const *, gme_info_t **out, int track)
Definition gme.cpp:281
void gme_set_fade(Music_Emu *, int start_msec)
Definition gme.cpp:366
const gme_type_t gme_vgm_type
Definition gme.h:174
const char * gme_err_t
Definition gme.h:14
const char * gme_voice_name(Music_Emu const *, int i)
Definition gme.cpp:398
void * gme_user_data(Music_Emu const *)
Definition gme.cpp:360
const gme_type_t gme_vgz_type
Definition gme.h:175
int gme_multi_channel(Music_Emu const *)
Definition gme.cpp:380
int gme_type_multitrack(gme_type_t)
Definition gme.cpp:379
int gme_tell(Music_Emu const *)
Definition gme.cpp:368
const gme_type_t gme_hes_type
Definition gme.h:168
@ gme_info_only
Definition gme.h:64
int gme_track_ended(Music_Emu const *)
Definition gme.cpp:367
gme_err_t gme_load_custom(Music_Emu *, gme_reader_t, long file_size, void *your_data)
Definition gme.cpp:260
void gme_mute_voice(Music_Emu *, int index, int mute)
Definition gme.cpp:375
gme_err_t gme_load_data(Music_Emu *, void const *data, long size)
Definition gme.cpp:254
const gme_type_t gme_nsf_type
Definition gme.h:170
void gme_equalizer(Music_Emu const *, gme_equalizer_t *out)
Definition gme.cpp:390
const char * gme_type_extension(gme_type_t music_type)
Definition gme.cpp:114
gme_type_t const * gme_type_list()
Definition gme.cpp:26
int gme_track_count(Music_Emu const *)
Definition gme.cpp:272
const gme_type_t gme_gym_type
Definition gme.h:167
gme_err_t gme_play(Music_Emu *, int count, short out[])
gme_type_t gme_identify_extension(const char path_or_extension[])
gme_type_t gme_type(Music_Emu const *)
Definition gme.cpp:268
void gme_clear_playlist(Music_Emu *)
Definition gme.cpp:378
static bool ignore
Definition pugl.h:1696
JSAMPIMAGE data
Definition jpeglib.h:945
float out
Definition lilv_test.c:1461
Definition Music_Emu.h:10
long sample_rate() const
Definition Music_Emu.h:217
Definition tap_eq.c:71
Definition gme.h:141
double bass
Definition gme.h:143
double d5
Definition gme.h:145
double d6
Definition gme.h:145
double d8
Definition gme.h:145
double d7
Definition gme.h:145
double treble
Definition gme.h:142
double d2
Definition gme.h:145
double d9
Definition gme.h:145
double d3
Definition gme.h:145
double d4
Definition gme.h:145
Definition gme.h:86
const char * s13
Definition gme.h:107
const char * s12
Definition gme.h:107
const char * comment
Definition gme.h:104
const char * s9
Definition gme.h:107
const char * s10
Definition gme.h:107
const char * s7
Definition gme.h:107
const char * dumper
Definition gme.h:105
int length
Definition gme.h:88
int i4
Definition gme.h:96
int i7
Definition gme.h:96
int intro_length
Definition gme.h:89
const char * s15
Definition gme.h:107
int i11
Definition gme.h:96
int play_length
Definition gme.h:94
int i14
Definition gme.h:96
const char * game
Definition gme.h:100
const char * author
Definition gme.h:102
const char * s11
Definition gme.h:107
const char * system
Definition gme.h:99
int i6
Definition gme.h:96
int i12
Definition gme.h:96
int i15
Definition gme.h:96
const char * s8
Definition gme.h:107
const char * copyright
Definition gme.h:103
const char * song
Definition gme.h:101
int i5
Definition gme.h:96
const char * s14
Definition gme.h:107
int i8
Definition gme.h:96
int i9
Definition gme.h:96
int i13
Definition gme.h:96
int loop_length
Definition gme.h:90
int i10
Definition gme.h:96
Definition Gme_File.h:16
int n
Definition crypt.c:458
ulg size
Definition extract.c:2350
#define void
Definition unzip.h:396
_WDL_CSTRING_PREFIX void INT_PTR count
Definition wdlcstring.h:263