Changeset 128:5cae7d8795d5 in roaraudio
- Timestamp:
- 07/13/08 19:23:13 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarfilt.c
r126 r128 15 15 " --chans CHANNELS - Set number of channels\n" 16 16 " --help - Show this help\n" 17 "\n" 18 " --half - half the volume\n" 19 " --double - double the volume\n" 17 20 ); 18 21 22 } 23 24 void vol2 (void * data, int mul, int div, int len) { 25 int16_t * samples = (int16_t *) data; 26 int i; 27 28 len /= 2; 29 30 for (i = 0; i < len; i++) 31 samples[i] = ((int) samples[i] * mul) / div; 32 } 33 34 void vol1 (void * data, int mul, int div, int len) { 35 int8_t * samples = (int8_t *) data; 36 int i; 37 38 len /= 2; 39 40 for (i = 0; i < len; i++) 41 samples[i] = ((int) samples[i] * mul) / div; 19 42 } 20 43 … … 28 51 int fh; 29 52 int i; 53 int mul = 1, div = 1; 30 54 char buf[BUFSIZE]; 31 55 … … 41 65 } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 42 66 channels = atoi(argv[++i]); 67 } else if ( strcmp(k, "--half") == 0 ) { 68 div *= 2; 69 } else if ( strcmp(k, "--double") == 0 ) { 70 mul *= 2; 43 71 } else if ( strcmp(k, "--help") == 0 ) { 44 72 usage(); … … 56 84 } 57 85 58 while((i = read(fh, buf, BUFSIZE))) 59 if (write(fh, buf, i) != i) 60 break; 86 if ( mul == div ) { 87 fprintf(stderr, "Error: filter is useless!\n"); 88 return 0; 89 } 90 91 if ( bits == 16 ) { 92 while((i = read(fh, buf, BUFSIZE))) { 93 vol2((void*)buf, mul, div, i); 94 if (write(fh, buf, i) != i) 95 break; 96 } 97 } else if ( bits == 8 ) { 98 while((i = read(fh, buf, BUFSIZE))) { 99 vol1((void*)buf, mul, div, i); 100 if (write(fh, buf, i) != i) 101 break; 102 } 103 } else { 104 fprintf(stderr, "Error: %i bits per sample is not supported!\n", bits); 105 return 1; 106 } 61 107 62 108 roar_simple_close(fh);
Note: See TracChangeset
for help on using the changeset viewer.