mirror of
https://github.com/holub/mame
synced 2025-07-05 01:48:29 +03:00
tms5220.c: improve perfect interpolation hack slightly, should be less noisy after inhibit frames. [Lord Nightmare]
This commit is contained in:
parent
f385ad5e0a
commit
272871986d
@ -273,7 +273,7 @@ device), PES Speech adapter (serial port connection)
|
||||
* if VOICED_ZERO_HACK defined, acts as shown in patent, but the first and >=51 samples are 0x80 (-128)
|
||||
* if VOICED_PULSE_HACK defined, acts as a pulse waveform with a period of PWIDTH samples at PAMP, PWIDTH samples at ~PAMP, and the rest at 0
|
||||
* if VOICED_PULSE_MONOPOLAR_HACK defined, acts as a pulse waveform with a period of PWIDTH samples at PAMP, and the rest at 0
|
||||
* If you want this to sound like MGE, set VOICED_PULSE_MONOPOLAR_HACK to 1, PAMP to 0x3F and PWIDTH to 1
|
||||
* If you want this to sound like MGE, set VOICED_PULSE_MONOPOLAR_HACK to 1, PAMP to 0x3F and PWIDTH to 2, and set the perfect interpolation hack below on as well.
|
||||
*/
|
||||
#undef VOICED_INV_HACK
|
||||
#undef VOICED_ZERO_HACK
|
||||
@ -1000,8 +1000,10 @@ 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 samples_per_frame = tms->subc_reload?175:266; // either (13 A cycles + 12 B cycles) * 7 interps for normal SPEAK/SPKEXT, or (13*2 A cycles + 12 B cycles) * 7 interps for SPKSLOW
|
||||
//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->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
|
||||
@ -1012,10 +1014,20 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size
|
||||
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 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++)
|
||||
tms->current_k[i] += (((tms->target_k[i] - tms->current_k[i])*(1-tms->inhibit))*current_sample)/samples_per_frame;
|
||||
if (tms->interp_period != 0) // if we're still interpolating...
|
||||
{
|
||||
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++)
|
||||
tms->current_k[i] += (((tms->target_k[i] - tms->current_k[i])*(1-tms->inhibit))*current_sample)/samples_per_frame;
|
||||
}
|
||||
else // we're done, play this frame for 1/8 frame.
|
||||
{
|
||||
tms->current_energy = tms->target_energy;
|
||||
tms->current_pitch = tms->target_pitch;
|
||||
for (i = 0; i < tms->coeff->num_k; i++)
|
||||
tms->current_k[i] = tms->target_k[i];
|
||||
}
|
||||
#else
|
||||
//Updates to parameters only happen on subcycle '2' (B cycle) of PCs.
|
||||
if (tms->subcycle == 2)
|
||||
|
Loading…
Reference in New Issue
Block a user