44
void sh_votrax_start(int Channel)
46
VotraxSamples = readsamples(VotraxTable,"votrax");
47
VotraxBaseFrequency = 8000;
48
VotraxBaseVolume = 230;
49
VotraxChannel = Channel;
52
void sh_votrax_stop(void)
61
static void votrax_update_sound(void *param, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
63
struct votrax_info *info = param;
64
stream_sample_t *buffer = _buffer[0];
68
/* load some info locally */
69
UINT32 pos = info->pos;
70
UINT32 frac = info->frac;
71
UINT32 step = info->step;
72
UINT32 length = info->sample->length;
73
INT16 *sample = info->sample->data;
77
/* do a linear interp on the sample */
78
INT32 sample1 = sample[pos];
79
INT32 sample2 = sample[(pos + 1) % length];
80
INT32 fracmult = frac >> (FRAC_BITS - 14);
81
*buffer++ = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14;
85
pos += frac >> FRAC_BITS;
86
frac = frac & ((1 << FRAC_BITS) - 1);
88
/* handle looping/ending */
96
/* push position back out */
103
static void *votrax_start(int sndindex, int clock, const void *config)
105
struct votrax_info *votrax;
107
votrax = auto_malloc(sizeof(*votrax));
108
memset(votrax, 0, sizeof(*votrax));
110
votrax->samples = readsamples(VotraxTable,"votrax");
111
votrax->frequency = 8000;
112
votrax->volume = 230;
114
votrax->channel = stream_create(0, 1, Machine->sample_rate, votrax, votrax_update_sound);
116
votrax->sample = NULL;
56
123
void votrax_w(int data)
125
struct votrax_info *info = sndti_token(SOUND_VOTRAX, 0);
58
126
int Phoneme,Intonation;
128
stream_update(info->channel, 0);
60
130
Phoneme = data & 0x3F;
61
131
Intonation = data >> 6;
63
133
logerror("Speech : %s at intonation %d\n",VotraxTable[Phoneme],Intonation);
66
mixer_stop_sample(VotraxChannel);
68
if(VotraxSamples->sample[Phoneme])
138
if(info->samples->sample[Phoneme].data)
70
mixer_set_volume(VotraxChannel,VotraxBaseVolume+(8*Intonation)*100/255);
71
mixer_play_sample(VotraxChannel,VotraxSamples->sample[Phoneme]->data,
72
VotraxSamples->sample[Phoneme]->length,
73
VotraxBaseFrequency+(256*Intonation),
140
info->sample = &info->samples->sample[Phoneme];
143
info->step = ((INT64)(info->sample->frequency + (256*Intonation)) << FRAC_BITS) / Machine->sample_rate;
144
stream_set_output_gain(info->channel, 0, (info->volume + (8*Intonation)*100/255) / 100.0);
78
148
int votrax_status_r(void)
80
return mixer_is_sample_playing(VotraxChannel);
150
struct votrax_info *info = sndti_token(SOUND_VOTRAX, 0);
151
stream_update(info->channel, 0);
152
return (info->sample != NULL);
157
/**************************************************************************
159
**************************************************************************/
161
static void votrax_set_info(void *token, UINT32 state, sndinfo *info)
165
/* no parameters to set */
170
void votrax_get_info(void *token, UINT32 state, sndinfo *info)
174
/* --- the following bits of info are returned as 64-bit signed integers --- */
176
/* --- the following bits of info are returned as pointers to data or functions --- */
177
case SNDINFO_PTR_SET_INFO: info->set_info = votrax_set_info; break;
178
case SNDINFO_PTR_START: info->start = votrax_start; break;
179
case SNDINFO_PTR_STOP: /* Nothing */ break;
180
case SNDINFO_PTR_RESET: /* Nothing */ break;
182
/* --- the following bits of info are returned as NULL-terminated strings --- */
183
case SNDINFO_STR_NAME: info->s = "Votrax SC-01"; break;
184
case SNDINFO_STR_CORE_FAMILY: info->s = "Votrax speech"; break;
185
case SNDINFO_STR_CORE_VERSION: info->s = "1.0"; break;
186
case SNDINFO_STR_CORE_FILE: info->s = __FILE__; break;
187
case SNDINFO_STR_CORE_CREDITS: info->s = "Copyright (c) 2004, The MAME Team"; break;