ref: 15eebf2ac836c134507c6e5c42979d44c1cfdd7c
parent: b19b25b65582eef28badf97da5168aec4a0d4ccf
author: menno <menno>
date: Thu Aug 24 08:18:23 EDT 2000
Fixed a bug in MS threshold calculation
--- a/psych.c
+++ b/psych.c
@@ -570,10 +570,11 @@
&psy_var_long[2], &psy_var_short[2]);
psy_step10(&part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan], &psy_stvar_short[sideChan],
&psy_var_long[3], &psy_var_short[3]);
+
+ psy_step11MS(&part_tbl_long, &part_tbl_short, psy_stvar_long, psy_stvar_short,
+ leftChan, rightChan, midChan, sideChan);
}
- psy_step11MS(&part_tbl_long, &part_tbl_short, psy_stvar_long, psy_stvar_short, no_of_chan);
-
psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[leftChan], &psy_stvar_short[leftChan]);
psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan], &psy_stvar_short[rightChan]);
if (use_MS == 0) {
@@ -1170,38 +1171,37 @@
}
}
-void psy_step11MS(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)
+void psy_step11MS(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 leftChan, int rightChan,
+ int midChan, int sideChan)
{
#if 1 // LAME's version
int b, i, p1;
double tempM, tempS;
- p1 = psy_stvar_long->p_nb;
+ p1 = psy_stvar_long[leftChan].p_nb;
- if (ch==3) {
- for(b = 0; b < part_tbl_long->len; b++) {
- tempM = 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 = 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]));
+ for(b = 0; b < part_tbl_long->len; b++) {
+ tempM = max(psy_stvar_long[midChan].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[sideChan].en[b], psy_stvar_long[sideChan].nb[p1+b]));
+ tempS = max(psy_stvar_long[sideChan].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[midChan].en[b], psy_stvar_long[midChan].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;
- }
+ if ((psy_stvar_long[leftChan].nb[p1+b] <= 1.58*psy_stvar_long[rightChan].nb[p1+b])&&(psy_stvar_long[rightChan].nb[p1+b] <= 1.58*psy_stvar_long[leftChan].nb[p1+b])) {
+ psy_stvar_long[midChan].nb[p1+b] = tempM;
+ psy_stvar_long[sideChan].nb[p1+b] = tempS;
}
+ }
- for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
- for(b = 0; b < part_tbl_short->len; b++) {
- tempM = 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 = 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]));
+ for (i = 0; i < MAX_SHORT_WINDOWS; i++) {
+ for(b = 0; b < part_tbl_short->len; b++) {
+ tempM = max(psy_stvar_short[midChan].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[sideChan].en[i][b], psy_stvar_short[sideChan].nb[i][b]));
+ tempS = max(psy_stvar_short[sideChan].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[midChan].en[i][b], psy_stvar_short[midChan].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;
- }
+ if ((psy_stvar_short[leftChan].nb[i][b] <= 1.58*psy_stvar_short[rightChan].nb[i][b])&&(psy_stvar_short[rightChan].nb[i][b] <= 1.58*psy_stvar_short[leftChan].nb[i][b])) {
+ psy_stvar_short[midChan].nb[i][b] = tempM;
+ psy_stvar_short[sideChan].nb[i][b] = tempS;
}
}
}
@@ -1210,52 +1210,51 @@
double t;
double tempL, tempR, tempM, tempS;
- p1 = psy_stvar_long->p_nb;
+ p1 = psy_stvar_long[leftChan].p_nb;
- 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];
+ for(b = 0; b < part_tbl_long->len; b++) {
+
+ if (psy_stvar_long[sideChan].nb[p1+b] != 0.0)
+ t = psy_stvar_long[midChan].nb[p1+b]/psy_stvar_long[sideChan].nb[p1+b];
+ else
+ t = 0;
+ if (t>1)
+ t = 1/t;
+ tempL = max(psy_stvar_long[leftChan].nb[p1+b]*t, min(psy_stvar_long[leftChan].nb[p1+b], part_tbl_long->dyn->bmax[b]*psy_stvar_long[leftChan].en[b]));
+ tempR = max(psy_stvar_long[rightChan].nb[p1+b]*t, min(psy_stvar_long[rightChan].nb[p1+b], part_tbl_long->dyn->bmax[b]*psy_stvar_long[rightChan].en[b]));
+
+ t = min(tempL,tempR);
+ tempM = min(t, max(psy_stvar_long[midChan].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[sideChan].en[b], psy_stvar_long[sideChan].nb[p1+b])));
+ tempS = min(t, max(psy_stvar_long[sideChan].nb[p1+b], min(part_tbl_long->dyn->bmax[b]*psy_stvar_long[midChan].en[b], psy_stvar_long[midChan].nb[p1+b])));
+
+ if ((psy_stvar_long[leftChan].nb[p1+b] >= 1.58*psy_stvar_long[rightChan].nb[p1+b])&&(psy_stvar_long[rightChan].nb[p1+b] >= 1.58*psy_stvar_long[leftChan].nb[p1+b])) {
+ psy_stvar_long[midChan].nb[p1+b] = tempM;
+ psy_stvar_long[sideChan].nb[p1+b] = tempS;
+ psy_stvar_long[leftChan].nb[p1+b] = tempL;
+ psy_stvar_long[rightChan].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[sideChan].nb[i][b] != 0.0)
+ t = psy_stvar_short[midChan].nb[i][b]/psy_stvar_short[sideChan].nb[i][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]));
+ tempL = max(psy_stvar_short[leftChan].nb[i][b]*t, min(psy_stvar_short[leftChan].nb[i][b], part_tbl_short->dyn->bmax[b]*psy_stvar_short[leftChan].en[i][b]));
+ tempR = max(psy_stvar_short[rightChan].nb[i][b]*t, min(psy_stvar_short[rightChan].nb[i][b], part_tbl_short->dyn->bmax[b]*psy_stvar_short[rightChan].en[i][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])));
+ tempM = min(t, max(psy_stvar_short[midChan].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[sideChan].en[i][b], psy_stvar_short[sideChan].nb[i][b])));
+ tempS = min(t, max(psy_stvar_short[sideChan].nb[i][b], min(part_tbl_short->dyn->bmax[b]*psy_stvar_short[midChan].en[i][b], psy_stvar_short[midChan].nb[i][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;
- }
+ if ((psy_stvar_short[leftChan].nb[i][b] >= 1.58*psy_stvar_short[rightChan].nb[i][b])&&(psy_stvar_short[rightChan].nb[i][b] >= 1.58*psy_stvar_short[leftChan].nb[i][b])) {
+ psy_stvar_short[midChan].nb[i][b] = tempM;
+ psy_stvar_short[sideChan].nb[i][b] = tempS;
+ psy_stvar_short[leftChan].nb[i][b] = tempL;
+ psy_stvar_short[rightChan].nb[i][b] = tempR;
}
}
}
--- a/psych.h
+++ b/psych.h
@@ -52,13 +52,10 @@
int cb_width_short[NSFB_SHORT];
} SR_INFO;
-/* added by T. Araki (1997.10.17) */
#define OFFSET_FOR_SHORT 448
#define NPART_LONG 100
#define NPART_SHORT 100
-/* added by T. Araki (1997.10.17) end */
-/* added by T. Araki (1997.07.10) */
typedef struct {
double hw[BLOCK_LEN_LONG*2]; /* Hann window table */
} FFT_TABLE_LONG;
@@ -161,7 +158,6 @@
double npart[MAX_SHORT_WINDOWS][NSFB_SHORT];
double pe[MAX_SHORT_WINDOWS];
} PSY_VARIABLE_SHORT;
-/* added by T. Araki (1997.07.10) end */
typedef struct {
double *p_ratio;
@@ -191,8 +187,6 @@
double *p_time_signal[],
enum WINDOW_TYPE block_type[],
int use_MS,
-// int qcSelect,
-// int frameLength,
/* output */
CH_PSYCH_OUTPUT_LONG p_chpo_long[],
CH_PSYCH_OUTPUT_SHORT p_chpo_short[][MAX_SHORT_WINDOWS]
@@ -238,7 +232,6 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
void psy_step4(PSY_STATVARIABLE_LONG *psy_stvar_long,
@@ -245,7 +238,6 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
void psy_step5(PARTITION_TABLE_LONG *part_tbl_long,
@@ -254,13 +246,8 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
-//void psy_step6_step1(void *inData);
-
-//void psy_step6_step1(void *inData);
-
void psy_step6(PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
@@ -293,7 +280,6 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
void psy_step11(PARTITION_TABLE_LONG *part_tbl_long,
@@ -300,15 +286,8 @@
PARTITION_TABLE_SHORT *part_tbl_short,
PSY_STATVARIABLE_LONG *psy_stvar_long,
PSY_STATVARIABLE_SHORT *psy_stvar_short
-// ,int ch
);
-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);
-
void psy_step12(
PARTITION_TABLE_LONG *part_tbl_long,
PARTITION_TABLE_SHORT *part_tbl_short,
@@ -316,12 +295,10 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long
,PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
void psy_step13(PSY_VARIABLE_LONG *psy_var_long,
enum WINDOW_TYPE *block_type
-// ,int ch
);
void psy_step14(SR_INFO *p_sri,
@@ -331,7 +308,6 @@
PSY_STATVARIABLE_SHORT *psy_stvar_short,
PSY_VARIABLE_LONG *psy_var_long,
PSY_VARIABLE_SHORT *psy_var_short
-// ,int ch
);
void psy_step15(SR_INFO *p_sri,
@@ -356,11 +332,12 @@
int leftChan, int rightChan,
int midChan, int sideChan);
-void psy_step11MS(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);
+void psy_step11MS(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 leftChan, int rightChan,
+ int midChan, int sideChan);
#ifdef __cplusplus
}