Changeset 5180:e8efeb11e78b in roaraudio
- Timestamp:
- 10/22/11 14:17:16 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
include/roaraudio.h
r5109 r5180 169 169 #include <libroar/libroar.h> 170 170 171 // Some settings for roard: 172 #ifndef ROAR_ROARD_BITS 173 #define ROAR_ROARD_BITS 32 174 #endif 175 171 176 // Some glocal network defaults: 172 177 #ifndef ROAR_NET_INET4_LOCALHOST -
libroar/stream.c
r5148 r5180 1268 1268 .channels = ROAR_CHANNELS_DEFAULT, 1269 1269 .codec = ROAR_CODEC_DEFAULT}}, 1270 {"default-server", 1271 {.rate = ROAR_RATE_DEFAULT, 1272 .bits = ROAR_ROARD_BITS, 1273 .channels = ROAR_CHANNELS_DEFAULT, 1274 .codec = ROAR_CODEC_DEFAULT}}, 1270 1275 {"wav", {.rate = ROAR_RATE_DEFAULT, 1271 1276 .bits = ROAR_BITS_DEFAULT, -
roarclients/roarfilt.c
r5179 r5180 57 57 " --div VAL - Set div\n" 58 58 #ifdef ROAR_HAVE_LIBM 59 " --lowpass freq - lowpass filter \n"59 " --lowpass freq - lowpass filter (obsolete)\n" 60 60 #endif 61 61 " --filter name - add filter name\n" … … 71 71 } 72 72 73 void vol2 (void * data, int mul, int div, int len) { 74 int16_t * samples = (int16_t *) data; 75 int i; 76 77 len /= 2; 78 79 for (i = 0; i < len; i++) 80 samples[i] = ((int) samples[i] * mul) / div; 81 } 82 83 void vol1 (void * data, int mul, int div, int len) { 84 int8_t * samples = (int8_t *) data; 85 int i; 86 87 for (i = 0; i < len; i++) 88 samples[i] = ((int) samples[i] * mul) / div; 89 } 73 #define _volX(bits,twobits,sf) \ 74 void vol##bits (void * data, int32_t mul, int32_t div, size_t len) { \ 75 int##bits##_t * samples = (int##bits##_t *) data; \ 76 size_t i; \ 77 \ 78 len /= sf; \ 79 \ 80 for (i = 0; i < len; i++) \ 81 samples[i] = ((int##twobits##_t) samples[i] * mul) / div; \ 82 } 83 84 _volX( 8,16,1) 85 _volX(16,32,2) 86 _volX(32,64,4) 90 87 91 88 #ifdef ROAR_HAVE_LIBM … … 139 136 140 137 int main (int argc, char * argv[]) { 141 int rate = 44100; 142 int bits = 16; 143 int channels = 2; 144 int codec = ROAR_CODEC_DEFAULT; 145 char * server = NULL; 146 char * k; 147 int i; 148 int mul = 1, div = 1; 149 int filter_id; 138 struct roar_audio_info info; 139 char * server = NULL; 140 char * k; 141 int i; 142 int32_t mul = 1, div = 1; 143 int filter_id; 150 144 int32_t tmp; 151 float logscale = 0;152 float lp = 0;153 char buf[BUFFERSIZE];145 float logscale = 0; 146 float lp = 0; 147 char buf[BUFFERSIZE]; 154 148 struct roardsp_filterchain fc; 155 149 struct roardsp_filter filter_real[8]; … … 158 152 struct roar_vio_calls svio; 159 153 154 _LIBROAR_IGNORE_RET(roar_profile2info(&info, "default-server")); 155 info.codec = ROAR_CODEC_DEFAULT; 156 160 157 #ifdef ROAR_HAVE_LIBM 161 158 memset(&g_lowpass, 0, sizeof(g_lowpass)); … … 170 167 server = argv[++i]; 171 168 } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 || strcmp(k, "-r") == 0 ) { 172 rate = roar_str2rate(argv[++i]);169 info.rate = roar_str2rate(argv[++i]); 173 170 } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 174 bits = roar_str2bits(argv[++i]);171 info.bits = roar_str2bits(argv[++i]); 175 172 } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 176 channels = roar_str2channels(argv[++i]);173 info.channels = roar_str2channels(argv[++i]); 177 174 } else if ( strcmp(k, "-b") == 0 ) { 178 bits = 8;175 info.bits = 8; 179 176 } else if ( strcmp(k, "-m") == 0 ) { 180 channels = 1;177 info.channels = 1; 181 178 } else if ( strcmp(k, "--half") == 0 || strcmp(k, "-half") == 0 ) { 182 179 div *= 2; … … 190 187 div = atoi(argv[++i]); 191 188 } else if ( strcmp(k, "--log") == 0 ) { 189 ROAR_WARN("The logscaler is obsolete and will be removed soon."); 192 190 logscale = atof(argv[++i]); 193 191 #ifdef ROAR_HAVE_LIBM 194 192 } else if ( strcmp(k, "--lowpass") == 0 ) { 195 lp = exp(-2 * M_PI * atof(argv[++i]) / rate) * 65536; 193 ROAR_WARN("The builtin lowpass is obsolete and will be removed soon. Use --filter lowpass."); 194 lp = exp(-2 * M_PI * atof(argv[++i]) / info.rate) * 65536; 196 195 g_lowpass.b = lp; 197 196 g_lowpass.a = 65536 - lp; … … 199 198 // printf("lowpass: A=%i, B=%i\n", g_lowpass.a, g_lowpass.b); 200 199 } else if ( strcmp(k, "--filter") == 0 ) { 201 stream.info.channels = channels; 202 stream.info.bits = bits; 203 stream.info.rate = rate; 200 stream.info = info; 204 201 filter_id = roardsp_filter_str2id(argv[++i]); 205 202 if ( filter_id == -1 ) { … … 245 242 } 246 243 247 if ( roar_vio_simple_stream(&svio, rate, channels, bits, codec, server, ROAR_DIR_FILTER, "roarfilt") == -1 ) { 244 if ( roar_vio_simple_stream(&svio, 245 info.rate, info.channels, info.bits, info.codec, 246 server, ROAR_DIR_FILTER, "roarfilt") == -1 ) { 248 247 fprintf(stderr, "Error: can not start playback\n"); 249 248 return 1; … … 259 258 } 260 259 261 switch ( bits) {260 switch (info.bits) { 262 261 case 8: 263 262 while((i = roar_vio_read(&svio, buf, sizeof(buf)))) { 264 vol 1((void*)buf, mul, div, i);265 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/ bits);263 vol8((void*)buf, mul, div, i); 264 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/info.bits); 266 265 if (roar_vio_write(&svio, buf, i) != i) 267 266 break; … … 271 270 while((i = roar_vio_read(&svio, buf, sizeof(buf)))) { 272 271 if ( mul != div ) 273 vol 2((void*)buf, mul, div, i);272 vol16((void*)buf, mul, div, i); 274 273 #ifdef ROAR_HAVE_LIBM 275 274 if ( logscale ) 276 275 logs2((void*)buf, logscale, i); 277 276 if ( g_lowpass.a ) 278 lowpass2((void*)buf, i, channels);279 #endif 280 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/ bits);277 lowpass2((void*)buf, i, info.channels); 278 #endif 279 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/info.bits); 281 280 if (roar_vio_write(&svio, buf, i) != i) 282 281 break; … … 285 284 case 32: 286 285 while((i = roar_vio_read(&svio, buf, sizeof(buf)))) { 287 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/bits); 286 vol32((void*)buf, mul, div, i); 287 roardsp_fchain_calc(&fc, (void*)buf, (8*i)/info.bits); 288 288 if (roar_vio_write(&svio, buf, i) != i) 289 289 break; … … 291 291 break; 292 292 default: 293 fprintf(stderr, "Error: %i bits per sample is not supported!\n", bits);293 fprintf(stderr, "Error: %i bits per sample is not supported!\n", (int)info.bits); 294 294 return 1; 295 295 } -
roard/include/roard.h
r5140 r5180 189 189 int g_terminate; 190 190 191 #ifndef ROAR_ROARD_BITS192 #define ROAR_ROARD_BITS 32193 #endif194 195 191 struct roar_audio_info * g_sa, * g_max_sa; 196 192 -
roard/roard.c
r5161 r5180 1436 1436 g_verbose = ROAR_DBG_INFO_NONE; 1437 1437 1438 sa.bits = ROAR_ROARD_BITS; 1439 sa.channels = ROAR_CHANNELS_DEFAULT; 1440 sa.rate = ROAR_RATE_DEFAULT; 1441 sa.codec = ROAR_CODEC_DEFAULT; 1438 _LIBROAR_IGNORE_RET(roar_profile2info(&sa, "default-server")); 1442 1439 1443 1440 g_sa = &sa;
Note: See TracChangeset
for help on using the changeset viewer.