📄 trakpit.c
字号:
scan_end = MIN (best_pitch * 3 / 2 - one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; pulse_locn += scan_beg; pulse_locn += get_pulsepos (databuf, scan_size); break; case uuvv: case vuuv: case vvuv: /* One can check if pitch doubling has occurred. At John's insistance, it has been removed.*//* if (best_pitch > 18 * prev_best_pitch / 10) { max_pitch = prev_best_pitch + one_msec; min_pitch = MAX (prev_best_pitch - one_msec, pitch_range_min); prev_best_pitch = best_pitch; ptrack_state = prev_state; get_raw_pitch (v_pflt_order, nolookback); ptrack_state = next_state[voiced][prev_state]; if (RELENT_min > uv_thresh) best_pitch = prev_best_pitch; else if (hptr) fprintf (hptr, "OOPs pitch doubling avoided ?\n"); prev_frame_size[3] = best_pitch; }*/ case uuuv: scan_beg = MAX (best_pitch / 2 - one_msec, pitch_range_min); scan_end = MIN (best_pitch * 3 / 2 - one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; pulse_locn += scan_beg; pulse_locn += get_pulsepos (databuf, scan_size); break; case uvvu: case vvvu: tracking_mode_range (best_pitch); pulse_locn += min_pitch; scan_size = max_pitch - min_pitch + 1; pulse_locn += get_pulsepos (databuf, scan_size); /* If possible, clean up current frame location also. */ ptrack_state = prev_state; get_raw_pitch (v_pflt_order, lookback); ptrack_state = next_state[voiced][prev_state]; if (RELENT_min < uv_thresh) { int plocn3, psize2; scan_beg = MAX (best_pitch - one_msec, pitch_range_min); scan_end = MIN (best_pitch + one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; best_pitch = scan_end - get_pulsepos (databuf - scan_end, scan_size); /* Possibly correct location and sizes */ plocn3 = smpnum + pulse_locn - best_pitch; psize2 = plocn3 - prev_frame_locn[2]; if (psize2 > pitch_range_min) prev_frame_locn[3] = plocn3; /* Check if there was pitch period stretching */ else if (psize2 + best_pitch < pitch_range_max) prev_frame_locn[3] = smpnum + pulse_locn; } /* if mae is small enough, continue in tracking mode */ if (mae_is_large (prev_frame_size)) { /* Pitch may change here */ min_pitch = pitch_range_min; max_pitch = pitch_range_max; } else { tracking_mode_range (best_pitch); ptrack_state = vvv; } break; case vvuu: if (hptr) fprintf (hptr, "vuu to vvv? Frame Locn %d\n", prev_frame_locn[3]); scan_beg = best_pitch / 2 - one_msec; scan_end = scan_beg + best_pitch; if (scan_beg > prev_frame_locn[3] - prev_frame_locn[2]) scan_beg = prev_frame_locn[3] - prev_frame_locn[2]; if (scan_end + prev_frame_locn[3] - prev_frame_locn[2] > pitch_range_max) scan_end = prev_frame_locn[2] + pitch_range_max - prev_frame_locn[3]; scan_size = scan_end - scan_beg + 1; disp = get_pulsepos (databuf - scan_beg, best_pitch); pulse_locn += disp - scan_beg; break; case uvvv: /* check if pitch doubling has occurred *//* if (best_pitch > 18 * prev_best_pitch / 10) { max_pitch = prev_best_pitch + one_msec; min_pitch = MAX (prev_best_pitch - one_msec, pitch_range_min); prev_best_pitch = best_pitch; ptrack_state = prev_state; get_raw_pitch (v_pflt_order, nolookback); ptrack_state = next_state[voiced][prev_state]; if (RELENT_min > uv_thresh) best_pitch = prev_best_pitch; else if (hptr) fprintf (hptr, "OOPs pitch doubling avoided ?\n"); prev_frame_size[3] = best_pitch; }*/ if (mae_is_large (prev_frame_size)) { scan_beg = MAX (best_pitch - one_msec, pitch_range_min); scan_end = MIN (best_pitch + one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; pulse_locn += scan_beg; pulse_locn += get_pulsepos (databuf, scan_size); ptrack_state = uvvv; break; } scan_beg = MAX (best_pitch / 2 - one_msec, pitch_range_min); scan_end = MIN (3 * best_pitch / 2 - one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; disp = scan_beg + get_pulsepos (databuf + scan_beg, scan_size); adjust (prev_frame_locn, prev_frame_size, best_pitch, &disp); pulse_locn += disp; tracking_mode_range (best_pitch); break; case vvv1: case vvv: scan_beg = MAX (best_pitch - one_msec, pitch_range_min); scan_end = MIN (best_pitch + one_msec, pitch_range_max); scan_size = scan_end - scan_beg + 1; disp = scan_beg - best_pitch + get_pulsepos (databuf + scan_beg, scan_size); pulse_locn += best_pitch; if (disp > -3 && disp < 3) pulse_locn += disp; freq_knt[disp + one_msec]++; if (prev_state == vvv1 && mae_is_large (prev_frame_size)) { /* Pitch may change here */ min_pitch = pitch_range_min; max_pitch = pitch_range_max; ptrack_state = uvvv; } else tracking_mode_range (best_pitch); break; } prev_best_pitch = best_pitch; } if (debug_level >= 2) { fprintf (stderr, "\t%d\t%d\t%d%\t%s\t%f\n", prev_frame_locn[3], prev_frame_size[3], prev_frame_type[3], v_chr[ptrack_state], RELENT_min); } frame_size[0] = frame_size[1] = -1; /* In some sense, if ptrack_state is in any of the following states, processing of the present frame is not over. So nothing is output. */ if (ptrack_state != uuu1 && ptrack_state != uuu2 && ptrack_state != vvv1 && ptrack_state != vvuu1) {/* NOTE: max_coh_dist is correct only if prev_frame_locn[0] has not been changedby trakpit.c routine, as in situations like ( vvuu1 + voiced ) or by function"adjust".*/ max_coh_dst[0] = prev_frame_size[0]; frame_size[0] = prev_frame_locn[1] - prev_frame_locn[0]; if (frame_size[0] < pitch_range_min) { prev_frame_locn[1] = prev_frame_locn[0]; frame_size[0] = -1; } else { frame_locn[0] = prev_frame_locn[0]; frame_type[0] = prev_frame_type[0]; frame_size[1] = -1; } for (i = 0; i < 3; i++) { prev_frame_size[i] = prev_frame_size[i + 1]; prev_frame_locn[i] = prev_frame_locn[i + 1]; prev_frame_type[i] = prev_frame_type[i + 1]; } }}tracking_mode_range (pitch)int pitch;{ min_pitch = pitch - pitch * pt_wsize / 100; max_pitch = pitch + pitch * pt_wsize / 100; max_pitch = MIN (pitch_range_max, max_pitch); min_pitch = MAX (pitch_range_min, min_pitch);}mae_is_large (prev_frame_size)int prev_frame_size[4];{ int i, j, median, mae; median = prev_frame_size[2]; i = prev_frame_size[1]; j = prev_frame_size[3]; if (i > j) { i = j; j = prev_frame_size[1]; } mae = j - i; if (j < median) { mae = median - i; median = j; } if (median < i) { mae = j - median; median = i; } if (hptr) { fprintf (hptr, "MAE = %d\tMEDIAN: %d", mae, median); for (i = 1; i < 4; i++) fprintf (hptr, "\t%d", prev_frame_size[i]); fprintf (hptr, "\n"); } if (mae > pt_wsize * median / 100) return (1); return (0);}adjust (locn, size, best_pitch, pdisp)int locn[], size[], best_pitch, *pdisp;{ int i, j, nlocn; nlocn = locn[3] + *pdisp - best_pitch; for (i = 2; i > 0; i--) nlocn -= size[i]; j = nlocn - locn[0]; while (j < 0) { j += best_pitch; *pdisp += best_pitch; } if (hptr && ((*pdisp - best_pitch) < -one_msec || (*pdisp - best_pitch) > one_msec)) fprintf (hptr, "CHECK for big adjustment: disp = %d\n", *pdisp - best_pitch); size[0] = j; if (hptr) fprintf (hptr, "%d\t%d\n", locn[0], size[0]); for (i = 1; i < 4; i++) { locn[i] = locn[i - 1] + size[i - 1]; if (hptr) fprintf (hptr, "%d\t%d\n", locn[i], size[i]); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -