Changeset 1061:b91fe3c6f1e8 in roaraudio


Ignore:
Timestamp:
12/24/08 13:21:36 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote zoh resampler, fixed a bug with output size calulation

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/convert.h

    r876 r1061  
    6666int roar_conv_chans_2to116 (void * out, void * in, int samples);           // yes          yes 
    6767 
    68 int roar_conv_rate    (void * out, void * in, int samples, int from, int to, int bits, int channels); 
    69 int roar_conv_rate_8  (void * out, void * in, int samples, int from, int to, int channels); 
    70 int roar_conv_rate_16 (void * out, void * in, int samples, int from, int to, int channels); 
     68int roar_conv_rate       (void * out, void * in, int samples, int from, int to, int bits, int channels); 
     69int roar_conv_rate_8     (void * out, void * in, int samples, int from, int to, int channels); 
     70int roar_conv_rate_16    (void * out, void * in, int samples, int from, int to, int channels); 
     71int roar_conv_rate_161zoh(void * out, void * in, int samples, int from, int to); 
     72int roar_conv_rate_162zoh(void * out, void * in, int samples, int from, int to); 
     73int roar_conv_rate_16nzoh(void * out, void * in, int samples, int from, int to, int channels); 
    7174 
    7275int roar_conv_codec (void * out, void * in, int samples, int from, int to, int bits); 
  • libroardsp/convert.c

    r1060 r1061  
    322322 
    323323int roar_conv_rate_16 (void * out, void * in, int samples, int from, int to, int channels) { 
    324  if ( channels == 1 ) { 
    325   printf("roar_conv_rate_16(): samples=%i -> %i, rate=%i -> %i\n", samples*from/to, samples, from, to); 
    326   return roar_conv_poly4_16s((int16_t*) out, (int16_t*) in, samples, samples*from/to, (float)from/to); 
    327 //  return roar_conv_poly4_16((int16_t*) out, (int16_t*) in, samples*to/from, samples); 
     324 if ( from > to ) { 
     325  switch (channels) { 
     326   case 1: 
     327     return roar_conv_rate_161zoh(out, in, samples, from, to); 
     328   case 2: 
     329   default: 
     330     return -1; 
     331  } 
     332 } else { 
     333  if ( channels == 1 ) { 
     334   printf("roar_conv_rate_16(): samples=%i -> %i, rate=%i -> %i\n", samples*from/to, samples, from, to); 
     335   return roar_conv_poly4_16s((int16_t*) out, (int16_t*) in, samples, samples*from/to, (float)from/to); 
     336 //  return roar_conv_poly4_16((int16_t*) out, (int16_t*) in, samples*to/from, samples); 
     337  } 
    328338 } 
    329339 
    330340 return -1; 
     341} 
     342 
     343int roar_conv_rate_161zoh(void * out, void * in, int samples, int from, int to) { 
     344 int16_t * ip = in; 
     345 int16_t * op = out; 
     346 float t = 0; 
     347 float step = (float)to/from; 
     348 int i; 
     349 
     350 for (i= 0; i < samples; i++) { 
     351  op[(int)t] = ip[i]; 
     352  t += step; 
     353 } 
     354 
     355 return 0; 
    331356} 
    332357 
  • roard/include/output.h

    r972 r1061  
    3838#define ROAR_OUTPUT_WRITE_SIZE     1024 
    3939 
    40 #define ROAR_OUTPUT_CALC_OUTBUFSIZE(x)   (ROAR_OUTPUT_BUFFER_SAMPLES * (x)->channels * ((x)->bits / 8)) 
    41 #define ROAR_OUTPUT_CALC_OUTBUFSAMP(x,y) ((y) / ((x)->channels * ((x)->bits / 8))) 
     40#define ROAR_OUTPUT_CALC_OUTBUFSIZE(x)   (ROAR_OUTPUT_BUFFER_SAMPLES * (x)->channels * ((x)->bits / 8) * ((float)(x)->rate/g_sa->rate)) 
     41#define ROAR_OUTPUT_CALC_OUTBUFSAMP(x,y) ((y) / ((x)->channels * ((x)->bits / 8)*((float)(x)->rate/g_sa->rate))) 
    4242 
    4343void         * g_output_buffer; 
Note: See TracChangeset for help on using the changeset viewer.