Check and fix source code formatting.

This commit is contained in:
Reece H. Dunn
2015-12-27 22:34:53 +00:00
parent ac04c20dea
commit 3e99752d0c
35 changed files with 3140 additions and 3132 deletions
+126 -127
View File
@@ -62,16 +62,16 @@ voice_t *wvoice;
FILE *f_log = NULL;
int option_waveout = 0;
static int option_harmonic1 = 10; // 10
static int option_harmonic1 = 10;
static int flutter_amp = 64;
static int general_amplitude = 60;
static int consonant_amp = 26; // 24
static int consonant_amp = 26;
int embedded_value[N_EMBEDDED_VALUES];
static int PHASE_INC_FACTOR;
int samplerate = 0; // this is set by Wavegeninit()
int samplerate = 0; // this is set by Wavegeninit()
int samplerate_native = 0;
extern int option_device_number;
extern int option_quiet;
@@ -84,7 +84,7 @@ int echo_head;
int echo_tail;
int echo_amp = 0;
short echo_buf[N_ECHO_BUF];
static int echo_length = 0; // period (in sample\) to ensure completion of echo at the end of speech, set in WavegenSetEcho()
static int echo_length = 0; // period (in sample\) to ensure completion of echo at the end of speech, set in WavegenSetEcho()
static int voicing;
static RESONATOR rbreath[N_PEAKS];
@@ -92,13 +92,13 @@ static RESONATOR rbreath[N_PEAKS];
static int harm_sqrt_n = 0;
#define N_LOWHARM 30
static int harm_inc[N_LOWHARM]; // only for these harmonics do we interpolate amplitude between steps
static int harm_inc[N_LOWHARM]; // only for these harmonics do we interpolate amplitude between steps
static int *harmspect;
static int hswitch = 0;
static int hspect[2][MAX_HARMONIC]; // 2 copies, we interpolate between then
static int hspect[2][MAX_HARMONIC]; // 2 copies, we interpolate between then
static int max_hval = 0;
static int nsamples = 0; // number to do
static int nsamples = 0; // number to do
static int modulation_type = 0;
static int glottal_flag = 0;
static int glottal_reduce = 0;
@@ -109,12 +109,12 @@ static int amp_ix;
static int amp_inc;
static unsigned char *amplitude_env = NULL;
static int samplecount = 0; // number done
static int samplecount_start = 0; // count at start of this segment
static int end_wave = 0; // continue to end of wave cycle
static int samplecount = 0; // number done
static int samplecount_start = 0; // count at start of this segment
static int end_wave = 0; // continue to end of wave cycle
static int wavephase;
static int phaseinc;
static int cycle_samples; // number of samples in a cycle at current pitch
static int cycle_samples; // number of samples in a cycle at current pitch
static int cbytes;
static int hf_factor;
@@ -132,10 +132,10 @@ int wcmdq_head = 0;
int wcmdq_tail = 0;
// pitch,speed,
int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, 175, 100, 50, 0, 0, 0, 175, 0, 0, 0, 0, 0, 0 };
static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };
int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, 175, 100, 50, 0, 0, 0, 175, 0, 0, 0, 0, 0, 0 };
static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };
#define N_CALLBACK_IX N_WAV_BUF-2 // adjust this delay to match display with the currently spoken word
#define N_CALLBACK_IX N_WAV_BUF-2 // adjust this delay to match display with the currently spoken word
int current_source_index = 0;
extern FILE *f_wave;
@@ -232,22 +232,22 @@ static int wavemult_max = 0;
// the presets are for 22050 Hz sample rate.
// A different rate will need to recalculate the presets in WavegenInit()
static unsigned char wavemult[N_WAVEMULT] = {
0, 0, 0, 2, 3, 5, 8, 11, 14, 18, 22, 27, 32, 37, 43, 49,
55, 62, 69, 76, 83, 90, 98, 105, 113, 121, 128, 136, 144, 152, 159, 166,
0, 0, 0, 2, 3, 5, 8, 11, 14, 18, 22, 27, 32, 37, 43, 49,
55, 62, 69, 76, 83, 90, 98, 105, 113, 121, 128, 136, 144, 152, 159, 166,
174, 181, 188, 194, 201, 207, 213, 218, 224, 228, 233, 237, 240, 244, 246, 249,
251, 252, 253, 253, 253, 253, 252, 251, 249, 246, 244, 240, 237, 233, 228, 224,
218, 213, 207, 201, 194, 188, 181, 174, 166, 159, 152, 144, 136, 128, 121, 113,
105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
// set from y = pow(2,x) * 128, x=-1 to 1
unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 86, 87, 88,
89, 91, 92, 93, 94, 96, 97, 98,
64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 86, 87, 88,
89, 91, 92, 93, 94, 96, 97, 98,
100, 101, 103, 104, 105, 107, 108, 110,
111, 113, 115, 116, 118, 119, 121, 123,
124, 126, 128, 130, 132, 133, 135, 137,
@@ -310,19 +310,19 @@ unsigned char pk_shape1[PEAKSHAPEW+1] = {
245, 244, 242, 241, 239, 238, 236, 234, 233, 231, 229, 227, 225, 223, 220, 218,
216, 213, 211, 209, 207, 205, 203, 201, 199, 197, 195, 193, 191, 189, 187, 185,
183, 180, 178, 176, 173, 171, 169, 166, 164, 161, 159, 156, 154, 151, 148, 146,
143, 140, 138, 135, 132, 129, 126, 123, 120, 118, 115, 112, 108, 105, 102, 99,
96, 95, 93, 91, 90, 88, 86, 85, 83, 82, 80, 79, 77, 76, 74, 73,
72, 70, 69, 68, 67, 66, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55,
55, 54, 53, 52, 52, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 46,
45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 44, 43,
42, 42, 41, 40, 40, 39, 38, 38, 37, 36, 36, 35, 35, 34, 33, 33,
32, 32, 31, 30, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 24, 24,
23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 16,
16, 15, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10,
10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5,
5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2,
2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0
143, 140, 138, 135, 132, 129, 126, 123, 120, 118, 115, 112, 108, 105, 102, 99,
96, 95, 93, 91, 90, 88, 86, 85, 83, 82, 80, 79, 77, 76, 74, 73,
72, 70, 69, 68, 67, 66, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55,
55, 54, 53, 52, 52, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 46,
45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 44, 43,
42, 42, 41, 40, 40, 39, 38, 38, 37, 36, 36, 35, 35, 34, 33, 33,
32, 32, 31, 30, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 24, 24,
23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 16,
16, 15, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10,
10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5,
5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2,
2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0
};
static unsigned char pk_shape2[PEAKSHAPEW+1] = {
@@ -331,18 +331,18 @@ static unsigned char pk_shape2[PEAKSHAPEW+1] = {
243, 243, 242, 241, 239, 237, 235, 233, 231, 229, 227, 225, 223, 221, 218, 216,
213, 211, 208, 205, 203, 200, 197, 194, 191, 187, 184, 181, 178, 174, 171, 167,
163, 160, 156, 152, 148, 144, 140, 136, 132, 127, 123, 119, 114, 110, 105, 100,
96, 94, 91, 88, 86, 83, 81, 78, 76, 74, 71, 69, 66, 64, 62, 60,
57, 55, 53, 51, 49, 47, 44, 42, 40, 38, 36, 34, 32, 30, 29, 27,
25, 23, 21, 19, 18, 16, 14, 12, 11, 9, 7, 6, 4, 3, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0
96, 94, 91, 88, 86, 83, 81, 78, 76, 74, 71, 69, 66, 64, 62, 60,
57, 55, 53, 51, 49, 47, 44, 42, 40, 38, 36, 34, 32, 30, 29, 27,
25, 23, 21, 19, 18, 16, 14, 12, 11, 9, 7, 6, 4, 3, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0
};
static unsigned char *pk_shape;
@@ -389,7 +389,7 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
out_ptr = out_start = outbuffer;
out_end = out_start + outbuffer_size;
}
out_end2 = &outbuffer[pa_size]; // top of data needed for the portaudio buffer
out_end2 = &outbuffer[pa_size]; // top of data needed for the portaudio buffer
#ifdef LIBRARY
event_list_ix = 0;
@@ -398,19 +398,17 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
result = WavegenFill(1);
// copy from the outbut buffer into the portaudio buffer
if (result && (out_ptr > out_end2)) {
result = 0; // don't end yet, there is more data in the buffer than can fit in portaudio
}
if (result && (out_ptr > out_end2))
result = 0; // don't end yet, there is more data in the buffer than can fit in portaudio
while (out_ptr < out_end2)
*out_ptr++ = 0; // fill with zeros up to the size of the portaudio buffer
*out_ptr++ = 0; // fill with zeros up to the size of the portaudio buffer
memcpy(outputBuffer, outbuffer, pa_size);
// move the remaining contents of the start of the output buffer
for (p = out_end2; p < out_end; p++) {
for (p = out_end2; p < out_end; p++)
p[-pa_size] = p[0];
}
out_ptr -= pa_size;
#ifdef LIBRARY
@@ -421,25 +419,23 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
event_list[event_list_ix].user_data = 0;
if (synth_callback(NULL, 0, event_list) == 1) {
SpeakNextClause(NULL, NULL, 2); // stop speaking
SpeakNextClause(NULL, NULL, 2); // stop speaking
result = 1;
}
}
#endif
#ifdef ARCH_BIG
{
// swap the order of bytes in each sound sample in the portaudio buffer
int c;
unsigned char *buf_end;
out_buf = (unsigned char *)outputBuffer;
buf_end = out_buf + framesPerBuffer*2;
while (out_buf < buf_end) {
c = out_buf[0];
out_buf[0] = out_buf[1];
out_buf[1] = c;
out_buf += 2;
}
// swap the order of bytes in each sound sample in the portaudio buffer
int c;
unsigned char *buf_end;
out_buf = (unsigned char *)outputBuffer;
buf_end = out_buf + framesPerBuffer*2;
while (out_buf < buf_end) {
c = out_buf[0];
out_buf[0] = out_buf[1];
out_buf[1] = c;
out_buf += 2;
}
#endif
@@ -591,7 +587,7 @@ int WavegenCloseSound()
return 1;
}
} else
WavegenOpenSound(); // still items in the queue, shouldn't be closed
WavegenOpenSound(); // still items in the queue, shouldn't be closed
}
return 0;
}
@@ -612,19 +608,24 @@ int WavegenInitSound()
}
return 0;
}
#else
int WavegenOpenSound()
{
return 0;
}
int WavegenCloseSound()
{
return 0;
}
int WavegenInitSound()
{
return 0;
}
#endif
void WavegenInit(int rate, int wavemult_fact)
@@ -633,11 +634,11 @@ void WavegenInit(int rate, int wavemult_fact)
double x;
if (wavemult_fact == 0)
wavemult_fact = 60; // default
wavemult_fact = 60; // default
wvoice = NULL;
samplerate = samplerate_native = rate;
PHASE_INC_FACTOR = 0x8000000 / samplerate; // assumes pitch is Hz*32
PHASE_INC_FACTOR = 0x8000000 / samplerate; // assumes pitch is Hz*32
Flutter_inc = (64 * samplerate)/rate;
samplecount = 0;
nsamples = 0;
@@ -666,7 +667,7 @@ void WavegenInit(int rate, int wavemult_fact)
}
}
pk_shape = pk_shape2; // pk_shape2
pk_shape = pk_shape2;
#ifdef INCLUDE_KLATT
KlattInit();
@@ -712,11 +713,11 @@ static void WavegenSetEcho(void)
amp = 0;
echo_head = (delay * samplerate)/1000;
echo_length = echo_head; // ensure completion of echo at the end of speech. Use 1 delay period?
echo_length = echo_head; // ensure completion of echo at the end of speech. Use 1 delay period?
if (amp == 0)
echo_length = 0;
if (amp > 20)
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
// echo_amp units are 1/256ths of the amplitude of the original sound.
echo_amp = amp;
@@ -727,21 +728,21 @@ static void WavegenSetEcho(void)
int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
{
// Calculate the amplitude of each harmonics from the formants
// Only for formants 0 to 5
// Calculate the amplitude of each harmonics from the formants
// Only for formants 0 to 5
// control 0=initial call, 1=every 64 cycles
// control 0=initial call, 1=every 64 cycles
// pitch and freqs are Hz<<16
int f;
wavegen_peaks_t *p;
int fp; // centre freq of peak
int fhi; // high freq of peak
int h; // harmonic number
int fp; // centre freq of peak
int fhi; // high freq of peak
int h; // harmonic number
int pk;
int hmax;
int hmax_samplerate; // highest harmonic allowed for the samplerate
int hmax_samplerate; // highest harmonic allowed for the samplerate
int x;
int ix;
int h1;
@@ -759,7 +760,7 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
hmax = MAX_HARMONIC-1;
// restrict highest harmonic to half the samplerate
hmax_samplerate = (((samplerate * 19)/40) << 16)/pitch; // only 95% of Nyquist freq
hmax_samplerate = (((samplerate * 19)/40) << 16)/pitch; // only 95% of Nyquist freq
if (hmax > hmax_samplerate)
hmax = hmax_samplerate;
@@ -787,7 +788,7 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
int h2;
// increase bass
y = peaks[1].height * 10; // addition as a multiple of 1/256s
h2 = (1000<<16)/pitch; // decrease until 1000Hz
h2 = (1000<<16)/pitch; // decrease until 1000Hz
if (h2 > 0) {
x = y/h2;
h = 1;
@@ -819,26 +820,25 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
htab[h] = (x * x) >> 8;
if ((ix = (f >> 19)) < N_TONE_ADJUST)
htab[h] = (htab[h] * wvoice->tone_adjust[ix]) >> 13; // index tone_adjust with Hz/8
htab[h] = (htab[h] * wvoice->tone_adjust[ix]) >> 13; // index tone_adjust with Hz/8
}
// adjust the amplitude of the first harmonic, affects tonal quality
h1 = htab[1] * option_harmonic1;
htab[1] = h1/8;
// calc intermediate increments of LF harmonics
if (control & 1) {
for (h = 1; h < N_LOWHARM; h++)
harm_inc[h] = (htab[h] - harmspect[h]) >> 3;
}
return hmax; // highest harmonic number
return hmax; // highest harmonic number
}
static void AdvanceParameters()
{
// Called every 64 samples to increment the formant freq, height, and widths
// Called every 64 samples to increment the formant freq, height, and widths
int x;
int ix;
@@ -859,7 +859,7 @@ static void AdvanceParameters()
Flutter_ix += Flutter_inc;
wdata.pitch += x;
if (wdata.pitch < 102400)
wdata.pitch = 102400; // min pitch, 25 Hz (25 << 12)
wdata.pitch = 102400; // min pitch, 25 Hz (25 << 12)
if (samplecount == samplecount_start)
return;
@@ -912,9 +912,9 @@ static double resonator(RESONATOR *r, double input)
static void setresonator(RESONATOR *rp, int freq, int bwidth, int init)
{
// freq Frequency of resonator in Hz
// bwidth Bandwidth of resonator in Hz
// init Initialize internal data
// freq Frequency of resonator in Hz
// bwidth Bandwidth of resonator in Hz
// init Initialize internal data
double x;
double arg;
@@ -1007,7 +1007,7 @@ int Wavegen()
static int agc = 256;
static int h_switch_sign = 0;
static int cycle_count = 0;
static int amplitude2 = 0; // adjusted for pitch
static int amplitude2 = 0; // adjusted for pitch
// continue until the output buffer is full, or
// the required number of samples have been produced
@@ -1033,7 +1033,7 @@ int Wavegen()
// pitch is Hz<<12
phaseinc = (wdata.pitch>>7) * PHASE_INC_FACTOR;
cycle_samples = samplerate/(wdata.pitch >> 12); // sr/(pitch*2)
cycle_samples = samplerate/(wdata.pitch >> 12); // sr/(pitch*2)
hf_factor = wdata.pitch >> 11;
maxh = maxh2;
@@ -1270,7 +1270,7 @@ static int PlayWave(int length, int resume, unsigned char *data, int scale, int
// 8 bit data, shift by the specified scale factor
value = (signed char)data[ix++] * scale;
}
value *= (consonant_amp * general_amplitude); // reduce strength of consonant
value *= (consonant_amp * general_amplitude); // reduce strength of consonant
value = value >> 10;
value = (value * amp)/32;
@@ -1353,14 +1353,14 @@ void SetEmbedded(int control, int value)
switch (command)
{
case EMBED_T:
WavegenSetEcho(); // and drop through to case P
WavegenSetEcho(); // and drop through to case P
case EMBED_P:
SetPitchFormants();
break;
case EMBED_A: // amplitude
case EMBED_A: // amplitude
general_amplitude = GetAmplitude();
break;
case EMBED_F: // emphasis
case EMBED_F: // emphasis
general_amplitude = GetAmplitude();
break;
case EMBED_H:
@@ -1383,7 +1383,7 @@ void WavegenSetVoice(voice_t *v)
consonant_amp = (v->consonant_amp * 26) /100;
if (samplerate <= 11000) {
consonant_amp = consonant_amp*2; // emphasize consonants at low sample rates
consonant_amp = consonant_amp*2; // emphasize consonants at low sample rates
option_harmonic1 = 6;
}
WavegenSetEcho();
@@ -1400,7 +1400,7 @@ static void SetAmplitude(int length, unsigned char *amp_env, int value)
amp_inc = (256 * ENV_LEN * STEPSIZE)/length;
wdata.amplitude = (value * general_amplitude)/16;
wdata.amplitude_v = (wdata.amplitude * wvoice->consonant_ampv * 15)/100; // for wave mixed with voiced sounds
wdata.amplitude_v = (wdata.amplitude * wvoice->consonant_ampv * 15)/100; // for wave mixed with voiced sounds
amplitude_env = amp_env;
}
@@ -1413,14 +1413,14 @@ void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pit
int pitch_value;
if (pitch1 > pitch2) {
x = pitch1; // swap values
x = pitch1; // swap values
pitch1 = pitch2;
pitch2 = x;
}
if ((pitch_value = embedded_value[EMBED_P]) > MAX_PITCH_VALUE)
pitch_value = MAX_PITCH_VALUE;
pitch_value -= embedded_value[EMBED_T]; // adjust tone for announcing punctuation
pitch_value -= embedded_value[EMBED_T]; // adjust tone for announcing punctuation
if (pitch_value < 0)
pitch_value = 0;
@@ -1436,10 +1436,10 @@ void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pit
void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
{
// length in samples
// length in samples
if ((wdata.pitch_env = env) == NULL)
wdata.pitch_env = env_fall; // default
wdata.pitch_env = env_fall; // default
wdata.pitch_ix = 0;
if (length == 0)
@@ -1449,7 +1449,7 @@ void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
SetPitch2(wvoice, pitch1, pitch2, &wdata.pitch_base, &wdata.pitch_range);
// set initial pitch
wdata.pitch = ((wdata.pitch_env[0] * wdata.pitch_range) >>8) + wdata.pitch_base; // Hz << 12
wdata.pitch = ((wdata.pitch_env[0] * wdata.pitch_range) >>8) + wdata.pitch_base; // Hz << 12
flutter_amp = wvoice->flutter;
}
@@ -1462,8 +1462,8 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
int length4;
int qix;
int cmd;
static int glottal_reduce_tab1[4] = { 0x30, 0x30, 0x40, 0x50 }; // vowel before [?], amp * 1/256
static int glottal_reduce_tab2[4] = { 0x90, 0xa0, 0xb0, 0xc0 }; // vowel after [?], amp * 1/256
static int glottal_reduce_tab1[4] = { 0x30, 0x30, 0x40, 0x50 }; // vowel before [?], amp * 1/256
static int glottal_reduce_tab2[4] = { 0x90, 0xa0, 0xb0, 0xc0 }; // vowel after [?], amp * 1/256
harm_sqrt_n = 0;
end_wave = 1;
@@ -1473,11 +1473,11 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
glottal_flag = 0;
if (modn & 0x400) {
glottal_flag = 3; // before a glottal stop
glottal_flag = 3; // before a glottal stop
glottal_reduce = glottal_reduce_tab1[(modn >> 8) & 3];
}
if (modn & 0x800) {
glottal_flag = 4; // after a glottal stop
glottal_flag = 4; // after a glottal stop
glottal_reduce = glottal_reduce_tab2[(modn >> 8) & 3];
}
@@ -1487,11 +1487,11 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
cmd = wcmdq[qix][0];
if (cmd == WCMD_SPECT) {
end_wave = 0; // next wave generation is from another spectrum
end_wave = 0; // next wave generation is from another spectrum
break;
}
if ((cmd == WCMD_WAVE) || (cmd == WCMD_PAUSE))
break; // next is not from spectrum, so continue until end of wave cycle
break; // next is not from spectrum, so continue until end of wave cycle
}
// round the length to a multiple of the stepsize
@@ -1513,7 +1513,7 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq = (int)peaks[ix].freq1;
next = (fr2->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
}
peaks[ix].height1 = (fr1->fheight[ix] * v->height[ix]) << 6;
@@ -1532,9 +1532,8 @@ void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
peaks[ix].right = (int)peaks[ix].right1;
next = (fr2->fright[ix] * v->width[ix]) << 10;
peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length2;
} else {
} else
peaks[ix].right = peaks[ix].left;
}
}
}
}
@@ -1549,7 +1548,7 @@ static int Wavegen2(int length, int modulation, int resume, frame_t *fr1, frame_
void Write4Bytes(FILE *f, int value)
{
// Write 4 bytes to a file, least significant first
// Write 4 bytes to a file, least significant first
int ix;
for (ix = 0; ix < 4; ix++) {
@@ -1560,9 +1559,9 @@ void Write4Bytes(FILE *f, int value)
int WavegenFill2(int fill_zeros)
{
// Pick up next wavegen commands from the queue
// return: 0 output buffer has been filled
// return: 1 input command queue is now empty
// Pick up next wavegen commands from the queue
// return: 0 output buffer has been filled
// return: 1 input command queue is now empty
intptr_t *q;
int length;
@@ -1577,14 +1576,14 @@ int WavegenFill2(int fill_zeros)
// continue to play silence until echo is completed
resume = PlaySilence(echo_complete, resume);
if (resume == 1)
return 0; // not yet finished
return 0; // not yet finished
}
if (fill_zeros) {
while (out_ptr < out_end)
*out_ptr++ = 0;
}
return 1; // queue empty, close sound channel
return 1; // queue empty, close sound channel
}
result = 0;
@@ -1628,15 +1627,15 @@ int WavegenFill2(int fill_zeros)
wdata.mix_wavefile_offset = 0;
wdata.mix_wavefile = (unsigned char *)q[2];
break;
case WCMD_SPECT2: // as WCMD_SPECT but stop any concurrent wave file
wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
case WCMD_SPECT2: // as WCMD_SPECT but stop any concurrent wave file
wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
case WCMD_SPECT:
echo_complete = echo_length;
result = Wavegen2(length & 0xffff, q[1] >> 16, resume, (frame_t *)q[2], (frame_t *)q[3]);
break;
#ifdef INCLUDE_KLATT
case WCMD_KLATT2: // as WCMD_SPECT but stop any concurrent wave file
wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
case WCMD_KLATT2: // as WCMD_SPECT but stop any concurrent wave file
wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
case WCMD_KLATT:
echo_complete = echo_length;
result = Wavegen_Klatt2(length & 0xffff, q[1] >> 16, resume, (frame_t *)q[2], (frame_t *)q[3]);
@@ -1663,7 +1662,7 @@ int WavegenFill2(int fill_zeros)
break;
case WCMD_FMT_AMPLITUDE:
if ((wdata.amplitude_fmt = q[1]) == 0)
wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
break;
#if HAVE_SONIC_H
case WCMD_SONIC_SPEED:
@@ -1683,7 +1682,7 @@ int WavegenFill2(int fill_zeros)
}
#if HAVE_SONIC_H
/* Speed up the audio samples with libsonic. */
// Speed up the audio samples with libsonic.
static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
{
if (length_in > 0) {
@@ -1704,7 +1703,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
}
#endif
/* Call WavegenFill2, and then speed up the output samples. */
// Call WavegenFill2, and then speed up the output samples.
int WavegenFill(int fill_zeros)
{
int finished;
@@ -1725,7 +1724,7 @@ int WavegenFill(int fill_zeros)
out_ptr = p_start + length;
if (length >= max_length)
finished = 0; // there may be more data to flush
finished = 0; // there may be more data to flush
}
#endif
return finished;