diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/sid.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c index a9ca457fb3..fed1e8acaa 100644 --- a/apps/codecs/sid.c +++ b/apps/codecs/sid.c | |||
@@ -67,6 +67,7 @@ CODEC_HEADER | |||
67 | 67 | ||
68 | #define CHUNK_SIZE (1024*2) | 68 | #define CHUNK_SIZE (1024*2) |
69 | #define SID_BUFFER_SIZE 0x10000 | 69 | #define SID_BUFFER_SIZE 0x10000 |
70 | #define SAMPLE_RATE 44100 | ||
70 | 71 | ||
71 | /* This codec supports SID Files: | 72 | /* This codec supports SID Files: |
72 | * | 73 | * |
@@ -157,8 +158,10 @@ struct sidflt { | |||
157 | int mixing_frequency IDATA_ATTR; | 158 | int mixing_frequency IDATA_ATTR; |
158 | unsigned long freqmul IDATA_ATTR; | 159 | unsigned long freqmul IDATA_ATTR; |
159 | int filtmul IDATA_ATTR; | 160 | int filtmul IDATA_ATTR; |
161 | #ifndef ROCKBOX | ||
160 | unsigned long attacks [16] IDATA_ATTR; | 162 | unsigned long attacks [16] IDATA_ATTR; |
161 | unsigned long releases[16] IDATA_ATTR; | 163 | unsigned long releases[16] IDATA_ATTR; |
164 | #endif | ||
162 | 165 | ||
163 | /* ------------------------------------------------------------ globals */ | 166 | /* ------------------------------------------------------------ globals */ |
164 | struct s6581 sid IDATA_ATTR; | 167 | struct s6581 sid IDATA_ATTR; |
@@ -187,6 +190,7 @@ static int internal_period, internal_order, internal_start, internal_end, | |||
187 | internal_add, internal_repeat_times, internal_repeat_start IDATA_ATTR; | 190 | internal_add, internal_repeat_times, internal_repeat_start IDATA_ATTR; |
188 | 191 | ||
189 | /* ---------------------------------------------------------- constants */ | 192 | /* ---------------------------------------------------------- constants */ |
193 | #ifndef ROCKBOX | ||
190 | static const float attackTimes[16] ICONST_ATTR = | 194 | static const float attackTimes[16] ICONST_ATTR = |
191 | { | 195 | { |
192 | 0.0022528606, 0.0080099577, 0.0157696042, 0.0237795619, | 196 | 0.0022528606, 0.0080099577, 0.0157696042, 0.0237795619, |
@@ -200,7 +204,23 @@ static const float decayReleaseTimes[16] ICONST_ATTR = | |||
200 | 0.169078356, 0.205199432, 0.240551975, 0.301266125, 0.750858245, | 204 | 0.169078356, 0.205199432, 0.240551975, 0.301266125, 0.750858245, |
201 | 1.50171551, 2.40243682, 3.00189298, 9.00721405, 15.010998, 24.0182111 | 205 | 1.50171551, 2.40243682, 3.00189298, 9.00721405, 15.010998, 24.0182111 |
202 | }; | 206 | }; |
203 | 207 | #else | |
208 | #define DIV(X) ((int)(0x1000000 / (X * SAMPLE_RATE))) | ||
209 | static const unsigned long attacks[16] ICONST_ATTR = | ||
210 | { | ||
211 | DIV(0.0022528606), DIV(0.0080099577), DIV(0.0157696042), DIV(0.0237795619), | ||
212 | DIV(0.0372963655), DIV(0.0550684591), DIV(0.0668330845), DIV(0.0783473987), | ||
213 | DIV(0.0981219818), DIV(0.2445540210), DIV(0.4891080420), DIV(0.7824727420), | ||
214 | DIV(0.9777154610), DIV(2.9336470100), DIV(4.8890779300), DIV(7.8227249300) | ||
215 | }; | ||
216 | static const unsigned long releases[16] ICONST_ATTR = | ||
217 | { | ||
218 | DIV(0.00891777693), DIV(0.0245940510), DIV(0.0484185907), DIV(0.0730116639), | ||
219 | DIV(0.11451247500), DIV(0.1690783560), DIV(0.2051994320), DIV(0.2405519750), | ||
220 | DIV(0.30126612500), DIV(0.7508582450), DIV(1.5017155100), DIV(2.4024368200), | ||
221 | DIV(3.00189298000), DIV(9.0072140500), DIV(15.010998000), DIV(24.018211100) | ||
222 | }; | ||
223 | #endif | ||
204 | static const int opcodes[256] ICONST_ATTR = { | 224 | static const int opcodes[256] ICONST_ATTR = { |
205 | _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, | 225 | _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, |
206 | bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, | 226 | bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, |
@@ -246,10 +266,14 @@ static inline int quickfloat_ConvertFromInt(int i) | |||
246 | { | 266 | { |
247 | return (i<<16); | 267 | return (i<<16); |
248 | } | 268 | } |
269 | #ifndef ROCKBOX | ||
249 | static inline int quickfloat_ConvertFromFloat(float f) | 270 | static inline int quickfloat_ConvertFromFloat(float f) |
250 | { | 271 | { |
251 | return (int)(f*(1<<16)); | 272 | return (int)(f*(1<<16)); |
252 | } | 273 | } |
274 | #else | ||
275 | #define quickfloat_ConvertFromFloat(X) (int)(X*(1<<16)) | ||
276 | #endif | ||
253 | static inline int quickfloat_Multiply(int a, int b) | 277 | static inline int quickfloat_Multiply(int a, int b) |
254 | { | 278 | { |
255 | return (a>>8)*(b>>8); | 279 | return (a>>8)*(b>>8); |
@@ -325,15 +349,19 @@ static inline int GenerateDigi(int sIn) | |||
325 | void synth_init(unsigned long mixfrq) ICODE_ATTR; | 349 | void synth_init(unsigned long mixfrq) ICODE_ATTR; |
326 | void synth_init(unsigned long mixfrq) | 350 | void synth_init(unsigned long mixfrq) |
327 | { | 351 | { |
352 | #ifndef ROCKBOX | ||
328 | int i; | 353 | int i; |
354 | #endif | ||
329 | mixing_frequency = mixfrq; | 355 | mixing_frequency = mixfrq; |
330 | fracPos = 0; | 356 | fracPos = 0; |
331 | freqmul = 15872000 / mixfrq; | 357 | freqmul = 15872000 / mixfrq; |
332 | filtmul = quickfloat_ConvertFromFloat(21.5332031f)/mixfrq; | 358 | filtmul = quickfloat_ConvertFromFloat(21.5332031f)/mixfrq; |
359 | #ifndef ROCKBOX | ||
333 | for (i=0;i<16;i++) { | 360 | for (i=0;i<16;i++) { |
334 | attacks [i]=(int) (0x1000000 / (attackTimes[i]*mixfrq)); | 361 | attacks [i]=(int) (0x1000000 / (attackTimes[i]*mixfrq)); |
335 | releases[i]=(int) (0x1000000 / (decayReleaseTimes[i]*mixfrq)); | 362 | releases[i]=(int) (0x1000000 / (decayReleaseTimes[i]*mixfrq)); |
336 | } | 363 | } |
364 | #endif | ||
337 | memset(&sid,0,sizeof(sid)); | 365 | memset(&sid,0,sizeof(sid)); |
338 | memset(osc,0,sizeof(osc)); | 366 | memset(osc,0,sizeof(osc)); |
339 | memset(&filter,0,sizeof(filter)); | 367 | memset(&filter,0,sizeof(filter)); |
@@ -1207,7 +1235,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) | |||
1207 | { | 1235 | { |
1208 | if (reason == CODEC_LOAD) { | 1236 | if (reason == CODEC_LOAD) { |
1209 | /* Make use of 44.1khz */ | 1237 | /* Make use of 44.1khz */ |
1210 | ci->configure(DSP_SWITCH_FREQUENCY, 44100); | 1238 | ci->configure(DSP_SWITCH_FREQUENCY, SAMPLE_RATE); |
1211 | /* Sample depth is 28 bit host endian */ | 1239 | /* Sample depth is 28 bit host endian */ |
1212 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | 1240 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); |
1213 | /* Mono output */ | 1241 | /* Mono output */ |
@@ -1241,7 +1269,7 @@ enum codec_status codec_run(void) | |||
1241 | return CODEC_ERROR; | 1269 | return CODEC_ERROR; |
1242 | } | 1270 | } |
1243 | 1271 | ||
1244 | c64Init(44100); | 1272 | c64Init(SAMPLE_RATE); |
1245 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, | 1273 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, |
1246 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); | 1274 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); |
1247 | sidPoke(24, 15); /* Turn on full volume */ | 1275 | sidPoke(24, 15); /* Turn on full volume */ |
@@ -1262,7 +1290,7 @@ enum codec_status codec_run(void) | |||
1262 | /* New time is ready in param */ | 1290 | /* New time is ready in param */ |
1263 | 1291 | ||
1264 | /* Start playing from scratch */ | 1292 | /* Start playing from scratch */ |
1265 | c64Init(44100); | 1293 | c64Init(SAMPLE_RATE); |
1266 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, | 1294 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, |
1267 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); | 1295 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); |
1268 | sidPoke(24, 15); /* Turn on full volume */ | 1296 | sidPoke(24, 15); /* Turn on full volume */ |