Mercurial > audlegacy-plugins
annotate src/console/gme.h @ 3052:95b34f46a231
Comment out MPEG2/MPEG4 determination using the variable id. It is not used anywhere. Code analysis run, unique ID 6nYoHM.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Sat, 18 Apr 2009 19:06:20 +0100 |
parents | 986f098da058 |
children |
rev | line source |
---|---|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
1 /* Game music emulator library C interface (also usable from C++) */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
2 |
341 | 3 /* Game_Music_Emu 0.5.2 */ |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
4 #ifndef GME_H |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
5 #define GME_H |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
6 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
7 #ifdef __cplusplus |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
8 extern "C" { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
9 #endif |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
10 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
11 /* Error string returned by library functions, or NULL if no error (success) */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
12 typedef const char* gme_err_t; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
13 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
14 /* First parameter of most gme_ functions is a pointer to the Music_Emu */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
15 typedef struct Music_Emu Music_Emu; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
16 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
17 |
341 | 18 /******** Basic operations ********/ |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
19 |
341 | 20 /* Create emulator and load game music file/data into it. Sets *out to new emulator. */ |
21 gme_err_t gme_open_file( const char* path, Music_Emu** out, long sample_rate ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
22 |
341 | 23 /* Number of tracks available */ |
24 int gme_track_count( Music_Emu const* ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
25 |
341 | 26 /* Start a track, where 0 is the first track */ |
27 gme_err_t gme_start_track( Music_Emu*, int index ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
28 |
341 | 29 /* Generate 'count' 16-bit signed samples info 'out'. Output is in stereo. */ |
30 gme_err_t gme_play( Music_Emu*, long count, short* out ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
31 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
32 /* Finish using emulator and free memory */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
33 void gme_delete( Music_Emu* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
34 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
35 |
341 | 36 /******** Track position/length ********/ |
37 | |
38 /* Set time to start fading track out. Once fade ends track_ended() returns true. | |
39 Fade time can be changed while track is playing. */ | |
40 void gme_set_fade( Music_Emu*, long start_msec ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
41 |
341 | 42 /* True if a track has reached its end */ |
43 int gme_track_ended( Music_Emu const* ); | |
44 | |
45 /* Number of milliseconds (1000 = one second) played since beginning of track */ | |
46 long gme_tell( Music_Emu const* ); | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
47 |
341 | 48 /* Seek to new time in track. Seeking backwards or far forward can take a while. */ |
49 gme_err_t gme_seek( Music_Emu*, long msec ); | |
50 | |
51 | |
52 /******** Informational ********/ | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
53 |
341 | 54 /* If you only need track information from a music file, pass gme_info_only for |
55 sample_rate to open/load. */ | |
56 enum { gme_info_only = -1 }; | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
57 |
341 | 58 /* Most recent warning string, or NULL if none. Clears current warning after returning. |
59 Warning is also cleared when loading a file and starting a track. */ | |
60 const char* gme_warning( Music_Emu* ); | |
61 | |
62 /* Load m3u playlist file (must be done after loading music) */ | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
63 gme_err_t gme_load_m3u( Music_Emu*, const char* path ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
64 |
341 | 65 /* Clear any loaded m3u playlist and any internal playlist that the music format |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
66 supports (NSFE for example). */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
67 void gme_clear_playlist( Music_Emu* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
68 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
69 /* Get information for a particular track (length, name, author, etc.) */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
70 typedef struct track_info_t track_info_t; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
71 gme_err_t gme_track_info( Music_Emu const*, track_info_t* out, int track ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
72 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
73 struct track_info_t |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
74 { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
75 long track_count; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
76 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
77 /* times in milliseconds; -1 if unknown */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
78 long length; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
79 long intro_length; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
80 long loop_length; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
81 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
82 /* empty string if not available */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
83 char system [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
84 char game [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
85 char song [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
86 char author [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
87 char copyright [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
88 char comment [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
89 char dumper [256]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
90 }; |
341 | 91 enum { gme_max_field = 255 }; |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
92 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
93 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
94 /******** Advanced playback ********/ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
95 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
96 /* Adjust stereo echo depth, where 0.0 = off and 1.0 = maximum. Has no effect for |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
97 GYM, SPC, and Sega Genesis VGM music */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
98 void gme_set_stereo_depth( Music_Emu*, double depth ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
99 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
100 /* Disable automatic end-of-track detection and skipping of silence at beginning |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
101 if ignore is true */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
102 void gme_ignore_silence( Music_Emu*, int ignore ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
103 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
104 /* Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
105 Track length as returned by track_info() assumes a tempo of 1.0. */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
106 void gme_set_tempo( Music_Emu*, double tempo ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
107 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
108 /* Number of voices used by currently loaded file */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
109 int gme_voice_count( Music_Emu const* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
110 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
111 /* Names of voices */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
112 const char** gme_voice_names( Music_Emu const* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
113 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
114 /* Mute/unmute voice i, where voice 0 is first voice */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
115 void gme_mute_voice( Music_Emu*, int index, int mute ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
116 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
117 /* Set muting state of all voices at once using a bit mask, where -1 mutes all |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
118 voices, 0 unmutes them all, 0x01 mutes just the first voice, etc. */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
119 void gme_mute_voices( Music_Emu*, int muting_mask ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
120 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
121 /* Frequency equalizer parameters (see gme.txt) */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
122 typedef struct gme_equalizer_t |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
123 { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
124 double treble; /* -50.0 = muffled, 0 = flat, +5.0 = extra-crisp */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
125 long bass; /* 1 = full bass, 90 = average, 16000 = almost no bass */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
126 } gme_equalizer_t; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
127 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
128 /* Get current frequency equalizater parameters */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
129 gme_equalizer_t gme_equalizer( Music_Emu const* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
130 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
131 /* Change frequency equalizer parameters */ |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
132 void gme_set_equalizer( Music_Emu*, gme_equalizer_t const* eq ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
133 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
134 |
341 | 135 |
136 /******** Game music types ********/ | |
137 | |
138 /* Emulator type constants for each supported file type */ | |
139 extern struct gme_type_t_ const gme_ay_type [], gme_gbs_type [], gme_gym_type [], | |
140 gme_hes_type [], gme_kss_type [], gme_nsf_type [], gme_nsfe_type [], | |
141 gme_sap_type [], gme_spc_type [], gme_vgm_type [], gme_vgz_type []; | |
142 typedef struct gme_type_t_ const* gme_type_t; | |
143 | |
144 /* Type of this emulator */ | |
145 gme_type_t gme_type( Music_Emu const* ); | |
146 | |
147 /* gme_type_t is a pointer to this structure. For example, gme_nsf_type->system is | |
148 "Nintendo NES" and gme_nsf_type->new_emu() is equilvant to new Nsf_Emu (in C++). */ | |
149 struct gme_type_t_ | |
150 { | |
151 const char* system; /* name of system this music file type is generally for */ | |
152 int track_count; /* non-zero for formats with a fixed number of tracks */ | |
153 Music_Emu* (*new_emu)(); /* Create new emulator for this type (useful in C++ only) */ | |
154 Music_Emu* (*new_info)(); /* Create new info reader for this type */ | |
155 | |
156 /* internal */ | |
157 const char* extension_; | |
158 int flags_; | |
159 }; | |
160 | |
161 /* Pointer to array of all music types, with NULL entry at end. Allows a player linked | |
162 to this library to support new music types without having to be updated. */ | |
163 gme_type_t const* gme_type_list(); | |
164 | |
165 | |
166 /******** Advanced file loading ********/ | |
167 | |
168 /* Error returned if file type is not supported */ | |
169 extern const char gme_wrong_file_type []; | |
170 | |
171 /* Same as gme_open_file(), but uses file data already in memory. Makes copy of data. */ | |
172 gme_err_t gme_open_data( void const* data, long size, Music_Emu** out, long sample_rate ); | |
173 | |
174 /* Determine likely game music type based on first four bytes of file. Returns | |
175 string containing proper file suffix (i.e. "NSF", "SPC", etc.) or "" if | |
176 file header is not recognized. */ | |
177 const char* gme_identify_header( void const* header ); | |
178 | |
179 /* Get corresponding music type for file path or extension passed in. */ | |
180 gme_type_t gme_identify_extension( const char* path_or_extension ); | |
181 | |
182 /* Determine file type based on file's extension or header (if extension isn't recognized). | |
183 Sets *type_out to type, or 0 if unrecognized or error. */ | |
184 gme_err_t gme_identify_file( const char* path, gme_type_t* type_out ); | |
185 | |
186 /* Create new emulator and set sample rate. Returns NULL if out of memory. If you only need | |
187 track information, pass gme_info_only for sample_rate. */ | |
188 Music_Emu* gme_new_emu( gme_type_t, long sample_rate ); | |
189 | |
190 /* Load music file into emulator */ | |
191 gme_err_t gme_load_file( Music_Emu*, const char* path ); | |
192 | |
193 /* Load music file from memory into emulator. Makes a copy of data passed. */ | |
194 gme_err_t gme_load_data( Music_Emu*, void const* data, long size ); | |
195 | |
196 /* Load music file using custom data reader function that will be called to | |
197 read file data. Most emulators load the entire file in one read call. */ | |
198 typedef gme_err_t (*gme_reader_t)( void* your_data, void* out, long count ); | |
199 gme_err_t gme_load_custom( Music_Emu*, gme_reader_t, long file_size, void* your_data ); | |
200 | |
201 /* Load m3u playlist file from memory (must be done after loading music) */ | |
202 gme_err_t gme_load_m3u_data( Music_Emu*, void const* data, long size ); | |
203 | |
204 | |
205 /******** User data ********/ | |
206 | |
207 /* Set/get pointer to data you want to associate with this emulator. | |
208 You can use this for whatever you want. */ | |
209 void gme_set_user_data( Music_Emu*, void* new_user_data ); | |
210 void* gme_user_data( Music_Emu const* ); | |
211 | |
212 /* Register cleanup function to be called when deleting emulator, or NULL to | |
213 clear it. Passes user_data to cleanup function. */ | |
214 typedef void (*gme_user_cleanup_t)( void* user_data ); | |
215 void gme_set_user_cleanup( Music_Emu*, gme_user_cleanup_t func ); | |
216 | |
217 | |
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
218 #ifdef __cplusplus |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
219 } |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
220 #endif |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
221 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
222 #endif |