diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/mod.c | 72 |
1 files changed, 66 insertions, 6 deletions
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c index 3dfaac663f..3703ecd304 100644 --- a/apps/codecs/mod.c +++ b/apps/codecs/mod.c | |||
@@ -178,12 +178,11 @@ struct s_modplayer { | |||
178 | /* Information about the channels */ | 178 | /* Information about the channels */ |
179 | struct s_modchannel modchannel[8]; | 179 | struct s_modchannel modchannel[8]; |
180 | 180 | ||
181 | /* The Amiga Period Table | 181 | /* The Amiga Period Table */ |
182 | (+1 because we use index 0 for period 0 = no new note) */ | 182 | unsigned short *periodtable; |
183 | unsigned short periodtable[37*8+1]; | ||
184 | 183 | ||
185 | /* The sinus table [-255,255] */ | 184 | /* The sinus table [-255,255] */ |
186 | signed short sintable[0x40]; | 185 | signed short *sintable; |
187 | 186 | ||
188 | /* Is the glissando effect enabled? */ | 187 | /* Is the glissando effect enabled? */ |
189 | bool glissandoenabled; | 188 | bool glissandoenabled; |
@@ -239,6 +238,58 @@ struct s_song modsong IDATA_ATTR; /* The Song */ | |||
239 | struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ | 238 | struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ |
240 | struct s_mixer mixer IDATA_ATTR; | 239 | struct s_mixer mixer IDATA_ATTR; |
241 | 240 | ||
241 | /* The Amiga Period Table (+1 because we use index 0 for period 0 = no new note) */ | ||
242 | static unsigned short s_periodtable[37*8+1] IDATA_ATTR = | ||
243 | { 0, 907, 900, 893, 887, 881, 874, 868, | ||
244 | 862, 856, 849, 843, 837, 831, 825, 819, | ||
245 | 813, 808, 802, 796, 790, 785, 779, 773, | ||
246 | 768, 762, 757, 751, 746, 740, 735, 730, | ||
247 | 725, 719, 714, 709, 704, 699, 694, 689, | ||
248 | 684, 679, 674, 669, 664, 660, 655, 650, | ||
249 | 645, 641, 636, 632, 627, 623, 618, 614, | ||
250 | 609, 605, 600, 596, 592, 588, 583, 579, | ||
251 | 575, 571, 567, 563, 559, 555, 551, 547, | ||
252 | 543, 539, 535, 531, 527, 523, 520, 516, | ||
253 | 512, 509, 505, 501, 498, 494, 490, 487, | ||
254 | 483, 480, 477, 473, 470, 466, 463, 460, | ||
255 | 456, 453, 450, 446, 443, 440, 437, 434, | ||
256 | 431, 428, 424, 421, 418, 415, 412, 409, | ||
257 | 406, 404, 401, 398, 395, 392, 389, 386, | ||
258 | 384, 381, 378, 375, 373, 370, 367, 365, | ||
259 | 362, 359, 357, 354, 352, 349, 347, 344, | ||
260 | 342, 339, 337, 334, 332, 330, 327, 325, | ||
261 | 322, 320, 318, 316, 313, 311, 309, 307, | ||
262 | 304, 302, 300, 298, 296, 294, 291, 289, | ||
263 | 287, 285, 283, 281, 279, 277, 275, 273, | ||
264 | 271, 269, 267, 265, 263, 261, 260, 258, | ||
265 | 256, 254, 252, 250, 249, 247, 245, 243, | ||
266 | 241, 240, 238, 236, 235, 233, 231, 230, | ||
267 | 228, 226, 225, 223, 221, 220, 218, 217, | ||
268 | 215, 214, 212, 210, 209, 207, 206, 204, | ||
269 | 203, 202, 200, 199, 197, 196, 194, 193, | ||
270 | 192, 190, 189, 187, 186, 185, 183, 182, | ||
271 | 181, 179, 178, 177, 176, 174, 173, 172, | ||
272 | 171, 169, 168, 167, 166, 165, 163, 162, | ||
273 | 161, 160, 159, 158, 156, 155, 154, 153, | ||
274 | 152, 151, 150, 149, 148, 147, 145, 144, | ||
275 | 143, 142, 141, 140, 139, 138, 137, 136, | ||
276 | 135, 134, 133, 132, 131, 130, 130, 129, | ||
277 | 128, 127, 126, 125, 124, 123, 122, 121, | ||
278 | 120, 120, 119, 118, 117, 116, 115, 115, | ||
279 | 114, 113, 112, 111, 110, 110, 109, 108, | ||
280 | 107}; | ||
281 | |||
282 | /* The sin table */ | ||
283 | static signed short s_sintable[0x40] IDATA_ATTR = | ||
284 | { 0, 25, 49, 74, 97, 120, 141, 162, | ||
285 | 180, 197, 212, 225, 235, 244, 250, 254, | ||
286 | 255, 254, 250, 244, 235, 225, 212, 197, | ||
287 | 180, 161, 141, 120, 97, 73, 49, 24, | ||
288 | 0, -25, -50, -74, -98, -120, -142, -162, | ||
289 | -180, -197, -212, -225, -236, -244, -250, -254, | ||
290 | -255, -254, -250, -244, -235, -224, -211, -197, | ||
291 | -180, -161, -141, -119, -97, -73, -49, -24}; | ||
292 | |||
242 | const unsigned short mixingrate = 44100; | 293 | const unsigned short mixingrate = 44100; |
243 | 294 | ||
244 | STATICIRAM void mixer_playsample(int channel, int instrument) ICODE_ATTR; | 295 | STATICIRAM void mixer_playsample(int channel, int instrument) ICODE_ATTR; |
@@ -299,8 +350,13 @@ static inline void mixer_setamigaperiod(int channel, int amigaperiod) | |||
299 | STATICIRAM void initmodplayer(void) ICODE_ATTR; | 350 | STATICIRAM void initmodplayer(void) ICODE_ATTR; |
300 | void initmodplayer(void) | 351 | void initmodplayer(void) |
301 | { | 352 | { |
302 | unsigned int i,c; | 353 | unsigned int c; |
354 | #if 0 | ||
355 | /* As the calculation of periodtable and sintable uses float and double | ||
356 | * rockbox uses two predefined tables. This reduces the codesize by | ||
357 | * several KB. */ | ||
303 | 358 | ||
359 | unsigned int i; | ||
304 | /* Calculate Amiga Period Values | 360 | /* Calculate Amiga Period Values |
305 | * Start with Period 907 (= C-1 with Finetune -8) and work upwards */ | 361 | * Start with Period 907 (= C-1 with Finetune -8) and work upwards */ |
306 | double f = 907.0f; | 362 | double f = 907.0f; |
@@ -347,7 +403,11 @@ void initmodplayer(void) | |||
347 | a = a+b; | 403 | a = a+b; |
348 | b = b-dd*a; | 404 | b = b-dd*a; |
349 | } | 405 | } |
350 | 406 | #else | |
407 | /* Point to the predefined tables */ | ||
408 | modplayer.periodtable = s_periodtable; | ||
409 | modplayer.sintable = s_sintable; | ||
410 | #endif | ||
351 | /* Set Default Player Values */ | 411 | /* Set Default Player Values */ |
352 | modplayer.currentline = 0; | 412 | modplayer.currentline = 0; |
353 | modplayer.currenttick = 0; | 413 | modplayer.currenttick = 0; |