Changeset 3024:df2a82f5057f in roaraudio
- Timestamp:
- 11/01/09 10:08:39 (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roarclients
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/Makefile
r2961 r3024 4 4 TARGETS_IO=roarcat roarcatplay roarcatvio roarbidir roarmon roarmonhttp roarradio 5 5 TARGETS_CTL=roarctl roarlight roarinterconnect 6 TARGETS_DSP=roarfilt 6 TARGETS_DSP=roarfilt roarvumeter 7 7 TARGETS_MISC=roarsockconnect roarphone roarshout 8 TARGETS_M= roarvumeter8 TARGETS_M= 9 9 10 10 TARGETS=$(TARGETS_IO) $(TARGETS_CTL) $(TARGETS_DSP) $(TARGETS_MISC) $(TARGETS_DEVEL) $(TARGETS_EXAMPLE) $(TARGETS_TESTS) $(TARGETS_M) … … 63 63 ${CC} ${LDFLAGS} -o roarsin roarsin.o $(LIBROARDSP) 64 64 roarvumeter: roarvumeter.o 65 ${CC} ${LDFLAGS} -o roarvumeter roarvumeter.o $(LIBROAR) $( lib_m)65 ${CC} ${LDFLAGS} -o roarvumeter roarvumeter.o $(LIBROAR) $(LIBROARDSP) $(lib_m) 66 66 roarsockconnect: roarsockconnect.o 67 67 $L -
roarclients/roarvumeter.c
r3019 r3024 24 24 25 25 #include <roaraudio.h> 26 #include <libroardsp/libroardsp.h> 26 27 27 28 #ifdef ROAR_HAVE_LIBM … … 49 50 } 50 51 51 int vumeter16bit2ch (struct roar_vio_calls * vio, int samples, int16_t * buf, int mode ) {52 int vumeter16bit2ch (struct roar_vio_calls * vio, int samples, int16_t * buf, int mode, struct roardsp_filterchain * fc) { 52 53 int i; 53 54 int samples_half = samples/2; 54 55 int64_t suml, sumr; 55 56 double rmsl, rmsr; 57 int run_filters = roardsp_fchain_num(fc); 56 58 57 59 printf("\e[s"); … … 60 62 while (roar_vio_read(vio, buf, samples * 2) > 0) { 61 63 suml = sumr = 0; 64 65 if ( run_filters ) { 66 roardsp_fchain_calc(fc, buf, samples * 2); 67 } 62 68 63 69 for (i = 0; i < samples; i += 2) { … … 83 89 } 84 90 85 int vumeter (struct roar_vio_calls * vio, int samples, int bits, int channels, int mode ) {91 int vumeter (struct roar_vio_calls * vio, int samples, int bits, int channels, int mode, struct roardsp_filterchain * fc) { 86 92 void * buf = malloc((samples*bits*channels)/8); 87 93 … … 91 97 if ( bits == 16 ) { 92 98 if ( channels == 2 ) { 93 vumeter16bit2ch(vio, samples, (int16_t *) buf, mode );99 vumeter16bit2ch(vio, samples, (int16_t *) buf, mode, fc); 94 100 free(buf); 95 101 return 0; … … 105 111 106 112 int 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; 107 118 int rate = ROAR_RATE_DEFAULT; 108 119 int bits = 16; … … 131 142 } else if ( strcmp(k, "--db") == 0 ) { 132 143 mode = MODE_DB; 144 } else if ( strcmp(k, "--lowpass") == 0 ) { 145 lowpass_freq = atof(argv[++i]); 133 146 } else if ( strcmp(k, "--help") == 0 ) { 134 147 usage(); … … 144 157 samples = rate/10; 145 158 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) { 147 165 fprintf(stderr, "Error: can not start monetoring\n"); 148 166 return 1; … … 155 173 } 156 174 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); 158 205 159 206 printf("\n"); // if the reach this then roard has quited and we should print a newline 160 207 161 208 roar_vio_close(&re); 209 210 roar_disconnect(&con); 211 212 roardsp_fchain_uninit(&fchain); 162 213 163 214 return 0;
Note: See TracChangeset
for help on using the changeset viewer.