summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme')
-rw-r--r--apps/codecs/libgme/ym2612_emu.c26
-rw-r--r--apps/codecs/libgme/ym2612_emu.h8
2 files changed, 28 insertions, 6 deletions
diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c
index 003be394dd..a1f96e3d70 100644
--- a/apps/codecs/libgme/ym2612_emu.c
+++ b/apps/codecs/libgme/ym2612_emu.c
@@ -490,7 +490,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
490{ 490{
491 assert( sample_rate ); 491 assert( sample_rate );
492 assert( !clock_rate || clock_rate > sample_rate ); 492 assert( !clock_rate || clock_rate > sample_rate );
493 493
494 int i; 494 int i;
495 495
496 // 144 = 12 * (prescale * 2) = 12 * 6 * 2 496 // 144 = 12 * (prescale * 2) = 12 * 6 * 2
@@ -505,6 +505,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
505 // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0) 505 // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0)
506 // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0) 506 // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0)
507 507
508#ifdef YM2612_USE_TL_TAB
508 for ( i = 0; i < TL_LENGHT; i++ ) 509 for ( i = 0; i < TL_LENGHT; i++ )
509 { 510 {
510 if (i >= PG_CUT_OFF) // YM2612 cut off sound after 78 dB (14 bits output ?) 511 if (i >= PG_CUT_OFF) // YM2612 cut off sound after 78 dB (14 bits output ?)
@@ -522,6 +523,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
522 impl->g.TL_TAB [TL_LENGHT + i] = -impl->g.TL_TAB [i]; 523 impl->g.TL_TAB [TL_LENGHT + i] = -impl->g.TL_TAB [i];
523 } 524 }
524 } 525 }
526#endif
525 527
526 // Tableau SIN : 528 // Tableau SIN :
527 // impl->g.SIN_TAB [x] [y] = sin(x) * y; 529 // impl->g.SIN_TAB [x] [y] = sin(x) * y;
@@ -908,8 +910,24 @@ short const* const ENV_TAB = g->ENV_TAB; \
908CALC_EN( 0 ) \ 910CALC_EN( 0 ) \
909CALC_EN( 1 ) \ 911CALC_EN( 1 ) \
910CALC_EN( 2 ) \ 912CALC_EN( 2 ) \
911CALC_EN( 3 ) \ 913CALC_EN( 3 )
912int const* const TL_TAB = g->TL_TAB; 914
915#ifndef YM2612_USE_TL_TAB
916static inline int tl_level( int i )
917{
918 if (i >= (PG_CUT_OFF + TL_LENGHT)) {
919 return 0;
920 } else if (i >= TL_LENGHT) {
921 return -tl_coeff [i - TL_LENGHT];
922 } else if (i >= PG_CUT_OFF) {
923 return 0;
924 } else
925 return tl_coeff [i];
926}
927#define SINT( i, o ) (tl_level (g->SIN_TAB [(i)] + (o)))
928#else
929#define SINT( i, o ) (g->TL_TAB [g->SIN_TAB [(i)] + (o)])
930#endif
913 931
914#define DO_FEEDBACK \ 932#define DO_FEEDBACK \
915int CH_S0_OUT_0 = ch->S0_OUT [0]; \ 933int CH_S0_OUT_0 = ch->S0_OUT [0]; \
@@ -919,8 +937,6 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \
919 CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); \ 937 CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); \
920} \ 938} \
921 939
922#define SINT( i, o ) (TL_TAB [g->SIN_TAB [(i)] + (o)])
923
924#define DO_LIMIT \ 940#define DO_LIMIT \
925CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ 941CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \
926 942
diff --git a/apps/codecs/libgme/ym2612_emu.h b/apps/codecs/libgme/ym2612_emu.h
index 96e3eae94b..146d92a0a3 100644
--- a/apps/codecs/libgme/ym2612_emu.h
+++ b/apps/codecs/libgme/ym2612_emu.h
@@ -10,6 +10,10 @@
10 #define YM2612_CALCUL_TABLES 10 #define YM2612_CALCUL_TABLES
11#endif 11#endif
12 12
13#if MEMORYSIZE > 2
14 #define YM2612_USE_TL_TAB
15#endif
16
13enum { ym2612_out_chan_count = 2 }; // stereo 17enum { ym2612_out_chan_count = 2 }; // stereo
14enum { ym2612_channel_count = 6 }; 18enum { ym2612_channel_count = 6 };
15enum { ym2612_disabled_time = -1 }; 19enum { ym2612_disabled_time = -1 };
@@ -172,7 +176,9 @@ struct tables_t
172 short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) 176 short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB)
173 short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE 177 short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE
174#endif 178#endif
175 int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) 179#ifdef YM2612_USE_TL_TAB
180 int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus)
181#endif
176 unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase 182 unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase
177 unsigned int FINC_TAB [2048]; // Frequency step table 183 unsigned int FINC_TAB [2048]; // Frequency step table
178}; 184};