Changeset 2156:62c741edbdbc in roaraudio


Ignore:
Timestamp:
07/24/09 23:49:32 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_remove_so() and roar_remove_so16()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/remove.h

    r2145 r2156  
    4949int roar_remove_32   (int8_t  * inout, int8_t  * subs, int samples, struct roar_remove_state * state); 
    5050 
     51int roar_remove_so   (void    * subout, void    * in, int samples, int bits, struct roar_remove_state * state); 
     52int roar_remove_so16 (int16_t * subout, int16_t * in, int samples, struct roar_remove_state * state); 
     53 
    5154#endif 
    5255 
  • libroardsp/remove.c

    r2145 r2156  
    8888} 
    8989 
     90int 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 
     101int 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 
    90134//ll 
Note: See TracChangeset for help on using the changeset viewer.