diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2010-02-04 17:31:10 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2010-02-04 17:31:10 +0000 |
commit | 35472fe7f1c7133fa4291dad36ae457a460f021c (patch) | |
tree | c84a0118c7c992a30d0cb42d1778ec9918184b1f /apps/codecs/libasap/asap.h | |
parent | b1a6c9096dfde44249d0f4d8a929c63a89987623 (diff) | |
download | rockbox-35472fe7f1c7133fa4291dad36ae457a460f021c.tar.gz rockbox-35472fe7f1c7133fa4291dad36ae457a460f021c.zip |
sync asap codec to ASAP 2.1
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24511 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libasap/asap.h')
-rw-r--r-- | apps/codecs/libasap/asap.h | 125 |
1 files changed, 75 insertions, 50 deletions
diff --git a/apps/codecs/libasap/asap.h b/apps/codecs/libasap/asap.h index 783d628019..02f6e680f2 100644 --- a/apps/codecs/libasap/asap.h +++ b/apps/codecs/libasap/asap.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * asap.h - public interface of the ASAP engine | 2 | * asap.h - public interface of ASAP |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 Piotr Fusik | 4 | * Copyright (C) 2005-2010 Piotr Fusik |
5 | * | 5 | * |
6 | * This file is part of ASAP (Another Slight Atari Player), | 6 | * This file is part of ASAP (Another Slight Atari Player), |
7 | * see http://asap.sourceforge.net | 7 | * see http://asap.sourceforge.net |
@@ -29,17 +29,19 @@ extern "C" { | |||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | /* ASAP version. */ | 31 | /* ASAP version. */ |
32 | #define ASAP_VERSION_MAJOR 1 | 32 | #define ASAP_VERSION_MAJOR 2 |
33 | #define ASAP_VERSION_MINOR 2 | 33 | #define ASAP_VERSION_MINOR 1 |
34 | #define ASAP_VERSION_MICRO 0 | 34 | #define ASAP_VERSION_MICRO 0 |
35 | #define ASAP_VERSION "1.2.0" | 35 | #define ASAP_VERSION "2.1.0" |
36 | 36 | ||
37 | /* Short credits of the ASAP engine. */ | 37 | /* Short credits of the ASAP engine. */ |
38 | #define ASAP_YEARS "2005-2008" | 38 | #define ASAP_YEARS "2005-2010" |
39 | #define ASAP_CREDITS \ | 39 | #define ASAP_CREDITS \ |
40 | "Another Slight Atari Player (C) 2005-2008 Piotr Fusik\n" \ | 40 | "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \ |
41 | "CMC, MPT, TMC players (C) 1994-2005 Marcin Lewandowski\n" \ | 41 | "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \ |
42 | "RMT player (C) 2002-2005 Radek Sterba\n" | 42 | "RMT player (C) 2002-2005 Radek Sterba\n" \ |
43 | "DLT player (C) 2009 Marek Konopka\n" \ | ||
44 | "CMS player (C) 1999 David Spilka\n" | ||
43 | 45 | ||
44 | /* Short GPL notice. | 46 | /* Short GPL notice. |
45 | Display after the credits. */ | 47 | Display after the credits. */ |
@@ -49,6 +51,32 @@ extern "C" { | |||
49 | "by the Free Software Foundation; either version 2 of the License,\n" \ | 51 | "by the Free Software Foundation; either version 2 of the License,\n" \ |
50 | "or (at your option) any later version." | 52 | "or (at your option) any later version." |
51 | 53 | ||
54 | /* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */ | ||
55 | #define ASAP_INFO_CHARS 128 | ||
56 | |||
57 | /* Maximum length of a "mm:ss.xxx" string including the terminator. */ | ||
58 | #define ASAP_DURATION_CHARS 10 | ||
59 | |||
60 | /* Maximum length of a supported input file. | ||
61 | You can assume that files longer than this are not supported by ASAP. */ | ||
62 | #define ASAP_MODULE_MAX 65000 | ||
63 | |||
64 | /* Maximum number of songs in a file. */ | ||
65 | #define ASAP_SONGS_MAX 32 | ||
66 | |||
67 | /* Output sample rate. */ | ||
68 | #define ASAP_SAMPLE_RATE 44100 | ||
69 | |||
70 | /* WAV file header length. */ | ||
71 | #define ASAP_WAV_HEADER_BYTES 44 | ||
72 | |||
73 | /* Output formats. */ | ||
74 | typedef enum { | ||
75 | ASAP_FORMAT_U8 = 8, /* unsigned char */ | ||
76 | ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ | ||
77 | ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ | ||
78 | } ASAP_SampleFormat; | ||
79 | |||
52 | /* Useful type definitions. */ | 80 | /* Useful type definitions. */ |
53 | #ifndef FALSE | 81 | #ifndef FALSE |
54 | #define FALSE 0 | 82 | #define FALSE 0 |
@@ -59,24 +87,25 @@ extern "C" { | |||
59 | typedef int abool; | 87 | typedef int abool; |
60 | typedef unsigned char byte; | 88 | typedef unsigned char byte; |
61 | 89 | ||
62 | /* Information about a file. */ | 90 | /* Information about a music file. */ |
63 | typedef struct { | 91 | typedef struct { |
64 | char author[128]; /* author's name */ | 92 | char author[ASAP_INFO_CHARS]; /* author's name */ |
65 | char name[128]; /* title */ | 93 | char name[ASAP_INFO_CHARS]; /* title */ |
66 | char date[128]; /* creation date */ | 94 | char date[ASAP_INFO_CHARS]; /* creation date */ |
67 | int channels; /* 1 for mono or 2 for stereo */ | 95 | int channels; /* 1 for mono or 2 for stereo */ |
68 | int songs; /* number of subsongs */ | 96 | int songs; /* number of subsongs */ |
69 | int default_song; /* 0-based index of the "main" subsong */ | 97 | int default_song; /* 0-based index of the "main" subsong */ |
70 | int durations[32]; /* lengths of songs, in milliseconds, -1 = unspecified */ | 98 | int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */ |
71 | abool loops[32]; /* whether songs repeat or not */ | 99 | abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */ |
72 | /* the following technical information should not be used outside ASAP. */ | 100 | /* the following technical information should not be used outside ASAP. */ |
73 | char type; | 101 | int type; |
74 | int fastplay; | 102 | int fastplay; |
75 | int music; | 103 | int music; |
76 | int init; | 104 | int init; |
77 | int player; | 105 | int player; |
106 | int covox_addr; | ||
78 | int header_len; | 107 | int header_len; |
79 | byte song_pos[128]; | 108 | byte song_pos[ASAP_SONGS_MAX]; |
80 | } ASAP_ModuleInfo; | 109 | } ASAP_ModuleInfo; |
81 | 110 | ||
82 | /* POKEY state. | 111 | /* POKEY state. |
@@ -117,7 +146,7 @@ typedef struct { | |||
117 | int delta3; | 146 | int delta3; |
118 | int delta4; | 147 | int delta4; |
119 | int skctl; | 148 | int skctl; |
120 | signed char delta_buffer[888]; | 149 | int delta_buffer[888]; |
121 | } PokeyState; | 150 | } PokeyState; |
122 | 151 | ||
123 | /* Player state. | 152 | /* Player state. |
@@ -140,6 +169,8 @@ typedef struct { | |||
140 | int timer4_cycle; | 169 | int timer4_cycle; |
141 | int irqst; | 170 | int irqst; |
142 | int extra_pokey_mask; | 171 | int extra_pokey_mask; |
172 | int consol; | ||
173 | byte covox[4]; | ||
143 | PokeyState base_pokey; | 174 | PokeyState base_pokey; |
144 | PokeyState extra_pokey; | 175 | PokeyState extra_pokey; |
145 | int sample_offset; | 176 | int sample_offset; |
@@ -160,23 +191,6 @@ typedef struct { | |||
160 | byte memory[65536]; | 191 | byte memory[65536]; |
161 | } ASAP_State; | 192 | } ASAP_State; |
162 | 193 | ||
163 | /* Maximum length of a "mm:ss.xxx" string including the terminator. */ | ||
164 | #define ASAP_DURATION_CHARS 10 | ||
165 | |||
166 | /* Maximum length of a supported input file. | ||
167 | You can assume that files longer than this are not supported by ASAP. */ | ||
168 | #define ASAP_MODULE_MAX 65000 | ||
169 | |||
170 | /* Output sample rate. */ | ||
171 | #define ASAP_SAMPLE_RATE 44100 | ||
172 | |||
173 | /* Output formats. */ | ||
174 | typedef enum { | ||
175 | ASAP_FORMAT_U8 = 8, /* unsigned char */ | ||
176 | ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ | ||
177 | ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ | ||
178 | } ASAP_SampleFormat; | ||
179 | |||
180 | /* Parses the string in the "mm:ss.xxx" format | 194 | /* Parses the string in the "mm:ss.xxx" format |
181 | and returns the number of milliseconds or -1 if an error occurs. */ | 195 | and returns the number of milliseconds or -1 if an error occurs. */ |
182 | int ASAP_ParseDuration(const char *s); | 196 | int ASAP_ParseDuration(const char *s); |
@@ -203,7 +217,7 @@ abool ASAP_GetModuleInfo(ASAP_ModuleInfo *module_info, const char *filename, | |||
203 | const byte module[], int module_len); | 217 | const byte module[], int module_len); |
204 | 218 | ||
205 | /* Loads music data. | 219 | /* Loads music data. |
206 | "as" is the destination structure. | 220 | "ast" is the destination structure. |
207 | "filename" determines file format. | 221 | "filename" determines file format. |
208 | "module" is the music data (contents of the file). | 222 | "module" is the music data (contents of the file). |
209 | "module_len" is the number of data bytes. | 223 | "module_len" is the number of data bytes. |
@@ -212,39 +226,50 @@ abool ASAP_GetModuleInfo(ASAP_ModuleInfo *module_info, const char *filename, | |||
212 | ASAP_Load() returns true on success. | 226 | ASAP_Load() returns true on success. |
213 | If false is returned, the structure is invalid and you cannot | 227 | If false is returned, the structure is invalid and you cannot |
214 | call the following functions. */ | 228 | call the following functions. */ |
215 | abool ASAP_Load(ASAP_State *as, const char *filename, | 229 | abool ASAP_Load(ASAP_State *ast, const char *filename, |
216 | const byte module[], int module_len); | 230 | const byte module[], int module_len); |
217 | 231 | ||
218 | /* Enables silence detection. | 232 | /* Enables silence detection. |
219 | Makes ASAP finish playing after the specified period of silence. | 233 | Makes ASAP finish playing after the specified period of silence. |
220 | "as" is ASAP state initialized by ASAP_Load(). | 234 | "ast" is ASAP state initialized by ASAP_Load(). |
221 | "seconds" is the minimum length of silence that ends playback. */ | 235 | "seconds" is the minimum length of silence that ends playback. */ |
222 | void ASAP_DetectSilence(ASAP_State *as, int seconds); | 236 | void ASAP_DetectSilence(ASAP_State *ast, int seconds); |
223 | 237 | ||
224 | /* Prepares ASAP to play the specified song of the loaded module. | 238 | /* Prepares ASAP to play the specified song of the loaded module. |
225 | "as" is ASAP state initialized by ASAP_Load(). | 239 | "ast" is ASAP state initialized by ASAP_Load(). |
226 | "song" is a zero-based index which must be less than the "songs" field | 240 | "song" is a zero-based index which must be less than the "songs" field |
227 | of the ASAP_ModuleInfo structure. | 241 | of the ASAP_ModuleInfo structure. |
228 | "duration" is playback time in milliseconds - use durations[song] | 242 | "duration" is playback time in milliseconds - use durations[song] |
229 | unless you want to override it. -1 means indefinitely. */ | 243 | unless you want to override it. -1 means indefinitely. */ |
230 | void ASAP_PlaySong(ASAP_State *as, int song, int duration); | 244 | void ASAP_PlaySong(ASAP_State *ast, int song, int duration); |
231 | 245 | ||
232 | /* Mutes the selected POKEY channels. | 246 | /* Mutes the selected POKEY channels. |
233 | This is only useful for people who want to grab samples of individual | 247 | This is only useful for people who want to grab samples of individual |
234 | instruments. | 248 | instruments. |
235 | "as" is ASAP state after calling ASAP_PlaySong(). | 249 | "ast" is ASAP state after calling ASAP_PlaySong(). |
236 | "mask" is a bit mask which selects POKEY channels to be muted. | 250 | "mask" is a bit mask which selects POKEY channels to be muted. |
237 | Bits 0-3 control the base POKEY channels, | 251 | Bits 0-3 control the base POKEY channels, |
238 | bits 4-7 control the extra POKEY channels. */ | 252 | bits 4-7 control the extra POKEY channels. */ |
239 | void ASAP_MutePokeyChannels(ASAP_State *as, int mask); | 253 | void ASAP_MutePokeyChannels(ASAP_State *ast, int mask); |
254 | |||
255 | /* Returns current position in milliseconds. | ||
256 | "ast" is ASAP state initialized by ASAP_PlaySong(). */ | ||
257 | int ASAP_GetPosition(const ASAP_State *ast); | ||
240 | 258 | ||
241 | /* Rewinds the current song. | 259 | /* Rewinds the current song. |
242 | "as" is ASAP state initialized by ASAP_PlaySong(). | 260 | "ast" is ASAP state initialized by ASAP_PlaySong(). |
243 | "position" is the requested absolute position in milliseconds. */ | 261 | "position" is the requested absolute position in milliseconds. */ |
244 | void ASAP_Seek(ASAP_State *as, int position); | 262 | void ASAP_Seek(ASAP_State *ast, int position); |
263 | |||
264 | /* Fills the specified buffer with WAV file header. | ||
265 | "ast" is ASAP state initialized by ASAP_PlaySong() with a positive "duration". | ||
266 | "buffer" is buffer of ASAP_WAV_HEADER_BYTES bytes. | ||
267 | "format" is the format of samples. */ | ||
268 | void ASAP_GetWavHeader(const ASAP_State *ast, byte buffer[], | ||
269 | ASAP_SampleFormat format); | ||
245 | 270 | ||
246 | /* Fills the specified buffer with generated samples. | 271 | /* Fills the specified buffer with generated samples. |
247 | "as" is ASAP state initialized by ASAP_PlaySong(). | 272 | "ast" is ASAP state initialized by ASAP_PlaySong(). |
248 | "buffer" is the destination buffer. | 273 | "buffer" is the destination buffer. |
249 | "buffer_len" is the length of this buffer in bytes. | 274 | "buffer_len" is the length of this buffer in bytes. |
250 | "format" is the format of samples. | 275 | "format" is the format of samples. |
@@ -252,7 +277,7 @@ void ASAP_Seek(ASAP_State *as, int position); | |||
252 | (less than buffer_len if reached the end of the song). | 277 | (less than buffer_len if reached the end of the song). |
253 | Normally you use a buffer of a few kilobytes or less, | 278 | Normally you use a buffer of a few kilobytes or less, |
254 | and call ASAP_Generate() in a loop or via a callback. */ | 279 | and call ASAP_Generate() in a loop or via a callback. */ |
255 | int ASAP_Generate(ASAP_State *as, void *buffer, int buffer_len, | 280 | int ASAP_Generate(ASAP_State *ast, void *buffer, int buffer_len, |
256 | ASAP_SampleFormat format); | 281 | ASAP_SampleFormat format); |
257 | 282 | ||
258 | /* Checks whether information in the specified file can be edited. */ | 283 | /* Checks whether information in the specified file can be edited. */ |