Changeset 5551:b2d3093178c9 in roaraudio


Ignore:
Timestamp:
06/18/12 00:07:18 (5 years ago)
Author:
phi
Branch:
default
Message:

limit output to avoid bad clippin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/filter_goertzel.c

    r5548 r5551  
    5959} 
    6060 
    61 #define _calcX(bits,twobits) \ 
     61#define _calcX(bits,twobits,limit) \ 
    6262int roardsp_goertzel_calc##bits  (struct roardsp_filter * filter, void * data, size_t samples) { \ 
    6363 struct roardsp_goertzel * self = (struct roardsp_goertzel *) filter->inst; \ 
     
    9191  s  += h; \ 
    9292  s  -= g; \ 
    93   s  *= 0.0001; 
    94   s  /= (float)((i+1)*(i+1)); 
     93  s  *= 0.0001; \ 
     94  s  /= (float)((i+1)*(i+1)); \ 
     95  if ( s > (limit) ) \ 
     96   s = (limit); \ 
    9597  samp[i]  = s; \ 
    96  }; \ 
     98 } \ 
    9799\ 
    98100 return 0; \ 
    99101} 
    100102 
    101 _calcX(8,16) 
    102 _calcX(16,32) 
    103 _calcX(32,64) 
     103_calcX(8,16,127.) 
     104_calcX(16,32,32767.) 
     105_calcX(32,64,2147483647.) 
    104106 
    105107int roardsp_goertzel_ctl   (struct roardsp_filter * filter, int cmd, void * data) { 
Note: See TracChangeset for help on using the changeset viewer.