comparison libao2/pl_eq.c @ 6439:edac9b35835d

Fixed lround replacement, hopefully fast enough.
author atmos4
date Sun, 16 Jun 2002 01:44:33 +0000
parents 61d750b7a989
children a94cde7ef947
comparison
equal deleted inserted replaced
6438:88938fa0c659 6439:edac9b35835d
87 } 87 }
88 } 88 }
89 return CONTROL_UNKNOWN; 89 return CONTROL_UNKNOWN;
90 } 90 }
91 91
92 // return rounded 16bit int
93 static inline int16_t lround16(double n){
94 return (int16_t)((n)>=0.0?(n)+0.5:(n)-0.5);
95 }
96
92 // 2nd order Band-pass Filter design 97 // 2nd order Band-pass Filter design
93 void bp2(int16_t* a, int16_t* b, float fc, float q){ 98 void bp2(int16_t* a, int16_t* b, float fc, float q){
94 double th=2*3.141592654*fc; 99 double th=2*3.141592654*fc;
95 double C=(1 - tan(th*q/2))/(1 + tan(th*q/2)); 100 double C=(1 - tan(th*q/2))/(1 + tan(th*q/2));
96 101
97 a[0] = (int16_t)( 16383.0 * (1 + C) * cos(th) + 0.5); 102 a[0] = lround16( 16383.0 * (1 + C) * cos(th));
98 a[1] = (int16_t)(-16383.0 * C + 0.5); 103 a[1] = lround16(-16383.0 * C);
99 104
100 b[0] = (int16_t)(-16383.0 * (C - 1)/2 + 0.5); 105 b[0] = lround16(-16383.0 * (C - 1)/2);
101 b[1] = (int16_t)(-16383.0 * 1.0050 + 0.5); 106 b[1] = lround16(-16383.0 * 1.0050);
102 } 107 }
103 108
104 // empty buffers 109 // empty buffers
105 static void reset(){ 110 static void reset(){
106 int k,l,c; 111 int k,l,c;