Changeset 59:db97b72a53ca in roaraudio


Ignore:
Timestamp:
07/12/08 12:18:18 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added another non-working resampling code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/convert.c

    r35 r59  
    9797 
    9898int roar_conv_rate_16 (void * out, void * in, int samples, int from, int to, int channels) { 
     99 int16_t * ip = (int16_t*) in, * op = (int16_t*) out; 
     100 int i, j; 
     101 int max; 
     102 int teiler = -1; 
     103 
     104 
     105 if ( from > to ) { 
     106  return -1; 
     107 } else { 
     108  for (i = 8; i > 0; i--) { 
     109   if ( from * i == to ) { 
     110    teiler = i; 
     111    break; 
     112   } 
     113  } 
     114 
     115  if ( teiler == -1 ) 
     116   return -1; 
     117 
     118  if ( channels == 2 ) { 
     119   max = (samples-1)/(2*teiler); 
     120 
     121   for (i = 0; i < max; i++) { 
     122    for (j = 0; j < teiler; j++) { 
     123     op[teiler*i*2     + j] = ip[i]; 
     124     op[teiler*i*2 + 2 + j] = ip[i+1]; 
     125    } 
     126   } 
     127 
     128  } else if ( channels == 1 ) { 
     129   max = (samples-1)/teiler; 
     130 
     131   for (i = 0; i < max; i++) { 
     132    for (j = 0; j < teiler; j++) { 
     133     op[teiler*i + j] = ip[i]; 
     134    } 
     135   } 
     136 
     137  } else { 
     138   return -1; 
     139   max = (samples-1)/teiler; 
     140 
     141   for (i = 0; i < max; i++) { 
     142    for (j = 0; j < teiler; j++) { 
     143//      printf("op[teiler*i + j = %i] = ip[i=%i]; // samples=%i, teiler=%i, channels=%i\n", 
     144//                teiler*i + j, i + ((i+j) % channels), samples, teiler, channels); 
     145      op[teiler*i + j] = ip[i + ((i+j) % channels)]; 
     146    } 
     147   } 
     148  } 
     149 
     150  return 0; 
     151 } 
     152 
    99153 return -1; 
    100154} 
Note: See TracChangeset for help on using the changeset viewer.