Changeset 682:6cf3ae19ffd3 in roaraudio


Ignore:
Timestamp:
08/27/08 15:46:45 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support for libroardsp filter chains

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarfilt.c

    r669 r682  
    2424 
    2525#include <roaraudio.h> 
     26#include <libroardsp/libroardsp.h> 
    2627#include <math.h> 
    2728 
     
    4950        "  --div VAL          - Set div\n" 
    5051        "  --lowpass freq     - lowpass filter\n" 
     52        "  --filter  name     - add filter name\n" 
     53        "  --ffreq   freq     - set filter freq\n" 
    5154       ); 
    5255 
     
    131134 float  lp       = 0; 
    132135 char buf[BUFSIZE]; 
     136 struct roardsp_filterchain fc; 
     137 struct roardsp_filter      filter; 
     138 struct roar_stream         stream; 
    133139 
    134140 memset(&g_lowpass, 0, sizeof(g_lowpass)); 
     141 
     142 roardsp_fchain_init(&fc); 
    135143 
    136144 for (i = 1; i < argc; i++) { 
     
    162170   g_lowpass.a = 65536 - lp; 
    163171//   printf("lowpass: A=%i, B=%i\n", g_lowpass.a, g_lowpass.b); 
     172  } else if ( strcmp(k, "--filter") == 0 ) { 
     173   stream.info.channels = channels; 
     174   stream.info.bits     = bits; 
     175   stream.info.rate     = rate; 
     176   roardsp_filter_init(&filter, &stream, roardsp_filter_str2id(argv[++i])); 
     177   roardsp_fchain_add(&fc, &filter); 
     178  } else if ( strcmp(k, "--ffreq") == 0 ) { 
     179   lp = atof(argv[++i]); 
     180   roardsp_filter_ctl(&filter, ROARDSP_FCTL_FREQ, &lp); 
    164181  } else if ( strcmp(k, "--help") == 0 ) { 
    165182   usage(); 
     
    177194 } 
    178195 
    179  if ( mul == div && logscale == 0 && lp == 0 ) { 
     196 if ( mul == div && logscale == 0 && g_lowpass.a == 0 && roardsp_fchain_num(&fc) == 0 ) { 
    180197  fprintf(stderr, "Error: filter is useless!\n"); 
    181198  return 0; 
     
    190207   if ( g_lowpass.a ) 
    191208    lowpass2((void*)buf, i, channels); 
     209   roardsp_fchain_calc(&fc, (void*)buf, (8*i)/bits); 
    192210   if (write(fh, buf, i) != i) 
    193211    break; 
     
    206224 roar_simple_close(fh); 
    207225 
     226 roardsp_fchain_uninit(&fc); 
     227 
    208228 return 0; 
    209229} 
Note: See TracChangeset for help on using the changeset viewer.