📄 smartsynt.c
字号:
/*| This material contains proprietary software of Entropic Processing, Inc.| Any reproduction, distribution, or publication without the the prior| written permission of Entropic Processing, Inc. is strictly prohibited.| Any public distribution of copies of this work authorized in writing by| Entropic Processing, Inc. must bear the notice|| "Copyright 1986 Entropic Processing, Inc."|| Written by: S. Shankar Narayan| Converted to SPS by: Rod Johnson (primarily) and John Shore|| Module: smart_synt.c|| This routine renders synthesizer smarter by detecting pitch doubling,| whenever possible. It also smoothens pitch contour.*/#ifdef SCCSstatic char *sccs_id = "@(#)smartsynt.c 1.1 8/20/86 EPI";#endif#include <stdio.h>#include <sps/sps.h>#include <sps/ana.h>#include <sps/sd.h>#define VOICED 1#define UNVOICED 0#define NPR 3extern float num[3], den[3];extern float rc0[100], rc1[100], rc2[100];extern FILE * hptr;smart_synt (locn, type, size, sig_power, order, psig_power, psize)int locn[], type[], size[], order, *psize;float sig_power[], *psig_power;{ double sqrt (); if (type[0] == type[2] && type[0] != type[1]) { if (hptr) fprintf (hptr, "V to U Mod useful at locn %d\n", locn[1]); type[1] = type[0]; } if (type[0] == VOICED && type[1] == VOICED && type[2] == VOICED && size[0] == size[2] && size[0] != size[1]) { if (size[0] - size[1] < 2 && size[0] - size[1] > -2) { if (hptr) fprintf (hptr, "Discontinuity at locn %d:\t%d\t%d\t%d\n", locn[1], size[0], size[1], size[2]); size[1] = size[0]; } } /* check for pitch doubling */ if (modify_ana_pars (locn, size, type, sig_power, psig_power, psize)) return 1; else return 0;}int modify_ana_pars (locn, size, type, sig_power, psig_power, psize)/* This routine checks for pitch doubling. If detected, it modifiesthe analysis parameters using simple linear interpolation scheme tocorrect the doubling effect.*/int locn[3], size[3], type[3], *psize;float sig_power[3], *psig_power;{ float g1, g2, se1, scale; int i = 1, newpitch; if (type[1] == VOICED && sig_power[0] && sig_power[1] && sig_power[2]) { if (type[0] == VOICED && type[2] == VOICED && size[1] > 0.9 * (size[0] + size[2])) { if (hptr) fprintf (hptr, "OOPs Pitch Doubling at %d?\t%d %d %d\n", locn[1], size[0], size[1], size[2]); i = 2.0 * size[1] / (size[0] + size[2]) + 0.5; } if (type[0] == VOICED && type[2] == UNVOICED && size[1] > 1.7 * size[0]) { if (hptr) fprintf (hptr, "OOPs Pitch Doubling at %d?\t%d %d\n", locn[1], size[0], size[1]); i = 1.0 * size[1] / size[0] + 0.5; } if (type[0] == UNVOICED && type[2] == VOICED && size[1] > 1.7 * size[2]) { if (hptr) fprintf (hptr, "OOPs Pitch Doubling at %d?\t%d %d \n", locn[1], size[1], size[2]); i = 1.0 * size[1] / size[2] + 0.5; type[0] = type[1]; } } if (i < 2) return 0; newpitch = 0.5 + size[1] / i; se1 = sig_power[1] * size[1]; g1 = newpitch * (size[1] * sig_power[0] + size[0] * sig_power[2]); size[1] -= newpitch; g2 = size[1] * (size[1] * sig_power[0] + (size[0] + newpitch) * sig_power[2]); scale = se1 / (g1 + g2); *psize = newpitch; *psig_power = g1 * scale / newpitch; size[0] = newpitch; locn[0] = locn[1]; sig_power[0] = *psig_power; locn[1] += newpitch; sig_power[1] = g2 * scale / size[1]; return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -