📄 psych.c
字号:
int b,i;
for(b = 0; b < part_tbl_long->len; b++){
if (psy_var_long->cb[b] > 0.0) {
psy_var_long->tb[b] = -0.299 - 0.43 * log(psy_var_long->cb[b]);
} else {
psy_var_long->tb[b] = 1.0;
}
if( psy_var_long->tb[b] > 1.0 )
psy_var_long->tb[b] = 1.0;
else if( psy_var_long->tb[b] < 0.0 )
psy_var_long->tb[b] = 0.0;
}
/* added by T. Araki (1997.10.16) */
for(i = 0; i < MAX_SHORT_WINDOWS; i++){
for(b = 0; b < part_tbl_short->len; b++){
if (psy_var_short->cb[i][b]>0.0) {
psy_var_short->tb[i][b] = -0.299 - 0.43 * log(psy_var_short->cb[i][b]);
} else {
psy_var_short->tb[i][b] = 1.0;
}
if( psy_var_short->tb[i][b] > 1.0 )
psy_var_short->tb[i][b] = 1.0;
else if( psy_var_short->tb[i][b] < 0.0 )
psy_var_short->tb[i][b] = 0.0;
}
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step8(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short)
{
int b,i;
double tmn = 18.0, nmt = 6.0;
for(b = 0; b < part_tbl_long->len; b++) {
psy_var_long->snr[b] = psy_var_long->tb[b] * tmn + (1.0 - psy_var_long->tb[b] ) * nmt;
}
/* added by T. Araki (1997.10.16) */
for(i = 0; i < MAX_SHORT_WINDOWS; i++){
for(b = 0; b < part_tbl_short->len; b++)
psy_var_short->snr[i][b] = psy_var_short->tb[i][b] * tmn + (1.0 - psy_var_short->tb[i][b] ) * nmt ;
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step9(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
)
{
int b,i;
for(b = 0; b < part_tbl_long->len; b++)
psy_var_long->bc[b] = pow(10.0, -psy_var_long->snr[b]/10.0);
/* added by T. Araki (1997.10.16) */
for(i = 0; i < MAX_SHORT_WINDOWS; i++){
for(b = 0; b < part_tbl_short->len; b++)
psy_var_short->bc[i][b] = pow(10.0, -psy_var_short->snr[i][b]/10.0);
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step10(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
/*int ch*/
)
{
int b,i;
psy_stvar_long->p_nb += NPART_LONG;
if( psy_stvar_long->p_nb == NPART_LONG*2 ) psy_stvar_long->p_nb = 0;
for(b = 0; b < part_tbl_long->len; b++){
psy_stvar_long->nb[psy_stvar_long->p_nb + b]
= psy_var_long->en[b] * psy_var_long->bc[b];
}
/* added by T. Araki (1997.10.16) */
for(i = 0; i < MAX_SHORT_WINDOWS; i++){
for(b = 0; b < part_tbl_short->len; b++){
psy_stvar_short->nb[i][b]
= psy_var_short->en[i][b] * psy_var_short->bc[i][b];
}
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step11(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short
/* int ch*/
)
{
int b,i;
int p1,p2;
double temp;
p1 = psy_stvar_long->p_nb;
if( p1 == 0 ) p2 = NPART_LONG;
else if( p1 == NPART_LONG ) p2 = 0;
for(b = 0; b < part_tbl_long->len; b++) {
temp = psy_min( psy_stvar_long->nb[p1+b],2.0*psy_stvar_long->nb[p2+b]);
if (temp > 0.01)
psy_stvar_long->nb[p1+b] = temp;
}
/* added by T. Araki (1997.10.16) */
for(b = 0; b < part_tbl_short->len; b++){
temp = psy_min( psy_stvar_short->nb[0][b], 1.0*psy_stvar_short->last7_nb[b]);
if (temp > 0.01)
psy_stvar_short->nb[0][b] = temp;
}
for(b = 0; b < part_tbl_short->len; b++){
psy_stvar_short->last7_nb[b] = psy_stvar_short->nb[7][b];
}
for(i = 1; i < MAX_SHORT_WINDOWS; i++){
for(b = 0; b < part_tbl_short->len; b++){
temp = psy_min( psy_stvar_short->nb[i][b],1.0*psy_stvar_short->nb[i - 1][b]);
if (temp > 0.01)
psy_stvar_short->nb[i][b] = temp;
}
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step11andahalf(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short,
int ch)
{
int b, i,p1;//p2;
double t;
double tempL, tempR, tempM, tempS;
p1 = psy_stvar_long->p_nb;
// if( p1 == 0 ) p2 = NPART_LONG;
// else if( p1 == NPART_LONG ) p2 = 0;
if (ch==3) {
for(b = 0; b < part_tbl_long->len; b++) {
if (psy_stvar_long[3].nb[p1+b] != 0.0)
t = psy_stvar_long[2].nb[p1+b]/psy_stvar_long[3].nb[p1+b];
else
t = 0;
if (t>1)
t = 1/t;
tempL = max(psy_stvar_long[0].nb[p1+b]*t, min(psy_stvar_long[0].nb[p1+b], part_tbl_long->dyn->bmax[b]*psy_stvar_long[0].en[b]));
tempR = max(psy_stvar_long[1].nb[p1+b]*t, min(psy_stvar_long[1].nb[p1+b], part_tbl_long->dyn->bmax[b]*psy_stvar_long[1].en[b]));
t = min(tempL,tempR);
tempM = min(t, max(psy_stvar_long[2].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[3].en[b], psy_stvar_long[3].nb[p1+b])));
tempS = min(t, max(psy_stvar_long[3].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[2].en[b], psy_stvar_long[2].nb[p1+b])));
if ((psy_stvar_long[0].nb[p1+b] >= 1.58*psy_stvar_long[1].nb[p1+b])&&(psy_stvar_long[1].nb[p1+b] >= 1.58*psy_stvar_long[0].nb[p1+b])) {
psy_stvar_long[2].nb[p1+b] = tempM;
psy_stvar_long[3].nb[p1+b] = tempS;
psy_stvar_long[0].nb[p1+b] = tempL;
psy_stvar_long[1].nb[p1+b] = tempR;
}
}
for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
for(b = 0; b < part_tbl_short->len; b++) {
if (psy_stvar_short[3].nb[i][b] != 0.0)
t = psy_stvar_short[2].nb[i][b]/psy_stvar_short[3].nb[i][b];
else
t = 0;
if (t>1)
t = 1/t;
tempL = max(psy_stvar_short[0].nb[i][b]*t, min(psy_stvar_short[0].nb[i][b], part_tbl_short->dyn->bmax[b]*psy_stvar_short[0].en[i][b]));
tempR = max(psy_stvar_short[1].nb[i][b]*t, min(psy_stvar_short[1].nb[i][b], part_tbl_short->dyn->bmax[b]*psy_stvar_short[1].en[i][b]));
t = min(tempL,tempR);
tempM = min(t, max(psy_stvar_short[2].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[3].en[i][b], psy_stvar_short[3].nb[i][b])));
tempS = min(t, max(psy_stvar_short[3].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[2].en[i][b], psy_stvar_short[2].nb[i][b])));
if ((psy_stvar_short[0].nb[i][b] >= 1.58*psy_stvar_short[1].nb[i][b])&&(psy_stvar_short[1].nb[i][b] >= 1.58*psy_stvar_short[0].nb[i][b])) {
psy_stvar_short[2].nb[i][b] = tempM;
psy_stvar_short[3].nb[i][b] = tempS;
psy_stvar_short[0].nb[i][b] = tempL;
psy_stvar_short[1].nb[i][b] = tempR;
}
}
}
}
}
/* added by T. Araki (1997.7.10) */
void psy_step12(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
/* int ch*/
)
{
int b;
psy_var_long->pe = 0.0;
for(b = 0; b < part_tbl_long->len; b++){
double tp = log((psy_stvar_long->nb[psy_stvar_long->p_nb + b] + 0.0001)
/ (psy_var_long->e[b] + 0.0001));
tp = min(0.0, tp);
psy_var_long->pe -= part_tbl_long->width[b] * tp;
}
}
void psy_step13(PSY_VARIABLE_LONG *psy_var_long,
enum WINDOW_TYPE *block_type,
int ch
)
{
static int old_type;
if (ch == 0) {
if(psy_var_long->pe < 1800) {
old_type = ONLY_LONG_WINDOW;
} else {
old_type = ONLY_SHORT_WINDOW;
}
} else if(ch == 1) {
if((psy_var_long->pe < 1800) && (old_type == ONLY_LONG_WINDOW)) {
*block_type = ONLY_LONG_WINDOW;
} else {
*block_type = ONLY_SHORT_WINDOW;
}
}
}
void psy_step14(SR_INFO *p_sri,
PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
/*int ch*/
)
{
int b, n, w, i;
int w_low, w_high;
double thr, minthr;
w_high = 0;
for(n = 0; n < p_sri->num_cb_long; n++){
w_low = w_high;
w_high += p_sri->cb_width_long[n];
psy_var_long->epart[n] = 0.0;
for(w = w_low; w < w_high; w++){
psy_var_long->epart[n] += psy_sqr(psy_stvar_long->fft_r[psy_stvar_long->p_fft + w]);
}
}
for(b = 0; b < part_tbl_long->len; b++){
thr = psy_stvar_long->nb[psy_stvar_long->p_nb + b]
/ part_tbl_long->width[b];
for(w = part_tbl_long->w_low[b]; w <= part_tbl_long->w_high[b]; w++){
psy_var_long->thr[w] = thr;
}
}
w_high = 0;
for(n = 0; n < p_sri->num_cb_long; n++){
w_low = w_high;
w_high += p_sri->cb_width_long[n];
minthr = psy_var_long->thr[w_low];
for(w = w_low+1; w < w_high; w++){
if(psy_var_long->thr[w] < minthr){
minthr = psy_var_long->thr[w];
}
}
psy_var_long->npart[n] = minthr * (w_high - w_low);
}
for(n = 0; n < p_sri->num_cb_long; n++){
if (psy_var_long->epart[n]!=0.0) {
psy_stvar_long->ismr[n] = psy_var_long->npart[n] / psy_var_long->epart[n];
} else {
psy_stvar_long->ismr[n] = 0.0;
}
}
/* added by T. Araki (1997.10.16) */
for(i = 0; i < MAX_SHORT_WINDOWS; i++){
w_high = 0;
for(n = 0; n < p_sri->num_cb_short; n++){
w_low = w_high;
w_high += p_sri->cb_width_short[n];
psy_var_short->epart[i][n] = 0.0;
for(w = w_low; w < w_high; w++){
psy_var_short->epart[i][n] += psy_sqr(psy_stvar_short->fft_r[i][w]);
}
}
for(b = 0; b < part_tbl_short->len; b++){
thr = psy_stvar_short->nb[i][b] / part_tbl_short->width[b];
for(w = part_tbl_short->w_low[b]; w <= part_tbl_short->w_high[b]; w++){
psy_var_short->thr[i][w] = thr;
}
}
w_high = 0;
for(n = 0; n < p_sri->num_cb_short; n++){
w_low = w_high;
w_high += p_sri->cb_width_short[n];
minthr = psy_var_short->thr[i][w_low];
for(w = w_low + 1; w < w_high; w++){
if(psy_var_short->thr[i][w] < minthr){
minthr = psy_var_short->thr[i][w];
}
}
psy_var_short->npart[i][n] = minthr * (w_high - w_low);
}
for(n = 0; n < p_sri->num_cb_short; n++){
if (psy_var_short->epart[i][n]!=0.0) {
psy_stvar_short->ismr[i][n] = psy_var_short->npart[i][n] / psy_var_short->epart[i][n];
} else {
psy_stvar_short->ismr[i][n] = 0.0;
}
}
}
/* added by T. Araki (1997.10.16) end */
}
void psy_step15(int use_ms_l[NSFB_LONG], int use_ms_s[MAX_SHORT_WINDOWS][NSFB_SHORT],
SR_INFO *p_sri,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long, PSY_VARIABLE_SHORT *psy_var_short,
int ch
)
{
int b, i;
double temp, x1, x2, db;
if (ch == 0) {
for (b = 0; b < p_sri->num_cb_long; b++)
psy_stvar_long->save_npart_l[b] = psy_var_long->npart[b];
for (i = 0; i < 8; i++)
for (b = 0; b < p_sri->num_cb_short; b++)
psy_stvar_short->save_npart_s[i][b] = psy_var_short->npart[i][b];
}
if (ch == 1) {
for (b = 0; b < p_sri->num_cb_long; b++) {
x1 = min(psy_stvar_long->save_npart_l[b],psy_var_long->npart[b]);
x2 = max(psy_stvar_long->save_npart_l[b],psy_var_long->npart[b]);
if (x2 >= 1000*x1)
db=30;
else
db = 10*log10(x2/x1);
temp = 0.35*(db)/5.0;
// printf("%d\t%f\n", b, temp);
if (temp < 0.35)
use_ms_l[b] = 1;
else
use_ms_l[b] = 0;
}
for (i = 0; i < 8; i++) {
for (b = 0; b < p_sri->num_cb_short; b++) {
x1 = min(psy_stvar_short->save_npart_s[i][b],psy_var_short->npart[i][b]);
x2 = max(psy_stvar_short->save_npart_s[i][b],psy_var_short->npart[i][b]);
if (x2 >= 1000*x1)
db=30;
else
db = 10*log10(x2/x1);
temp = 0.35*(db)/5.0;
// printf("%d\t%f\n", b, temp);
if (temp < 0.35)
use_ms_s[i][b] = 1;
else
use_ms_s[i][b] = 0;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -