73#include "EST_cutils.h"
85 static double prev_pf = BREAK_NUMBER;
87 int n,
j, k, N0 = 0,
N1,
N2,
N_,
q,
lower_found = 0, score = 1,
apply_bias;
94 double xx = 0.0,
yy = 0.0,
zz = 0.0,
xy = 0.0,
yz = 0.0,
xz = 0.0;
144 for (
q = 0;
q <
p_cc->size;
p_cc->coeff[
q++] = 0.0);
146 p_status->pitch_freq = BREAK_NUMBER;
175 for (k = 0,
xy = 0.0; k < n; k +=
paras->L)
181 for (
q = n -
paras->Nmin + 1;
183 p_cc->coeff[
q++] = 0.0);
213 p_status->pitch_freq = BREAK_NUMBER;
229 if (
yy == 0.0 ||
zz == 0.0)
252 for (
j = 0;
j < tail->N0;
j++)
253 xx += (
double)
seg.data[
paras->Nmax - tail->N0 +
j] *
259 for (
j = 0;
j < tail->N0;
j++) {
278 if ((tail == head && score == 1 &&
p_status->v_uv != VOICED) ||
311 for (
j = 0;
j <
N1;
j++) {
321 for (n =
N1 + 1; n <=
N2; n++,
j++) {
324 for (k = 0,
xy = 0.0; k < n; k++)
334 if (N0 - 1 <
paras->Nmin || N0 ==
N1)
N_ = N0;
335 else if (N0 + 1 >
paras->Nmax || N0 ==
N2)
N_ = N0 - 1;
342 for (
j = 0;
j <
N_;
j++) {
358 else if (
beta >= 1.0) {
423 fprintf (
stderr,
"improper fseek () to reposition a stream");
426 fprintf (
stderr,
"artificial frame length set out of range");
429 fprintf (
stderr,
"maximum pitch frequency value (Hz) not set");
432 fprintf (
stderr,
"minimum pitch frequency value (Hz) not set");
439 fprintf (
stderr,
"-l 'lower pitch frequency limit' {%f (Hz)}\n",
441 fprintf (
stderr,
"-u 'upper pitch frequency limit' {%f (Hz)}\n",
447 fprintf (
stderr,
"-h 'unvoiced to voiced coeff threshold' {%f}\n",
449 fprintf (
stderr,
"-m 'min. voiced to unvoiced coeff threshold' {%f}\n",
451 fprintf (
stderr,
"-r 'voiced to unvoiced coeff threshold ratio' {%f}\n",
453 fprintf (
stderr,
"-t 'anti pitch doubling/halving threshold' {%f}\n",
456 fprintf (
stderr,
"-f 'sampling frequency' {%d (Hz)}\n", DEFAULT_SF);
457 fprintf (
stderr,
"-s 'frame shift' {%f (ms)}\n", DEFAULT_SHIFT);
465 fprintf (
stderr,
"attempt to set sampling frequency negative");
471 fprintf (
stderr,
"anti pitch doubling/halving threshold not set");
474 fprintf (
stderr,
"unvoiced to voiced coeff threshold not set");
477 fprintf (
stderr,
"voiced to unvoiced coeff threshold ratio not set");
480 fprintf (
stderr,
"minimum voiced to unvoiced coeff threshold not set");
493 p_par->L = DEFAULT_DECIMATION;
494 p_par->min_pitch = DEFAULT_MIN_PITCH;
495 p_par->max_pitch = DEFAULT_MAX_PITCH;
496 p_par->shift = DEFAULT_SHIFT;
497 p_par->length = DEFAULT_LENGTH;
498 p_par->Tsilent = DEFAULT_TSILENT;
499 p_par->Tmin = DEFAULT_TMIN;
500 p_par->Tmax_ratio = DEFAULT_TMAX_RATIO;
501 p_par->Thigh = DEFAULT_THIGH;
502 p_par->Tdh = DEFAULT_TDH;
503 p_par->make_ascii = 0;
504 p_par->peak_tracking = 0;
505 p_par->sample_freq = DEFAULT_SF;
520 p_seg->shift = (int) rint(
p_par->shift / 1000.0 * (
float)
p_par->sample_freq );
521 p_seg->length = (int) rint(
p_par->length / 1000.0 * (
float)
p_par->sample_freq );
525 p_cc->coeff = walloc(
double,
p_cc->size);
534 p_status->pitch_freq = BREAK_NUMBER;
564 if (
status == BEGINNING) {
654 %
p_seg->shift == 0 ? 0 : 1);
672 offset =
p_seg->shift;
676 for ( ; i <
p_seg->size; ++i)
714 if (
paras.make_ascii)
732 next = (*p_list_hd)->next_item;