Changeset 5533:42f48072307c in roaraudio for roarclients/roarvumeter.c


Ignore:
Timestamp:
06/12/12 14:39:40 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Fixed usage of -R/-B/-C/-E as well as --aiprofile in roarclients (Closes: #176)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarvumeter.c

    r5381 r5533  
    4545 printf("\nOptions:\n\n"); 
    4646 
    47  printf("  --server  SERVER   - Set server hostname\n" 
    48         "  --rate    RATE     - Set sample rate\n" 
    49         "  --bits    BITS     - Set bits per sample\n" 
    50         "  --chans   CHANNELS - Set number of channels\n" 
    51         "  --samples SAMPLES  - Set number of input samples per block\n" 
    52         "  --pc               - Use percent scale\n" 
    53         "  --db               - Use dB scale\n" 
    54         "  --beat             - Enable beat detection\n" 
    55         "  --lowpass FREQ     - Use lowpass to filter input (-%idB/dec)\n" 
    56         "  --help             - Show this help\n", 
     47 printf("  --server  SERVER    - Set server hostname\n" 
     48        "  --rate  -R RATE     - Set sample rate\n" 
     49        "  --bits  -B BITS     - Set bits per sample\n" 
     50        "  --chans -C CHANS    - Set number of channels\n" 
     51        "  --aiprofile PROFILE - Set audio profile\n" 
     52        "  --samples SAMPLES   - Set number of input samples per block\n" 
     53        "  --pc                - Use percent scale\n" 
     54        "  --db                - Use dB scale\n" 
     55        "  --beat              - Enable beat detection\n" 
     56        "  --lowpass FREQ      - Use lowpass to filter input (-%idB/dec)\n" 
     57        "  --help              - Show this help\n", 
    5758        LOWPASS_ORDER * 20 
    5859       ); 
     
    163164 struct roardsp_filter      * filter; 
    164165 float  lowpass_freq = 0; 
    165  int    rate     = ROAR_RATE_DEFAULT; 
    166  int    bits     = 16; 
    167  int    channels = 2; 
    168  int    codec    = ROAR_CODEC_DEFAULT; 
     166 struct roar_audio_info info; 
    169167 int    samples  = -1; 
    170168 char * server   = NULL; 
     
    174172 int    mode = 0; 
    175173 
     174 if ( roar_profile2info(&info, "default") == -1 ) 
     175  return 1; 
     176 
    176177 for (i = 1; i < argc; i++) { 
    177178  k = argv[i]; 
     
    179180  if ( strcmp(k, "--server") == 0 ) { 
    180181   server = argv[++i]; 
    181   } else if ( strcmp(k, "--rate") == 0 ) { 
    182    rate = roar_str2rate(argv[++i]); 
    183   } else if ( strcmp(k, "--bits") == 0 ) { 
    184    bits = roar_str2bits(argv[++i]); 
    185   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0) { 
    186    channels = roar_str2channels(argv[++i]); 
     182  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     183   info.rate = roar_str2rate(argv[++i]); 
     184  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     185   info.bits = roar_str2bits(argv[++i]); 
     186  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     187   info.channels = roar_str2channels(argv[++i]); 
     188  } else if ( !strcmp(k, "--aiprofile") ) { 
     189   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     190    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     191    return 1; 
     192   } 
    187193  } else if ( strcmp(k, "--samples") == 0 ) { 
    188194   samples = atoi(argv[++i]); 
     
    213219 
    214220 if ( samples == -1 ) 
    215   samples = rate/10; 
     221  samples = info.rate/10; 
    216222 
    217223 if ( roar_simple_connect(&con, server, "roarvumeter") == -1 ) { 
     
    220226 } 
    221227 
    222  if ( roar_vio_simple_new_stream_obj(&stream, &con, &s, rate, channels, bits, codec, ROAR_DIR_MONITOR, -1) == -1) { 
     228 if ( roar_vio_simple_new_stream_obj(&stream, &con, &s, 
     229                                     info.rate, info.channels, info.bits, ROAR_CODEC_DEFAULT, 
     230                                     ROAR_DIR_MONITOR, -1) == -1) { 
    223231  fprintf(stderr, "Error: can not start monetoring\n"); 
    224232  return 1; 
     
    262270 } 
    263271 
    264  vumeter(&re, samples*channels, bits, channels, mode, &fchain); 
     272 vumeter(&re, samples*info.channels, info.bits, info.channels, mode, &fchain); 
    265273 
    266274 printf("\n"); // if the reach this then roard has quited and we should print a newline 
Note: See TracChangeset for help on using the changeset viewer.