📄 synt.c
字号:
exit (2); } else { zeros (start + nan - locn, oh, ostrm); exit (0); } } } exit (0);}voidzeros (n, h, fd)struct header *h;FILE * fd;{ static float zero[1] = { 0 }; static short szero[1] = { 0 }; while (n-- > 0) if (sflag) put_sd_recs (szero, 1, h, fd); else put_sd_recf (zero, 1, h, fd);}voidfcopy (dst, src, n)float *dst, *src;{ while (n-- > 0) *dst++ = *src++;}int get_ana (plocn, ptype, psize, psig_power, order_vcd, order_unvcd, synt_filt_order, hd, stream)int *plocn, *ptype, *psize, order_vcd, order_unvcd, synt_filt_order;float *psig_power;struct header *hd;FILE * stream;{ int i, j, order; static int locn[3], type[3], size[3], EOF_flag = 0, pd_flag = 0; static float sig_power[3]; if (debug_level) fprintf (stderr, "get_ana: "); if (EOF_flag) { fprintf (stderr, "EOF encountered\n"); return 0; } if (pd_flag == 0) { if (!read_ana (&locn[2], &size[2], &type[2], &sig_power[2], rc2, order_vcd, order_unvcd, hd, stream)) { /* EOF encountered. Flush buffer */ *plocn = locn[1]; *ptype = type[1]; *psize = size[1]; *psig_power = sig_power[1]; EOF_flag = 1; return 1; } order = (type[2] == VOICED) ? order_vcd : order_unvcd; if (debug_level) fprintf (stderr, "locn: %d type: %c, size: %d\n", locn[2], (type[2] == VOICED) ? 'v' : 'u', size[2]); if (hptr) { int allzero = 1; for (i = 0; i < order && allzero; i++) if (rc2[i] != 0.0) allzero = 0; if (allzero) fprintf (hptr, "All rc's are zeros at %d\n", locn[2]); } if (type[2] == VOICED && window_flag) extend_rc (rc2, size[2], order_vcd, synt_filt_order); else for (i = order; i < synt_filt_order; i++) rc2[i] = 0.0; if (debug_level >= 2) { fprintf (stderr, "sig_power: %f\nRCs:\n ", sig_power[2]); for (i = 0; i < synt_filt_order; i++) fprintf (stderr, " %f", rc2[i]); putc ('\n', stderr); } } *ptype = type[1]; *plocn = locn[1];/* perform interpolation of spectral parameters */ if (smooth_int_flag && type[1] == VOICED && type[2] == VOICED) for (j = 0; j < synt_filt_order; j++) { delta_rc[j] = (rc2[j] - rc1[j]) / locn[1]; } if (int_flag && type[0] == VOICED && type[1] == VOICED && type[2] == VOICED) { for (i = 0; i < synt_filt_order; i++) int_rc[i] = (rc0[i] + rc1[i] + rc2[i]) / 3.0; } else for (i = 0; i < synt_filt_order; i++) int_rc[i] = rc1[i]; for (i = 0; i < synt_filt_order; i++) rc0[i] = rc1[i];/* If not dsp version of synt, perform smart synthesis */ if (smart_synt_flag) { if (pd_flag = smart_synt (locn, type, size, sig_power, order, psig_power, psize)) return 1; } *psig_power = sig_power[1]; *psize = size[1]; for (i = 0; i < 2; i++) { type[i] = type[i + 1]; sig_power[i] = sig_power[i + 1]; size[i] = size[i + 1]; locn[i] = locn[i + 1]; } for (i = 0; i < synt_filt_order; i++) rc1[i] = rc2[i]; return 1;}int read_ana (plocn, psize, ptype, psig_power, rc, order_vcd, order_unvcd, hd, stream)int *plocn, *psize, *ptype;float *psig_power;float rc[];int order_vcd, order_unvcd;struct header *hd;FILE * stream;{ static int num_pulses = 0, num_pulses_used = 0; static int locn, type; int size; int i; if (debug_level >= 3) fprintf (stderr, "read_ana: %d pulses, %d used.\n", num_pulses, num_pulses_used); if (num_pulses_used >= num_pulses) { if (get_ana_rec (ana_rec, hd, stream) == EOF)/* eof */ { if (debug_level >= 3) fprintf (stderr, "no more ana_records.\n"); return 0; } locn = ana_rec -> tag; if (ana_rec -> p_pulse_len[0] == 0) { type = UNVOICED; num_pulses = 1; } else { type = VOICED; for (i = 0; i < hd -> hd.ana -> maxpulses && ana_rec -> p_pulse_len[i] != 0; i++ ) { } num_pulses = i; /* fake out power per pulse if only one power */ if (num_pulses > 1 && ana_rec -> raw_power[1] < 0) for (i = 1; i < num_pulses; i++) { ana_rec -> raw_power[i] = ana_rec -> raw_power[0]; } if (num_pulses > 1 && ana_rec -> lpc_power[1] < 0) for (i = 1; i < num_pulses; i++) { ana_rec -> lpc_power[i] = ana_rec -> lpc_power[0]; } } num_pulses_used = 0; if (debug_level >= 3) fprintf (stderr, "type: %d, now %d pulses.\n", type, num_pulses); } *plocn = locn; locn += (size = ana_rec -> p_pulse_len[num_pulses_used]); *psize = (type == VOICED) ? size : ana_rec -> frame_len; *ptype = type; *psig_power = ana_rec -> raw_power[num_pulses_used]; fcopy (rc, ana_rec -> ref_coeff, (type = VOICED) ? order_vcd : order_unvcd); if (debug_level >= 3) fprintf (stderr, "locn: %d, size: %d, power: %f, order: %d.\n", *plocn, *psize, *psig_power, (type = VOICED) ? order_vcd : order_unvcd); num_pulses_used++; return 1;}short par_interp (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "none") == 0) return NONE; else if (strcmp (string, "pulse") == 0) return PULSE; else if (strcmp (string, "sample") == 0) return SAMPLE; else parm_err (string, pstring);/* will exit(1) */}short par_pwr (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "rawpulse") == 0) return RAWPULSE; else if (strcmp (string, "lpcpulse") == 0) return LPCPULSE; else parm_err (string, pstring);/* will exit(1) */}short par_rc (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "ana") == 0) return ANA; else if (strcmp (string, "sinx") == 0) return SINX; else parm_err (string, pstring);/* will exit(1) */}short par_v_excit (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "impulse") == 0) return IMPULSE; else if (strcmp (string, "white") == 0) return WHITE; else parm_err (string, pstring);/* will exit(1) */}short par_uv_excit (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "white") == 0) return WHITE; else parm_err (string, pstring);/* will exit(1) */}short par_method (pstring)char *pstring;{ char *string; string = getsym_s (pstring); if (strcmp (string, "psynch") == 0) return PSYNCH; else parm_err (string, pstring);/* will exit(1) */}voidparm_err (string, pstring)char *string, *pstring;{ fprintf (stderr, "synt: unknown string %s for paramter %s in SPS parameter file\n", string, pstring); exit (1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -