Changeset 3024:df2a82f5057f in roaraudio


Ignore:
Timestamp:
11/01/09 10:08:39 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support for lowpasses as input filters

Location:
roarclients
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roarclients/Makefile

    r2961 r3024  
    44TARGETS_IO=roarcat roarcatplay roarcatvio roarbidir roarmon roarmonhttp roarradio 
    55TARGETS_CTL=roarctl roarlight roarinterconnect 
    6 TARGETS_DSP=roarfilt 
     6TARGETS_DSP=roarfilt roarvumeter 
    77TARGETS_MISC=roarsockconnect roarphone roarshout 
    8 TARGETS_M=roarvumeter 
     8TARGETS_M= 
    99 
    1010TARGETS=$(TARGETS_IO) $(TARGETS_CTL) $(TARGETS_DSP) $(TARGETS_MISC) $(TARGETS_DEVEL) $(TARGETS_EXAMPLE) $(TARGETS_TESTS) $(TARGETS_M) 
     
    6363        ${CC} ${LDFLAGS} -o roarsin roarsin.o $(LIBROARDSP) 
    6464roarvumeter: roarvumeter.o 
    65         ${CC} ${LDFLAGS} -o roarvumeter roarvumeter.o $(LIBROAR) $(lib_m) 
     65        ${CC} ${LDFLAGS} -o roarvumeter roarvumeter.o $(LIBROAR) $(LIBROARDSP) $(lib_m) 
    6666roarsockconnect: roarsockconnect.o 
    6767        $L 
  • roarclients/roarvumeter.c

    r3019 r3024  
    2424 
    2525#include <roaraudio.h> 
     26#include <libroardsp/libroardsp.h> 
    2627 
    2728#ifdef ROAR_HAVE_LIBM 
     
    4950} 
    5051 
    51 int vumeter16bit2ch (struct roar_vio_calls * vio, int samples, int16_t * buf, int mode) { 
     52int vumeter16bit2ch (struct roar_vio_calls * vio, int samples, int16_t * buf, int mode, struct roardsp_filterchain * fc) { 
    5253 int i; 
    5354 int samples_half = samples/2; 
    5455 int64_t suml, sumr; 
    5556 double  rmsl, rmsr; 
     57 int run_filters = roardsp_fchain_num(fc); 
    5658 
    5759 printf("\e[s"); 
     
    6062 while (roar_vio_read(vio, buf, samples * 2) > 0) { 
    6163  suml = sumr = 0; 
     64 
     65  if ( run_filters ) { 
     66   roardsp_fchain_calc(fc, buf, samples * 2); 
     67  } 
    6268 
    6369  for (i = 0; i < samples; i += 2) { 
     
    8389} 
    8490 
    85 int vumeter (struct roar_vio_calls * vio, int samples, int bits, int channels, int mode) { 
     91int vumeter (struct roar_vio_calls * vio, int samples, int bits, int channels, int mode, struct roardsp_filterchain * fc) { 
    8692 void * buf = malloc((samples*bits*channels)/8); 
    8793 
     
    9197 if ( bits == 16 ) { 
    9298  if ( channels == 2 ) { 
    93    vumeter16bit2ch(vio, samples, (int16_t *) buf, mode); 
     99   vumeter16bit2ch(vio, samples, (int16_t *) buf, mode, fc); 
    94100   free(buf); 
    95101   return 0; 
     
    105111 
    106112int main (int argc, char * argv[]) { 
     113 struct roar_connection       con; 
     114 struct roar_stream           s; 
     115 struct roardsp_filterchain   fchain; 
     116 struct roardsp_filter      * filter; 
     117 float  lowpass_freq = 0; 
    107118 int    rate     = ROAR_RATE_DEFAULT; 
    108119 int    bits     = 16; 
     
    131142  } else if ( strcmp(k, "--db") == 0 ) { 
    132143   mode = MODE_DB; 
     144  } else if ( strcmp(k, "--lowpass") == 0 ) { 
     145   lowpass_freq = atof(argv[++i]); 
    133146  } else if ( strcmp(k, "--help") == 0 ) { 
    134147   usage(); 
     
    144157  samples = rate/10; 
    145158 
    146  if ( roar_vio_simple_stream(&stream, rate, channels, bits, codec, server, ROAR_DIR_MONITOR, "roarvumeter") == -1) { 
     159 if ( roar_simple_connect(&con, server, "roarvumeter") == -1 ) { 
     160  fprintf(stderr, "Error: can not connect to server!\n"); 
     161  return 1; 
     162 } 
     163 
     164 if ( roar_vio_simple_new_stream_obj(&stream, &con, &s, rate, channels, bits, codec, ROAR_DIR_MONITOR) == -1) { 
    147165  fprintf(stderr, "Error: can not start monetoring\n"); 
    148166  return 1; 
     
    155173 } 
    156174 
    157  vumeter(&re, samples*channels, bits, channels, mode); 
     175 if ( roardsp_fchain_init(&fchain) == -1 ) { 
     176  roar_vio_close(&re); 
     177  fprintf(stderr, "Error: can not init filterchain\n"); 
     178  return 1; 
     179 } 
     180 
     181 if ( lowpass_freq > 1 ) { 
     182  if ( roardsp_filter_new(&filter, &s, ROARDSP_FILTER_LOWP) == -1 ) { 
     183   fprintf(stderr, "Error: can not open lowpass\n"); 
     184   roar_vio_close(&re); 
     185   roardsp_fchain_uninit(&fchain); 
     186   return 1; 
     187  } 
     188 
     189  if ( roardsp_filter_ctl(filter, ROARDSP_FCTL_FREQ, &lowpass_freq) == -1 ) { 
     190   fprintf(stderr, "Error: can not set filter frequency\n"); 
     191   roar_vio_close(&re); 
     192   roardsp_fchain_uninit(&fchain); 
     193   return 1; 
     194  } 
     195 
     196  if ( roardsp_fchain_add(&fchain, filter) == -1 ) { 
     197   fprintf(stderr, "Error: can not set filter frequency\n"); 
     198   roar_vio_close(&re); 
     199   roardsp_fchain_uninit(&fchain); 
     200   return 1; 
     201  } 
     202 } 
     203 
     204 vumeter(&re, samples*channels, bits, channels, mode, &fchain); 
    158205 
    159206 printf("\n"); // if the reach this then roard has quited and we should print a newline 
    160207 
    161208 roar_vio_close(&re); 
     209 
     210 roar_disconnect(&con); 
     211 
     212 roardsp_fchain_uninit(&fchain); 
    162213 
    163214 return 0; 
Note: See TracChangeset for help on using the changeset viewer.