Changeset 5550:61fb37b34dc4 in roaraudio


Ignore:
Timestamp:
06/17/12 23:40:38 (5 years ago)
Author:
phi
Branch:
default
Message:

support setting volume

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarsin.c

    r5549 r5550  
    8383         "  --freq FREQ             - Set frequency (in Hz)\n" 
    8484         "  --time TIME             - Set time (in sec)\n" 
     85         "  --volume VOL            - Set volume\n" 
    8586        ); 
    8687 
     
    108109 int16_t out[1024]; 
    109110 double (*func)(double x) = sin; 
     111 double volume = 1; 
    110112 
    111113 for (i = 1; i < argc; i++) { 
     
    118120  } else if ( !strcmp(argv[i], "--rate") || !strcmp(argv[i], "-R") ) { 
    119121   rate = roar_str2rate(argv[++i]); 
     122  } else if ( !strcmp(argv[i], "--volume") ) { 
     123   volume = atof(argv[++i]); 
    120124  } else if ( !strcmp(argv[i], "--sin") ) { 
    121125   func   = sin; 
     
    144148 } 
    145149 
     150 if ( roar_vs_volume_mono(vss, volume, NULL) == 0 ) { 
     151  // If setting server volume successed set local volume to one. 
     152  volume = 1; 
     153 } 
     154 
    146155 while (t < 2*M_PI*freq*length) { 
    147156  for (i = 0; i < 1024; i++) { 
    148    out[i] = 32767*func(tcalc); 
     157   out[i] = 32767.*volume*func(tcalc); 
    149158   t     += step; 
    150159   tcalc += step; 
Note: See TracChangeset for help on using the changeset viewer.