Changeset 1061:b91fe3c6f1e8 in roaraudio for libroardsp/convert.c


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.