tms5220.c: fixed perfect interpolation hack the rest of the

way, now it works as it did before 0.140 or so. [Lord Nightmare]
This commit is contained in:
Jonathan Gevaryahu 2011-04-17 21:01:51 +00:00
parent 9ec834eb29
commit f385ad5e0a

View File

@ -288,7 +288,6 @@ device), PES Speech adapter (serial port connection)
#undef ALLOW_4_LSB
/* HACK: if defined, uses impossibly perfect 'straight line' interpolation */
// TODO: as of around mame 0.141 this doesn't work right. please fix! - LN, to LN
#undef PERFECT_INTERPOLATION_HACK
@ -1002,8 +1001,9 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
if (tms->interp_period == 0) tms->inhibit = 0; // disable inhibit when reaching the last interp period
#ifdef PERFECT_INTERPOLATION_HACK
int samples_per_frame = tms->subc_reload?200:304; // either (13 A cycles + 12 B cycles) * 8 interps for normal SPEAK/SPKEXT, or (13*2 A cycles + 12 B cycles) * 8 interps for SPKSLOW
int current_sample = ((tms->PC*(3-tms->subc_reload))+((tms->subc_reload?38:25)*((tms->interp_period-1)&7)));
int current_sample = (tms->subcycle - tms->subc_reload)+(tms->PC*(3-tms->subc_reload))+((tms->subc_reload?25:38)*((tms->interp_period-1)&7));
zpar = OLD_FRAME_UNVOICED_FLAG;
//fprintf(stderr, "CS: %03d", current_sample);
// reset the current energy, pitch, etc to what it was at frame start
tms->current_energy = tms->coeff->energytable[tms->old_frame_energy_idx];
tms->current_pitch = tms->coeff->pitchtable[tms->old_frame_pitch_idx];
@ -1011,7 +1011,7 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
tms->current_k[i] = tms->coeff->ktable[i][tms->old_frame_k_idx[i]];
for (i = 4; i < tms->coeff->num_k; i++)
tms->current_k[i] = (tms->coeff->ktable[i][tms->old_frame_k_idx[i]] * (1-zpar));
// now adjust each value to be exactly correct for each of the samples per frsme
// now adjust each value to be exactly correct for each of the samples per frame
tms->current_energy += (((tms->target_energy - tms->current_energy)*(1-tms->inhibit))*current_sample)/samples_per_frame;
tms->current_pitch += (((tms->target_pitch - tms->current_pitch)*(1-tms->inhibit))*current_sample)/samples_per_frame;
for (i = 0; i < tms->coeff->num_k; i++)
@ -1113,6 +1113,7 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
}
this_sample = lattice_filter(tms); /* execute lattice filter */
#ifdef DEBUG_GENERATION_VERBOSE
//fprintf(stderr,"C: %01d; ",tms->subcycle);
//fprintf(stderr,"IP: %01d; PC: %02d; X:%04d; E:%04d; P:%04d; Pc:%04d ",tms->interp_period, tms->PC, tms->excitation_data, tms->current_energy, tms->current_pitch, tms->pitch_count);
fprintf(stderr,"X:%04d; E:%04d; P:%04d; Pc:%04d ", tms->excitation_data, tms->current_energy, tms->current_pitch, tms->pitch_count);
for (i=0; i<10; i++)