Changeset 383:56f41c54f169 in roaraudio for libroardsp/convert.c


Ignore:
Timestamp:
08/06/08 04:03:43 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added working 16 bit mono resampling code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/convert.c

    r59 r383  
    222222} 
    223223 
     224 
     225 
     226int roar_conv_poly4_16 (int16_t * out, int16_t * in, size_t olen, size_t ilen) { 
     227 float poly[4]; 
     228 float data[4]; 
     229 float t    = 0; 
     230 float step = (float)ilen/olen; 
     231 int16_t * ci = in; 
     232 int io, ii = 0; 
     233 int i; 
     234 
     235 // we can not make a poly4 with less than 4 points ;) 
     236 if ( ilen < 4 ) 
     237  return -1; 
     238 
     239 for (i = 0; i < 4; i++) 
     240  data[i] = ci[i]; 
     241 roar_math_mkpoly_4x4(poly, data); 
     242/* 
     243 printf("new poly: data[4] = {%f, %f, %f, %f}, poly[4] = {%f, %f, %f, %f}\n", 
     244         data[0], data[1], data[2], data[3], 
     245         poly[0], poly[1], poly[2], poly[3] 
     246       ); 
     247*/ 
     248 
     249 //0 1 2 3 
     250 
     251 for (io = 0; io < olen; io++) { 
     252//  printf("t=%f\n", t); 
     253  out[io] = roar_math_cvpoly_4x4(poly, t); 
     254  t += step; 
     255  if ( t > 2 ) { // we need a new ploynome 
     256 //  printf("t > 2, need new data\n"); 
     257   if ( (ii + 4) < ilen ) { // else: end of block. 
     258    t -= 1; 
     259//    printf("new data: ii=%i\n", ii); 
     260    ii++; 
     261    ci++; 
     262    for (i = 0; i < 4; i++) 
     263     data[i] = ci[i]; 
     264    roar_math_mkpoly_4x4(poly, data); 
     265/*  
     266   printf("new poly: data[4] = {%f, %f, %f, %f}, poly[4] = {%f, %f, %f, %f}\n", 
     267           data[0], data[1], data[2], data[3], 
     268           poly[0], poly[1], poly[2], poly[3] 
     269          ); 
     270*/ 
     271   } 
     272  } 
     273 } 
     274 
     275 return 0; 
     276} 
     277 
    224278//ll 
Note: See TracChangeset for help on using the changeset viewer.