tms5220: Remove unnecessary interpolation code; Add extra check to make unvoiced mode trigger at the correct sample. [Lord Nightmare]

This commit is contained in:
Jonathan Gevaryahu 2010-05-09 08:04:41 +00:00
parent e067fc79a8
commit 55a4f03e78

View File

@ -870,17 +870,17 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
#else
interp_period = tms->sample_count / 25;
#endif
#define PC_COUNT_LOAD 7
if (interp_period == 7) tms->inhibit = 0; // disable inhibit when reaching the last interp period
zpar = OLD_FRAME_UNVOICED_FLAG;
#ifdef PERFECT_INTERPOLATION_HACK
// 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];
for (i = 0; i < 4; i++)
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 the 200 samples per frsme
// now adjust each value to be exactly correct for each of the 200 samples per frsme
tms->current_energy += (((tms->target_energy - tms->current_energy)*(1-tms->inhibit))*tms->sample_count)/200;
tms->current_pitch += (((tms->target_pitch - tms->current_pitch)*(1-tms->inhibit))*tms->sample_count)/200;
for (i = 0; i < tms->coeff->num_k; i++)
@ -894,85 +894,62 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
case 1: /* PC=0, B cycle, nothing happens (update energy) */
break;
case 2: /* PC=1, A cycle, update energy (calc pitch) */
if (interp_period == PC_COUNT_LOAD)
tms->current_energy = tms->coeff->energytable[tms->old_frame_energy_idx];
tms->current_energy += (((tms->target_energy - tms->current_energy)*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 3: /* PC=1, B cycle, nothing happens (update pitch) */
break;
case 4: /* PC=2, A cycle, update pitch (calc K1) */
if (interp_period == PC_COUNT_LOAD)
tms->current_pitch = tms->coeff->pitchtable[tms->old_frame_pitch_idx];
if (interp_period == 7) tms->old_frame_pitch_idx = tms->new_frame_pitch_idx; // this is to make it so the unvoiced behavior is correct during interpolation
tms->current_pitch += (((tms->target_pitch - tms->current_pitch)*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 5: /* PC=2, B cycle, nothing happens (update K1) */
break;
case 6: /* PC=3, A cycle, update K1 (calc K2) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[0] = tms->coeff->ktable[0][tms->old_frame_k_idx[0]];
tms->current_k[0] += (((tms->target_k[0] - tms->current_k[0])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 7: /* PC=3, B cycle, nothing happens (update K2) */
break;
case 8: /* PC=4, A cycle, update K2 (calc K3) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[1] = tms->coeff->ktable[1][tms->old_frame_k_idx[1]];
tms->current_k[1] += (((tms->target_k[1] - tms->current_k[1])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 9: /* PC=4, B cycle, nothing happens (update K3) */
break;
case 10: /* PC=5, A cycle, update K3 (calc K4) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[2] = tms->coeff->ktable[2][tms->old_frame_k_idx[2]];
tms->current_k[2] += (((tms->target_k[2] - tms->current_k[2])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 11: /* PC=5, B cycle, nothing happens (update K4) */
break;
case 12: /* PC=6, A cycle, update K4 (calc K5) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[3] = tms->coeff->ktable[3][tms->old_frame_k_idx[3]];
tms->current_k[3] += (((tms->target_k[3] - tms->current_k[3])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 13: /* PC=6, B cycle, nothing happens (update K5) */
break;
case 14: /* PC=7, A cycle, update K5 (calc K6) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[4] = (tms->coeff->ktable[4][tms->old_frame_k_idx[4]] * (1-zpar));
tms->current_k[4] += (((tms->target_k[4] - tms->current_k[4])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 15: /* PC=7, B cycle, nothing happens (update K6) */
break;
case 16: /* PC=8, A cycle, update K6 (calc K7) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[5] = (tms->coeff->ktable[5][tms->old_frame_k_idx[5]] * (1-zpar));
tms->current_k[5] += (((tms->target_k[5] - tms->current_k[5])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 17: /* PC=8, B cycle, nothing happens (update K7) */
break;
case 18: /* PC=9, A cycle, update K7 (calc K8) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[6] = (tms->coeff->ktable[6][tms->old_frame_k_idx[6]] * (1-zpar));
tms->current_k[6] += (((tms->target_k[6] - tms->current_k[6])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 19: /* PC=9, B cycle, nothing happens (update K8) */
break;
case 20: /* PC=10, A cycle, update K8 (calc K9) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[7] = (tms->coeff->ktable[7][tms->old_frame_k_idx[7]] * (1-zpar));
tms->current_k[7] += (((tms->target_k[7] - tms->current_k[7])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 21: /* PC=10, B cycle, nothing happens (update K9) */
break;
case 22: /* PC=11, A cycle, update K9 (calc K10) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[8] = (tms->coeff->ktable[8][tms->old_frame_k_idx[8]] * (1-zpar));
tms->current_k[8] += (((tms->target_k[8] - tms->current_k[8])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
case 23: /* PC=11, B cycle, nothing happens (update K10) */
break;
case 24: /* PC=12, A cycle, update K10 (do nothing) */
if (interp_period == PC_COUNT_LOAD)
tms->current_k[9] = (tms->coeff->ktable[9][tms->old_frame_k_idx[9]] * (1-zpar));
tms->current_k[9] += (((tms->target_k[9] - tms->current_k[9])*(1-tms->inhibit)) >> tms->coeff->interp_coeff[interp_period]);
break;
}