Changeset 2438:42679f780d53 in roaraudio


Ignore:
Timestamp:
08/19/09 20:54:21 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some basic code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/fader.c

    r2434 r2438  
    2525#include "libroardsp.h" 
    2626 
     27#define _CHECK_BASIC()   if ( state == NULL ) return -1 
     28#define _CHECK_CALCPCM() _CHECK_BASIC(); if ( frames == 0 ) return 0; if ( data == NULL ) return -1; 
     29 
     30int roar_fader_init         (struct roar_fader_state * state, float * poly, int coeff) { 
     31 _CHECK_BASIC(); 
     32 
     33 if ( poly == NULL ) 
     34  return -1; 
     35 
     36 if ( coeff < 2 ) 
     37  return -1; 
     38 
     39 if ( coeff > ROAR_FADER_MAX_COEFF ) 
     40  return -1; 
     41 
     42 memset(state, 0, sizeof(struct roar_fader_state)); 
     43 
     44 state->rate  = -1; 
     45 state->coeff = coeff; 
     46 
     47 memcpy(&(state->poly), poly, sizeof(float)*coeff); 
     48 
     49 return 0; 
     50} 
     51 
     52int roar_fader_set_rate     (struct roar_fader_state * state, int rate) { 
     53 _CHECK_BASIC(); 
     54 
     55 state->rate = rate; 
     56 
     57 return 0; 
     58} 
     59 
     60int roar_fader_set_startstop(struct roar_fader_state * state, ssize_t start, ssize_t stop) { 
     61 _CHECK_BASIC(); 
     62 
     63 if ( start >= 0 ) 
     64  state->start = start; 
     65 
     66 if ( stop  >= 0 ) 
     67  state->stop  = stop; 
     68 
     69 return 0; 
     70} 
     71 
     72int roar_fader_calcpcm_i16n(struct roar_fader_state * state, int16_t * data, size_t frames, int channels) { 
     73 _CHECK_CALCPCM(); 
     74 
     75 switch (channels) { 
     76  case 1: return roar_fader_calcpcm_i161(state, data, frames); 
     77 } 
     78 
     79 return -1; 
     80} 
     81 
     82int roar_fader_calcpcm_i161(struct roar_fader_state * state, int16_t * data, size_t frames) { 
     83 return -1; 
     84} 
    2785 
    2886//ll 
Note: See TracChangeset for help on using the changeset viewer.