Changeset 2916:3df957c2297b in roaraudio
- Timestamp:
- 10/16/09 16:48:20 (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roarclients
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/Makefile
r2845 r2916 46 46 $L 47 47 roarctl: roarctl.o 48 $L 48 $L $(lib_m) 49 49 roarmon: roarmon.o 50 50 $L -
roarclients/roarctl.c
r2814 r2916 36 36 #include <sys/time.h> 37 37 #include <time.h> 38 39 #ifdef ROAR_HAVE_LIBM 40 #include <math.h> 41 #endif 38 42 39 43 int g_verbose = 0; … … 423 427 } 424 428 429 #ifdef ROAR_HAVE_LIBM 430 #define _DB ", %.2fdB" 431 #else 432 #define _DB "" 433 #endif 434 425 435 for (i = 0; i < channels; i++) 426 printf("Mixer volume chan %2i : %i (%.2f%%)\n", i, mixer.mixer[i], (float)mixer.mixer[i]/655.35); 436 printf("Mixer volume chan %2i : %i (%.2f%%" _DB ")\n", i, mixer.mixer[i], 437 (float)mixer.mixer[i]/655.35f 438 #ifdef ROAR_HAVE_LIBM 439 , 20*log10f((float)mixer.mixer[i]/65535.f) 440 #endif 441 ); 427 442 428 443 return 0; 444 } 445 446 static unsigned int set_mixer_parse_volume (char * k, int len) { 447 switch (k[len - 1]) { 448 case '%': 449 k[len - 1] = 0; 450 return (atof(k)*65535.f)/100; 451 break; 452 #ifdef ROAR_HAVE_LIBM 453 case 'b': 454 case 'B': 455 // TODO: can we hanle the error better? 456 if ( len < 2 ) 457 return 0; 458 459 k[len - 2] = 0; 460 return powf(10, atof(k)/20.f)*65535.f; 461 break; 462 #endif 463 } 464 465 return atoi(k); 429 466 } 430 467 … … 464 501 len = strlen(k); 465 502 466 if ( k[len - 1] == '%' ) { 467 k[len - 1] = 0; 468 vol_mono = (atof(k)*65535)/100; 469 } else { 470 vol_mono = atoi(k); 471 } 503 vol_mono = set_mixer_parse_volume(k, len); 472 504 473 505 for (i = 0; i < old_chans; i++) … … 485 517 len = strlen(k); 486 518 487 if ( k[len - 1] == '%' ) { 488 k[len - 1] = 0; 489 vol_l = (atof(k)*65535)/100; 490 } else { 491 vol_l = atoi(k); 492 } 519 vol_l = set_mixer_parse_volume(k, len); 493 520 494 521 k = arg[++(*cur)]; 495 522 len = strlen(k); 496 523 497 if ( k[len - 1] == '%' ) { 498 k[len - 1] = 0; 499 vol_r = (atof(k)*65535)/100; 500 } else { 501 vol_r = atoi(k); 502 } 524 vol_r = set_mixer_parse_volume(k, len); 503 525 504 526 vol_mono = (vol_l + vol_r) / 2; … … 554 576 len = strlen(k); 555 577 556 if ( k[len - 1] == '%' ) { 557 k[len - 1] = 0; 558 mixer.mixer[i] = (atof(k)*(int)65535)/100; 559 } else { 560 mixer.mixer[i] = atoi(k); 561 } 578 mixer.mixer[i] = set_mixer_parse_volume(k, len); 562 579 } 563 580 }
Note: See TracChangeset
for help on using the changeset viewer.