Replaced the frame parse and speech generation code from tms5110.c with the code from tms5220.c,

should be significantly more accurate and allow the cores to be much more easily merged in the future.
This also allowed finally getting rid of the COEFF_ENERGY_SENTINEL hack in tms5110r.inc [Lord Nightmare]
This commit is contained in:
Lord-Nightmare 2015-08-13 18:31:55 -04:00
parent a27a536928
commit fb6c64985d
3 changed files with 673 additions and 371 deletions

File diff suppressed because it is too large Load Diff

View File

@ -94,6 +94,7 @@ private:
int extract_bits(int count);
void request_bits(int no);
void perform_dummy_read();
INT32 lattice_filter();
void process(INT16 *buffer, unsigned int size);
void PDC_set(int data);
void parse_frame();
@ -108,8 +109,7 @@ private:
UINT8 m_PDC;
UINT8 m_CTL_pins;
UINT8 m_speaking_now;
// UINT8 m_talk_status is a protected member, see above
UINT8 m_state;
/* Rom interface */
@ -131,31 +131,66 @@ private:
devcb_write_line m_romclk_cb; // rom clock - Only used to drive the data lines
/* these contain data describing the current and previous voice frames */
UINT16 m_old_energy;
UINT16 m_old_pitch;
INT32 m_old_k[10];
#define OLD_FRAME_SILENCE_FLAG m_OLDE // 1 if E=0, 0 otherwise.
#define OLD_FRAME_UNVOICED_FLAG m_OLDP // 1 if P=0 (unvoiced), 0 if voiced
UINT8 m_OLDE;
UINT8 m_OLDP;
UINT16 m_new_energy;
UINT16 m_new_pitch;
INT32 m_new_k[10];
#define NEW_FRAME_STOP_FLAG (m_new_frame_energy_idx == 0xF) // 1 if this is a stop (Energy = 0xF) frame
#define NEW_FRAME_SILENCE_FLAG (m_new_frame_energy_idx == 0) // ditto as above
#define NEW_FRAME_UNVOICED_FLAG (m_new_frame_pitch_idx == 0) // ditto as above
UINT8 m_new_frame_energy_idx;
UINT8 m_new_frame_pitch_idx;
UINT8 m_new_frame_k_idx[10];
/* these are all used to contain the current state of the sound generation */
UINT16 m_current_energy;
UINT16 m_current_pitch;
#ifndef PERFECT_INTERPOLATION_HACK
INT16 m_current_energy;
INT16 m_current_pitch;
INT16 m_current_k[10];
INT16 m_target_energy;
INT16 m_target_pitch;
INT16 m_target_k[10];
#else
UINT8 m_old_frame_energy_idx;
UINT8 m_old_frame_pitch_idx;
UINT8 m_old_frame_k_idx[10];
INT32 m_current_energy;
INT32 m_current_pitch;
INT32 m_current_k[10];
UINT16 m_target_energy;
UINT16 m_target_pitch;
INT32 m_target_energy;
INT32 m_target_pitch;
INT32 m_target_k[10];
#endif
UINT8 m_interp_count; /* number of interp periods (0-7) */
UINT8 m_sample_count; /* sample number within interp (0-24) */
INT32 m_pitch_count;
UINT16 m_previous_energy; /* needed for lattice filter to match patent */
INT32 m_x[11];
UINT8 m_subcycle; /* contains the current subcycle for a given PC: 0 is A' (only used on SPKSLOW mode on 51xx), 1 is A, 2 is B */
UINT8 m_subc_reload; /* contains 1 for normal speech, 0 when SPKSLOW is active */
UINT8 m_PC; /* current parameter counter (what param is being interpolated), ranges from 0 to 12 */
/* TODO/NOTE: the current interpolation period, counts 1,2,3,4,5,6,7,0 for divide by 8,8,8,4,4,2,2,1 */
UINT8 m_IP; /* the current interpolation period */
UINT8 m_inhibit; /* If 1, interpolation is inhibited until the DIV1 period */
UINT16 m_pitch_count; /* pitch counter; provides chirp rom address */
INT32 m_u[11];
INT32 m_x[10];
INT32 m_RNG; /* the random noise generator configuration is: 1 + x + x^3 + x^4 + x^13 */
INT16 m_excitation_data;
/* The TMS51xx has two different ways of providing output data: the
analog speaker pins (which were usually used) and the Digital I/O pin.
The internal DAC used to feed the analog pins is only 8 bits, and has the
funny clipping/clamping logic, while the digital pin gives full 10 bit
resolution of the output data.
TODO: add a way to set/reset this other than the FORCE_DIGITAL define
*/
UINT8 m_digital_select;
INT32 m_speech_rom_bitnum;

View File

@ -70,7 +70,6 @@
#define MAX_K 10
#define MAX_SCALE_BITS 6
#define MAX_SCALE (1<<MAX_SCALE_BITS)
#define COEFF_ENERGY_SENTINEL (511)
#define MAX_CHIRP_SIZE 52
struct tms5100_coeffs
@ -92,21 +91,13 @@ struct tms5100_coeffs
#define TI_0280_PATENT_ENERGY \
/* E */\
{ 0, 0, 1, 1, 2, 3, 5, 7, \
10, 15, 21, 30, 43, 61, 86, COEFF_ENERGY_SENTINEL }, // last rom value is actually really 0, but the tms5110.c code still requires the sentinel value to function correctly, until it is properly updated or merged with tms5220.c
10, 15, 21, 30, 43, 61, 86, 0 },
#define TI_0280_LATER_ENERGY \
/* E */\
{ 0, 1, 2, 3, 4, 6, 8, 11, \
16, 23, 33, 47, 63, 85,114, COEFF_ENERGY_SENTINEL }, // last rom value is actually really 0, but the tms5110.c code still requires the sentinel value to function correctly, until it is properly updated or merged with tms5220.c
//technically this is the same as above, but tms5220.c expects the 0 rather than needing a sentinel value
//TODO: when tms5110.c no longer needs sentinel, get rid of this and merge with above.
#define TI_0285_LATER_ENERGY \
#define TI_028X_LATER_ENERGY \
/* E */\
{ 0, 1, 2, 3, 4, 6, 8, 11, \
16, 23, 33, 47, 63, 85,114, 0 },
/* pitch */
#define TI_0280_2801_PATENT_PITCH \
/* P */\
@ -375,7 +366,7 @@ static const struct tms5100_coeffs T0280D_0281D_coeff =
4,
5,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0280_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_0280_2801_PATENT_PITCH
{
TI_0280_PATENT_LPC
@ -411,7 +402,7 @@ static const struct tms5100_coeffs T0280F_2801A_coeff =
4,
5,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0280_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_0280_2801_PATENT_PITCH
{
TI_2801_2501E_LPC
@ -435,7 +426,7 @@ static const struct tms5100_coeffs M58817_coeff =
4,
5,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0280_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_0280_2801_PATENT_PITCH
{
TI_2801_2501E_LPC
@ -460,7 +451,7 @@ static const struct tms5100_coeffs T0280F_2802_coeff =
4,
5,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0280_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_2802_PITCH
{
TI_2802_LPC
@ -492,7 +483,7 @@ static const struct tms5100_coeffs tms5110a_coeff =
4,
5,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0280_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_5110_PITCH
{
TI_5110_5220_LPC
@ -518,7 +509,7 @@ static const struct tms5100_coeffs pat4335277_coeff =
4,
6,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0285_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_2501E_PITCH
{
/* K1dc */
@ -591,7 +582,7 @@ static const struct tms5100_coeffs T0285_2501E_coeff =
4,
6,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0285_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_2501E_PITCH
{
TI_2801_2501E_LPC
@ -620,7 +611,7 @@ static const struct tms5100_coeffs tms5220_coeff =
4,
6,
{ 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 },
TI_0285_LATER_ENERGY
TI_028X_LATER_ENERGY
TI_5220_PITCH
{
TI_5110_5220_LPC