// c_utils.cpp // utility functions for vad program #include "c_utils.h" #include S2byte sature16(S4byte data) { if ( data > (S2byte)0x7fff ) { return (S2byte)MAX_16; } if ( data < (S2byte)0xffff8000 ) { return (S2byte)MIN_16; } return (S2byte)data; } void bqInit (t_biquad *bq, S2byte a0, S2byte a1, S2byte a2, S2byte b1, S2byte b2) { bq->a0 = a0; bq->a11 = a1; bq->a12 = a2; bq->negb11 = -b1; bq->negb12 = -b2; bq->dn_1 = 0; bq->dn_2 = 0; } void bqProcess(t_biquad *bq, S2byte *datain, S2byte *dataout, int n) { int i; static S2byte prev = 1700; for (i = 0; i < n; i++) { /* do biquad processing */ dataout[i] = datain[i] - prev; prev = datain[i]; } } void calcPower ( int length, U4byte *login, float *logout) // formerly called log10_32() { int i; for (i = 0; i < length; i++) { logout[i] = (float) (10 * log10(login[i]) - 10 * 9.332); } }