Changeset 2156:62c741edbdbc in roaraudio
- Timestamp:
- 07/24/09 23:49:32 (15 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroardsp/remove.h
r2145 r2156 49 49 int roar_remove_32 (int8_t * inout, int8_t * subs, int samples, struct roar_remove_state * state); 50 50 51 int roar_remove_so (void * subout, void * in, int samples, int bits, struct roar_remove_state * state); 52 int roar_remove_so16 (int16_t * subout, int16_t * in, int samples, struct roar_remove_state * state); 53 51 54 #endif 52 55 -
libroardsp/remove.c
r2145 r2156 88 88 } 89 89 90 int roar_remove_so (void * subout, void * in, int samples, int bits, struct roar_remove_state * state) { 91 if ( subout == NULL || in == NULL || samples < 0 ) 92 return -1; 93 94 switch (bits) { 95 case 16: return roar_remove_so16(subout, in, samples, state); break; 96 } 97 98 return -1; 99 } 100 101 int roar_remove_so16 (int16_t * subout, int16_t * in, int samples, struct roar_remove_state * state) { 102 int i; 103 register int32_t s; 104 register int32_t peak; 105 106 if ( state == NULL ) { 107 for (i = 0; i < samples; i++) { 108 s = -subout[i]; 109 s += in[i]; 110 subout[i] = s; 111 } 112 } else { 113 peak = 65535; 114 for (i = 0; i < samples; i++) { 115 s = -subout[i]; 116 s += in[i]; 117 s = s < 0 ? -s : s; // we true 32 bit, not int operation here 118 if ( s > peak ) 119 peak = s; 120 } 121 122 for (i = 0; i < samples; i++) { 123 s = -subout[i]; 124 s *= 65535; 125 s /= peak; 126 s += in[i]; 127 subout[i] = s; 128 } 129 } 130 131 return 0; 132 } 133 90 134 //ll
Note: See TracChangeset
for help on using the changeset viewer.