diff options
Diffstat (limited to 'apps/codecs/libgme/ym2612_emu.c')
-rw-r--r-- | apps/codecs/libgme/ym2612_emu.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c index 970e4462e1..003be394dd 100644 --- a/apps/codecs/libgme/ym2612_emu.c +++ b/apps/codecs/libgme/ym2612_emu.c | |||
@@ -35,12 +35,18 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ | |||
35 | // Ported again to c by gama. | 35 | // Ported again to c by gama. |
36 | // Not sure if performance is better than the original c version. | 36 | // Not sure if performance is better than the original c version. |
37 | 37 | ||
38 | #if !defined(ROCKBOX) | 38 | #if !defined(YM2612_CALCUL_TABLES) |
39 | #define YM2612_CALCUL_TABLES | ||
40 | #else | ||
41 | #include "ymtables.h" | 39 | #include "ymtables.h" |
42 | #endif | 40 | #endif |
43 | 41 | ||
42 | #ifdef YM2612_CALCUL_TABLES | ||
43 | #define FREQ_TAB_LOOKUP g->LFO_FREQ_TAB | ||
44 | #define ENV_TAB_LOOKUP g->LFO_ENV_TAB | ||
45 | #else | ||
46 | #define FREQ_TAB_LOOKUP lfo_freq_coeff | ||
47 | #define ENV_TAB_LOOKUP lfo_env_coeff | ||
48 | #endif | ||
49 | |||
44 | const int output_bits = 14; | 50 | const int output_bits = 14; |
45 | 51 | ||
46 | static const unsigned char DT_DEF_TAB [4 * 32] = | 52 | static const unsigned char DT_DEF_TAB [4 * 32] = |
@@ -540,11 +546,10 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double | |||
540 | impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j; | 546 | impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j; |
541 | } | 547 | } |
542 | 548 | ||
549 | #ifdef YM2612_CALCUL_TABLES | ||
543 | // Tableau LFO (LFO wav) : | 550 | // Tableau LFO (LFO wav) : |
544 | |||
545 | for ( i = 0; i < LFO_LENGHT; i++ ) | 551 | for ( i = 0; i < LFO_LENGHT; i++ ) |
546 | { | 552 | { |
547 | #ifdef YM2612_CALCUL_TABLES | ||
548 | double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus | 553 | double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus |
549 | x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation | 554 | x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation |
550 | 555 | ||
@@ -554,11 +559,8 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double | |||
554 | x *= (1 << (LFO_HBITS - 1)) - 1; | 559 | x *= (1 << (LFO_HBITS - 1)) - 1; |
555 | 560 | ||
556 | impl->g.LFO_FREQ_TAB [i] = (int) x; | 561 | impl->g.LFO_FREQ_TAB [i] = (int) x; |
557 | #else | ||
558 | impl->g.LFO_ENV_TAB [i] = lfo_env_coeff [i]; | ||
559 | impl->g.LFO_FREQ_TAB [i] = lfo_freq_coeff [i]; | ||
560 | #endif | ||
561 | } | 562 | } |
563 | #endif | ||
562 | 564 | ||
563 | // Tableau Enveloppe : | 565 | // Tableau Enveloppe : |
564 | // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve | 566 | // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve |
@@ -901,7 +903,7 @@ int YM2612_LFOcnt = g->LFOcnt + YM2612_LFOinc; | |||
901 | ((temp##x - ch->SLOT [S##x].env_max) >> 31); | 903 | ((temp##x - ch->SLOT [S##x].env_max) >> 31); |
902 | 904 | ||
903 | #define GET_ENV \ | 905 | #define GET_ENV \ |
904 | int const env_LFO = g->LFO_ENV_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \ | 906 | int const env_LFO = ENV_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \ |
905 | short const* const ENV_TAB = g->ENV_TAB; \ | 907 | short const* const ENV_TAB = g->ENV_TAB; \ |
906 | CALC_EN( 0 ) \ | 908 | CALC_EN( 0 ) \ |
907 | CALC_EN( 1 ) \ | 909 | CALC_EN( 1 ) \ |
@@ -923,7 +925,7 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \ | |||
923 | CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ | 925 | CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ |
924 | 926 | ||
925 | #define UPDATE_PHASE_CYCLE \ | 927 | #define UPDATE_PHASE_CYCLE \ |
926 | unsigned freq_LFO = ((g->LFO_FREQ_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \ | 928 | unsigned freq_LFO = ((FREQ_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \ |
927 | ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \ | 929 | ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \ |
928 | YM2612_LFOcnt += YM2612_LFOinc; \ | 930 | YM2612_LFOcnt += YM2612_LFOinc; \ |
929 | in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ | 931 | in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ |