summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Jonathan Gevaryahu <Lord-Nightmare@users.noreply.github.com>2011-04-17 23:35:22 +0000
committer Jonathan Gevaryahu <Lord-Nightmare@users.noreply.github.com>2011-04-17 23:35:22 +0000
commit272871986debf1ce811f7fcbadb67d2544c9dd4e (patch)
treeea6f93b92ebdea8724e6a7775b4ea3ab6a6730bf
parentf385ad5e0aa49c16c39246164e8466cdb72c3e12 (diff)
tms5220.c: improve perfect interpolation hack slightly, should be less noisy after inhibit frames. [Lord Nightmare]
-rw-r--r--src/emu/sound/tms5220.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c
index 1d271907f4f..cb0fef2986a 100644
--- a/src/emu/sound/tms5220.c
+++ b/src/emu/sound/tms5220.c
@@ -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)