Changeset 5181:ca57e34b2a35 in roaraudio for libroardsp/filter_add.c


Ignore:
Timestamp:
10/22/11 16:17:35 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

updated filters to support 8 and 32 bit as well as 16 bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/filter_add.c

    r4708 r5181  
    2626#include "libroardsp.h" 
    2727 
    28 int roardsp_add_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id) { 
    29  struct roardsp_amp * self = roar_mm_malloc(sizeof(struct roardsp_amp)); 
    30  
    31  if ( self == NULL ) 
    32   return -1; 
    33  
    34  memset(self, 0, sizeof(struct roardsp_amp)); 
    35  
    36  filter->inst = (void*) self; 
    37  
    38  roardsp_filter_reset(filter, ROARDSP_RESET_FULL); 
    39  
    40  return 0; 
     28#define _calcX(bits) \ 
     29int roardsp_add_calc##bits  (struct roardsp_filter * filter, void * data, size_t samples) { \ 
     30 struct roardsp_amp * self = (struct roardsp_amp *) filter->inst; \ 
     31 int##bits##_t * samp = (int##bits##_t *) data; \ 
     32 size_t i; \ 
     33\ 
     34 for (i = 0; i < samples; i++) { \ 
     35  samp[i] += self->mul / self->div; \ 
     36 }; \ 
     37\ 
     38 return 0; \ 
    4139} 
    4240 
    43 int roardsp_add_calc16  (struct roardsp_filter * filter, void * data, size_t samples) { 
    44  struct roardsp_amp * self = (struct roardsp_amp *) filter->inst; 
    45  int16_t * samp = (int16_t *) data; 
    46  size_t i; 
    47  
    48  for (i = 0; i < samples; i++) { 
    49   samp[i] += self->mul / self->div; 
    50  }; 
    51  
    52  return 0; 
    53 } 
     41_calcX(8) 
     42_calcX(16) 
     43_calcX(32) 
    5444 
    5545int roardsp_add_reset (struct roardsp_filter * filter, int what) { 
Note: See TracChangeset for help on using the changeset viewer.