2004-02-14 Saito <saito2@digitalme.com>
* timidity/playmidi.[ch], timidity/mix.c,
- timidity/sndfont.c, timidity/instrum.c:
+ timidity/sndfont.c, timidity/instrum.c
+ timidity/tables.c, timidity/timidity.c:
Fix modulation envelope of SoundFont.
Fix bahaviour of filter.
Hack up around load_instrument().
if(!opt_modulation_envelope) {return 0;}
if (vp->sample->modes & MODES_ENVELOPE) {
- /* if (vp->modenv_stage > 1)
- vp->last_modenv_volume = attack_vol_table[vp->modenv_volume >> 20];
- else*/
- vp->last_modenv_volume = convex_vol_table[vp->modenv_volume >> 20];
+ if (vp->modenv_stage > 1)
+ vp->last_modenv_volume = modenv_decay_vol_table[vp->modenv_volume >> 20];
+ else
+ vp->last_modenv_volume = modenv_attack_vol_table[vp->modenv_volume >> 20];
}
recompute_voice_filter(v);
sb_vol_table[i] = pow(10.0, (double)(1023 - i) * 960.0 / (1023.0 * -200.0));
}
-FLOAT_T convex_vol_table[1024];
+FLOAT_T modenv_attack_vol_table[1024];
+FLOAT_T modenv_decay_vol_table[1024];
-void init_convex_vol_table(void)
+void init_modenv_vol_table(void)
{
int i;
-
+ double x;
+
for (i = 0; i < 1024; i++) {
- convex_vol_table[i] = 1.0 - (-20.0 / 96.0 * log(((double)i * (double)i) / (1023.0 * 1023.0)) / log(10.0));
- if(convex_vol_table[i] < 0) {convex_vol_table[i] = 0;}
+ modenv_decay_vol_table[i] = log((double)i / 1023.0f + 1) / log(2);
}
- convex_vol_table[0] = 0;
- convex_vol_table[1023] = 1.0;
+ modenv_attack_vol_table[0] = 0;
+ for (i = 1; i < 1023; i++) {
+ x = (1.0 - (-20.0 / 96.0 * log(((double)i * (double)i) / (1023.0 * 1023.0)) / log(10.0)));
+ if(x < 0) {x = 0;}
+ modenv_attack_vol_table[i] = log(x + 1) / log(2);
+ }
+ modenv_attack_vol_table[1023] = 1.0;
}
FLOAT_T cb_to_amp_table[961] =
extern FLOAT_T sc_pan_table[], gm2_pan_table[];
extern FLOAT_T sc_drum_level_table[];
extern FLOAT_T sb_vol_table[];
-extern FLOAT_T convex_vol_table[];
+extern FLOAT_T modenv_attack_vol_table[];
+extern FLOAT_T modenv_decay_vol_table[];
extern FLOAT_T cb_to_amp_table[];
extern FLOAT_T reverb_time_table[];
extern FLOAT_T pan_delay_table[];
extern void init_gm2_pan_table(void);
extern void init_attack_vol_table(void);
extern void init_sb_vol_table(void);
-extern void init_convex_vol_table(void);
+extern void init_modenv_vol_table(void);
extern void init_def_vol_table(void);
extern void init_gs_vol_table(void);
extern void init_perceived_vol_table(void);
init_gm2_pan_table();
init_attack_vol_table();
init_sb_vol_table();
- init_convex_vol_table();
+ init_modenv_vol_table();
init_def_vol_table();
init_gs_vol_table();
init_perceived_vol_table();