struct defs
typedefs
global vars
void _mccat_main();
int InitDisplay();
int UpdateDisplay(float amps[], int width, int height, float min,
float max);
int AnnotateDisplay(int *ub, char *string);
int SetDisplayValue(int value);
int comm(char *s, char *table[]);
complex_st21 cmul(complex_st21 a, complex_st21 b);
complex_st21 cadd(complex_st21 a, complex_st21 b);
complex_st21 csub(complex_st21 a, complex_st21 b);
complex_st21 cdiv(complex_st21 a, complex_st21 b);
complex_st21 cmplx(float a, float b);
float real(complex_st21 a);
float aimag(complex_st21 a);
float cmag(complex_st21 c);
float cmag2(complex_st21 c);
float cphase(complex_st21 c);
complex_st21 csqrt(complex_st21 x);
complex_st21 conjugate(complex_st21 x);
complex_st21 iToPower(int m);
complex_st21 cexp(complex_st21 x);
complex_st21 cis(float theta);
int printcomplex(complex_st21 c);
int InitCorrelation(int Channels, int Length);
int SendInputToCorrelation(float Data[]);
float *MakeHamming(int Length);
float *MakeCompensator(int Length);
float SimpleCorrelation(float *_U_Output_6, int Lags);
float FFTCorrelation(float *_U_Output_7, int Lags);
float HartleyCorrelation(float *_U_Output_8, int Lags);
float EarCorrelation(float *_U_Output_9, int Lags);
int StretchDisplay(float *data, int lags, int channels);
int main(int argc, char **argv);
int RecordVideo();
int RunRealTime();
struct polynomial *AllocatePolynomial(int order);
int PrintPolynomial(struct polynomial *pp);
complex_st75 PolyEval(struct polynomial *pp, complex_st75 x);
struct filter *MakeFilter(struct polynomial *forward, struct polynomial *feedback,
float fsamp, float freq, float gain);
complex_st75 FilterEval(struct filter *fp, complex_st75 z);
complex_st75 FilterGain(struct filter *fp, float freq);
float FilterNumeratorCoeff(struct filter *fp, int i);
float FilterDenominatorCoeff(struct filter *fp, int i);
int PrintFilter(struct filter *fp);
float EarBandwidth(float cf);
float CascadeZeroCF(float cf);
float CascadeZeroQ(float cf);
float CascadePoleCF(float cf);
float CascadePoleQ(float cf);
float MaximumEarCF(float fs);
float EarChannelCF(int index, float fs);
float EpsilonFromTauFS(float tau, float fs);
struct polynomial *FirstOrderFromTau(float tau, float fs);
struct polynomial *FirstOrderFromCorner(float fc, float fs);
struct polynomial *SecondOrderFromCenterQ(float NatFreq, float q,
float fs);
struct filter *OuterMiddleEarFilter(float fs);
struct filter *EarFrontFilter(float fs);
struct filter *EarStageFilter(float cf, float fs, float DCGain);
int EARSTEP(float *input, float output[]);
int sos(float input[], float state1[], float state2[], float _U_a0_11[],
float _U_a1_12[], float _U_a2_13[], float _U_b1_14[], float _U_b2_15[],
float output[], int n);
int agc(float input[], float state[], float output[], float epsilon,
float target, int n);
int hwr(float input[], float output[], int n);
int difference(float input[], float output[], int n);
int fos(float input[], float state[], float output[], float gain,
int n);
float *initfft(int Size);
int fft(float a[], float b[], int m, int iopt);
int Read16BitsLowHigh(struct _iobuf *fp);
int Read16BitsHighLow(struct _iobuf *fp);
int Write16BitsLowHigh(struct _iobuf *fp, int i);
long Read32Bits(struct _iobuf *fp);
int Write32Bits(struct _iobuf *fp, long i);
float *ReadADCFile(char *FileName, float *SamplingRate, long *Length);
int WriteADCFile(char *FileName, float SamplingRate, long Length,
float *Data);
long FileLength(struct _iobuf *fp);
float *ReadWavFile(char *FileName, long *Length);
float *ReadByteFile(char *FileName, long *Length);
int WriteByteFile(char *FileName, long Length, float *Data);
float *ReadDyaxisFile(char *FileName, int *Length);
float *ReadNeXTFile(char *FileName, int *Length, float *SamplingRate);
int fileAbort(char *str, char *arg);
float *ReadNativeFloatFile(char *FileName, long *Length);
char *GetFileSuffix(char *FileName);
float *ReadInputFile(char *FileName, float *SamplingRate, long *Length);
int OpenConnection(char *machine);
int SendCommandToRemote(char *command);
int CloseConnection();
int OpenOutputFile(char *_U_ofn_20);
int WriteOutputFile(float *Data, int Length);
int CloseOutputFile();
int picout(char *name, float *pic, long num);
int BytePicout(char *name, float *pic, long num, float min, float max);
int ProcessOption(char *p);
int ProcessArgument(char *p);
int PrintStats();
int syntax();
int ChangeAgcParams();
int ChangeDecimationParameters();
int DesignEarFilters();
int INITCOM(struct CommonStruct *CBlock);
extern long ftell();
extern double atof();
int InitDisplay()
{
}
int UpdateDisplay(
float amps[],
int width,
int height,
float min,
float max)
{
}
int AnnotateDisplay(
int *ub,
char *string)
{
}
int SetDisplayValue(
int value)
{
}
int comm(
char *s,
char *table[])
{
local vars
i1 = 0;
for ( temp_141 = table1[i1] ; (temp_142 != 0) ; temp_143 = table1[i3] )
{
j2 = 0;
temp_162 = table1[i2][j2];
r2 = (int ) temp_162;
temp_172 = s1[j2];
temp_182 = (int ) temp_172;
temp_152 = (r2 == temp_182);
if ((temp_152 != 0))
{
temp_153 = (r2 != 0);
}
for ( ; (temp_155 != 0) ; )
{
j4 = (j3 + 1);
temp_193 = table1[i2][j4];
r4 = (int ) temp_193;
temp_203 = s1[j4];
temp_213 = (int ) temp_203;
temp_156 = (r4 == temp_213);
if ((temp_156 != 0))
{
temp_157 = (r4 != 0);
}
}
temp_222 = (r5 == 0);
if ((temp_222 != 0))
{
/** temp_22 = ((char ) s[j] == 61) **/
temp_232 = s1[j5];
temp_242 = (char ) temp_232;
temp_223 = (temp_242 == 61);
}
if ((temp_224 != 0))
{
/** (i + 1) **/
temp_252 = (i2 + 1);
return (temp_252);
}
i3 = (i2 + 1);
}
temp_261 = (&_iob[2]);
temp_271 = "bad option: %s\n";
fprintf1(temp_261, temp_271, s1);
syntax2();
exit(1);
}
complex_st21 cmul(
complex_st21 a,
complex_st21 b)
{
local vars
temp_291 = a1.real;
temp_301 = b1.real;
temp_281 = (temp_291 * temp_301);
temp_321 = a1.im;
temp_331 = b1.im;
temp_311 = (temp_321 * temp_331);
c1.real = (temp_281 - temp_311);
temp_351 = a1.real;
temp_361 = b1.im;
temp_341 = (temp_351 * temp_361);
temp_381 = a1.im;
temp_391 = b1.real;
temp_371 = (temp_381 * temp_391);
c1.im = (temp_341 + temp_371);
return (c1);
}
complex_st21 cadd(
complex_st21 a,
complex_st21 b)
{
local vars
temp_401 = a1.real;
temp_411 = b1.real;
c1.real = (temp_401 + temp_411);
temp_421 = a1.im;
temp_431 = b1.im;
c1.im = (temp_421 + temp_431);
return (c1);
}
complex_st21 csub(
complex_st21 a,
complex_st21 b)
{
local vars
temp_44 = a.real;
temp_45 = b.real;
c.real = (temp_44 - temp_45);
temp_46 = a.im;
temp_47 = b.im;
c.im = (temp_46 - temp_47);
return (c);
}
complex_st21 cdiv(
complex_st21 a,
complex_st21 b)
{
local vars
temp_491 = b1.real;
temp_501 = b1.real;
temp_481 = (temp_491 * temp_501);
temp_521 = b1.im;
temp_531 = b1.im;
temp_511 = (temp_521 * temp_531);
mag1 = (temp_481 + temp_511);
temp_561 = a1.im;
temp_571 = b1.im;
temp_551 = (temp_561 * temp_571);
temp_591 = a1.real;
temp_601 = b1.real;
temp_581 = (temp_591 * temp_601);
temp_541 = (temp_551 + temp_581);
c1.real = (temp_541 / mag1);
temp_631 = a1.im;
temp_641 = b1.real;
temp_621 = (temp_631 * temp_641);
temp_661 = a1.real;
temp_671 = b1.im;
temp_651 = (temp_661 * temp_671);
temp_611 = (temp_621 - temp_651);
c1.im = (temp_611 / mag1);
return (c1);
}
complex_st21 cmplx(
float a,
float b)
{
local vars
c1.real = a1;
c1.im = b1;
return (c1);
}
float real(
complex_st21 a)
{
local vars
temp_68 = a.real;
return (temp_68);
}
float aimag(
complex_st21 a)
{
local vars
temp_69 = a.im;
return (temp_69);
}
float cmag(
complex_st21 c)
{
local vars
temp_721 = c1.real;
temp_731 = c1.real;
temp_711 = (temp_721 * temp_731);
temp_751 = c1.im;
temp_761 = c1.im;
temp_741 = (temp_751 * temp_761);
temp_771 = (temp_711 + temp_741);
temp_781 = (double ) temp_771;
temp_702 = sqrt(temp_781);
return (temp_702);
}
float cmag2(
complex_st21 c)
{
local vars
temp_81 = c.real;
temp_82 = c.real;
temp_80 = (temp_81 * temp_82);
temp_84 = c.im;
temp_85 = c.im;
temp_83 = (temp_84 * temp_85);
temp_79 = (temp_80 + temp_83);
return (temp_79);
}
float cphase(
complex_st21 c)
{
local vars
temp_87 = c.im;
temp_88 = (double ) temp_87;
temp_89 = c.real;
temp_90 = (double ) temp_89;
temp_86 = atan2(temp_88, temp_90);
return (temp_86);
}
complex_st21 csqrt(
complex_st21 x)
{
local vars
temp_91 = x.im;
temp_92 = (double ) temp_91;
temp_93 = x.real;
temp_94 = (double ) temp_93;
temp_95 = atan2(temp_92, temp_94);
angle = (float ) temp_95;
temp_97 = x.real;
temp_98 = x.real;
temp_96 = (temp_97 * temp_98);
temp_100 = x.im;
temp_101 = x.im;
temp_99 = (temp_100 * temp_101);
temp_102 = (temp_96 + temp_99);
temp_103 = (double ) temp_102;
temp_104 = sqrt(temp_103);
mag = (float ) temp_104;
temp_105 = (double ) mag;
temp_106 = sqrt(temp_105);
mag = (float ) temp_106;
temp_107 = (double ) angle;
temp_108 = (temp_107 / 2.00000000000000e+00);
angle = (float ) temp_108;
temp_111 = (double ) mag;
temp_113 = (double ) angle;
temp_112 = cos(temp_113);
temp_110 = (temp_111 * temp_112);
temp_115 = (double ) mag;
temp_117 = (double ) angle;
temp_116 = sin(temp_117);
temp_114 = (temp_115 * temp_116);
temp_109 = cmplx1(temp_110, temp_114);
return (temp_109);
}
complex_st21 conjugate(
complex_st21 x)
{
local vars
temp_119 = x.real;
temp_120 = (double ) temp_119;
temp_121 = x.im;
temp_122 = (-temp_121);
temp_123 = (double ) temp_122;
temp_118 = cmplx1(temp_120, temp_123);
return (temp_118);
}
complex_st21 iToPower(
int m)
{
local vars
temp_124 = (m % 4);
switch (temp_124)
{
case 0 :
{
temp_125 = cmplx1(1.00000000000000e+00, 0.00000000000000e+00);
return (temp_125);
temp_126 = cmplx2(0.00000000000000e+00, 1.00000000000000e+00);
return (temp_126);
temp_127 = cmplx3(-1.00000000000000e+00, 0.00000000000000e+00);
return (temp_127);
temp_128 = cmplx4(0.00000000000000e+00, -1.00000000000000e+00);
return (temp_128);
break;
}
case 1 :
{
_U_temp_126_0 = cmplx5(0.00000000000000e+00, 1.00000000000000e+00);
return (_U_temp_126_0);
_U_temp_127_1 = cmplx6(-1.00000000000000e+00, 0.00000000000000e+00);
return (_U_temp_127_1);
_U_temp_128_2 = cmplx7(0.00000000000000e+00, -1.00000000000000e+00);
return (_U_temp_128_2);
break;
}
case 2 :
{
_U_temp_127_3 = cmplx8(-1.00000000000000e+00, 0.00000000000000e+00);
return (_U_temp_127_3);
_U_temp_128_4 = cmplx9(0.00000000000000e+00, -1.00000000000000e+00);
return (_U_temp_128_4);
break;
}
case 3 :
{
_U_temp_128_5 = cmplx10(0.00000000000000e+00, -1.00000000000000e+00);
return (_U_temp_128_5);
break;
}
default :
{
break;
}
}
}
complex_st21 cexp(
complex_st21 x)
{
local vars
temp_129 = x.real;
temp_130 = (double ) temp_129;
temp_131 = exp(temp_130);
mag = (float ) temp_131;
temp_134 = (double ) mag;
temp_136 = x.im;
temp_137 = (double ) temp_136;
temp_135 = cos(temp_137);
temp_133 = (temp_134 * temp_135);
temp_139 = (double ) mag;
temp_141 = x.im;
temp_142 = (double ) temp_141;
temp_140 = sin(temp_142);
temp_138 = (temp_139 * temp_140);
temp_132 = cmplx1(temp_133, temp_138);
return (temp_132);
}
complex_st21 cis(
float theta)
{
local vars
temp_1451 = (double ) theta1;
temp_1442 = cos(temp_1451);
temp_1471 = (double ) theta1;
temp_1462 = sin(temp_1471);
temp_1432 = cmplx1(temp_1442, temp_1462);
return (temp_1432);
}
int printcomplex(
complex_st21 c)
{
local vars
temp_148 = "(%g,%g)";
temp_149 = c.real;
temp_150 = (double ) temp_149;
temp_151 = c.im;
temp_152 = (double ) temp_151;
printf(temp_148, temp_150, temp_152);
}
extern malloc_t_st23 calloc();
int InitCorrelation(
int Channels,
int Length)
{
local vars
CorrelationChannels_st341 = Channels1;
CorrelationDataLength_st361 = Length1;
CorrelationIndex_st351 = 0;
CorrelationLogLength_st391 = 0;
for ( temp_1531 = (1 << CorrelationLogLength_st391) ; (temp_1532 < Length1) ; temp_1533 = (1 << CorrelationLogLength_st393) )
{
CorrelationLogLength_st393 = (CorrelationLogLength_st392 + 1);
}
CorrelationLogLength_st395 = (CorrelationLogLength_st394 + 1);
CorrelationFFTLength_st381 = (1 << CorrelationLogLength_st395);
temp_1561 = (long ) CorrelationChannels_st341;
temp_1551 = (temp_1561 + 1);
temp_1571 = (long ) CorrelationDataLength_st361;
temp_1541 = (temp_1551 * temp_1571);
temp_1582 = calloc(temp_1541, 4);
CorrelationData_st331 = (float *) temp_1582;
if ((CorrelationData_st331 == 0))
{
temp_1591 = (&_iob[2]);
temp_1601 = "%s: Can't allocate %d bytes for correlation data.\n";
temp_1631 = (long ) Channels1;
temp_1621 = (temp_1631 + 1);
temp_1641 = (long ) Length1;
temp_1651 = (temp_1621 * temp_1641);
temp_1661 = (unsigned long ) temp_1651;
temp_1611 = (temp_1661 * 4);
fprintf1(temp_1591, temp_1601, progname1, temp_1611);
exit(1);
}
temp_1681 = (long ) CorrelationFFTLength_st381;
temp_1671 = (temp_1681 + 1);
temp_1692 = calloc(temp_1671, 4);
Real_st401 = (float *) temp_1692;
temp_1711 = (long ) CorrelationFFTLength_st381;
temp_1701 = (temp_1711 + 1);
temp_1722 = calloc(temp_1701, 4);
Im_st411 = (float *) temp_1722;
temp_1731 = (Real_st401 == 0);
if ((temp_1731 == 0))
{
temp_1732 = (Im_st411 == 0);
}
if ((temp_1733 != 0))
{
temp_1741 = (&_iob[2]);
temp_1751 = "%s: Can't allocate %ld bytes for correlation FFTs.\n";
temp_1771 = (long ) CorrelationFFTLength_st381;
temp_1781 = (temp_1771 + 1);
temp_1791 = (unsigned long ) temp_1781;
temp_1761 = (temp_1791 * 8);
fprintf2(temp_1741, temp_1751, progname1, temp_1761);
exit(1);
}
if ((UseUltra1 != 0))
{
InitDisplay3();
SetDisplayValue4(16732240);
UpdateDisplay5(CorrelationData_st331, 0, 0, 0.00000000000000e+00, 1.00000000000000e+00);
SetDisplayValue6(16732240);
UpdateDisplay7(CorrelationData_st331, 0, 0, 0.00000000000000e+00, 1.00000000000000e+00);
}
}
int SendInputToCorrelation(
float Data[])
{
local vars
One1 = 1;
for ( Channel1 = 0 ; (Channel2 < CorrelationChannels_st342) ; Channel3 = (Channel2 + 1) )
{
f2 = Data1[Channel2];
temp_1822 = (long ) Channel2;
temp_1832 = (long ) CorrelationDataLength_st362;
temp_1812 = (temp_1822 * temp_1832);
temp_1852 = (long ) CorrelationDataLength_st362;
temp_1842 = (CorrelationIndex_st352 % temp_1852);
temp_1802 = (temp_1812 + temp_1842);
CorrelationData_st332[temp_1802] = f2;
}
temp_1861 = (CorrelationIndex_st352 + 1);
temp_1871 = (long ) CorrelationDataLength_st362;
CorrelationIndex_st352 = (temp_1861 % temp_1871);
CorrelationDataCount_st371 = (CorrelationDataCount_st37 + 1);
temp_1881 = (long ) CorrelationDataLength_st362;
if ((CorrelationDataCount_st371 > temp_1881))
{
CorrelationDataCount_st372 = (long ) CorrelationDataLength_st362;
}
}
float *MakeHamming(
int Length)
{
local vars
temp_1891 = (HammingWindow_st422 == 0);
if ((temp_1891 == 0))
{
temp_1892 = (Length1 != HammingLength_st43);
}
if ((temp_1893 != 0))
{
if ((HammingWindow_st422 != 0))
{
free1(HammingWindow_st422);
}
temp_1911 = (long ) Length1;
temp_1921 = (unsigned long ) temp_1911;
temp_1901 = (temp_1921 * 4);
temp_1932 = malloc(temp_1901);
HammingWindow_st424 = (float *) temp_1932;
if ((HammingWindow_st424 == 0))
{
temp_1941 = (&_iob[2]);
temp_1951 = "%s: Can't allocate space for %d hamming window.\n";
fprintf2(temp_1941, temp_1951, progname3, Length1);
exit(1);
}
HammingLength_st431 = Length1;
temp_1961 = "Making a hamming window of length %d.\n";
printf(temp_1961, Length1);
for ( i1 = 0 ; (i2 < Length1) ; i3 = (i2 + 1) )
{
/** HammingWindow_st42[i] = (float ) (5.40000000000000e-01 + (4.60000000000000e-01 * cos(((3.14159265358979e+00 * (((float)i) - (((float)Length) / 2.00000000000000e+00))) / (((float)Length) / 2.00000000000000e+00))))) **/
temp_2022 = (double ) i2;
temp_2042 = (double ) Length1;
temp_2032 = (temp_2042 / 2.00000000000000e+00);
temp_2012 = (temp_2022 - temp_2032);
temp_2002 = (3.14159265358979e+00 * temp_2012);
temp_2062 = (double ) Length1;
temp_2052 = (temp_2062 / 2.00000000000000e+00);
temp_1992 = (temp_2002 / temp_2052);
temp_1983 = cos(temp_1992);
temp_1972 = (4.60000000000000e-01 * temp_1983);
temp_2072 = (5.40000000000000e-01 + temp_1972);
HammingWindow_st424[i2] = (float ) temp_2072;
}
}
return (HammingWindow_st425);
}
float *MakeCompensator(
int Length)
{
local vars
Hamming = MakeHamming2(Length);
temp_208 = (CompensatorWindow_st44 == 0);
if ((temp_208 == 0))
{
/** temp_208 = (((float)Length) != CompensatorLength_st45) **/
temp_209 = (float ) Length;
temp_208 = (temp_209 != CompensatorLength_st45);
}
if ((temp_208 != 0))
{
if ((CompensatorWindow_st44 != 0))
{
free3(CompensatorWindow_st44);
}
temp_211 = (unsigned int ) Length;
temp_210 = (temp_211 * 4);
temp_212 = malloc(temp_210);
CompensatorWindow_st44 = (float *) temp_212;
if ((CompensatorWindow_st44 == 0))
{
temp_213 = (&_iob[2]);
temp_214 = "%s: Can't allocate space for %d Compensator window.\n";
fprintf4(temp_213, temp_214, progname, Length);
exit(1);
}
CompensatorLength_st45 = (float ) Length;
temp_215 = "Making a Compensator window of length %d.\n";
printf(temp_215, Length);
for ( lag = 0 ; (lag < Length) ; lag = (lag + 1) )
{
sum = 0.00000000000000e+00;
i = 0;
for ( temp_216 = (i + lag) ; (temp_216 < Length) ; temp_216 = (i + lag) )
{
temp_218 = Hamming[i];
temp_220 = (i + lag);
temp_219 = Hamming[temp_220];
temp_217 = (temp_218 * temp_219);
sum = (sum + temp_217);
i = (i + 1);
}
temp_221 = CompensatorWindow_st44[0];
CompensatorWindow_st44[i] = (sum / temp_221);
}
}
temp_222 = "Compensator";
temp_223 = (Length * 8);
picout5(temp_222, CompensatorWindow_st44, temp_223);
exit(1);
return (CompensatorWindow_st44);
}
float SimpleCorrelation(
float *_U_Output_6,
int Lags)
{
local vars
Max = 0.00000000000000e+00;
Hamming = MakeHamming2(CorrelationDataLength_st36);
for ( Channel = 0 ; (Channel < CorrelationChannels_st34) ; Channel = (Channel + 1) )
{
for ( Lag = 0 ; (Lag < Lags) ; Lag = (Lag + 1) )
{
Sum = 0.00000000000000e+00;
for ( i = Lag ; (i < CorrelationDataLength_st36) ; i = (i + 1) )
{
temp_228 = (long ) Channel;
temp_229 = (long ) CorrelationDataLength_st36;
temp_227 = (temp_228 * temp_229);
temp_232 = (long ) i;
temp_231 = (CorrelationIndex_st35 + temp_232);
temp_233 = (long ) CorrelationDataLength_st36;
temp_230 = (temp_231 % temp_233);
temp_226 = (temp_227 + temp_230);
temp_225 = CorrelationData_st33[temp_226];
temp_237 = (long ) Channel;
temp_238 = (long ) CorrelationDataLength_st36;
temp_236 = (temp_237 * temp_238);
temp_241 = (i - Lag);
temp_242 = (long ) temp_241;
temp_240 = (CorrelationIndex_st35 + temp_242);
temp_243 = (long ) CorrelationDataLength_st36;
temp_239 = (temp_240 % temp_243);
temp_235 = (temp_236 + temp_239);
temp_234 = CorrelationData_st33[temp_235];
temp_224 = (temp_225 * temp_234);
Sum = (Sum + temp_224);
}
if ((Lag == 0))
{
temp_244 = (double ) Sum;
if ((temp_244 == 0.00000000000000e+00))
{
Scaling = 1.00000000000000e+00;
}
else
{
/** Scaling = (float ) (1.00000000000000e+00 / pow(Sum, Normalization)) **/
temp_246 = (double ) Sum;
temp_247 = (double ) Normalization;
temp_245 = pow(temp_246, temp_247);
temp_248 = (1.00000000000000e+00 / temp_245);
Scaling = (float ) temp_248;
}
}
temp_251 = (long ) Channel;
temp_252 = (long ) Lags;
temp_250 = (temp_251 * temp_252);
temp_253 = (long ) Lag;
temp_249 = (temp_250 + temp_253);
_U_Output_6[temp_249] = (Sum * Scaling);
}
}
temp_255 = (float ) CorrelationLags;
temp_254 = (temp_255 * AgcStage4Target);
temp_256 = (temp_254 * AgcStage4Target);
temp_257 = (double ) temp_256;
temp_258 = (temp_257 * 1.25000000000000e-01);
Max = (float ) temp_258;
temp_259 = (double ) Max;
temp_261 = (double ) Max;
temp_262 = (double ) Normalization;
temp_260 = pow(temp_261, temp_262);
temp_263 = (temp_259 / temp_260);
Max = (float ) temp_263;
return (Max);
}
float FFTCorrelation(
float *_U_Output_7,
int Lags)
{
local vars
max1 = 0.00000000000000e+00;
Hamming2 = MakeHamming2(CorrelationDataLength_st364);
temp_2641 = (CorrelationFFTLength_st384 / 2);
if ((Lags1 >= temp_2641))
{
temp_2651 = (&_iob[2]);
temp_2661 = "%s: Number of Lags (%d) is greater than data size (%d)\n";
temp_2671 = (CorrelationFFTLength_st384 / 2);
fprintf3(temp_2651, temp_2661, progname4, Lags1, temp_2671);
exit(1);
}
for ( Channel1 = 0 ; (Channel2 < CorrelationChannels_st344) ; Channel3 = (Channel2 + 2) )
{
for ( i2 = 0 ; (i3 < CorrelationDataLength_st364) ; i4 = (i3 + 1) )
{
temp_2713 = (long ) Channel2;
temp_2723 = (long ) CorrelationDataLength_st364;
temp_2703 = (temp_2713 * temp_2723);
temp_2753 = (long ) i3;
temp_2743 = (CorrelationIndex_st354 + temp_2753);
temp_2763 = (long ) CorrelationDataLength_st364;
temp_2733 = (temp_2743 % temp_2763);
temp_2693 = (temp_2703 + temp_2733);
temp_2683 = CorrelationData_st334[temp_2693];
temp_2773 = Hamming2[i3];
Real_st404[i3] = (temp_2683 * temp_2773);
temp_2813 = (Channel2 + 1);
temp_2823 = (long ) temp_2813;
temp_2833 = (long ) CorrelationDataLength_st364;
temp_2803 = (temp_2823 * temp_2833);
temp_2863 = (long ) i3;
temp_2853 = (CorrelationIndex_st354 + temp_2863);
temp_2873 = (long ) CorrelationDataLength_st364;
temp_2843 = (temp_2853 % temp_2873);
temp_2793 = (temp_2803 + temp_2843);
temp_2783 = CorrelationData_st334[temp_2793];
temp_2883 = Hamming2[i3];
Im_st414[i3] = (temp_2783 * temp_2883);
temp_2893 = (CorrelationFFTLength_st384 - i3);
Real_st404[temp_2893] = 0.00000000000000e+00;
temp_2903 = (CorrelationFFTLength_st384 - i3);
Im_st414[temp_2903] = 0.00000000000000e+00;
}
temp_2912 = (CorrelationFFTLength_st384 / 2);
for ( i6 = CorrelationDataLength_st364 ; (i7 <= temp_2913) ; i8 = (i7 + 1) )
{
Im_st414[i7] = 0.00000000000000e+00;
Real_st404[i7] = Im_st414[i7];
temp_2923 = (CorrelationFFTLength_st384 - i7);
Real_st404[temp_2923] = 0.00000000000000e+00;
temp_2933 = (CorrelationFFTLength_st384 - i7);
Im_st414[temp_2933] = 0.00000000000000e+00;
temp_2914 = (CorrelationFFTLength_st384 / 2);
}
fft4(Real_st404, Im_st414, CorrelationLogLength_st398, 0);
Real_st404[CorrelationFFTLength_st384] = Real_st404[0];
Im_st414[CorrelationFFTLength_st384] = Im_st414[0];
temp_2942 = (CorrelationFFTLength_st384 / 2);
for ( i10 = 0 ; (i11 <= temp_2943) ; i12 = (i11 + 1) )
{
j3 = (CorrelationFFTLength_st384 - i11);
temp_2953 = Real_st404[i11];
temp_2963 = Real_st404[j3];
temp_2973 = (temp_2953 + temp_2963);
temp_2983 = (double ) temp_2973;
temp_2993 = (temp_2983 / 2.00000000000000e+00);
FirstReal3 = (float ) temp_2993;
temp_3003 = Im_st414[i11];
temp_3013 = Im_st414[j3];
temp_3023 = (temp_3003 - temp_3013);
temp_3033 = (double ) temp_3023;
temp_3043 = (temp_3033 / 2.00000000000000e+00);
FirstIm3 = (float ) temp_3043;
temp_3053 = Im_st414[i11];
temp_3063 = Im_st414[j3];
temp_3073 = (temp_3053 + temp_3063);
temp_3083 = (double ) temp_3073;
temp_3093 = (temp_3083 / 2.00000000000000e+00);
SecondReal3 = (float ) temp_3093;
temp_3103 = Real_st404[i11];
temp_3113 = Real_st404[j3];
temp_3123 = (temp_3103 - temp_3113);
temp_3133 = (double ) temp_3123;
temp_3143 = (temp_3133 / 2.00000000000000e+00);
SecondIm3 = (float ) temp_3143;
temp_3153 = (FirstReal3 * FirstReal3);
temp_3163 = (FirstIm3 * FirstIm3);
FirstMag3 = (temp_3153 + temp_3163);
temp_3173 = (SecondReal3 * SecondReal3);
temp_3183 = (SecondIm3 * SecondIm3);
SecondMag3 = (temp_3173 + temp_3183);
Real_st404[j3] = FirstMag3;
Real_st404[i11] = Real_st404[j3];
Im_st414[j3] = SecondMag3;
Im_st414[i11] = Im_st414[j3];
temp_2944 = (CorrelationFFTLength_st384 / 2);
}
fft5(Real_st404, Im_st414, CorrelationLogLength_st398, 1);
temp_3212 = Real_st404[0];
temp_3222 = (double ) temp_3212;
temp_3202 = (temp_3222 <= 0.00000000000000e+00);
if ((temp_3202 == 0))
{
/** temp_320 = (Real_st40[0] < Real_st40[1]) **/
temp_3232 = Real_st404[0];
temp_3242 = Real_st404[1];
temp_3203 = (temp_3232 < temp_3242);
}
temp_3192 = temp_3204;
if ((temp_3192 == 0))
{
/** temp_319 = (Real_st40[0] < Real_st40[2]) **/
temp_3252 = Real_st404[0];
temp_3262 = Real_st404[2];
temp_3193 = (temp_3252 < temp_3262);
}
if ((temp_3194 != 0))
{
FirstScale2 = 0.00000000000000e+00;
}
else
{
temp_3282 = Real_st404[0];
temp_3292 = (double ) temp_3282;
temp_3302 = (double ) Normalization;
temp_3273 = pow(temp_3292, temp_3302);
temp_3312 = (1.00000000000000e+00 / temp_3273);
FirstScale3 = (float ) temp_3312;
}
temp_3342 = Im_st414[0];
temp_3352 = (double ) temp_3342;
temp_3332 = (temp_3352 <= 0.00000000000000e+00);
if ((temp_3332 == 0))
{
/** temp_333 = (Im_st41[0] < Im_st41[1]) **/
temp_3362 = Im_st414[0];
temp_3372 = Im_st414[1];
temp_3333 = (temp_3362 < temp_3372);
}
temp_3322 = temp_3334;
if ((temp_3322 == 0))
{
/** temp_332 = (Im_st41[0] < Im_st41[2]) **/
temp_3382 = Im_st414[0];
temp_3392 = Im_st414[2];
temp_3323 = (temp_3382 < temp_3392);
}
if ((temp_3324 != 0))
{
SecondScale2 = 0.00000000000000e+00;
}
else
{
temp_3412 = Im_st414[0];
temp_3422 = (double ) temp_3412;
temp_3432 = (double ) Normalization;
temp_3403 = pow(temp_3422, temp_3432);
temp_3442 = (1.00000000000000e+00 / temp_3403);
SecondScale3 = (float ) temp_3442;
}
for ( i14 = 0 ; (i15 < Lags1) ; i16 = (i15 + 1) )
{
temp_3473 = (long ) Channel2;
temp_3483 = (long ) Lags1;
temp_3463 = (temp_3473 * temp_3483);
temp_3493 = (long ) i15;
temp_3453 = (temp_3463 + temp_3493);
temp_3503 = Real_st404[i15];
_U_Output_71[temp_3453] = (temp_3503 * FirstScale4);
temp_3533 = (Channel2 + 1);
temp_3543 = (long ) temp_3533;
temp_3553 = (long ) Lags1;
temp_3523 = (temp_3543 * temp_3553);
temp_3563 = (long ) i15;
temp_3513 = (temp_3523 + temp_3563);
temp_3573 = Im_st414[i15];
_U_Output_71[temp_3513] = (temp_3573 * SecondScale4);
}
}
temp_3591 = (float ) CorrelationLags;
temp_3581 = (temp_3591 * AgcStage4Target);
temp_3601 = (temp_3581 * AgcStage4Target);
temp_3611 = (double ) temp_3601;
temp_3621 = (temp_3611 * 1.25000000000000e-01);
max2 = (float ) temp_3621;
temp_3631 = (double ) max2;
temp_3651 = (double ) max2;
temp_3661 = (double ) Normalization;
temp_3642 = pow(temp_3651, temp_3661);
temp_3671 = (temp_3631 / temp_3642);
max3 = (float ) temp_3671;
return (max3);
}
float HartleyCorrelation(
float *_U_Output_8,
int Lags)
{
local vars
Max = 0.00000000000000e+00;
Hamming = MakeHamming2(CorrelationDataLength_st36);
for ( Channel = 0 ; (Channel < CorrelationChannels_st34) ; Channel = (Channel + 1) )
{
for ( i = 0 ; (i < CorrelationDataLength_st36) ; i = (i + 1) )
{
temp_371 = (long ) Channel;
temp_372 = (long ) CorrelationDataLength_st36;
temp_370 = (temp_371 * temp_372);
temp_375 = (long ) i;
temp_374 = (CorrelationIndex_st35 + temp_375);
temp_376 = (long ) CorrelationDataLength_st36;
temp_373 = (temp_374 % temp_376);
temp_369 = (temp_370 + temp_373);
temp_368 = CorrelationData_st33[temp_369];
temp_377 = Hamming[i];
Real_st40[i] = (temp_368 * temp_377);
temp_378 = (CorrelationFFTLength_st38 - i);
Real_st40[temp_378] = 0.00000000000000e+00;
temp_379 = (CorrelationFFTLength_st38 - i);
Im_st41[temp_379] = 0.00000000000000e+00;
Im_st41[i] = Im_st41[temp_379];
}
temp_380 = (CorrelationFFTLength_st38 / 2);
for ( i = CorrelationDataLength_st36 ; (i <= temp_380) ; i = (i + 1) )
{
Im_st41[i] = 0.00000000000000e+00;
Real_st40[i] = Im_st41[i];
temp_381 = (CorrelationFFTLength_st38 - i);
Real_st40[temp_381] = 0.00000000000000e+00;
temp_382 = (CorrelationFFTLength_st38 - i);
Im_st41[temp_382] = 0.00000000000000e+00;
temp_380 = (CorrelationFFTLength_st38 / 2);
}
fft3(Real_st40, Im_st41, CorrelationLogLength_st39, 0);
Real_st40[CorrelationFFTLength_st38] = Real_st40[0];
Im_st41[CorrelationFFTLength_st38] = Im_st41[0];
for ( i = 0 ; (i < CorrelationFFTLength_st38) ; i = (i + 1) )
{
FirstReal = Real_st40[i];
FirstIm = Im_st41[i];
temp_383 = (FirstReal * FirstReal);
temp_384 = (FirstIm * FirstIm);
Real_st40[i] = (temp_383 + temp_384);
Im_st41[i] = 0.00000000000000e+00;
}
fft4(Real_st40, Im_st41, CorrelationLogLength_st39, 1);
temp_387 = Real_st40[0];
temp_388 = (double ) temp_387;
temp_386 = (temp_388 <= 0.00000000000000e+00);
if ((temp_386 == 0))
{
/** temp_386 = (Real_st40[0] < Real_st40[1]) **/
temp_389 = Real_st40[0];
temp_390 = Real_st40[1];
temp_386 = (temp_389 < temp_390);
}
temp_385 = temp_386;
if ((temp_385 == 0))
{
/** temp_385 = (Real_st40[0] < Real_st40[2]) **/
temp_391 = Real_st40[0];
temp_392 = Real_st40[2];
temp_385 = (temp_391 < temp_392);
}
if ((temp_385 != 0))
{
Scaling = 0.00000000000000e+00;
}
else
{
temp_394 = Real_st40[0];
temp_395 = (double ) temp_394;
temp_396 = (double ) Normalization;
temp_393 = pow(temp_395, temp_396);
temp_397 = (1.00000000000000e+00 / temp_393);
Scaling = (float ) temp_397;
}
for ( i = 0 ; (i < Lags) ; i = (i + 1) )
{
temp_400 = (long ) Channel;
temp_401 = (long ) Lags;
temp_399 = (temp_400 * temp_401);
temp_402 = (long ) i;
temp_398 = (temp_399 + temp_402);
temp_403 = Real_st40[i];
_U_Output_8[temp_398] = (temp_403 * Scaling);
}
}
temp_405 = (float ) CorrelationLags;
temp_404 = (temp_405 * AgcStage4Target);
temp_406 = (temp_404 * AgcStage4Target);
temp_407 = (double ) temp_406;
temp_408 = (temp_407 * 1.25000000000000e-01);
Max = (float ) temp_408;
temp_409 = (double ) Max;
temp_411 = (double ) Max;
temp_412 = (double ) Normalization;
temp_410 = pow(temp_411, temp_412);
temp_413 = (temp_409 / temp_410);
Max = (float ) temp_413;
return (Max);
}
float EarCorrelation(
float *_U_Output_9,
int Lags)
{
local vars
Max2 = FFTCorrelation1(_U_Output_91, Lags1);
if ((UseUltra5 != 0))
{
Min1 = 0.00000000000000e+00;
temp_4141 = (double ) Max2;
UpdateDisplay2(_U_Output_91, Lags1, CorrelationChannels_st345, 0.00000000000000e+00, temp_4141);
}
return (Max2);
}
int StretchDisplay(
float *data,
int lags,
int channels)
{
local vars
if ((StretchStarted_st51 == 0))
{
temp_416 = (unsigned int ) lags;
temp_415 = (4 * temp_416);
temp_417 = malloc(temp_415);
index_st46 = (int *) temp_417;
temp_419 = (unsigned int ) lags;
temp_418 = (4 * temp_419);
temp_420 = malloc(temp_418);
warp_st47 = (float *) temp_420;
temp_422 = (unsigned int ) lags;
temp_421 = (4 * temp_422);
temp_423 = malloc(temp_421);
frac_st48 = (float *) temp_423;
temp_425 = (unsigned int ) lags;
temp_424 = (4 * temp_425);
temp_426 = malloc(temp_424);
frac1_st49 = (float *) temp_426;
temp_428 = (unsigned int ) lags;
temp_427 = (4 * temp_428);
temp_429 = malloc(temp_427);
newd_st50 = (float *) temp_429;
for ( i = 0 ; (i < lags) ; i = (i + 1) )
{
temp_431 = (lags - 1);
temp_432 = (double ) temp_431;
temp_434 = (float ) lags;
temp_435 = (double ) temp_434;
temp_433 = pow(temp_435, 2.71800000000000e+00);
temp_430 = (temp_432 / temp_433);
temp_437 = (float ) i;
temp_438 = (double ) temp_437;
temp_436 = pow(temp_438, 2.71800000000000e+00);
temp_439 = (temp_430 * temp_436);
warp_st47[i] = (float ) temp_439;
temp_440 = warp_st47[i];
temp_441 = (double ) temp_440;
temp_442 = floor(temp_441);
index_st46[i] = (int ) temp_442;
temp_443 = warp_st47[i];
temp_444 = index_st46[i];
temp_445 = (float ) temp_444;
frac_st48[i] = (temp_443 - temp_445);
temp_446 = frac_st48[i];
frac1_st49[i] = (1.00000000000000e+00 - temp_446);
temp_447 = "warp.d";
picout1(temp_447, warp_st47, lags);
}
StretchStarted_st51 = 1;
}
for ( j = 0 ; (j < channels) ; j = (j + 1) )
{
temp_448 = (j * lags);
row = (&data[temp_448]);
for ( i = 0 ; (i < lags) ; i = (i + 1) )
{
/** newd_st50[i] = ((row[index_st46[(i + 1)]] * frac1_st49[(i + 1)]) + (row[(index_st46[(i + 1)] + 1)] * frac_st48[(i + 1)])) **/
temp_452 = (i + 1);
temp_451 = index_st46[temp_452];
temp_450 = row[temp_451];
temp_454 = (i + 1);
temp_453 = frac1_st49[temp_454];
temp_449 = (temp_450 * temp_453);
temp_459 = (i + 1);
temp_458 = index_st46[temp_459];
temp_457 = (temp_458 + 1);
temp_456 = row[temp_457];
temp_461 = (i + 1);
temp_460 = frac_st48[temp_461];
temp_455 = (temp_456 * temp_460);
newd_st50[i] = (temp_449 + temp_455);
}
for ( i = 0 ; (i < lags) ; i = (i + 1) )
{
row[i] = newd_st50[i];
}
}
}
void _mccat_main()
{
local vars
_sl_difference_initialized_11 = 0;
temp_15481 = (char *) "$Header: animate.c,v 2.0.1.1 89/08/10 22:30:05 malcolm Exp $";
RCSid_st02 = (char *) temp_15481;
buf1 = 0;
temp_15491 = (char *) "$Header: comm.c,v 2.0 89/07/25 18:58:09 malcolm Exp $";
RCSid_st102 = (char *) temp_15491;
temp_15501 = (char *) "$Header: complex.c,SPEC v 1.0 $";
RCSid_st112 = (char *) temp_15501;
temp_15511 = (char *) "$Header: correlate.c, SPEC v 1.0 $";
RCSid_st222 = (char *) temp_15511;
CorrelationData_st332 = 0;
CorrelationChannels_st342 = 0;
CorrelationIndex_st353 = 0;
CorrelationDataLength_st362 = 0;
CorrelationDataCount_st374 = 0;
CorrelationFFTLength_st382 = 0;
CorrelationLogLength_st396 = 0;
HammingWindow_st428 = 0;
HammingLength_st435 = 0;
CompensatorWindow_st441 = 0;
CompensatorLength_st451 = 0.00000000000000e+00;
StretchStarted_st511 = 0;
temp_15521 = (char *) "$Header: ear.c, SPEC v 1.0 $";
RCSid_st522 = (char *) temp_15521;
temp_15531 = (char *) "$Header: eardesign.c,SPEC v 1.0 $";
RCSid_st642 = (char *) temp_15531;
temp_15541 = (char *) "$Header: earfilters.c,SPEC v 1.0 $";
RCSid_st772 = (char *) temp_15541;
Debug1 = 0;
printflag1 = 1;
ImpulseInput1 = 0;
UseAgc1 = 1;
UseCascade1 = 1;
UseDifference1 = 1;
CalculateResponse1 = 0;
ComputeFiltered1 = 0;
UseUltra2 = 0;
CPUs1 = 4;
VideoRecord1 = 0;
temp_15551 = (char *) "data.adc";
ifn2 = (char *) temp_15551;
temp_15561 = (char *) "cochlea.pic";
ofn2 = (char *) temp_15561;
ffn1 = 0;
cfn1 = 0;
sample_rate1 = 1.60000000000000e+04;
MaxSamples1 = -1;
AgcStage1Tau1 = 6.40000000000000e-01;
AgcStage2Tau1 = 1.60000000000000e-01;
AgcStage3Tau1 = 4.00000000000000e-02;
AgcStage4Tau1 = 1.00000000000000e-02;
AgcStage1Target1 = 3.20000000000000e-03;
AgcStage2Target1 = 1.60000000000000e-03;
AgcStage3Target1 = 8.00000000000000e-04;
AgcStage4Target1 = 4.00000000000000e-04;
DecimationFactor1 = 20;
CorrelationStep1 = 128;
CorrelationLags1 = 256;
TauFactor1 = 3.00000000000000e+00;
Normalization1 = 7.50000000000000e-01;
UltraHeadroom1 = 1.00000000000000e+00;
ImpulseHeight1 = 1.00000000000000e-01;
ImpulseZero1 = 0.00000000000000e+00;
EarBreakFreq1 = 1.00000000000000e+03;
EarQ1 = 8.00000000000000e+00;
EarStepFactor1 = 2.50000000000000e-01;
EarSharpness1 = 5.00000000000000e+00;
EarZeroOffset1 = 1.50000000000000e+00;
EarPreemphCorner1 = 3.00000000000000e+02;
EarLength1 = 128;
SampleNumber1 = 0;
temp_15571 = (char *) "$Header: fft.c, SPEC v 1.0 $";
RCSid_st872 = (char *) temp_15571;
fftzero1 = 0.00000000000000e+00;
temp_15581 = (char *) "$Header: file.c, SPEC v 1.0 $";
RCSid_st972 = (char *) temp_15581;
temp_15591 = (char *) "$Header: output.c, SPEC v 1.0 $";
RCSid_st992 = (char *) temp_15591;
ofp_st1012 = 0;
LineCount_st1021 = 0;
LineLength_st1031 = 0;
temp_15601 = (char *) "";
FileName_st1042 = (char *) temp_15601;
temp_15611 = (char *) "$Header: picout.c, SPEC v 1.0 $";
RCSid_st1052 = (char *) temp_15611;
temp_15621 = (char *) "$Header: utilities.c, SPEC v 1.0 $";
RCSid_st1062 = (char *) temp_15621;
temp_15631 = (char *) "if";
ArgumentTable2[0] = (char *) temp_15631;
temp_15641 = (char *) "of";
ArgumentTable3[1] = (char *) temp_15641;
temp_15651 = (char *) "tau1";
ArgumentTable4[2] = (char *) temp_15651;
temp_15661 = (char *) "tau2";
ArgumentTable5[3] = (char *) temp_15661;
temp_15671 = (char *) "tau3";
ArgumentTable6[4] = (char *) temp_15671;
temp_15681 = (char *) "tau4";
ArgumentTable7[5] = (char *) temp_15681;
temp_15691 = (char *) "target1";
ArgumentTable8[6] = (char *) temp_15691;
temp_15701 = (char *) "target2";
ArgumentTable9[7] = (char *) temp_15701;
temp_15711 = (char *) "target3";
ArgumentTable10[8] = (char *) temp_15711;
temp_15721 = (char *) "target4";
ArgumentTable11[9] = (char *) temp_15721;
temp_15731 = (char *) "taufactor";
ArgumentTable12[10] = (char *) temp_15731;
temp_15741 = (char *) "df";
ArgumentTable13[11] = (char *) temp_15741;
temp_15751 = (char *) "breakf";
ArgumentTable14[12] = (char *) temp_15751;
temp_15761 = (char *) "earq";
ArgumentTable15[13] = (char *) temp_15761;
temp_15771 = (char *) "stepfactor";
ArgumentTable16[14] = (char *) temp_15771;
temp_15781 = (char *) "sharpness";
ArgumentTable17[15] = (char *) temp_15781;
temp_15791 = (char *) "offset";
ArgumentTable18[16] = (char *) temp_15791;
temp_15801 = (char *) "preemph";
ArgumentTable19[17] = (char *) temp_15801;
temp_15811 = (char *) "ff";
ArgumentTable20[18] = (char *) temp_15811;
temp_15821 = (char *) "cf";
ArgumentTable21[19] = (char *) temp_15821;
temp_15831 = (char *) "cstep";
ArgumentTable22[20] = (char *) temp_15831;
temp_15841 = (char *) "clag";
ArgumentTable23[21] = (char *) temp_15841;
temp_15851 = (char *) "cpus";
ArgumentTable24[22] = (char *) temp_15851;
temp_15861 = (char *) "normalize";
ArgumentTable25[23] = (char *) temp_15861;
temp_15871 = (char *) "umax";
ArgumentTable26[24] = (char *) temp_15871;
temp_15881 = (char *) "maxsamples";
ArgumentTable27[25] = (char *) temp_15881;
ArgumentTable28[26] = 0;
}
int main(
int argc,
char **argv)
{
local vars
_mccat_main1();
progname2 = (*argv1);
argv1 = (argv1 + 1);
argc1 = (argc1 - 1);
while ( (argc2 != 0) )
{
temp_4622 = (*argv2);
temp_4632 = (*temp_4622);
temp_4642 = (char ) temp_4632;
if ((temp_4642 == 63))
{
syntax2();
}
temp_4672 = (*argv2);
temp_4682 = (*temp_4672);
temp_4692 = (char ) temp_4682;
temp_4662 = (temp_4692 == 45);
if ((temp_4662 == 0))
{
/** temp_466 = ((char ) (*(*argv)) == 43) **/
temp_4702 = (*argv2);
temp_4712 = (*temp_4702);
temp_4722 = (char ) temp_4712;
temp_4663 = (temp_4722 == 43);
}
temp_4652 = temp_4664;
if ((temp_4652 != 0))
{
/** temp_465 = ((char ) argv[0][1] != 0) **/
temp_4732 = argv2[0][1];
temp_4742 = (char ) temp_4732;
temp_4653 = (temp_4742 != 0);
}
if ((temp_4654 != 0))
{
temp_4752 = (*argv2);
ProcessOption3(temp_4752);
}
else
{
temp_4762 = (*argv2);
ProcessArgument4(temp_4762);
}
argc3 = (argc2 - 1);
argv3 = (argv2 + 1);
}
if ((ffn6 != 0))
{
temp_4771 = "w";
ffp3 = fopen5(ffn6, temp_4771);
if ((ffp3 == 0))
{
temp_4781 = (&_iob[2]);
temp_4791 = "%s: Can't open %s for writing filtered data.\n";
temp_4801 = argv4[0];
fprintf6(temp_4781, temp_4791, temp_4801);
exit(1);
}
}
if ((printflag6 != 0))
{
PrintStats7();
}
OpenOutputFile8(ofn7);
if ((ImpulseInput6 != 0))
{
DataLength1 = 512;
temp_4812 = calloc(DataLength1, 4);
Data1 = (float *) temp_4812;
Data1[0] = 1.00000000000000e-01;
}
else
{
temp_4821 = (&sample_rate);
temp_4831 = (&DataLength);
Data3 = ReadInputFile9(ifn7, temp_4821, temp_4831);
}
ChangeDecimationParameters10();
ChangeAgcParams11();
DesignEarFilters12();
if ((CalculateResponse6 != 0))
{
temp_4841 = (256 * EarLength3);
temp_4852 = calloc(temp_4841, 4);
OutputArray1 = (float *) temp_4852;
if ((OutputArray1 == 0))
{
temp_4861 = (&_iob[2]);
temp_4871 = "%s: Couldn't allocate %d floats for OutputArray.\n";
temp_4881 = (256 * EarLength3);
fprintf13(temp_4861, temp_4871, progname2, temp_4881);
exit(1);
}
temp_4892 = calloc(256, 4);
Hamming1 = (float *) temp_4892;
if ((Hamming1 == 0))
{
temp_4901 = (&_iob[2]);
temp_4911 = "%s: Couldn't allocate %d bytes for Hamming.\n";
fprintf14(temp_4901, temp_4911, progname2, 256);
exit(1);
}
for ( i1 = 0 ; (i2 <= 255) ; i3 = (i2 + 1) )
{
/** Hamming[i] = (float ) (5.40000000000000e-01 + (4.60000000000000e-01 * cos((((6.28318530717958e+00 * ((float)i)) / 2.00000000000000e+00) / 2.56000000000000e+02)))) **/
temp_4972 = (double ) i2;
temp_4962 = (6.28318530717958e+00 * temp_4972);
temp_4952 = (temp_4962 / 2.00000000000000e+00);
temp_4942 = (temp_4952 / 2.56000000000000e+02);
temp_4933 = cos(temp_4942);
temp_4922 = (4.60000000000000e-01 * temp_4933);
temp_4982 = (5.40000000000000e-01 + temp_4922);
Hamming1[i2] = (float ) temp_4982;
}
for ( i5 = 0 ; (i6 <= 255) ; i7 = (i6 + 1) )
{
if ((i6 == 0))
{
temp_4992 = (&ImpulseHeight);
}
else
{
temp_4993 = (&ImpulseZero);
}
temp_5002 = _sl_main_Output_0;
EARSTEP15(temp_4994, temp_5002);
for ( j2 = 0 ; (j3 < EarLength3) ; j4 = (j3 + 1) )
{
/** OutputArray[((i * (long ) EarLength) + (long ) j)] = _sl_main_Output_0[(j + 1)] **/
temp_5033 = (long ) EarLength3;
temp_5023 = (i6 * temp_5033);
temp_5043 = (long ) j3;
temp_5013 = (temp_5023 + temp_5043);
temp_5053 = (j3 + 1);
OutputArray1[temp_5013] = _sl_main_Output_02[temp_5053];
}
}
for ( j7 = 0 ; (j8 < EarLength3) ; j9 = (j8 + 1) )
{
temp_5063 = calloc(513, 4);
real2 = (float *) temp_5063;
temp_5073 = calloc(513, 4);
im2 = (float *) temp_5073;
temp_5082 = (real2 == 0);
if ((temp_5082 == 0))
{
temp_5083 = (im2 == 0);
}
if ((temp_5084 != 0))
{
temp_5092 = (&_iob[2]);
temp_5102 = "%s: Can't allocate temporary space for fft arrays.\n";
fprintf16(temp_5092, temp_5102, progname2);
exit(1);
}
for ( i10 = 0 ; (i11 <= 255) ; i12 = (i11 + 1) )
{
temp_5113 = Hamming1[i11];
temp_5153 = (long ) EarLength3;
temp_5143 = (i11 * temp_5153);
temp_5163 = (long ) j8;
temp_5133 = (temp_5143 + temp_5163);
temp_5123 = OutputArray1[temp_5133];
real2[i11] = (temp_5113 * temp_5123);
temp_5173 = (512 - i11);
im2[temp_5173] = 0.00000000000000e+00;
im2[i11] = im2[temp_5173];
temp_5183 = (512 - i11);
real2[temp_5183] = 0.00000000000000e+00;
}
fft17(real2, im2, 9, 0);
for ( i14 = 0 ; (i15 <= 255) ; i16 = (i15 + 1) )
{
temp_5193 = real2[i15];
temp_5203 = (double ) temp_5193;
temp_5213 = (temp_5203 / 1.00000000000000e-01);
realpart3 = (float ) temp_5213;
temp_5223 = im2[i15];
temp_5233 = (double ) temp_5223;
temp_5243 = (temp_5233 / 1.00000000000000e-01);
impart3 = (float ) temp_5243;
temp_5273 = (long ) EarLength3;
temp_5263 = (i15 * temp_5273);
temp_5283 = (long ) j8;
temp_5253 = (temp_5263 + temp_5283);
temp_5313 = (realpart3 * realpart3);
temp_5323 = (impart3 * impart3);
temp_5333 = (temp_5313 + temp_5323);
temp_5343 = (double ) temp_5333;
temp_5303 = (temp_5343 + 1.00000000000000e-20);
temp_5294 = log(temp_5303);
temp_5353 = (-1.00000000000000e+01 * temp_5294);
OutputArray1[temp_5253] = (float ) temp_5353;
}
}
temp_5361 = (256 * EarLength3);
fwrite18(OutputArray1, 4, temp_5361, ofp1);
temp_5371 = "Image (%s) is %dx%d.\n";
printf(temp_5371, ofn7, EarLength3, 256);
}
else
{
LineCount1 = 0;
CorrelationLineCount1 = 0;
CorrelationPictureCount1 = 0;
CorrelationOutput1 = 0;
CorrelationZero1 = 0;
temp_5381 = (cfn6 != 0);
if ((temp_5381 == 0))
{
temp_5382 = (UseUltra7 != 0);
}
if ((temp_5383 != 0))
{
temp_5391 = (EarLength3 - 2);
temp_5401 = (2 * CorrelationLags6);
InitCorrelation19(temp_5391, temp_5401);
temp_5411 = (EarLength3 + 10);
temp_5421 = (long ) temp_5411;
temp_5431 = (long ) CorrelationLags6;
CorrelationOutputSize1 = (temp_5421 * temp_5431);
temp_5451 = (unsigned long ) CorrelationOutputSize1;
temp_5441 = (temp_5451 * 4);
temp_5462 = malloc(temp_5441);
CorrelationOutput2 = (float *) temp_5462;
if ((CorrelationOutput2 == 0))
{
temp_5471 = (&_iob[2]);
temp_5481 = "%s: Couldn't get %ld bytes for correlation output.\n";
temp_5491 = argv4[0];
fprintf20(temp_5471, temp_5481, temp_5491, CorrelationOutputSize1);
exit(2);
}
}
for ( i19 = 0 ; (i20 < DataLength3) ; i21 = (i20 + 1) )
{
SampleNumber4 = (int ) i20;
temp_5502 = (&Data4[i20]);
temp_5512 = _sl_main_Output_0;
EARSTEP21(temp_5502, temp_5512);
temp_5522 = (DecimationFactor7 == 0);
if ((temp_5522 == 0))
{
/** temp_552 = ((i % (long ) DecimationFactor) == 0) **/
temp_5542 = (long ) DecimationFactor7;
temp_5532 = (i20 % temp_5542);
temp_5523 = (temp_5532 == 0);
}
if ((temp_5524 != 0))
{
temp_5562 = _sl_main_Output_0;
temp_5552 = (temp_5562 + 2);
temp_5572 = (EarLength3 - 2);
WriteOutputFile22(temp_5552, temp_5572);
}
temp_5582 = (cfn6 != 0);
if ((temp_5582 == 0))
{
temp_5583 = (UseUltra7 != 0);
}
if ((temp_5584 != 0))
{
/** SendInputToCorrelation((_sl_main_Output_0 + 2)) **/
temp_5602 = _sl_main_Output_0;
temp_5592 = (temp_5602 + 2);
SendInputToCorrelation23(temp_5592);
}
temp_5632 = (cfn6 != 0);
if ((temp_5632 == 0))
{
temp_5633 = (UseUltra7 != 0);
}
temp_5622 = temp_5634;
if ((temp_5622 != 0))
{
temp_5623 = (i20 != 0);
}
temp_5612 = temp_5624;
if ((temp_5612 != 0))
{
/** temp_561 = ((i % (long ) CorrelationStep) == 0) **/
temp_5652 = (long ) CorrelationStep6;
temp_5642 = (i20 % temp_5652);
temp_5613 = (temp_5642 == 0);
}
if ((temp_5614 != 0))
{
Max3 = EarCorrelation24(CorrelationOutput3, CorrelationLags6);
if ((VideoRecord6 != 0))
{
RecordVideo25();
}
if ((cfn6 != 0))
{
temp_5662 = Name;
temp_5672 = "%s%05ld(%dx%d)";
temp_5682 = (EarLength3 - 2);
sprintf26(temp_5662, temp_5672, cfn6, i20, CorrelationLags6, temp_5682);
temp_5692 = Name;
temp_5712 = (EarLength3 - 2);
temp_5722 = (long ) temp_5712;
temp_5732 = (long ) CorrelationLags6;
temp_5702 = (temp_5722 * temp_5732);
picout27(temp_5692, CorrelationOutput3, temp_5702);
}
CorrelationPictureCount3 = (CorrelationPictureCount2 + 1);
}
}
if ((UseUltra7 == 0))
{
if ((cfn6 != 0))
{
temp_5741 = "Correlagram (%s) is %dx%dx%d.\n";
temp_5751 = (EarLength3 - 2);
printf(temp_5741, cfn6, CorrelationLags6, temp_5751, CorrelationPictureCount5);
}
}
}
CloseOutputFile28();
if ((ffp4 != 0))
{
fclose(ffp4);
}
temp_5761 = "err.out";
temp_5771 = "w";
fp2 = fopen29(temp_5761, temp_5771);
if ((fp2 == 0))
{
temp_5781 = (&_iob[2]);
temp_5791 = "Error opening err.out file\n";
fprintf30(temp_5781, temp_5791);
exit(99);
}
for ( i24 = 0 ; (i25 <= 127) ; i26 = (i25 + 1) )
{
/** fprintf(fp, "\t%10.5E\n", _sl_main_Output_0[i]) **/
temp_5802 = "\t%10.5E\n";
temp_5812 = _sl_main_Output_07[i25];
temp_5822 = (double ) temp_5812;
fprintf31(fp2, temp_5802, temp_5822);
}
fclose(fp2);
}
int RecordVideo()
{
}
int RunRealTime()
{
}
struct polynomial *AllocatePolynomial(
int order)
{
local vars
temp_5832 = calloc(1, 8);
pp1 = (struct polynomial *) temp_5832;
if ((pp1 == 0))
{
temp_5841 = (&_iob[2]);
temp_5851 = "AllocatePolynomial: Couldn't allocate polynomial structure.\n";
fprintf1(temp_5841, temp_5851);
exit(1);
}
(*pp1).order = order1;
temp_5861 = (order1 + 1);
temp_5872 = calloc(temp_5861, 4);
(*pp1).coeff = (float *) temp_5872;
temp_5881 = (*pp1).coeff;
if ((temp_5881 == 0))
{
temp_5891 = (&_iob[2]);
temp_5901 = "AllocatePolynomial: Couldn't allocate space for polynomial list.\n";
fprintf2(temp_5891, temp_5901);
exit(1);
}
temp_5911 = (*pp1).coeff;
temp_5911[order1] = 1.00000000000000e+00;
return (pp1);
}
int PrintPolynomial(
struct polynomial *pp)
{
local vars
if ((pp != 0))
{
i = 0;
temp_593 = (*pp).order;
for ( temp_592 = (temp_593 + 1) ; (i < temp_592) ; temp_592 = (temp_593 + 1) )
{
temp_594 = (i == 0);
if ((temp_594 == 0))
{
/** temp_594 = ((double ) (*pp).coeff[i] != 1.00000000000000e+00) **/
temp_595 = (*pp).coeff;
temp_596 = temp_595[i];
temp_597 = (double ) temp_596;
temp_594 = (temp_597 != 1.00000000000000e+00);
}
if ((temp_594 != 0))
{
/** printf("%g", (*pp).coeff[i]) **/
temp_598 = "%g";
temp_599 = (*pp).coeff;
temp_600 = temp_599[i];
temp_601 = (double ) temp_600;
printf(temp_598, temp_601);
}
if ((i == 1))
{
/** printf("z") **/
temp_602 = "z";
printf(temp_602);
}
else
{
if ((i > 1))
{
/** printf("z**%d", i) **/
temp_603 = "z**%d";
printf(temp_603, i);
}
}
temp_604 = (*pp).order;
if ((i != temp_604))
{
/** printf(" + ") **/
temp_605 = " + ";
printf(temp_605);
}
i = (i + 1);
temp_593 = (*pp).order;
}
}
else
{
/** printf("1") **/
temp_606 = "1";
printf(temp_606);
}
}
complex_st75 PolyEval(
struct polynomial *pp,
complex_st75 x)
{
local vars
if ((pp1 == 0))
{
/** cmplx(1.00000000000000e+00, 0.00000000000000e+00) **/
temp_6072 = cmplx1(1.00000000000000e+00, 0.00000000000000e+00);
return (temp_6072);
}
xpow2 = cmplx2(1.00000000000000e+00, 0.00000000000000e+00);
y2 = cmplx3(0.00000000000000e+00, 0.00000000000000e+00);
i1 = 0;
temp_6091 = (*pp1).order;
for ( temp_6081 = (temp_6091 + 1) ; (i2 < temp_6082) ; temp_6083 = (temp_6093 + 1) )
{
temp_6122 = (*pp1).coeff;
temp_6132 = temp_6122[i2];
temp_6142 = (double ) temp_6132;
temp_6113 = cmplx4(temp_6142, 0.00000000000000e+00);
temp_6103 = cmul5(xpow3, temp_6113);
y5 = cadd6(y3, temp_6103);
xpow5 = cmul7(xpow3, x1);
i3 = (i2 + 1);
temp_6093 = (*pp1).order;
}
return (y6);
}
struct filter *MakeFilter(
struct polynomial *forward,
struct polynomial *feedback,
float fsamp,
float freq,
float gain)
{
local vars
temp_6152 = calloc(1, 20);
fp1 = (struct filter *) temp_6152;
if ((fp1 == 0))
{
temp_6161 = (&_iob[2]);
temp_6171 = ": Couldn't allocate coefficient structure.\n";
fprintf1(temp_6161, temp_6171);
exit(1);
}
if ((forward1 != 0))
{
(*fp1).forward = forward1;
}
else
{
/** (*fp).forward = (forward = AllocatePolynomial(0)) **/
forward3 = AllocatePolynomial2(0);
(*fp1).forward = forward3;
}
if ((feedback1 != 0))
{
(*fp1).feedback = feedback1;
}
else
{
/** (*fp).feedback = (feedback = AllocatePolynomial(0)) **/
feedback3 = AllocatePolynomial3(0);
(*fp1).feedback = feedback3;
}
(*fp1).sample_rate = fsamp1;
(*fp1).gain = gain1;
(*fp1).freq = freq1;
temp_6201 = (*fp1).freq;
temp_6211 = (double ) temp_6201;
temp_6192 = FilterGain4(fp1, temp_6211);
temp_6182 = cmag5(temp_6192);
gain1 = (gain1 / temp_6182);
i1 = 0;
temp_6231 = (*forward4).order;
for ( temp_6221 = (temp_6231 + 1) ; (i2 < temp_6222) ; temp_6223 = (temp_6233 + 1) )
{
temp_6262 = (*forward4).coeff;
temp_6252 = (temp_6262 + i2);
temp_6242 = temp_6252;
temp_6272 = (*temp_6242);
(*temp_6242) = (temp_6272 * gain1);
i3 = (i2 + 1);
temp_6233 = (*forward4).order;
}
return (fp1);
}
complex_st75 FilterEval(
struct filter *fp,
complex_st75 z)
{
local vars
temp_6281 = (*fp1).forward;
a2 = PolyEval1(temp_6281, z1);
temp_6291 = (*fp1).feedback;
b2 = PolyEval2(temp_6291, z1);
temp_6302 = cdiv3(a2, b2);
return (temp_6302);
}
complex_st75 FilterGain(
struct filter *fp,
float freq)
{
local vars
temp_6351 = (double ) freq1;
temp_6341 = (6.28318530717958e+00 * temp_6351);
temp_6361 = (*fp1).sample_rate;
temp_6371 = (double ) temp_6361;
temp_6331 = (temp_6341 / temp_6371);
temp_6322 = cis1(temp_6331);
temp_6312 = FilterEval2(fp1, temp_6322);
return (temp_6312);
}
float FilterNumeratorCoeff(
struct filter *fp,
int i)
{
local vars
pp1 = (*fp1).forward;
temp_6381 = (*pp1).order;
if ((i1 <= temp_6381))
{
/** (*pp).coeff[i] **/
temp_6401 = (*pp1).coeff;
temp_6391 = temp_6401[i1];
return (temp_6391);
}
else
{
return (0.00000000000000e+00);
}
}
float FilterDenominatorCoeff(
struct filter *fp,
int i)
{
local vars
pp1 = (*fp1).feedback;
temp_6411 = (*pp1).order;
if ((i1 <= temp_6411))
{
/** (*pp).coeff[i] **/
temp_6431 = (*pp1).coeff;
temp_6421 = temp_6431[i1];
return (temp_6421);
}
else
{
return (0.00000000000000e+00);
}
}
int PrintFilter(
struct filter *fp)
{
local vars
temp_644 = "\t";
printf(temp_644);
temp_645 = (*fp).forward;
PrintPolynomial1(temp_645);
temp_646 = " / ";
printf(temp_646);
temp_647 = (*fp).feedback;
PrintPolynomial2(temp_647);
temp_648 = "\n";
printf(temp_648);
temp_649 = "\tSampling rate of %g, desired gain is %g at %g hz.\n";
temp_650 = (*fp).sample_rate;
temp_651 = (double ) temp_650;
temp_652 = (*fp).gain;
temp_653 = (double ) temp_652;
temp_654 = (*fp).freq;
temp_655 = (double ) temp_654;
printf(temp_649, temp_651, temp_653, temp_655);
temp_657 = (*fp).freq;
temp_658 = (double ) temp_657;
temp_656 = FilterGain3(fp, temp_658);
gain = cmag4(temp_656);
temp_659 = "\tActual gain is %g at %g.\n";
temp_660 = (double ) gain;
temp_661 = (*fp).freq;
temp_662 = (double ) temp_661;
printf(temp_659, temp_660, temp_662);
}
float EarBandwidth(
float cf)
{
local vars
temp_6651 = (cf1 * cf1);
temp_6661 = (EarBreakFreq15 * EarBreakFreq15);
temp_6671 = (temp_6651 + temp_6661);
temp_6681 = (double ) temp_6671;
temp_6642 = sqrt(temp_6681);
temp_6691 = (double ) EarQ15;
temp_6631 = (temp_6642 / temp_6691);
return (temp_6631);
}
float CascadeZeroCF(
float cf)
{
local vars
temp_6741 = (double ) cf1;
temp_6732 = EarBandwidth1(temp_6741);
temp_6721 = (temp_6732 * EarStepFactor16);
temp_6711 = (temp_6721 * EarZeroOffset16);
temp_6701 = (cf1 + temp_6711);
return (temp_6701);
}
float CascadeZeroQ(
float cf)
{
local vars
temp_6781 = (double ) cf1;
temp_6772 = CascadeZeroCF1(temp_6781);
temp_6761 = (EarSharpness17 * temp_6772);
temp_6801 = (double ) cf1;
temp_6792 = EarBandwidth2(temp_6801);
temp_6751 = (temp_6761 / temp_6792);
return (temp_6751);
}
float CascadePoleCF(
float cf)
{
return (cf1);
}
float CascadePoleQ(
float cf)
{
local vars
temp_6831 = (double ) cf1;
temp_6822 = EarBandwidth1(temp_6831);
temp_6811 = (cf1 / temp_6822);
return (temp_6811);
}
float MaximumEarCF(
float fs)
{
local vars
temp_6841 = (double ) fs1;
temp_6851 = (temp_6841 / 2.00000000000000e+00);
topf1 = (float ) temp_6851;
temp_6901 = (double ) topf1;
temp_6892 = CascadeZeroCF1(temp_6901);
temp_6881 = (temp_6892 - topf1);
temp_6871 = (topf1 - temp_6881);
temp_6931 = (double ) topf1;
temp_6922 = EarBandwidth2(temp_6931);
temp_6911 = (temp_6922 * EarStepFactor20);
temp_6861 = (temp_6871 + temp_6911);
return (temp_6861);
}
float EarChannelCF(
int index,
float fs)
{
local vars
temp_6951 = (index1 >= 0);
if ((temp_6951 != 0))
{
temp_6952 = (index1 <= 255);
}
temp_6941 = temp_6953;
if ((temp_6941 != 0))
{
/** temp_694 = ((double ) EarChannelCFResults_st76[index] != 0.00000000000000e+00) **/
temp_6961 = EarChannelCFResults_st7616[index1];
temp_6971 = (double ) temp_6961;
temp_6942 = (temp_6971 != 0.00000000000000e+00);
}
if ((temp_6943 != 0))
{
/** EarChannelCFResults_st76[index] **/
temp_6981 = EarChannelCFResults_st7616[index1];
return (temp_6981);
}
if ((index1 == 0))
{
/** EarChannelCFResults_st76[index] = MaximumEarCF(fs) **/
temp_6991 = (double ) fs1;
EarChannelCFResults_st763[index1] = MaximumEarCF1(temp_6991);
temp_7001 = EarChannelCFResults_st763[index1];
return (temp_7001);
}
else
{
temp_7011 = (index1 - 1);
temp_7021 = (double ) fs1;
cf2 = EarChannelCF2(temp_7011, temp_7021);
temp_7051 = (double ) cf2;
temp_7042 = EarBandwidth3(temp_7051);
temp_7031 = (EarStepFactor21 * temp_7042);
result1 = (cf2 - temp_7031);
temp_7061 = (index1 >= 0);
if ((temp_7061 != 0))
{
temp_7062 = (index1 <= 255);
}
if ((temp_7063 != 0))
{
EarChannelCFResults_st765[index1] = result1;
}
return (result1);
}
}
float EpsilonFromTauFS(
float tau,
float fs)
{
local vars
temp_7111 = (double ) tau1;
temp_7101 = (-1.00000000000000e+00 / temp_7111);
temp_7121 = (double ) fs1;
temp_7091 = (temp_7101 / temp_7121);
temp_7082 = exp(temp_7091);
temp_7071 = (1.00000000000000e+00 - temp_7082);
return (temp_7071);
}
struct polynomial *FirstOrderFromTau(
float tau,
float fs)
{
local vars
pp = AllocatePolynomial2(1);
temp_713 = (*pp).coeff;
temp_714 = (double ) tau;
temp_715 = (double ) fs;
temp_716 = EpsilonFromTauFS3(temp_714, temp_715);
temp_717 = (double ) temp_716;
temp_718 = (temp_717 - 1.00000000000000e+00);
temp_713[0] = (float ) temp_718;
temp_719 = (*pp).coeff;
temp_719[1] = 1.00000000000000e+00;
return (pp);
}
struct polynomial *FirstOrderFromCorner(
float fc,
float fs)
{
local vars
pp2 = AllocatePolynomial2(1);
fct1 = (fc1 / fs1);
temp_7211 = (double ) fct1;
temp_7201 = (-6.28318530717958e+00 * temp_7211);
temp_7222 = exp(temp_7201);
rho1 = (float ) temp_7222;
temp_7231 = (*pp2).coeff;
temp_7231[0] = (-rho1);
temp_7241 = (*pp2).coeff;
temp_7241[1] = 1.00000000000000e+00;
return (pp2);
}
struct polynomial *SecondOrderFromCenterQ(
float NatFreq,
float q,
float fs)
{
local vars
pp2 = AllocatePolynomial2(2);
cft1 = (NatFreq1 / fs1);
temp_7271 = (double ) cft1;
temp_7261 = (-3.14159265358979e+00 * temp_7271);
temp_7281 = (double ) q1;
temp_7251 = (temp_7261 / temp_7281);
temp_7292 = exp(temp_7251);
rho1 = (float ) temp_7292;
temp_7311 = (double ) cft1;
temp_7301 = (6.28318530717958e+00 * temp_7311);
temp_7361 = (double ) q1;
temp_7351 = (2.50000000000000e-01 / temp_7361);
temp_7371 = (double ) q1;
temp_7341 = (temp_7351 / temp_7371);
temp_7331 = (1.00000000000000e+00 - temp_7341);
temp_7322 = sqrt(temp_7331);
temp_7381 = (temp_7301 * temp_7322);
theta1 = (float ) temp_7381;
temp_7391 = (*pp2).coeff;
temp_7391[0] = (rho1 * rho1);
temp_7401 = (*pp2).coeff;
temp_7421 = (double ) rho1;
temp_7411 = (-2.00000000000000e+00 * temp_7421);
temp_7441 = (double ) theta1;
temp_7432 = cos(temp_7441);
temp_7451 = (temp_7411 * temp_7432);
temp_7401[1] = (float ) temp_7451;
temp_7461 = (*pp2).coeff;
temp_7461[2] = 1.00000000000000e+00;
return (pp2);
}
struct filter *OuterMiddleEarFilter(
float fs)
{
local vars
temp_7481 = (double ) EarPreemphCorner25;
temp_7491 = (double ) fs1;
temp_7472 = FirstOrderFromCorner1(temp_7481, temp_7491);
temp_7501 = (double ) fs1;
temp_7521 = (double ) fs1;
temp_7511 = (temp_7521 / 4.00000000000000e+00);
fp2 = MakeFilter2(temp_7472, 0, temp_7501, temp_7511, 1.00000000000000e+00);
return (fp2);
}
struct filter *EarFrontFilter(
float fs)
{
local vars
pp2 = AllocatePolynomial1(2);
temp_7531 = (*pp2).coeff;
temp_7531[0] = -1.00000000000000e+00;
temp_7541 = (*pp2).coeff;
temp_7541[1] = 0.00000000000000e+00;
temp_7551 = (*pp2).coeff;
temp_7551[2] = 1.00000000000000e+00;
temp_7571 = (double ) fs1;
temp_7582 = MaximumEarCF2(temp_7571);
temp_7591 = (double ) temp_7582;
temp_7601 = (double ) fs1;
temp_7612 = MaximumEarCF3(temp_7601);
temp_7621 = (double ) temp_7612;
temp_7632 = CascadePoleQ4(temp_7621);
temp_7641 = (double ) temp_7632;
temp_7651 = (double ) fs1;
temp_7562 = SecondOrderFromCenterQ5(temp_7591, temp_7641, temp_7651);
temp_7661 = (double ) fs1;
temp_7681 = (double ) fs1;
temp_7671 = (temp_7681 / 4.00000000000000e+00);
fp2 = MakeFilter6(pp2, temp_7562, temp_7661, temp_7671, 1.00000000000000e+00);
return (fp2);
}
struct filter *EarStageFilter(
float cf,
float fs,
float DCGain)
{
local vars
temp_7701 = (double ) cf1;
temp_7712 = CascadeZeroCF1(temp_7701);
temp_7721 = (double ) temp_7712;
temp_7731 = (double ) cf1;
temp_7742 = CascadeZeroQ2(temp_7731);
temp_7751 = (double ) temp_7742;
temp_7761 = (double ) fs1;
temp_7692 = SecondOrderFromCenterQ3(temp_7721, temp_7751, temp_7761);
temp_7781 = (double ) cf1;
temp_7792 = CascadePoleCF4(temp_7781);
temp_7801 = (double ) temp_7792;
temp_7811 = (double ) cf1;
temp_7822 = CascadePoleQ5(temp_7811);
temp_7831 = (double ) temp_7822;
temp_7841 = (double ) fs1;
temp_7772 = SecondOrderFromCenterQ6(temp_7801, temp_7831, temp_7841);
temp_7851 = (double ) fs1;
temp_7861 = (double ) DCGain1;
fp2 = MakeFilter7(temp_7692, temp_7772, temp_7851, 0.00000000000000e+00, temp_7861);
return (fp2);
}
int EARSTEP(
float *input,
float output[])
{
local vars
if ((UseCascade28 != 0))
{
temp_7871 = (EarLength25 - 1);
for ( i1 = temp_7871 ; (i2 > 0) ; i3 = (i2 - 1) )
{
/** InputState[i] = InputState[(i - 1)] **/
temp_7882 = (i2 - 1);
InputState9[i2] = InputState8[temp_7882];
}
InputState11[0] = (*input1);
}
else
{
for ( i5 = 0 ; (i6 < EarLength25) ; i7 = (i6 + 1) )
{
InputState13[i6] = (*input1);
}
}
temp_7891 = InputState;
temp_7901 = Sos1State;
temp_7911 = Sos2State;
temp_7921 = a0;
temp_7931 = a1;
temp_7941 = a2;
temp_7951 = b1;
temp_7961 = b2;
temp_7971 = InputState;
sos1(temp_7891, temp_7901, temp_7911, temp_7921, temp_7931, temp_7941, temp_7951, temp_7961, temp_7971, EarLength25);
if ((UseAgc28 != 0))
{
temp_7981 = InputState;
hwr2(temp_7981, output1, EarLength25);
temp_7991 = Agc1State;
temp_8001 = (double ) AgcEpsilon123;
temp_8011 = (double ) AgcStage1Target28;
agc3(output1, temp_7991, output1, temp_8001, temp_8011, EarLength25);
temp_8021 = Agc2State;
temp_8031 = (double ) AgcEpsilon223;
temp_8041 = (double ) AgcStage2Target28;
agc4(output1, temp_8021, output1, temp_8031, temp_8041, EarLength25);
temp_8051 = Agc3State;
temp_8061 = (double ) AgcEpsilon323;
temp_8071 = (double ) AgcStage3Target28;
agc5(output1, temp_8051, output1, temp_8061, temp_8071, EarLength25);
temp_8081 = Agc4State;
temp_8091 = (double ) AgcEpsilon423;
temp_8101 = (double ) AgcStage4Target28;
agc6(output1, temp_8081, output1, temp_8091, temp_8101, EarLength25);
}
else
{
for ( i10 = 0 ; (i11 < EarLength25) ; i12 = (i11 + 1) )
{
output1[i11] = InputState16[i11];
}
}
if ((ComputeFiltered28 != 0))
{
if ((UseAgc28 != 0))
{
for ( i15 = 0 ; (i16 < EarLength25) ; i17 = (i16 + 1) )
{
temp_8142 = InputState16[i16];
temp_8152 = (double ) temp_8142;
temp_8182 = (i16 + 1);
temp_8192 = Agc1State12[temp_8182];
temp_8202 = (double ) temp_8192;
temp_8172 = (1.00000000000000e+00 - temp_8202);
temp_8163 = fabs(temp_8172);
temp_8132 = (temp_8152 * temp_8163);
temp_8232 = (i16 + 1);
temp_8242 = Agc2State12[temp_8232];
temp_8252 = (double ) temp_8242;
temp_8222 = (1.00000000000000e+00 - temp_8252);
temp_8213 = fabs(temp_8222);
temp_8122 = (temp_8132 * temp_8213);
temp_8282 = (i16 + 1);
temp_8292 = Agc3State12[temp_8282];
temp_8302 = (double ) temp_8292;
temp_8272 = (1.00000000000000e+00 - temp_8302);
temp_8263 = fabs(temp_8272);
temp_8112 = (temp_8122 * temp_8263);
temp_8332 = (i16 + 1);
temp_8342 = Agc4State12[temp_8332];
temp_8352 = (double ) temp_8342;
temp_8322 = (1.00000000000000e+00 - temp_8352);
temp_8313 = fabs(temp_8322);
temp_8362 = (temp_8112 * temp_8313);
_U_Output_102[i16] = (float ) temp_8362;
}
temp_8371 = _U_Output_10;
fwrite7(temp_8371, EarLength25, 4, ffp26);
}
else
{
temp_8381 = InputState;
fwrite8(temp_8381, EarLength25, 4, ffp26);
}
}
if ((UseDifference28 != 0))
{
difference9(output1, output1, EarLength25);
hwr10(output1, output1, EarLength25);
}
if ((DecimationFactor29 > 0))
{
temp_8391 = DecimateState1;
temp_8401 = (double ) DecimationEpsilon23;
fos11(output1, temp_8391, output1, temp_8401, EarLength25);
temp_8411 = DecimateState2;
temp_8421 = (double ) DecimationEpsilon23;
fos12(output1, temp_8411, output1, temp_8421, EarLength25);
}
}
int sos(
float input[],
float state1[],
float state2[],
float _U_a0_11[],
float _U_a1_12[],
float _U_a2_13[],
float _U_b1_14[],
float _U_b2_15[],
float output[],
int n)
{
local vars
for ( i1 = 0 ; (i2 < n1) ; i3 = (i2 + 1) )
{
tempin2 = input1[i2];
temp_8442 = _U_a0_111[i2];
temp_8432 = (temp_8442 * tempin2);
temp_8452 = state11[i2];
output1[i2] = (temp_8432 + temp_8452);
temp_8482 = _U_a1_121[i2];
temp_8472 = (temp_8482 * tempin2);
temp_8502 = _U_b1_141[i2];
temp_8512 = output1[i2];
temp_8492 = (temp_8502 * temp_8512);
temp_8462 = (temp_8472 - temp_8492);
temp_8522 = state21[i2];
state11[i2] = (temp_8462 + temp_8522);
temp_8542 = _U_a2_131[i2];
temp_8532 = (temp_8542 * tempin2);
temp_8562 = _U_b2_151[i2];
temp_8572 = output1[i2];
temp_8552 = (temp_8562 * temp_8572);
state21[i2] = (temp_8532 - temp_8552);
}
}
int agc(
float input[],
float state[],
float output[],
float epsilon,
float target,
int n)
{
local vars
temp_8591 = (double ) epsilon1;
temp_8581 = (1.00000000000000e+00 - temp_8591);
temp_8601 = (temp_8581 / 3.00000000000000e+00);
OneMinusEpsOverThree1 = (float ) temp_8601;
EpsOverTarget1 = (epsilon1 / target1);
state1[0] = state1[1];
temp_8611 = (n1 + 1);
state1[temp_8611] = state1[n1];
for ( i1 = 0 ; (i2 < n1) ; i3 = (i2 + 1) )
{
temp_8642 = (i2 + 1);
temp_8652 = state1[temp_8642];
temp_8662 = (double ) temp_8652;
temp_8632 = (1.00000000000000e+00 - temp_8662);
temp_8672 = input1[i2];
temp_8682 = (double ) temp_8672;
temp_8622 = (temp_8632 * temp_8682);
temp_8693 = fabs(temp_8622);
output1[i2] = (float ) temp_8693;
temp_8702 = (i2 + 1);
temp_8722 = output1[i2];
temp_8712 = (temp_8722 * EpsOverTarget1);
temp_8762 = state1[i2];
temp_8782 = (i2 + 1);
temp_8772 = state1[temp_8782];
temp_8752 = (temp_8762 + temp_8772);
temp_8802 = (i2 + 2);
temp_8792 = state1[temp_8802];
temp_8742 = (temp_8752 + temp_8792);
temp_8732 = (OneMinusEpsOverThree1 * temp_8742);
temp2[temp_8702] = (temp_8712 + temp_8732);
}
temp_8811 = (n1 + 1);
for ( i5 = 1 ; (i6 < temp_8812) ; i7 = (i6 + 1) )
{
f2 = temp3[i6];
temp_8822 = (double ) f2;
if ((temp_8822 > 1.00000000000000e+00))
{
f3 = 1.00000000000000e+00;
}
state1[i6] = f4;
temp_8813 = (n1 + 1);
}
}
int hwr(
float input[],
float output[],
int n)
{
local vars
for ( i1 = 0 ; (i2 < n1) ; i3 = (i2 + 1) )
{
temp2 = input1[i2];
temp_8832 = (double ) temp2;
if ((temp_8832 < 0.00000000000000e+00))
{
output1[i2] = 0.00000000000000e+00;
}
else
{
output1[i2] = temp2;
}
}
}
int difference(
float input[],
float output[],
int n)
{
local vars
if ((_sl_difference_initialized_115 == 0))
{
for ( i1 = 0 ; (i2 <= 127) ; i3 = (i2 + 1) )
{
_sl_difference_old_input_211[i2] = 0.00000000000000e+00;
}
}
_sl_difference_initialized_112 = 1;
temp_8841 = (n1 - 1);
for ( i6 = temp_8841 ; (i7 > 0) ; i8 = (i7 - 1) )
{
temp2 = input1[i7];
temp_8862 = (i7 - 1);
temp_8852 = input1[temp_8862];
output1[i7] = (temp_8852 - temp2);
_sl_difference_old_input_215[i7] = temp2;
}
_sl_difference_old_input_217[0] = input1[0];
output1[0] = output1[1];
}
int fos(
float input[],
float state[],
float output[],
float gain,
int n)
{
local vars
temp_8871 = (double ) gain1;
temp_8881 = (1.00000000000000e+00 - temp_8871);
OneMinusGain1 = (float ) temp_8881;
for ( i1 = 0 ; (i2 < n1) ; i3 = (i2 + 1) )
{
/** state[i] = (output[i] = ((gain * input[i]) + (OneMinusGain * state[i]))) **/
temp_8902 = input1[i2];
temp_8892 = (gain1 * temp_8902);
temp_8922 = state1[i2];
temp_8912 = (OneMinusGain1 * temp_8922);
output1[i2] = (temp_8892 + temp_8912);
state1[i2] = output1[i2];
}
}
float *initfft(
int Size)
{
local vars
temp_893 = (&fftzero);
return (temp_893);
}
int fft(
float a[],
float b[],
int m,
int iopt)
{
local vars
n1 = (1 << m1);
if ((iopt1 != 0))
{
i1 = 0;
ap1 = a1;
for ( bp1 = b1 ; (i2 < n1) ; i3 = (i2 + 1) )
{
temp_8952 = ap2;
ap3 = (ap2 + 1);
temp_8942 = temp_8952;
temp_8962 = (*temp_8942);
temp_8972 = (float ) n1;
(*temp_8942) = (temp_8962 / temp_8972);
temp_8992 = bp2;
bp3 = (bp2 + 1);
temp_8982 = temp_8992;
temp_9002 = (*temp_8982);
temp_9012 = (-n1);
temp_9022 = (float ) temp_9012;
(*temp_8982) = (temp_9002 / temp_9022);
}
}
nv21 = (n1 / 2);
nm11 = (n1 - 1);
j1 = 0;
for ( i6 = 0 ; (i7 < nm11) ; i8 = (i7 + 1) )
{
if ((i7 < j2))
{
ta2 = a1[j2];
tb2 = b1[j2];
a1[j2] = a1[i7];
b1[j2] = b1[i7];
a1[i7] = ta2;
b1[i7] = tb2;
}
l2 = nv21;
temp_9032 = (j2 + 1);
while ( (l3 < temp_9033) )
{
j4 = (j3 - l3);
l4 = (l3 / 2);
temp_9034 = (j4 + 1);
}
j6 = (j5 + l5);
}
pi1 = 3.14159265350000e+00;
for ( l7 = 1 ; (l8 <= m1) ; l9 = (l8 + 1) )
{
le2 = (1 << l8);
le12 = (le2 >> 1);
ua2 = 1.00000000000000e+00;
ub2 = 0.00000000000000e+00;
temp_9042 = (float ) le12;
pile12 = (pi1 / temp_9042);
temp_9052 = (double ) pile12;
temp_9063 = cos(temp_9052);
wa2 = (float ) temp_9063;
temp_9082 = (double ) pile12;
temp_9073 = sin(temp_9082);
temp_9092 = (-temp_9073);
wb2 = (float ) temp_9092;
for ( j9 = 0 ; (j10 < le12) ; j11 = (j10 + 1) )
{
for ( i12 = j10 ; (i13 < n1) ; i14 = (i13 + le2) )
{
ip4 = (i13 + le12);
temp_9114 = a1[ip4];
temp_9104 = (temp_9114 * ua3);
temp_9134 = b1[ip4];
temp_9124 = (temp_9134 * ub3);
ta8 = (temp_9104 - temp_9124);
temp_9154 = a1[ip4];
temp_9144 = (temp_9154 * ub3);
temp_9174 = b1[ip4];
temp_9164 = (temp_9174 * ua3);
tb8 = (temp_9144 + temp_9164);
temp_9184 = a1[i13];
a1[ip4] = (temp_9184 - ta8);
temp_9194 = b1[i13];
b1[ip4] = (temp_9194 - tb8);
temp_9204 = i13;
temp_9214 = a1[temp_9204];
a1[temp_9204] = (temp_9214 + ta8);
temp_9224 = i13;
temp_9234 = b1[temp_9224];
b1[temp_9224] = (temp_9234 + tb8);
}
tmp3 = ua3;
temp_9243 = (tmp3 * wa2);
temp_9253 = (ub3 * wb2);
ua4 = (temp_9243 - temp_9253);
temp_9263 = (tmp3 * wb2);
temp_9273 = (ub3 * wa2);
ub4 = (temp_9263 + temp_9273);
}
}
if ((iopt1 != 0))
{
for ( i18 = 0 ; (i19 < n1) ; i20 = (i19 + 1) )
{
/** b[i] = (-b[i]) **/
temp_9282 = b1[i19];
b1[i19] = (-temp_9282);
}
}
}
int Read16BitsLowHigh(
struct _iobuf *fp)
{
local vars
temp_9301 = (*fp1)._cnt;
(*fp1)._cnt = (temp_9301 - 1);
temp_9311 = (temp_9301 - 1);
if ((temp_9311 >= 0))
{
/** temp_929 = (int ) (*((*fp)._ptr++)) **/
temp_9321 = (*fp1)._ptr;
(*fp1)._ptr = (temp_9321 + 1);
temp_9331 = (*temp_9321);
temp_9291 = (int ) temp_9331;
}
else
{
temp_9293 = _filbuf(fp1);
}
first1 = (255 & temp_9294);
temp_9351 = (*fp1)._cnt;
(*fp1)._cnt = (temp_9351 - 1);
temp_9361 = (temp_9351 - 1);
if ((temp_9361 >= 0))
{
/** temp_934 = (int ) (*((*fp)._ptr++)) **/
temp_9371 = (*fp1)._ptr;
(*fp1)._ptr = (temp_9371 + 1);
temp_9381 = (*temp_9371);
temp_9341 = (int ) temp_9381;
}
else
{
temp_9343 = _filbuf(fp1);
}
second1 = (255 & temp_9344);
temp_9391 = (second1 << 8);
result1 = (temp_9391 + first1);
temp_9401 = (result1 & 32768);
if ((temp_9401 != 0))
{
result2 = (result1 - 65536);
}
return (result3);
}
int Read16BitsHighLow(
struct _iobuf *fp)
{
local vars
temp_9421 = (*fp1)._cnt;
(*fp1)._cnt = (temp_9421 - 1);
temp_9431 = (temp_9421 - 1);
if ((temp_9431 >= 0))
{
/** temp_941 = (int ) (*((*fp)._ptr++)) **/
temp_9441 = (*fp1)._ptr;
(*fp1)._ptr = (temp_9441 + 1);
temp_9451 = (*temp_9441);
temp_9411 = (int ) temp_9451;
}
else
{
temp_9413 = _filbuf(fp1);
}
first1 = (255 & temp_9414);
temp_9471 = (*fp1)._cnt;
(*fp1)._cnt = (temp_9471 - 1);
temp_9481 = (temp_9471 - 1);
if ((temp_9481 >= 0))
{
/** temp_946 = (int ) (*((*fp)._ptr++)) **/
temp_9491 = (*fp1)._ptr;
(*fp1)._ptr = (temp_9491 + 1);
temp_9501 = (*temp_9491);
temp_9461 = (int ) temp_9501;
}
else
{
temp_9463 = _filbuf(fp1);
}
second1 = (255 & temp_9464);
temp_9511 = (first1 << 8);
result1 = (temp_9511 + second1);
temp_9521 = (result1 & 32768);
if ((temp_9521 != 0))
{
result2 = (result1 - 65536);
}
return (result3);
}
int Write16BitsLowHigh(
struct _iobuf *fp,
int i)
{
local vars
temp_953 = (*fp)._cnt;
(*fp)._cnt = (temp_953 - 1);
temp_954 = (temp_953 - 1);
if ((temp_954 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = (unsigned char ) (char ) i) **/
temp_955 = (*fp)._ptr;
(*fp)._ptr = (temp_955 + 1);
temp_956 = (char ) i;
(*temp_955) = (unsigned char ) temp_956;
}
else
{
temp_959 = (*fp)._flag;
temp_958 = (temp_959 & 128);
temp_957 = (temp_958 != 0);
if ((temp_957 != 0))
{
/** temp_957 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_961 = (*fp)._cnt;
temp_960 = (-temp_961);
temp_962 = (*fp)._bufsiz;
temp_957 = (temp_960 < temp_962);
}
if ((temp_957 != 0))
{
temp_963 = (*fp)._ptr;
temp_964 = (char ) i;
(*temp_963) = (unsigned char ) temp_964;
temp_965 = (*temp_963);
if ((temp_965 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_966 = (*fp)._ptr;
(*fp)._ptr = (temp_966 + 1);
(*temp_966);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_967 = (*fp)._ptr;
temp_968 = (*temp_967);
temp_969 = (int ) temp_968;
_flsbuf(temp_969, fp);
}
}
else
{
/** _flsbuf(i, fp) **/
temp_970 = (char ) i;
temp_971 = (unsigned char ) temp_970;
temp_972 = (int ) temp_971;
_flsbuf(temp_972, fp);
}
}
temp_973 = (*fp)._cnt;
(*fp)._cnt = (temp_973 - 1);
temp_974 = (temp_973 - 1);
if ((temp_974 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = (unsigned char ) (char ) (i >> 8)) **/
temp_975 = (*fp)._ptr;
(*fp)._ptr = (temp_975 + 1);
temp_976 = (i >> 8);
temp_977 = (char ) temp_976;
(*temp_975) = (unsigned char ) temp_977;
}
else
{
temp_980 = (*fp)._flag;
temp_979 = (temp_980 & 128);
temp_978 = (temp_979 != 0);
if ((temp_978 != 0))
{
/** temp_978 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_982 = (*fp)._cnt;
temp_981 = (-temp_982);
temp_983 = (*fp)._bufsiz;
temp_978 = (temp_981 < temp_983);
}
if ((temp_978 != 0))
{
temp_984 = (*fp)._ptr;
temp_985 = (i >> 8);
temp_986 = (char ) temp_985;
(*temp_984) = (unsigned char ) temp_986;
temp_987 = (*temp_984);
if ((temp_987 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_988 = (*fp)._ptr;
(*fp)._ptr = (temp_988 + 1);
(*temp_988);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_989 = (*fp)._ptr;
temp_990 = (*temp_989);
temp_991 = (int ) temp_990;
_flsbuf(temp_991, fp);
}
}
else
{
/** _flsbuf((i >> 8), fp) **/
temp_992 = (i >> 8);
temp_993 = (char ) temp_992;
temp_994 = (unsigned char ) temp_993;
temp_995 = (int ) temp_994;
_flsbuf(temp_995, fp);
}
}
}
long Read32Bits(
struct _iobuf *fp)
{
local vars
temp_9962 = Read16BitsLowHigh1(fp1);
temp_9971 = (65535 & temp_9962);
first1 = (long ) temp_9971;
temp_9982 = Read16BitsLowHigh2(fp1);
temp_9991 = (65535 & temp_9982);
second1 = (long ) temp_9991;
temp_10001 = (second1 << 16);
result1 = (temp_10001 + first1);
return (result1);
}
int Write32Bits(
struct _iobuf *fp,
long i)
{
local vars
temp_1001 = (i & 65535);
temp_1002 = (int ) temp_1001;
Write16BitsLowHigh1(fp, temp_1002);
temp_1003 = (i >> 16);
temp_1004 = (temp_1003 & 65535);
temp_1005 = (int ) temp_1004;
Write16BitsLowHigh2(fp, temp_1005);
}
float *ReadADCFile(
char *FileName,
float *SamplingRate,
long *Length)
{
local vars
temp_10061 = "r";
fp2 = fopen1(FileName1, temp_10061);
if ((fp2 == 0))
{
temp_10071 = (&_iob[2]);
temp_10081 = "ReadADCFile: Couldn't open %s for reading.\n";
fprintf2(temp_10071, temp_10081, FileName1);
exit(1);
}
temp_10092 = Read16BitsLowHigh3(fp2);
HeaderSize1 = (long ) temp_10092;
HeaderSize2 = (HeaderSize1 - 1);
Read16BitsLowHigh4(fp2);
HeaderSize3 = (HeaderSize2 - 1);
Read16BitsLowHigh5(fp2);
HeaderSize4 = (HeaderSize3 - 1);
temp_10102 = Read16BitsLowHigh6(fp2);
SampleTime1 = (long ) temp_10102;
HeaderSize5 = (HeaderSize4 - 1);
n2 = Read32Bits7(fp2);
temp_10111 = (MaxSamples38 >= 0);
if ((temp_10111 != 0))
{
temp_10112 = (n2 > MaxSamples38);
}
if ((temp_10113 != 0))
{
n3 = MaxSamples38;
}
HeaderSize6 = (HeaderSize5 - 2);
while ( (HeaderSize7 > 0) )
{
Read16BitsLowHigh8(fp2);
HeaderSize8 = (HeaderSize7 - 1);
}
temp_10121 = (double ) SampleTime1;
temp_10131 = (4.00000000000000e+06 / temp_10121);
(*SamplingRate1) = (float ) temp_10131;
temp_10141 = "Reading %ld samples from %s with sampling rate of %g.\n";
temp_10151 = (*SamplingRate1);
temp_10161 = (double ) temp_10151;
printf(temp_10141, n4, FileName1, temp_10161);
temp_10181 = (unsigned long ) n4;
temp_10171 = (temp_10181 * 4);
temp_10192 = malloc(temp_10171);
Data1 = (float *) temp_10192;
if ((Data1 == 0))
{
temp_10201 = (&_iob[2]);
temp_10211 = "ReadADCFile: Can't get space for %ld samples.\n";
fprintf9(temp_10201, temp_10211, n4);
exit(1);
}
for ( i1 = 0 ; (i2 < n4) ; i3 = (i2 + 1) )
{
/** Data[i] = (float ) (((float)Read16BitsLowHigh(fp)) / 6.55360000000000e+05) **/
temp_10223 = Read16BitsLowHigh10(fp2);
temp_10232 = (double ) temp_10223;
temp_10242 = (temp_10232 / 6.55360000000000e+05);
Data1[i2] = (float ) temp_10242;
}
(*Length1) = i4;
fclose(fp2);
return (Data1);
}
int WriteADCFile(
char *FileName,
float SamplingRate,
long Length,
float *Data)
{
local vars
temp_1025 = "w";
fp = fopen1(FileName, temp_1025);
if ((fp == 0))
{
temp_1026 = (&_iob[2]);
temp_1027 = "WriteADCFile: Couldn't open %s for writing.\n";
fprintf2(temp_1026, temp_1027, FileName);
exit(1);
}
Write16BitsLowHigh3(fp, 6);
Write16BitsLowHigh4(fp, 0);
Write16BitsLowHigh5(fp, 1);
temp_1028 = (double ) SamplingRate;
temp_1029 = (4.00000000000000e+06 / temp_1028);
temp_1030 = (int ) temp_1029;
Write16BitsLowHigh6(fp, temp_1030);
Write32Bits7(fp, Length);
Max = Data[0];
for ( i = 1 ; (i < Length) ; i = (i + 1) )
{
/** (Data[i] > Max) **/
temp_1031 = Data[i];
if ((temp_1031 > Max))
{
Max = Data[i];
}
}
temp_1032 = "Writing %s with sample rate %f and length %ld.\n";
temp_1033 = (double ) SamplingRate;
printf(temp_1032, FileName, temp_1033, Length);
temp_1034 = " Maximum value of file is %g.\n";
temp_1035 = (double ) Max;
printf(temp_1034, temp_1035);
Max = (4.09500000000000e+03 / Max);
for ( i = 0 ; (i < Length) ; i = (i + 1) )
{
/** Write16BitsLowHigh(fp, (trunc(Data[i] * Max))) **/
temp_1036 = Data[i];
temp_1037 = (temp_1036 * Max);
temp_1038 = (int ) temp_1037;
Write16BitsLowHigh8(fp, temp_1038);
}
fclose(fp);
}
long FileLength(
struct _iobuf *fp)
{
local vars
temp_10392 = ftell(fp1);
pos1 = (int ) temp_10392;
fseek(fp1, 0, 2);
temp_10402 = ftell(fp1);
end1 = (int ) temp_10402;
fseek(fp1, pos1, 0);
return (end1);
}
float *ReadWavFile(
char *FileName,
long *Length)
{
local vars
temp_10411 = "r";
fp2 = fopen1(FileName1, temp_10411);
if ((fp2 == 0))
{
temp_10421 = (&_iob[2]);
temp_10431 = "ReadByteFile: Couldn't open %s for reading.\n";
fprintf2(temp_10421, temp_10431, FileName1);
exit(1);
}
(*Length1) = FileLength3(fp2);
temp_10441 = (MaxSamples40 >= 0);
if ((temp_10441 != 0))
{
/** temp_1044 = ((*Length) > MaxSamples) **/
temp_10451 = (*Length1);
temp_10442 = (temp_10451 > MaxSamples40);
}
if ((temp_10443 != 0))
{
(*Length1) = MaxSamples40;
}
temp_10471 = (*Length1);
temp_10481 = (unsigned long ) temp_10471;
temp_10461 = (temp_10481 * 4);
temp_10492 = malloc(temp_10461);
Data1 = (float *) temp_10492;
if ((Data1 == 0))
{
temp_10501 = (&_iob[2]);
temp_10511 = "ReadByteFile: Can't get space for %d samples.\n";
temp_10521 = (*Length1);
fprintf4(temp_10501, temp_10511, temp_10521);
exit(1);
}
i1 = 0;
for ( temp_10531 = (*Length1) ; (i2 < temp_10532) ; temp_10533 = (*Length1) )
{
temp_10543 = Read16BitsLowHigh5(fp2);
temp_10552 = (double ) temp_10543;
temp_10562 = (temp_10552 / 3.27680000000000e+05);
Data1[i2] = (float ) temp_10562;
i3 = (i2 + 1);
}
return (Data1);
}
float *ReadByteFile(
char *FileName,
long *Length)
{
local vars
temp_10571 = "r";
fp2 = fopen1(FileName1, temp_10571);
if ((fp2 == 0))
{
temp_10581 = (&_iob[2]);
temp_10591 = "ReadByteFile: Couldn't open %s for reading.\n";
fprintf2(temp_10581, temp_10591, FileName1);
exit(1);
}
(*Length1) = FileLength3(fp2);
temp_10601 = (MaxSamples41 >= 0);
if ((temp_10601 != 0))
{
/** temp_1060 = ((*Length) > MaxSamples) **/
temp_10611 = (*Length1);
temp_10602 = (temp_10611 > MaxSamples41);
}
if ((temp_10603 != 0))
{
(*Length1) = MaxSamples41;
}
temp_10631 = (*Length1);
temp_10641 = (unsigned long ) temp_10631;
temp_10621 = (temp_10641 * 4);
temp_10652 = malloc(temp_10621);
Data1 = (float *) temp_10652;
if ((Data1 == 0))
{
temp_10661 = (&_iob[2]);
temp_10671 = "ReadByteFile: Can't get space for %d samples.\n";
temp_10681 = (*Length1);
fprintf4(temp_10661, temp_10671, temp_10681);
exit(1);
}
i1 = 0;
temp_10691 = (long ) i1;
for ( temp_10701 = (*Length1) ; (temp_10692 < temp_10702) ; temp_10703 = (*Length1) )
{
temp_10762 = (*fp2)._cnt;
(*fp2)._cnt = (temp_10762 - 1);
temp_10772 = (temp_10762 - 1);
if ((temp_10772 >= 0))
{
/** temp_1072 = (int ) (*((*fp)._ptr++)) **/
temp_10782 = (*fp2)._ptr;
(*fp2)._ptr = (temp_10782 + 1);
temp_10792 = (*temp_10782);
temp_10722 = (int ) temp_10792;
}
else
{
temp_10724 = _filbuf(fp2);
}
temp_10712 = (temp_10725 & 255);
temp_10732 = (temp_10712 - 128);
temp_10742 = (double ) temp_10732;
temp_10752 = (temp_10742 / 1.28000000000000e+03);
Data1[i2] = (float ) temp_10752;
i3 = (i2 + 1);
temp_10693 = (long ) i3;
}
return (Data1);
}
int WriteByteFile(
char *FileName,
long Length,
float *Data)
{
local vars
temp_1080 = "w";
fp = fopen1(FileName, temp_1080);
if ((fp == 0))
{
temp_1081 = (&_iob[2]);
temp_1082 = "WriteByteFile: Couldn't open %s for writing.\n";
fprintf2(temp_1081, temp_1082, FileName);
exit(1);
}
Max = Data[0];
for ( i = 1 ; (i < Length) ; i = (i + 1) )
{
/** (Data[i] > Max) **/
temp_1083 = Data[i];
if ((temp_1083 > Max))
{
Max = Data[i];
}
}
temp_1084 = "Writing byte file %s with length %ld.\n";
printf(temp_1084, FileName, Length);
temp_1085 = " Maximum value of file is %g.\n";
temp_1086 = (double ) Max;
printf(temp_1085, temp_1086);
Max = (1.27000000000000e+02 / Max);
for ( i = 0 ; (i < Length) ; i = (i + 1) )
{
temp_1087 = (*fp)._cnt;
(*fp)._cnt = (temp_1087 - 1);
temp_1088 = (temp_1087 - 1);
if ((temp_1088 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = (unsigned char ) ((char ) (trunc(Data[i] * Max)) + -128)) **/
temp_1089 = (*fp)._ptr;
(*fp)._ptr = (temp_1089 + 1);
temp_1090 = Data[i];
temp_1091 = (temp_1090 * Max);
temp_1092 = (int ) temp_1091;
temp_1093 = (char ) temp_1092;
temp_1094 = (temp_1093 + -128);
(*temp_1089) = (unsigned char ) temp_1094;
}
else
{
temp_1097 = (*fp)._flag;
temp_1096 = (temp_1097 & 128);
temp_1095 = (temp_1096 != 0);
if ((temp_1095 != 0))
{
/** temp_1095 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_1099 = (*fp)._cnt;
temp_1098 = (-temp_1099);
temp_1100 = (*fp)._bufsiz;
temp_1095 = (temp_1098 < temp_1100);
}
if ((temp_1095 != 0))
{
temp_1101 = (*fp)._ptr;
temp_1102 = Data[i];
temp_1103 = (temp_1102 * Max);
temp_1104 = (int ) temp_1103;
temp_1105 = (char ) temp_1104;
temp_1106 = (temp_1105 + -128);
(*temp_1101) = (unsigned char ) temp_1106;
temp_1107 = (*temp_1101);
if ((temp_1107 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_1108 = (*fp)._ptr;
(*fp)._ptr = (temp_1108 + 1);
(*temp_1108);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_1109 = (*fp)._ptr;
temp_1110 = (*temp_1109);
temp_1111 = (int ) temp_1110;
_flsbuf(temp_1111, fp);
}
}
else
{
/** _flsbuf(((char ) (trunc(Data[i] * Max)) + -128), fp) **/
temp_1112 = Data[i];
temp_1113 = (temp_1112 * Max);
temp_1114 = (int ) temp_1113;
temp_1115 = (char ) temp_1114;
temp_1116 = (temp_1115 + -128);
temp_1117 = (unsigned char ) temp_1116;
temp_1118 = (int ) temp_1117;
_flsbuf(temp_1118, fp);
}
}
}
fclose(fp);
}
float *ReadDyaxisFile(
char *FileName,
int *Length)
{
local vars
temp_11191 = "r";
fp2 = fopen1(FileName1, temp_11191);
if ((fp2 == 0))
{
temp_11201 = (&_iob[2]);
temp_11211 = "ReadByteFile: Couldn't open %s for reading.\n";
fprintf2(temp_11201, temp_11211, FileName1);
exit(1);
}
len2 = FileLength3(fp2);
temp_11221 = (len2 - 512);
temp_11231 = (temp_11221 / 4);
(*Length1) = (int ) temp_11231;
temp_11241 = (MaxSamples42 >= 0);
if ((temp_11241 != 0))
{
/** temp_1124 = ((long ) (*Length) > MaxSamples) **/
temp_11251 = (*Length1);
temp_11261 = (long ) temp_11251;
temp_11242 = (temp_11261 > MaxSamples42);
}
if ((temp_11243 != 0))
{
(*Length1) = (int ) MaxSamples42;
}
temp_11281 = (*Length1);
temp_11291 = (unsigned int ) temp_11281;
temp_11271 = (temp_11291 * 4);
temp_11302 = malloc(temp_11271);
Data1 = (float *) temp_11302;
if ((Data1 == 0))
{
temp_11311 = (&_iob[2]);
temp_11321 = "ReadByteFile: Can't get space for %d samples.\n";
temp_11331 = (*Length1);
fprintf4(temp_11311, temp_11321, temp_11331);
exit(1);
}
i1 = 0;
for ( temp_11341 = (*Length1) ; (i2 < temp_11342) ; temp_11343 = (*Length1) )
{
temp_11353 = Read16BitsHighLow5(fp2);
temp_11362 = (double ) temp_11353;
temp_11372 = (temp_11362 / 3.27680000000000e+05);
Data1[i2] = (float ) temp_11372;
Read16BitsHighLow6(fp2);
i3 = (i2 + 1);
}
return (Data1);
}
float *ReadNeXTFile(
char *FileName,
int *Length,
float *SamplingRate)
{
local vars
temp_11381 = "r";
fp2 = fopen1(FileName1, temp_11381);
if ((fp2 == 0))
{
/** fileAbort("Couldn't open %s for reading.\n", FileName) **/
temp_11391 = "Couldn't open %s for reading.\n";
fileAbort2(temp_11391, FileName1);
}
temp_11411 = (&header);
temp_11402 = fread3(temp_11411, 24, 1, fp2);
if ((temp_11402 != 1))
{
/** fileAbort("Can't read header of %s.\n", FileName) **/
temp_11421 = "Can't read header of %s.\n";
fileAbort4(temp_11421, FileName1);
}
temp_11431 = header1.mode;
if ((temp_11431 != 3))
{
/** fileAbort("Sound file %s is not 16-bit linear (mode 3).\n", FileName) **/
temp_11441 = "Sound file %s is not 16-bit linear (mode 3).\n";
fileAbort5(temp_11441, FileName1);
}
temp_11461 = header1.hdr_len;
temp_11451 = (temp_11461 + 4);
fseek(fp2, temp_11451, 0);
temp_11471 = header1.srate;
(*SamplingRate1) = (float ) temp_11471;
temp_11481 = header1.nChannels;
stereo1 = (temp_11481 == 2);
temp_11491 = header1.data_len;
temp_11501 = (temp_11491 / 2);
(*Length1) = (int ) temp_11501;
if ((stereo1 != 0))
{
/** (*Length) = ((*Length) / 2) **/
temp_11511 = Length1;
temp_11521 = (*temp_11511);
(*temp_11511) = (temp_11521 / 2);
}
temp_11531 = (MaxSamples43 >= 0);
if ((temp_11531 != 0))
{
/** temp_1153 = ((long ) (*Length) > MaxSamples) **/
temp_11541 = (*Length1);
temp_11551 = (long ) temp_11541;
temp_11532 = (temp_11551 > MaxSamples43);
}
if ((temp_11533 != 0))
{
(*Length1) = (int ) MaxSamples43;
}
temp_11571 = (*Length1);
temp_11581 = (unsigned int ) temp_11571;
temp_11561 = (temp_11581 * 4);
temp_11592 = malloc(temp_11561);
Data1 = (float *) temp_11592;
if ((Data1 == 0))
{
/** fileAbort("Can't get space for %d samples.\n", (*Length)) **/
temp_11601 = "Can't get space for %d samples.\n";
temp_11611 = (*Length1);
fileAbort6(temp_11601, temp_11611);
}
i1 = 0;
for ( temp_11621 = (*Length1) ; (i2 < temp_11622) ; temp_11623 = (*Length1) )
{
temp_11633 = Read16BitsHighLow7(fp2);
temp_11642 = (double ) temp_11633;
temp_11652 = (temp_11642 / 3.27680000000000e+05);
Data1[i2] = (float ) temp_11652;
if ((stereo1 != 0))
{
Read16BitsHighLow8(fp2);
}
i3 = (i2 + 1);
}
return (Data1);
}
int fileAbort(
char *str,
char *arg)
{
local vars
temp_11661 = (&_iob[2]);
temp_11671 = "Reading data file: ";
fprintf1(temp_11661, temp_11671);
temp_11681 = (&_iob[2]);
fprintf2(temp_11681, str1, arg1);
exit(1);
}
float *ReadNativeFloatFile(
char *FileName,
long *Length)
{
local vars
temp_11691 = "r";
fp2 = fopen1(FileName1, temp_11691);
if ((fp2 == 0))
{
temp_11701 = (&_iob[2]);
temp_11711 = "ReadByteFile: Couldn't open %s for reading.\n";
fprintf2(temp_11701, temp_11711, FileName1);
exit(1);
}
temp_11722 = FileLength3(fp2);
temp_11731 = (unsigned long ) temp_11722;
temp_11741 = (temp_11731 / 4);
(*Length1) = (long ) temp_11741;
temp_11751 = (MaxSamples45 >= 0);
if ((temp_11751 != 0))
{
/** temp_1175 = ((*Length) > MaxSamples) **/
temp_11761 = (*Length1);
temp_11752 = (temp_11761 > MaxSamples45);
}
if ((temp_11753 != 0))
{
(*Length1) = MaxSamples45;
}
temp_11781 = (*Length1);
temp_11791 = (unsigned long ) temp_11781;
temp_11771 = (temp_11791 * 4);
temp_11802 = malloc(temp_11771);
Data1 = (float *) temp_11802;
if ((Data1 == 0))
{
temp_11811 = (&_iob[2]);
temp_11821 = "ReadByteFile: Can't get space for %d samples.\n";
temp_11831 = (*Length1);
fprintf4(temp_11811, temp_11821, temp_11831);
exit(1);
}
temp_11841 = (*Length1);
fread5(Data1, 4, temp_11841, fp2);
return (Data1);
}
char *GetFileSuffix(
char *FileName)
{
local vars
p1 = FileName1;
for ( temp_11851 = (*p1) ; (temp_11852 != 0) ; temp_11853 = (*p3) )
{
p3 = (p2 + 1);
}
temp_11871 = (*p4);
temp_11881 = (char ) temp_11871;
temp_11861 = (temp_11881 != 46);
if ((temp_11861 != 0))
{
temp_11862 = (p4 >= FileName1);
}
for ( ; (temp_11864 != 0) ; )
{
p6 = (p5 - 1);
temp_11892 = (*p6);
temp_11902 = (char ) temp_11892;
temp_11865 = (temp_11902 != 46);
if ((temp_11865 != 0))
{
temp_11866 = (p6 >= FileName1);
}
}
temp_11911 = (*p7);
temp_11921 = (char ) temp_11911;
if ((temp_11921 == 46))
{
/** (p + 1) **/
temp_11931 = (p7 + 1);
return (temp_11931);
}
else
{
return (FileName1);
}
}
float *ReadInputFile(
char *FileName,
float *SamplingRate,
long *Length)
{
local vars
Data1 = 0;
Suffix2 = GetFileSuffix1(FileName1);
temp_11961 = "adc";
temp_11952 = strncmp(Suffix2, temp_11961, 3);
temp_11941 = (temp_11952 == 0);
if ((temp_11941 == 0))
{
/** temp_1194 = (strncmp(Suffix, "ADC", 3) == 0) **/
temp_11981 = "ADC";
temp_11972 = strncmp(Suffix2, temp_11981, 3);
temp_11942 = (temp_11972 == 0);
}
if ((temp_11943 != 0))
{
Data3 = ReadADCFile2(FileName1, SamplingRate1, Length1);
}
else
{
temp_12011 = "wav";
temp_12002 = strncmp(Suffix2, temp_12011, 3);
temp_11991 = (temp_12002 == 0);
if ((temp_11991 == 0))
{
/** temp_1199 = (strncmp(Suffix, "WAV", 3) == 0) **/
temp_12031 = "WAV";
temp_12022 = strncmp(Suffix2, temp_12031, 3);
temp_11992 = (temp_12022 == 0);
}
if ((temp_11993 != 0))
{
Data5 = ReadWavFile3(FileName1, Length1);
(*SamplingRate1) = 1.60000000000000e+04;
}
else
{
temp_12061 = "m22";
temp_12052 = strncmp(Suffix2, temp_12061, 3);
temp_12041 = (temp_12052 == 0);
if ((temp_12041 == 0))
{
/** temp_1204 = (strncmp(Suffix, "M22", 3) == 0) **/
temp_12081 = "M22";
temp_12072 = strncmp(Suffix2, temp_12081, 3);
temp_12042 = (temp_12072 == 0);
}
if ((temp_12043 != 0))
{
(*SamplingRate1) = 2.22545454545455e+04;
Data7 = ReadByteFile4(FileName1, Length1);
}
else
{
temp_12111 = "m11";
temp_12102 = strncmp(Suffix2, temp_12111, 3);
temp_12091 = (temp_12102 == 0);
if ((temp_12091 == 0))
{
/** temp_1209 = (strncmp(Suffix, "M11", 3) == 0) **/
temp_12131 = "M11";
temp_12122 = strncmp(Suffix2, temp_12131, 3);
temp_12092 = (temp_12122 == 0);
}
if ((temp_12093 != 0))
{
(*SamplingRate1) = 1.11272727272727e+04;
Data9 = ReadByteFile5(FileName1, Length1);
}
else
{
temp_12161 = "m7";
temp_12152 = strncmp(Suffix2, temp_12161, 2);
temp_12141 = (temp_12152 == 0);
if ((temp_12141 == 0))
{
/** temp_1214 = (strncmp(Suffix, "M7", 2) == 0) **/
temp_12181 = "M7";
temp_12172 = strncmp(Suffix2, temp_12181, 2);
temp_12142 = (temp_12172 == 0);
}
if ((temp_12143 != 0))
{
(*SamplingRate1) = 7.00000000000000e+03;
Data11 = ReadByteFile6(FileName1, Length1);
}
else
{
temp_12211 = "dy22";
temp_12202 = strncmp(Suffix2, temp_12211, 4);
temp_12191 = (temp_12202 == 0);
if ((temp_12191 == 0))
{
/** temp_1219 = (strncmp(Suffix, "DY22", 4) == 0) **/
temp_12231 = "DY22";
temp_12222 = strncmp(Suffix2, temp_12231, 4);
temp_12192 = (temp_12222 == 0);
}
if ((temp_12193 != 0))
{
(*SamplingRate1) = 2.20500000000000e+04;
Data13 = ReadDyaxisFile7(FileName1, Length1);
}
else
{
temp_12261 = "dy44";
temp_12252 = strncmp(Suffix2, temp_12261, 4);
temp_12241 = (temp_12252 == 0);
if ((temp_12241 == 0))
{
/** temp_1224 = (strncmp(Suffix, "DY44", 4) == 0) **/
temp_12281 = "DY44";
temp_12272 = strncmp(Suffix2, temp_12281, 4);
temp_12242 = (temp_12272 == 0);
}
if ((temp_12243 != 0))
{
(*SamplingRate1) = 4.41000000000000e+04;
Data15 = ReadDyaxisFile8(FileName1, Length1);
}
else
{
/** (strncmp(Suffix, "snd", 3) == 0) **/
temp_12301 = "snd";
temp_12292 = strncmp(Suffix2, temp_12301, 3);
if ((temp_12292 == 0))
{
Data17 = ReadNeXTFile9(FileName1, Length1, SamplingRate1);
}
else
{
temp_12331 = "fl";
temp_12322 = strncmp(Suffix2, temp_12331, 2);
temp_12311 = (temp_12322 == 0);
if ((temp_12311 == 0))
{
/** temp_1231 = (strncmp(Suffix, "FL", 2) == 0) **/
temp_12351 = "FL";
temp_12342 = strncmp(Suffix2, temp_12351, 2);
temp_12312 = (temp_12342 == 0);
}
if ((temp_12313 != 0))
{
(*SamplingRate1) = 1.60000000000000e+04;
Data19 = ReadNativeFloatFile10(FileName1, Length1);
}
else
{
temp_12361 = (&_iob[2]);
temp_12371 = "Can't open input file '%s'\n";
fprintf11(temp_12361, temp_12371, FileName1);
exit(1);
}
}
}
}
}
}
}
}
}
return (Data28);
}
int OpenConnection(
char *machine)
{
local vars
temp_1238 = topipe;
i = pipe(temp_1238);
if ((i < 0))
{
temp_1239 = "OpenConnection: To Pipe failed";
perror(temp_1239);
exit(1);
}
temp_1240 = frompipe;
pipe(temp_1240);
if ((i < 0))
{
temp_1241 = "OpenConnection: From Pipe failed";
perror(temp_1241);
exit(1);
}
RemotePID = fork();
if ((RemotePID < 0))
{
temp_1242 = (&_iob[2]);
temp_1243 = "Couldn't fork to open connection to %s.\n";
fprintf1(temp_1242, temp_1243, machine);
temp_1244 = (&_iob[2]);
temp_1245 = "Try setting NCPUS to one to disable multiprocessing.\n";
fprintf2(temp_1244, temp_1245);
exit(1);
}
if ((RemotePID > 0))
{
temp_1246 = topipe[0];
i = dup2(temp_1246, 0);
if ((i < 0))
{
temp_1247 = "OpenConnection: Dup2 ToPipe Failed";
perror(temp_1247);
exit(1);
}
temp_1248 = frompipe[1];
i = dup2(temp_1248, 1);
if ((i < 0))
{
temp_1249 = "OpenConnection: Dup2 FromPipe Failed";
perror(temp_1249);
exit(1);
}
temp_1250 = frompipe[1];
i = dup2(temp_1250, 2);
if ((i < 0))
{
temp_1251 = "OpenConnection: Dup2 FromPipe Failed";
perror(temp_1251);
exit(1);
}
temp_1252 = topipe[0];
i = close(temp_1252);
if ((i < 0))
{
temp_1253 = "OpenConnection: Close ToPipe[0] Failed";
perror(temp_1253);
exit(1);
}
temp_1254 = topipe[1];
i = close(temp_1254);
if ((i < 0))
{
temp_1255 = "OpenConnection: Close ToPipe[1] Failed";
perror(temp_1255);
exit(1);
}
temp_1256 = frompipe[0];
i = close(temp_1256);
if ((i < 0))
{
temp_1257 = "OpenConnection: Close FromPipe[0] Failed";
perror(temp_1257);
exit(1);
}
temp_1258 = frompipe[1];
i = close(temp_1258);
if ((i < 0))
{
temp_1259 = "OpenConnection: Close FromPipe[1] Failed";
perror(temp_1259);
exit(1);
}
temp_1260 = "/usr/ucb/remsh";
temp_1261 = "remsh";
temp_1262 = "exec";
temp_1263 = "/bin/csh";
temp_1264 = "-i";
execl(temp_1260, temp_1261, machine, temp_1262, temp_1263, temp_1264, 0);
temp_1265 = (&_iob[2]);
temp_1266 = "Couldn't exec remsh from child.\n";
fprintf3(temp_1265, temp_1266);
exit(1);
}
temp_1267 = topipe[1];
temp_1268 = "a";
ToRemote = fdopen4(temp_1267, temp_1268);
if ((ToRemote == 0))
{
temp_1269 = (&_iob[2]);
temp_1270 = "OpenConnection: FDOpen topipe failed.\n";
fprintf5(temp_1269, temp_1270);
exit(1);
}
temp_1271 = frompipe[0];
temp_1272 = "r";
FromRemote = fdopen6(temp_1271, temp_1272);
if ((FromRemote == 0))
{
temp_1273 = (&_iob[2]);
temp_1274 = "OpenConnection: FDOpen frompipe failed.\n";
fprintf7(temp_1273, temp_1274);
exit(1);
}
temp_1275 = topipe[0];
i = close(temp_1275);
if ((i < 0))
{
temp_1276 = "OpenConnection: Close ToPipe[0] Failed";
perror(temp_1276);
exit(1);
}
temp_1277 = frompipe[1];
close(temp_1277);
if ((i < 0))
{
temp_1278 = "OpenConnection: Close FromPipe[1] Failed";
perror(temp_1278);
exit(1);
}
temp_1280 = (*FromRemote)._cnt;
(*FromRemote)._cnt = (temp_1280 - 1);
temp_1281 = (temp_1280 - 1);
if ((temp_1281 >= 0))
{
/** temp_1279 = (int ) (*((*FromRemote)._ptr++)) **/
temp_1282 = (*FromRemote)._ptr;
(*FromRemote)._ptr = (temp_1282 + 1);
temp_1283 = (*temp_1282);
temp_1279 = (int ) temp_1283;
}
else
{
temp_1279 = _filbuf(FromRemote);
}
i = temp_1279;
while ( (i != 37) )
{
temp_1286 = (&_iob[1]);
temp_1284 = (*temp_1286)._cnt;
(*temp_1286)._cnt = (temp_1284 - 1);
temp_1285 = (temp_1284 - 1);
if ((temp_1285 >= 0))
{
/** (int ) ((*(_iob[1]._ptr++)) = (unsigned char ) i) **/
temp_1288 = (&_iob[1]);
temp_1287 = (*temp_1288)._ptr;
(*temp_1288)._ptr = (temp_1287 + 1);
(*temp_1287) = (unsigned char ) i;
}
else
{
temp_1292 = (&_iob[1]);
temp_1291 = (*temp_1292)._flag;
temp_1290 = (temp_1291 & 128);
temp_1289 = (temp_1290 != 0);
if ((temp_1289 != 0))
{
/** temp_1289 = ((-_iob[1]._cnt) < _iob[1]._bufsiz) **/
temp_1295 = (&_iob[1]);
temp_1294 = (*temp_1295)._cnt;
temp_1293 = (-temp_1294);
temp_1297 = (&_iob[1]);
temp_1296 = (*temp_1297)._bufsiz;
temp_1289 = (temp_1293 < temp_1296);
}
if ((temp_1289 != 0))
{
temp_1299 = (&_iob[1]);
temp_1298 = (*temp_1299)._ptr;
(*temp_1298) = (unsigned char ) i;
temp_1300 = (*temp_1298);
if ((temp_1300 != 10))
{
/** (int ) (*(_iob[1]._ptr++)) **/
temp_1302 = (&_iob[1]);
temp_1301 = (*temp_1302)._ptr;
(*temp_1302)._ptr = (temp_1301 + 1);
(*temp_1301);
}
else
{
/** _flsbuf((*_iob[1]._ptr), (&_iob[1])) **/
temp_1304 = (&_iob[1]);
temp_1303 = (*temp_1304)._ptr;
temp_1305 = (*temp_1303);
temp_1306 = (int ) temp_1305;
temp_1307 = (&_iob[1]);
_flsbuf(temp_1306, temp_1307);
}
}
else
{
/** _flsbuf(i, (&_iob[1])) **/
temp_1308 = (unsigned char ) i;
temp_1309 = (int ) temp_1308;
temp_1310 = (&_iob[1]);
_flsbuf(temp_1309, temp_1310);
}
}
_U_temp_1280_17 = (*FromRemote)._cnt;
(*FromRemote)._cnt = (_U_temp_1280_17 - 1);
_U_temp_1281_16 = (_U_temp_1280_17 - 1);
if ((_U_temp_1281_16 >= 0))
{
_U_temp_1282_19 = (*FromRemote)._ptr;
(*FromRemote)._ptr = (_U_temp_1282_19 + 1);
_U_temp_1283_18 = (*_U_temp_1282_19);
temp_1279 = (int ) _U_temp_1283_18;
}
else
{
temp_1279 = _filbuf(FromRemote);
}
i = temp_1279;
}
temp_1311 = (*FromRemote)._cnt;
(*FromRemote)._cnt = (temp_1311 - 1);
temp_1312 = (temp_1311 - 1);
if ((temp_1312 >= 0))
{
/** (int ) (*((*FromRemote)._ptr++)) **/
temp_1313 = (*FromRemote)._ptr;
(*FromRemote)._ptr = (temp_1313 + 1);
(*temp_1313);
}
else
{
_filbuf(FromRemote);
}
temp_1314 = "set prompt = \"ok\\\n\"\n";
SendCommandToRemote8(temp_1314);
}
int SendCommandToRemote(
char *command)
{
local vars
i = strchr1(command, 10);
if ((i == 0))
{
temp_1315 = strlen(command);
command[temp_1315] = 10;
temp_1317 = strlen(command);
temp_1316 = (temp_1317 + 1);
command[temp_1316] = 0;
}
i = fputs2(command, ToRemote);
fflush(ToRemote);
do
{
temp_1324 = Buffer;
fgets3(temp_1324, 1024, FromRemote);
temp_1320 = (*FromRemote)._flag;
temp_1319 = (temp_1320 & 16);
temp_1318 = (temp_1319 == 0);
if ((temp_1318 != 0))
{
/** temp_1318 = (strcmp(Buffer, "ok\n") != 0) **/
temp_1322 = Buffer;
temp_1323 = "ok\n";
temp_1321 = strcmp(temp_1322, temp_1323);
temp_1318 = (temp_1321 != 0);
}
}
while ( (temp_1318 != 0) );
temp_1326 = (*FromRemote)._flag;
temp_1325 = (temp_1326 & 16);
if ((temp_1325 != 0))
{
temp_1327 = "Got an end of file from the remote command.\n";
printf(temp_1327);
exit(1);
}
}
int CloseConnection()
{
if ((ToRemote != 0))
{
fclose(ToRemote);
}
if ((FromRemote != 0))
{
fclose(FromRemote);
}
}
int OpenOutputFile(
char *_U_ofn_20)
{
local vars
temp_13281 = (_U_ofn_201 != 0);
if ((temp_13281 != 0))
{
/** temp_1328 = ((char ) (*ofn) != 0) **/
temp_13291 = (*_U_ofn_201);
temp_13301 = (char ) temp_13291;
temp_13282 = (temp_13301 != 0);
}
if ((temp_13283 != 0))
{
FileName_st1045 = _U_ofn_201;
temp_13311 = "w";
ofp_st1016 = fopen1(_U_ofn_201, temp_13311);
if ((ofp_st1016 == 0))
{
temp_13321 = (&_iob[2]);
temp_13331 = "OpenOutputFile: Can't open %s for output data.\n";
fprintf2(temp_13321, temp_13331, _U_ofn_201);
exit(1);
}
}
}
int WriteOutputFile(
float *Data,
int Length)
{
local vars
if ((ofp_st1018 != 0))
{
temp_13341 = (LineLength_st10350 != 0);
if ((temp_13341 != 0))
{
temp_13342 = (Length1 != LineLength_st10350);
}
if ((temp_13343 != 0))
{
temp_13351 = (&_iob[2]);
temp_13361 = "WriteOutputFile: Uneven line lengths.\n";
fprintf1(temp_13351, temp_13361);
temp_13371 = (&_iob[2]);
temp_13381 = " Expecting %d, got %d at line %d.\n";
fprintf2(temp_13371, temp_13381, LineLength_st10350, Length1, LineCount_st10250);
exit(1);
}
LineLength_st1038 = Length1;
result2 = fwrite3(Data1, 4, Length1, ofp_st1018);
if ((result2 != Length1))
{
temp_13391 = (&_iob[2]);
temp_13401 = "Couldn't write output data (%d).\n";
fprintf4(temp_13391, temp_13401, result2);
CloseOutputFile5();
exit(1);
}
LineCount_st1028 = (LineCount_st10250 + 1);
}
}
int CloseOutputFile()
{
local vars
if ((ofp_st1019 != 0))
{
temp_13411 = "Image (%s) is %dx%d (floating point, no header).\n";
printf(temp_13411, FileName_st1048, LineLength_st10310, LineCount_st10210);
fclose(ofp_st1019);
}
}
int picout(
char *name,
float *pic,
long num)
{
local vars
output2 = creat(name1, 420);
if ((output2 >= 0))
{
temp_13421 = (unsigned long ) num1;
temp_13431 = (temp_13421 * 4);
num1 = (long ) temp_13431;
temp_13441 = (unsigned int ) num1;
temp_13452 = write(output2, pic1, temp_13441);
temp_13461 = (long ) temp_13452;
if ((temp_13461 != num1))
{
temp_13471 = "Error %d in the write of %ld bytes to %s.\n";
printf(temp_13471, errno1, num1, name1);
exit(0);
}
close(output2);
}
else
{
temp_13481 = (&_iob[2]);
temp_13491 = "Couldn't open %s for creating picture output.\n";
fprintf1(temp_13481, temp_13491, name1);
exit(1);
}
}
int BytePicout(
char *name,
float *pic,
long num,
float min,
float max)
{
local vars
temp_1350 = (max - min);
temp_1351 = (double ) temp_1350;
temp_1352 = (2.55000000000000e+02 / temp_1351);
gain = (float ) temp_1352;
temp_1353 = "w";
fp = fopen1(name, temp_1353);
if ((fp != 0))
{
for ( i = 0 ; (i < num) ; pic = (pic + 1) )
{
temp_1356 = (*pic);
temp_1355 = (temp_1356 - min);
temp_1357 = (max - min);
temp_1354 = (temp_1355 / temp_1357);
temp_1358 = (temp_1354 * 2.55000000000000e+02);
ch = (int ) temp_1358;
if ((ch < 0))
{
temp_1359 = (*fp)._cnt;
(*fp)._cnt = (temp_1359 - 1);
temp_1360 = (temp_1359 - 1);
if ((temp_1360 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = 0) **/
temp_1361 = (*fp)._ptr;
(*fp)._ptr = (temp_1361 + 1);
(*temp_1361) = 0;
}
else
{
temp_1364 = (*fp)._flag;
temp_1363 = (temp_1364 & 128);
temp_1362 = (temp_1363 != 0);
if ((temp_1362 != 0))
{
/** temp_1362 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_1366 = (*fp)._cnt;
temp_1365 = (-temp_1366);
temp_1367 = (*fp)._bufsiz;
temp_1362 = (temp_1365 < temp_1367);
}
if ((temp_1362 != 0))
{
temp_1368 = (*fp)._ptr;
(*temp_1368) = 0;
temp_1369 = (*temp_1368);
if ((temp_1369 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_1370 = (*fp)._ptr;
(*fp)._ptr = (temp_1370 + 1);
(*temp_1370);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_1371 = (*fp)._ptr;
temp_1372 = (*temp_1371);
temp_1373 = (int ) temp_1372;
_flsbuf(temp_1373, fp);
}
}
else
{
_flsbuf(0, fp);
}
}
}
else
{
if ((ch > 254))
{
temp_1374 = (*fp)._cnt;
(*fp)._cnt = (temp_1374 - 1);
temp_1375 = (temp_1374 - 1);
if ((temp_1375 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = 255) **/
temp_1376 = (*fp)._ptr;
(*fp)._ptr = (temp_1376 + 1);
(*temp_1376) = 255;
}
else
{
temp_1379 = (*fp)._flag;
temp_1378 = (temp_1379 & 128);
temp_1377 = (temp_1378 != 0);
if ((temp_1377 != 0))
{
/** temp_1377 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_1381 = (*fp)._cnt;
temp_1380 = (-temp_1381);
temp_1382 = (*fp)._bufsiz;
temp_1377 = (temp_1380 < temp_1382);
}
if ((temp_1377 != 0))
{
temp_1383 = (*fp)._ptr;
(*temp_1383) = 255;
temp_1384 = (*temp_1383);
if ((temp_1384 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_1385 = (*fp)._ptr;
(*fp)._ptr = (temp_1385 + 1);
(*temp_1385);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_1386 = (*fp)._ptr;
temp_1387 = (*temp_1386);
temp_1388 = (int ) temp_1387;
_flsbuf(temp_1388, fp);
}
}
else
{
_flsbuf(255, fp);
}
}
}
else
{
temp_1389 = (*fp)._cnt;
(*fp)._cnt = (temp_1389 - 1);
temp_1390 = (temp_1389 - 1);
if ((temp_1390 >= 0))
{
/** (int ) ((*((*fp)._ptr++)) = (unsigned char ) ch) **/
temp_1391 = (*fp)._ptr;
(*fp)._ptr = (temp_1391 + 1);
(*temp_1391) = (unsigned char ) ch;
}
else
{
temp_1394 = (*fp)._flag;
temp_1393 = (temp_1394 & 128);
temp_1392 = (temp_1393 != 0);
if ((temp_1392 != 0))
{
/** temp_1392 = ((-(*fp)._cnt) < (*fp)._bufsiz) **/
temp_1396 = (*fp)._cnt;
temp_1395 = (-temp_1396);
temp_1397 = (*fp)._bufsiz;
temp_1392 = (temp_1395 < temp_1397);
}
if ((temp_1392 != 0))
{
temp_1398 = (*fp)._ptr;
(*temp_1398) = (unsigned char ) ch;
temp_1399 = (*temp_1398);
if ((temp_1399 != 10))
{
/** (int ) (*((*fp)._ptr++)) **/
temp_1400 = (*fp)._ptr;
(*fp)._ptr = (temp_1400 + 1);
(*temp_1400);
}
else
{
/** _flsbuf((*(*fp)._ptr), fp) **/
temp_1401 = (*fp)._ptr;
temp_1402 = (*temp_1401);
temp_1403 = (int ) temp_1402;
_flsbuf(temp_1403, fp);
}
}
else
{
/** _flsbuf(ch, fp) **/
temp_1404 = (unsigned char ) ch;
temp_1405 = (int ) temp_1404;
_flsbuf(temp_1405, fp);
}
}
}
}
i = (i + 1);
}
fclose(fp);
}
else
{
temp_1406 = (&_iob[2]);
temp_1407 = "Couldn't open %s for creating picture output.\n";
fprintf2(temp_1406, temp_1407, name);
exit(1);
}
}
extern int atoi();
int ProcessOption(
char *p)
{
local vars
temp_14081 = (*p1);
temp_14091 = (char ) temp_14081;
if ((temp_14091 == 43))
{
Flag1 = 1;
}
else
{
Flag2 = 0;
}
p1 = (p1 + 1);
temp_14101 = (*p1);
cc1 = (int ) temp_14101;
while ( (cc2 != 0) )
{
switch (cc2)
{
case 68 :
case 100 :
{
if ((Flag3 != 0))
{
/** (Debug++) **/
Debug8 = (Debug7 + 1);
}
else
{
Debug9 = 0;
}
break;
}
case 112 :
{
printflag8 = Flag3;
break;
}
case 105 :
{
ImpulseInput8 = Flag3;
break;
}
case 97 :
{
UseAgc8 = Flag3;
break;
}
case 99 :
{
UseCascade8 = Flag3;
break;
}
case 109 :
{
UseDifference8 = Flag3;
break;
}
case 114 :
{
CalculateResponse8 = Flag3;
if ((Flag3 != 0))
{
UseDifference9 = 0;
UseAgc9 = UseDifference9;
ImpulseInput9 = 1;
}
break;
}
case 117 :
{
UseUltra9 = Flag3;
if ((Flag3 != 0))
{
DecimationFactor9 = 1;
}
break;
}
case 118 :
{
VideoRecord8 = Flag3;
break;
}
default :
{
temp_14112 = (&_iob[2]);
temp_14122 = "bad flag: %c\n";
fprintf1(temp_14112, temp_14122, cc2);
exit(1);
break;
}
}
p3 = (p2 + 1);
temp_14103 = (*p3);
cc3 = (int ) temp_14103;
}
}
int ProcessArgument(
char *p)
{
local vars
temp_14141 = ArgumentTable;
temp_14132 = comm1(p1, temp_14141);
switch (temp_14132)
{
case 1 :
{
ifn8 = (p1 + 3);
break;
}
case 2 :
{
ofn8 = (p1 + 3);
temp_14151 = (*ofn8);
temp_14161 = (char ) temp_14151;
if ((temp_14161 == 0))
{
ofn9 = 0;
}
break;
}
case 3 :
{
temp_14171 = (p1 + 5);
AgcStage1Tau8 = atof(temp_14171);
break;
}
case 4 :
{
temp_14181 = (p1 + 5);
AgcStage2Tau8 = atof(temp_14181);
break;
}
case 5 :
{
temp_14191 = (p1 + 5);
AgcStage3Tau8 = atof(temp_14191);
break;
}
case 6 :
{
temp_14201 = (p1 + 5);
AgcStage4Tau8 = atof(temp_14201);
break;
}
case 7 :
{
temp_14211 = (p1 + 8);
AgcStage1Target8 = atof(temp_14211);
break;
}
case 8 :
{
temp_14221 = (p1 + 8);
AgcStage2Target8 = atof(temp_14221);
break;
}
case 9 :
{
temp_14231 = (p1 + 8);
AgcStage3Target8 = atof(temp_14231);
break;
}
case 10 :
{
temp_14241 = (p1 + 8);
AgcStage4Target8 = atof(temp_14241);
break;
}
case 11 :
{
temp_14251 = (p1 + 10);
TauFactor8 = atof(temp_14251);
break;
}
case 12 :
{
temp_14261 = (p1 + 3);
DecimationFactor14 = atoi(temp_14261);
if ((DecimationFactor14 < 0))
{
DecimationFactor15 = 1;
}
break;
}
case 13 :
{
temp_14271 = (p1 + 7);
EarBreakFreq8 = atof(temp_14271);
break;
}
case 14 :
{
temp_14281 = (p1 + 5);
EarQ8 = atof(temp_14281);
break;
}
case 15 :
{
temp_14291 = (p1 + 11);
EarStepFactor8 = atof(temp_14291);
break;
}
case 16 :
{
temp_14301 = (p1 + 10);
EarSharpness8 = atof(temp_14301);
break;
}
case 17 :
{
temp_14311 = (p1 + 7);
EarZeroOffset8 = atof(temp_14311);
break;
}
case 18 :
{
temp_14321 = (p1 + 8);
EarPreemphCorner8 = atof(temp_14321);
break;
}
case 19 :
{
ffn7 = (p1 + 3);
temp_14331 = (*ffn7);
if ((temp_14331 != 0))
{
ComputeFiltered7 = 1;
}
else
{
ffn8 = 0;
}
break;
}
case 20 :
{
cfn7 = (p1 + 3);
temp_14341 = (*cfn7);
temp_14351 = (char ) temp_14341;
if ((temp_14351 == 0))
{
cfn8 = 0;
}
break;
}
case 21 :
{
temp_14361 = (p1 + 6);
CorrelationStep8 = atoi(temp_14361);
break;
}
case 22 :
{
temp_14371 = (p1 + 5);
CorrelationLags8 = atoi(temp_14371);
break;
}
case 23 :
{
temp_14381 = (p1 + 5);
CPUs8 = atoi(temp_14381);
break;
}
case 24 :
{
temp_14391 = (p1 + 10);
Normalization8 = atof(temp_14391);
break;
}
case 25 :
{
temp_14401 = (p1 + 5);
UltraHeadroom8 = atof(temp_14401);
break;
}
case 26 :
{
temp_14411 = (p1 + 11);
temp_14422 = atoi(temp_14411);
MaxSamples7 = (long ) temp_14422;
break;
}
default :
{
break;
}
}
}
int PrintStats()
{
local vars
temp_14431 = "Lyon Ear Model\n";
printf(temp_14431);
temp_14441 = "\tInput File (if)..................... %s\n";
if ((ImpulseInput14 != 0))
{
/** temp_1445 = (char *) (char *) "An Impulse" **/
temp_14461 = "An Impulse";
temp_14451 = (char *) temp_14461;
}
else
{
temp_14452 = ifn10;
}
printf(temp_14441, temp_14453);
temp_14471 = "\tOutput File (of).................... %s\n";
if ((ofn12 != 0))
{
temp_14481 = (char *) ofn12;
}
else
{
temp_14482 = "None";
}
printf(temp_14471, temp_14483);
temp_14491 = "\tFiltered Sound File (ff)............ %s\n";
if ((ffn11 != 0))
{
temp_14501 = (char *) ffn11;
}
else
{
temp_14502 = "None";
}
printf(temp_14491, temp_14503);
temp_14511 = "\tCorrelation Output File (cf)........ %s\n";
if ((cfn11 != 0))
{
temp_14521 = (char *) cfn11;
}
else
{
temp_14522 = "None";
}
printf(temp_14511, temp_14523);
if ((UseAgc14 != 0))
{
temp_14531 = "\tAgc Stage 1 Tau (tau1).............. %gs\n";
temp_14541 = (double ) AgcStage1Tau10;
printf(temp_14531, temp_14541);
temp_14551 = "\tAgc Stage 2 Tau (tau2).............. %gs\n";
temp_14561 = (double ) AgcStage2Tau10;
printf(temp_14551, temp_14561);
temp_14571 = "\tAgc Stage 3 Tau (tau3).............. %gs\n";
temp_14581 = (double ) AgcStage3Tau10;
printf(temp_14571, temp_14581);
temp_14591 = "\tAgc Stage 4 Tau (tau4).............. %gs\n";
temp_14601 = (double ) AgcStage4Tau10;
printf(temp_14591, temp_14601);
temp_14611 = "\tAgc State 1 Target (target1)........ %g\n";
temp_14621 = (double ) AgcStage1Target10;
printf(temp_14611, temp_14621);
temp_14631 = "\tAgc State 2 Target (target2)........ %g\n";
temp_14641 = (double ) AgcStage2Target10;
printf(temp_14631, temp_14641);
temp_14651 = "\tAgc State 3 Target (target3)........ %g\n";
temp_14661 = (double ) AgcStage3Target10;
printf(temp_14651, temp_14661);
temp_14671 = "\tAgc State 4 Target (target4)........ %g\n";
temp_14681 = (double ) AgcStage4Target10;
printf(temp_14671, temp_14681);
}
temp_14691 = "\tDecimation Tau Factor (taufactor)... %g\n";
temp_14701 = (double ) TauFactor10;
printf(temp_14691, temp_14701);
temp_14711 = "\tDecimation Factor (df).............. %d\n";
printf(temp_14711, DecimationFactor18);
temp_14721 = "\tEar Break Frequency (breakf)........ %g\n";
temp_14731 = (double ) EarBreakFreq10;
printf(temp_14721, temp_14731);
temp_14741 = "\tEar Q Factor (earq)................. %g\n";
temp_14751 = (double ) EarQ10;
printf(temp_14741, temp_14751);
temp_14761 = "\tEar Step Factor (stepfactor)........ %g\n";
temp_14771 = (double ) EarStepFactor10;
printf(temp_14761, temp_14771);
temp_14781 = "\tEar Zero Sharpness (sharpness)...... %g\n";
temp_14791 = (double ) EarSharpness10;
printf(temp_14781, temp_14791);
temp_14801 = "\tEar Zero Offset (offset)............ %g\n";
temp_14811 = (double ) EarZeroOffset10;
printf(temp_14801, temp_14811);
temp_14821 = "\tEar Preemphasis Corner (preemph).... %g\n";
temp_14831 = (double ) EarPreemphCorner10;
printf(temp_14821, temp_14831);
temp_14841 = (UseUltra13 != 0);
if ((temp_14841 == 0))
{
temp_14842 = (cfn11 != 0);
}
if ((temp_14843 != 0))
{
temp_14851 = "\tCorrelation Time Step (cstep)....... %d samples\n";
printf(temp_14851, CorrelationStep10);
temp_14861 = "\tCorrelation Lags (clag)............. %d samples\n";
printf(temp_14861, CorrelationLags10);
temp_14871 = "\tCorrelation Normalize (normalize)... %g\n";
temp_14881 = (double ) Normalization10;
printf(temp_14871, temp_14881);
temp_14891 = "\tUltra Headroom factor (umax)........ %g\n";
temp_14901 = (double ) UltraHeadroom10;
printf(temp_14891, temp_14901);
}
if ((MaxSamples9 > 0))
{
/** printf("\tNumber of samples (maxsamples)...... %ld\n", MaxSamples) **/
temp_14911 = "\tNumber of samples (maxsamples)...... %ld\n";
printf(temp_14911, MaxSamples9);
}
if ((UseAgc14 == 0))
{
/** printf("\tNo AGC (-a)\n") **/
temp_14921 = "\tNo AGC (-a)\n";
printf(temp_14921);
}
if ((UseCascade12 == 0))
{
/** printf("\tNo cascade (independent channels) (-c)\n") **/
temp_14931 = "\tNo cascade (independent channels) (-c)\n";
printf(temp_14931);
}
if ((UseDifference14 == 0))
{
/** printf("\tNo difference of channels (-m)\n") **/
temp_14941 = "\tNo difference of channels (-m)\n";
printf(temp_14941);
}
if ((CalculateResponse12 != 0))
{
/** printf("\tJust calculate response (+r)\n") **/
temp_14951 = "\tJust calculate response (+r)\n";
printf(temp_14951);
}
if ((UseUltra13 != 0))
{
/** printf("\tAnimate correlagram on Ultra (+u)\n") **/
temp_14961 = "\tAnimate correlagram on Ultra (+u)\n";
printf(temp_14961);
}
temp_14971 = (UseUltra13 != 0);
if ((temp_14971 != 0))
{
temp_14972 = (VideoRecord12 != 0);
}
if ((temp_14973 != 0))
{
/** printf("\tRecording video onto VTR (+v)\n") **/
temp_14981 = "\tRecording video onto VTR (+v)\n";
printf(temp_14981);
}
if ((Debug14 != 0))
{
/** printf("\tDebug Mode\n") **/
temp_14991 = "\tDebug Mode\n";
printf(temp_14991);
}
temp_15001 = (&_iob[1]);
fflush(temp_15001);
}
int syntax()
{
}
int ChangeAgcParams()
{
local vars
temp_15011 = (double ) AgcStage1Tau12;
temp_15021 = (double ) sample_rate33;
AgcEpsilon13 = EpsilonFromTauFS1(temp_15011, temp_15021);
temp_15031 = (double ) AgcStage2Tau12;
temp_15041 = (double ) sample_rate33;
AgcEpsilon23 = EpsilonFromTauFS2(temp_15031, temp_15041);
temp_15051 = (double ) AgcStage3Tau12;
temp_15061 = (double ) sample_rate33;
AgcEpsilon33 = EpsilonFromTauFS3(temp_15051, temp_15061);
temp_15071 = (double ) AgcStage4Tau12;
temp_15081 = (double ) sample_rate33;
AgcEpsilon43 = EpsilonFromTauFS4(temp_15071, temp_15081);
}
int ChangeDecimationParameters()
{
local vars
if ((DecimationFactor21 <= 0))
{
temp_15101 = 1;
}
else
{
temp_15102 = DecimationFactor21;
}
temp_15111 = (float ) temp_15103;
temp_15091 = (temp_15111 * TauFactor13);
temp_15121 = (temp_15091 / sample_rate34);
temp_15131 = (double ) temp_15121;
temp_15141 = (double ) sample_rate34;
DecimationEpsilon3 = EpsilonFromTauFS1(temp_15131, temp_15141);
}
int DesignEarFilters()
{
local vars
temp_15151 = (double ) sample_rate35;
fp2 = OuterMiddleEarFilter1(temp_15151);
a23[0] = FilterNumeratorCoeff2(fp2, 0);
a13[0] = FilterNumeratorCoeff3(fp2, 1);
a03[0] = FilterNumeratorCoeff4(fp2, 2);
b22[0] = 0.00000000000000e+00;
b12[0] = 0.00000000000000e+00;
temp_15161 = (double ) sample_rate35;
fp4 = EarFrontFilter5(temp_15161);
a25[1] = FilterNumeratorCoeff6(fp4, 0);
a15[1] = FilterNumeratorCoeff7(fp4, 1);
a05[1] = FilterNumeratorCoeff8(fp4, 2);
b24[1] = FilterDenominatorCoeff9(fp4, 0);
b14[1] = FilterDenominatorCoeff10(fp4, 1);
for ( i1 = 2 ; (i2 <= 127) ; i3 = (i2 + 1) )
{
temp_15172 = (i2 - 2);
temp_15182 = (double ) sample_rate35;
prevcf3 = EarChannelCF11(temp_15172, temp_15182);
temp_15192 = (double ) sample_rate35;
cf3 = EarChannelCF12(i2, temp_15192);
StageDcGain2 = (prevcf3 / cf3);
temp_15202 = (double ) cf3;
temp_15213 = CascadePoleQ13(temp_15202);
temp_15222 = (double ) temp_15213;
if ((temp_15222 < 5.00000000000000e-01))
{
if ((i2 > EarLength4))
{
temp_15232 = EarLength4;
}
else
{
temp_15233 = i2;
}
EarLength5 = temp_15234;
a27[i2] = 0.00000000000000e+00;
a17[i2] = a27[i2];
a07[i2] = a17[i2];
b26[i2] = 0.00000000000000e+00;
b16[i2] = b26[i2];
}
else
{
temp_15242 = (double ) cf3;
temp_15252 = (double ) sample_rate35;
temp_15262 = (double ) StageDcGain2;
fp7 = EarStageFilter14(temp_15242, temp_15252, temp_15262);
a29[i2] = FilterNumeratorCoeff15(fp7, 0);
a19[i2] = FilterNumeratorCoeff16(fp7, 1);
a09[i2] = FilterNumeratorCoeff17(fp7, 2);
b28[i2] = FilterDenominatorCoeff18(fp7, 0);
b18[i2] = FilterDenominatorCoeff19(fp7, 1);
}
}
if ((Debug18 != 0))
{
temp_15271 = "coeffs.list";
temp_15281 = "w";
_U_fp_212 = fopen20(temp_15271, temp_15281);
if ((_U_fp_212 == 0))
{
temp_15291 = (&_iob[2]);
temp_15301 = "ear: Couldn't open coeffs.list for coefficient list.\n";
fprintf21(temp_15291, temp_15301);
return;
}
for ( i5 = 0 ; (i6 < EarLength7) ; i7 = (i6 + 1) )
{
temp_15312 = "((%g %g %g)\n";
temp_15322 = a211[i6];
temp_15332 = (double ) temp_15322;
temp_15342 = a111[i6];
temp_15352 = (double ) temp_15342;
temp_15362 = a011[i6];
temp_15372 = (double ) temp_15362;
fprintf22(_U_fp_212, temp_15312, temp_15332, temp_15352, temp_15372);
temp_15382 = " (%g %g %g))\n";
temp_15392 = b210[i6];
temp_15402 = (double ) temp_15392;
temp_15412 = b110[i6];
temp_15422 = (double ) temp_15412;
fprintf23(_U_fp_212, temp_15382, temp_15402, temp_15422, 1.00000000000000e+00);
}
fclose(_U_fp_212);
}
}
int INITCOM(
struct CommonStruct *CBlock)
{
local vars
(*CBlock).n = EarLength;
(*CBlock).UseAgc = UseAgc;
(*CBlock).UseDifference = UseDifference;
(*CBlock).UseCascade = UseCascade;
(*CBlock).ComputeFiltered = ComputeFiltered;
(*CBlock).DecimationFactor = DecimationFactor;
(*CBlock).DecimationEpsilon = DecimationEpsilon;
(*CBlock).AgcEpsilon1 = AgcEpsilon1;
(*CBlock).AgcEpsilon2 = AgcEpsilon2;
(*CBlock).AgcEpsilon3 = AgcEpsilon3;
(*CBlock).AgcEpsilon4 = AgcEpsilon4;
(*CBlock).AgcStage1Target = AgcStage1Target;
(*CBlock).AgcStage2Target = AgcStage2Target;
(*CBlock).AgcStage3Target = AgcStage3Target;
(*CBlock).AgcStage4Target = AgcStage4Target;
for ( i = 0 ; (i <= 127) ; i = (i + 1) )
{
temp_1543 = (*CBlock).a0;
temp_1543[i] = a0[i];
temp_1544 = (*CBlock).a1;
temp_1544[i] = a1[i];
temp_1545 = (*CBlock).a2;
temp_1545[i] = a2[i];
temp_1546 = (*CBlock).b1;
temp_1546[i] = b1[i];
temp_1547 = (*CBlock).b2;
temp_1547[i] = b2[i];
}
}
|