Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members  

audioproc.cpp

00001 /* MuSE - Multiple Streaming Engine
00002  *
00003  * DSP processing routines
00004  * Copyright (C) 2002 Matteo Nastasi aka mop <nastasi@alternativeoutput.it>
00005  *
00006  * This source code is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Public License as published 
00008  * by the Free Software Foundation; either version 2 of the License,
00009  * or (at your option) any later version.
00010  *
00011  * This source code is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00014  * Please refer to the GNU Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Public License along with
00017  * this source code; if not, write to:
00018  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  
00020  "$Id: audioproc.cpp,v 1.1.1.1 2003/12/08 12:20:33 jaromil Exp $"
00021  
00022  */
00023 
00024 #include <math.h>
00025 #include <generic.h>
00026 #include <config.h>
00027 
00028 #ifdef MOP_RESAMP
00029 #include <stdio.h>
00030 #include <resarr320to441.h>
00031 #include <resarr160to441.h>
00032 
00033 #define CLIP16BIT(a) ((a) > 32767L ? 32767L : ((a) < -32767L ? -32767L : (a)))
00034 
00035 
00036 #endif
00037 #include <jutils.h>
00038 
00039 /* TERMINOLOGY
00040    samples are 32bit if stereo, 16bit if mono (assuming 16bit sound)
00041    frames = samples * channels;
00042    bytes = frames * ( sizeof( typeof( frames ) ) );
00043    in our case the type of frames is IN_DATATYPE configured to be 2 bytes
00044 */
00045 
00046 
00047 /* resampling routines
00048    
00049    these resample an input pcm buffer to 16bit stereo 44khz
00050    stereo is treated as interleaved
00051    *src is the input buffer
00052    *dest is the the resampled buffer: interleaved stereo 16bit 44khz
00053    num is number of FRAMES to be mixed
00054    volume multiplier is also applied during resampling
00055    
00056    value returned is number of FRAMES processed
00057 */
00058 
00059 #ifdef MOP_RESAMP
00060 int resample_mono_16(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00061                      unsigned int num, float volume) {
00062   /* il .001 per garantire che una qualche approssimazione non faccia
00063      andare a leggere dati che non sono presenti */
00064   int tnum = (int)((float)num * (441.0 / 160.001))<<1; 
00065   int c, cc;
00066   int disp = 0, modul = 0, oldin = -1, curin;
00067   long lframe;
00068   float ka,kb,kc;
00069 
00070   //  fprintf(stderr,"prev %d\n",prev[3]);
00071 
00072   lframe = (long)(prev[2] * volume);
00073   dest[0] = dest[1] = (IN_DATATYPE)CLIP16BIT(lframe);
00074   /*    a = y1
00075         b = 2y2 - (y3 + 3y1) / 2
00076         c = (y3 + y1) / 2 - y2
00077         dove:
00078         y1 = prev[2]    y2 = prev[3]    y3 = src[0]  */
00079   ka = (float)prev[2];
00080   kb = (float)(2.0*prev[3]) - ((float)(src[0] + 3 * prev[2]) / 2.0);
00081   kc = ((float)(src[0] + prev[2]) / 2.0) - (float)prev[3];
00082     lframe = (long)((ka + (kb + kc * resarr160to441x[1]) *
00083                    resarr160to441x[1]) * volume);
00084   dest[2] = dest[3] = (IN_DATATYPE)CLIP16BIT(lframe);
00085   lframe = (long)((ka + (kb + kc * resarr160to441x[2]) *
00086                    resarr160to441x[2]) * volume);
00087   dest[4] = dest[5] = (IN_DATATYPE)CLIP16BIT(lframe);
00088   lframe = (long)((ka + (kb + kc * resarr160to441x[3]) *
00089                    resarr160to441x[3]) * volume);
00090   dest[6] = dest[7] = (IN_DATATYPE)CLIP16BIT(lframe);
00091   lframe = (long)((ka + (kb + kc * resarr160to441x[4]) *
00092                    resarr160to441x[4]) * volume);
00093   dest[8] = dest[9] = (IN_DATATYPE)CLIP16BIT(lframe);
00094 
00095   /*    y1 = prev[3]    y2 = src[0]    y3 = src[1]    */
00096   ka = (float)prev[3];
00097   kb = (float)(2.0*src[0]) - ((float)(src[1] + 3 * prev[3]) / 2.0);
00098   kc = ((float)(src[1] + prev[3]) / 2.0) - (float)src[0];
00099   lframe = (long)((ka + (kb + kc * resarr160to441x[5]) * 
00100                    resarr160to441x[5]) * volume);
00101   dest[10] = dest[11] = (IN_DATATYPE)CLIP16BIT(lframe);
00102   lframe = (long)((ka + (kb + kc * resarr160to441x[6]) * 
00103                    resarr160to441x[6]) * volume);
00104   dest[12] = dest[13] = (IN_DATATYPE)CLIP16BIT(lframe);
00105 
00106   for (c = 14 , modul = 0 ; c < tnum ; c+= 2) {
00107     cc = (c>>1) - modul;
00108     curin = disp+resarr160to441lc[cc];
00109     if (curin != oldin) {
00110       oldin = curin;
00111       /*    y1 = src[curin]    y2 = src[curin+1]    y3 = src[curin+2]    */
00112       ka = (float)src[curin];
00113       kb = (float)(2.0*src[curin+1]) - ((float)(src[curin+2] + 3 * src[curin]) / 2.0);
00114       kc = ((float)(src[curin+2] + src[curin]) / 2.0) - (float)src[curin+1];
00115     }
00116     lframe = (long)((ka + (kb + kc * resarr160to441lx[cc]) * 
00117                      resarr160to441lx[cc]) * volume);
00118     dest[c] = dest[c+1] = (IN_DATATYPE)CLIP16BIT(lframe);
00119     if (cc == 441) {
00120       modul += 441;
00121       disp += 160;
00122     }
00123   }
00124   //  fprintf(stderr,"last %d\n",src[(num>>1)]);
00125 
00126   return (tnum);
00127 }
00128 
00129 int resample_stereo_16(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00130                      unsigned int num, float volume) {
00131   /* il .001 per garantire che una qualche approssimazione non faccia
00132      andare a leggere dati che non sono presenti */
00133   int tnum = (int)((float)(num>>1) * (441.0 / 160.001))<<1; 
00134   int c, cc;
00135   int disp = 0, modul = 0, oldin = -1, curin;
00136   long lframe;
00137   float ka,kb,kc;
00138   float ha,hb,hc;
00139 
00140   //  fprintf(stderr,"prev %d %d %d %d\n",prev[0],prev[1],prev[2],prev[3]);
00141 
00142   /* CHANNEL 0  -  samples 0,1,2,3,4  -  frames 0,2,4,6,8  */
00143   /*    a = y1
00144         b = 2y2 - (y3 + 3y1) / 2
00145         c = (y3 + y1) / 2 - y2
00146         dove:
00147         y1 = prev[0]    y2 = prev[2]    y3 = src[0]  */
00148   ka = (float)prev[0];
00149   kb = (float)(2.0*prev[2]) - ((float)(src[0] + 3 * prev[0]) / 2.0);
00150   kc = ((float)(src[0] + prev[0]) / 2.0) - (float)prev[2];
00151   
00152   lframe = (long)(prev[0] * volume);
00153   dest[0] = (IN_DATATYPE)CLIP16BIT(lframe);
00154   lframe = (long)((ka + (kb + kc * resarr160to441x[1]) *
00155                    resarr160to441x[1]) * volume);
00156   dest[2] = (IN_DATATYPE)CLIP16BIT(lframe);
00157   lframe = (long)((ka + (kb + kc * resarr160to441x[2]) *
00158                    resarr160to441x[2]) * volume);
00159   dest[4] = (IN_DATATYPE)CLIP16BIT(lframe);
00160   lframe = (long)((ka + (kb + kc * resarr160to441x[3]) *
00161                    resarr160to441x[3]) * volume);
00162   dest[6] = (IN_DATATYPE)CLIP16BIT(lframe);
00163   lframe = (long)((ka + (kb + kc * resarr160to441x[4]) *
00164                    resarr160to441x[4]) * volume);
00165   dest[8] = (IN_DATATYPE)CLIP16BIT(lframe);
00166 
00167   /* CHANNEL 1  -  samples 0,1,2,3,4  -  frames 1,3,5,7,9  */
00168   /*  y1 = prev[1]    y2 = prev[3]    y3 = src[1]  */
00169   ha = (float)prev[1];
00170   hb = (float)(2.0*prev[3]) - ((float)(src[1] + 3 * prev[1]) / 2.0);
00171   hc = ((float)(src[1] + prev[1]) / 2.0) - (float)prev[3];
00172   
00173   lframe = (long)(prev[1] * volume);
00174   dest[1] = (IN_DATATYPE)CLIP16BIT(lframe);
00175   lframe = (long)((ha + (hb + hc * resarr160to441x[1]) *
00176                    resarr160to441x[1]) * volume);
00177   dest[3] = (IN_DATATYPE)CLIP16BIT(lframe);
00178   lframe = (long)((ha + (hb + hc * resarr160to441x[2]) *
00179                    resarr160to441x[2]) * volume);
00180   dest[5] = (IN_DATATYPE)CLIP16BIT(lframe);
00181   lframe = (long)((ha + (hb + hc * resarr160to441x[3]) *
00182                    resarr160to441x[3]) * volume);
00183   dest[7] = (IN_DATATYPE)CLIP16BIT(lframe);
00184   lframe = (long)((ha + (hb + hc * resarr160to441x[4]) *
00185                    resarr160to441x[4]) * volume);
00186   dest[9] = (IN_DATATYPE)CLIP16BIT(lframe);
00187   // dest[1] = dest[3] = dest[5] = dest[7] = dest[9] = 0;
00188   /* CHANNEL 0  -  samples 5,6  -  frames 10,12  */
00189   /*    y1 = prev[2]    y2 = src[0]    y3 = src[2]    */
00190   ka = (float)prev[2];
00191   kb = (float)(2.0*src[0]) - ((float)(src[2] + 3 * prev[2]) / 2.0);
00192   kc = ((float)(src[2] + prev[2]) / 2.0) - (float)src[0];
00193   lframe = (long)((ka + (kb + kc * resarr160to441x[5]) * 
00194                    resarr160to441x[5]) * volume);
00195   dest[10] = (IN_DATATYPE)CLIP16BIT(lframe);
00196   lframe = (long)((ka + (kb + kc * resarr160to441x[6]) * 
00197                    resarr160to441x[6]) * volume);
00198   dest[12] = (IN_DATATYPE)CLIP16BIT(lframe);
00199 
00200   /* CHANNEL 1  -  samples 5,6  -  frames 11,13  */
00201   /*    y1 = prev[3]    y2 = src[1]    y3 = src[3]    */
00202   ha = (float)prev[3];
00203   hb = (float)(2.0*src[1]) - ((float)(src[3] + 3 * prev[3]) / 2.0);
00204   hc = ((float)(src[3] + prev[3]) / 2.0) - (float)src[1];
00205   lframe = (long)((ha + (hb + hc * resarr160to441x[5]) * 
00206                    resarr160to441x[5]) * volume);
00207   dest[11] = (IN_DATATYPE)CLIP16BIT(lframe);
00208   lframe = (long)((ha + (hb + hc * resarr160to441x[6]) * 
00209                    resarr160to441x[6]) * volume);
00210   dest[13] = (IN_DATATYPE)CLIP16BIT(lframe);
00211   // dest[11] = dest[13] = 0;
00212 
00213 
00214   for (c = 14 , modul = 0 ; c < tnum ; c+= 2) {
00215     cc = (c>>1) - modul;
00216     curin = disp+(resarr160to441lc[cc] << 1);
00217     if (curin != oldin) {
00218       oldin = curin;
00219       /*    y1 = src[curin]    y2 = src[curin+2]    y3 = src[curin+4]    */
00220       ka = (float)src[curin];
00221       kb = (float)(2.0*src[curin+2]) - ((float)(src[curin+4] + 
00222                                                 3 * src[curin]) / 2.0);
00223       kc = ((float)(src[curin+4] + src[curin]) / 2.0) - (float)src[curin+2];
00224       /*    y1 = src[curin+1]  y2 = src[curin+3]    y3 = src[curin+5]    */
00225       ha = (float)src[curin+1];
00226       hb = (float)(2.0*src[curin+3]) - ((float)(src[curin+5] + 
00227                                                 3 * src[curin+1]) / 2.0);
00228       hc = ((float)(src[curin+5] + src[curin+1]) / 2.0) - (float)src[curin+3];
00229 
00230     }
00231     lframe = (long)((ka + (kb + kc * resarr160to441lx[cc]) * 
00232                      resarr160to441lx[cc]) * volume);
00233     dest[c] = (IN_DATATYPE)CLIP16BIT(lframe);
00234     lframe = (long)((ha + (hb + hc * resarr160to441lx[cc]) * 
00235                      resarr160to441lx[cc]) * volume);
00236     dest[c+1] = (IN_DATATYPE)CLIP16BIT(lframe);
00237     // dest[c+1] = 0;
00238     if (cc == 441) {
00239       modul += 441;
00240       disp += 320;
00241     }
00242   }
00243   //  fprintf(stderr,"last %d %d  %d %d|",src[num-4],src[num-3],src[num-2],src[num-1]);
00244 
00245   return (tnum);
00246 }
00247 #endif
00248 
00249 int resample_mono_22(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00250                      unsigned int num, float volume) {
00251 #ifdef MOP_RESAMP
00252   float volmez;
00253   unsigned int i, ipu;
00254 
00255   volmez = volume / 2.0;
00256   dest[0] = dest[1] = (IN_DATATYPE)((float)((long)prev[3] + (long)src[0]) * volmez);
00257   dest[2] = dest[3] = (IN_DATATYPE)((float)src[0] * volume);
00258   
00259   for (i = 1 ; i < num ; i++) {
00260     ipu = i<<2;
00261     dest[ipu] = dest[ipu+1] = (IN_DATATYPE)((float)((long)src[i-1] + 
00262                                                     (long)src[i]) * volmez);
00263     dest[ipu+2] = dest[ipu+3] = (IN_DATATYPE)((float)src[i] * volume);
00264   }
00265 
00266   return((int)num<<2);
00267 #else
00268   unsigned int c,cc;
00269   for(c=0,cc=0;c<num;c++) {
00270     cc = c<<2;
00271     dest[cc] = dest[cc+1] = dest[cc+2] = dest[cc+3] =
00272       (IN_DATATYPE) (src[c]*volume);
00273   }
00274   return((int)num<<2);
00275 #endif
00276 }
00277 
00278 int resample_stereo_22(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00279                      unsigned int num, float volume) {
00280 #ifdef MOP_RESAMP
00281   float volmez;
00282   unsigned int i, ipu;
00283 
00284   volmez = volume / 2.0;
00285   dest[0] = (IN_DATATYPE)((float)((long)prev[2] + (long)src[0]) * volmez);
00286   dest[1] = (IN_DATATYPE)((float)((long)prev[3] + (long)src[1]) * volmez);
00287   dest[2] = (IN_DATATYPE)((float)src[0] * volume);
00288   dest[3] = (IN_DATATYPE)((float)src[1] * volume);
00289   
00290   for (i = 2 ; i < num ; i+=2) {
00291     ipu = i<<1;
00292     dest[ipu]   = (IN_DATATYPE)((float)((long)src[i-2] + 
00293                                                     (long)src[i]) * volmez);
00294     dest[ipu+1] = (IN_DATATYPE)((float)((long)src[i-1] + 
00295                                                     (long)src[i+1]) * volmez);
00296     dest[ipu+2] = (IN_DATATYPE)((float)src[i] * volume);
00297     dest[ipu+3] = (IN_DATATYPE)((float)src[i+1] * volume);
00298   }
00299 
00300   return((int)num<<1);
00301 #else
00302   unsigned int c,cc;
00303   for(c=0,cc=0;c<num;c++) {
00304     cc = c<<1;
00305     dest[cc] = dest[cc+1] = (IN_DATATYPE) (src[c]*volume);
00306   }
00307   return((int)num<<1);
00308 #endif
00309 }
00310 
00311 
00312 #ifdef MOP_RESAMP
00313 int resample_mono_32(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00314                      unsigned int num, float volume) {
00315   /* il .001 per garantire che una qualche approssimazione non faccia
00316      andare a leggere dati che non sono presenti */
00317   int tnum = (int)((float)num * (441.0 / 320.001))<<1; 
00318   int c, cc;
00319   int disp = 0, modul = 0, oldin = -1, curin;
00320   long lframe;
00321   float ka,kb,kc;
00322 
00323   /*    a = y1
00324         b = 2y2 - (y3 + 3y1) / 2
00325         c = (y3 + y1) / 2 - y2
00326         dove:
00327         y1 = prev[2]    y2 = prev[3]    y3 = src[0]  */
00328   ka = (float)prev[2];
00329   kb = (float)(2.0*prev[3]) - ((float)(src[0] + 3 * prev[2]) / 2.0);
00330   kc = ((float)(src[0] + prev[2]) / 2.0) - (float)prev[3];
00331   
00332   lframe = (long)(prev[2] * volume);
00333   dest[0] = dest[1] = (IN_DATATYPE)CLIP16BIT(lframe);
00334   lframe = (long)((ka + (kb + kc * resarr320to441x[1]) *
00335                    resarr320to441x[1]) * volume);
00336   dest[2] = dest[3] = (IN_DATATYPE)CLIP16BIT(lframe);
00337   lframe = (long)((ka + (kb + kc * resarr320to441x[2]) *
00338                    resarr320to441x[2]) * volume);
00339   dest[4] = dest[5] = (IN_DATATYPE)CLIP16BIT(lframe);
00340 
00341   /*    y1 = prev[3]    y2 = src[0]    y3 = src[1]    */
00342   ka = (float)prev[3];
00343   kb = (float)(2.0*src[0]) - ((float)(src[1] + 3 * prev[3]) / 2.0);
00344   kc = ((float)(src[1] + prev[3]) / 2.0) - (float)src[0];
00345   lframe = (long)((ka + (kb + kc * resarr320to441x[3]) * 
00346                    resarr320to441x[3]) * volume);
00347   dest[6] = dest[7] = (IN_DATATYPE)CLIP16BIT(lframe);
00348   for (c = 8 , modul = 0 ; c < tnum ; c+= 2) {
00349     cc = (c>>1) - modul;
00350     curin = disp+resarr320to441lc[cc];
00351     if (curin != oldin) {
00352       oldin = curin;
00353       /*    y1 = src[curin]    y2 = src[curin+1]    y3 = src[curin+2]    */
00354       ka = (float)src[curin];
00355       kb = (float)(2.0*src[curin+1]) - ((float)(src[curin+2] + 3 * src[curin]) / 2.0);
00356       kc = ((float)(src[curin+2] + src[curin]) / 2.0) - (float)src[curin+1];
00357     }
00358     lframe = (long)((ka + (kb + kc * resarr320to441lx[cc]) * 
00359                      resarr320to441lx[cc]) * volume);
00360     dest[c] = dest[c+1] = (IN_DATATYPE)CLIP16BIT(lframe);
00361     
00362     if (cc == 441) {
00363       modul += 441;
00364       disp += 320;
00365     }
00366   }
00367 
00368   return (tnum);
00369 }
00370 #endif
00371 
00372 #ifdef MOP_RESAMP
00373 int resample_stereo_32(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00374                      unsigned int num, float volume) {
00375   /* il .001 per garantire che una qualche approssimazione non faccia
00376      andare a leggere dati che non sono presenti */
00377   int tnum = (int)((float)(num>>1) * (441.0 / 320.001))<<1; 
00378   int c, cc;
00379   int disp = 0, modul = 0, oldin = -1, curin;
00380   long lframe;
00381   float ka,kb,kc;
00382   float ha,hb,hc;
00383 
00384   /* CHANNEL 0  -  samples 0,1,2  -  frames 0,2,4  */
00385   /*    a = y1
00386         b = 2y2 - (y3 + 3y1) / 2
00387         c = (y3 + y1) / 2 - y2
00388         dove:
00389         y1 = prev[0]    y2 = prev[2]    y3 = src[0]  */
00390   ka = (float)prev[0];
00391   kb = (float)(2.0*prev[2]) - ((float)(src[0] + 3 * prev[0]) / 2.0);
00392   kc = ((float)(src[0] + prev[0]) / 2.0) - (float)prev[2];
00393   
00394   lframe = (long)(prev[0] * volume);
00395   dest[0] = (IN_DATATYPE)CLIP16BIT(lframe);
00396 
00397   lframe = (long)((ka + (kb + kc * resarr320to441x[1]) *
00398                    resarr320to441x[1]) * volume);
00399   dest[2] = (IN_DATATYPE)CLIP16BIT(lframe);
00400 
00401   lframe = (long)((ka + (kb + kc * resarr320to441x[2]) *
00402                    resarr320to441x[2]) * volume);
00403   dest[4] = (IN_DATATYPE)CLIP16BIT(lframe);
00404 
00405   /* CHANNEL 1  -  samples 0,1,2  -  frames 1,3,5  */
00406   /*  y1 = prev[1]    y2 = prev[3]    y3 = src[1]  */
00407   ha = (float)prev[1];
00408   hb = (float)(2.0*prev[3]) - ((float)(src[1] + 3 * prev[1]) / 2.0);
00409   hc = ((float)(src[1] + prev[1]) / 2.0) - (float)prev[3];
00410   
00411   lframe = (long)(prev[1] * volume);
00412   dest[1] = (IN_DATATYPE)CLIP16BIT(lframe);
00413 
00414   lframe = (long)((ha + (hb + hc * resarr320to441x[1]) *
00415                    resarr320to441x[1]) * volume);
00416   dest[3] = (IN_DATATYPE)CLIP16BIT(lframe);
00417 
00418   lframe = (long)((ha + (hb + hc * resarr320to441x[2]) *
00419                    resarr320to441x[2]) * volume);
00420   dest[5] = (IN_DATATYPE)CLIP16BIT(lframe);
00421 
00422   /* CHANNEL 0  -  samples 3  -  frames 6  */
00423   /*    y1 = prev[2]    y2 = src[0]    y3 = src[2]    */
00424   ka = (float)prev[2];
00425   kb = (float)(2.0*src[0]) - ((float)(src[2] + 3 * prev[2]) / 2.0);
00426   kc = ((float)(src[2] + prev[2]) / 2.0) - (float)src[0];
00427   lframe = (long)((ka + (kb + kc * resarr320to441x[3]) * 
00428                    resarr320to441x[3]) * volume);
00429   dest[6] = (IN_DATATYPE)CLIP16BIT(lframe);
00430 
00431   /* CHANNEL 1  -  samples 3  -  frames 7  */
00432   /*    y1 = prev[3]    y2 = src[1]    y3 = src[3]    */
00433   ha = (float)prev[3];
00434   hb = (float)(2.0*src[1]) - ((float)(src[3] + 3 * prev[3]) / 2.0);
00435   hc = ((float)(src[3] + prev[3]) / 2.0) - (float)src[1];
00436   lframe = (long)((ha + (hb + hc * resarr320to441x[3]) * 
00437                    resarr320to441x[3]) * volume);
00438   dest[7] = (IN_DATATYPE)CLIP16BIT(lframe);
00439 
00440   for (c = 8 , modul = 0 ; c < tnum ; c+= 2) {
00441     cc = (c>>1) - modul;
00442     curin = disp+(resarr320to441lc[cc] << 1);
00443     if (curin != oldin) {
00444       oldin = curin;
00445       /*    y1 = src[curin]    y2 = src[curin+2]    y3 = src[curin+4]    */
00446       ka = (float)src[curin];
00447       kb = (float)(2.0*src[curin+2]) - ((float)(src[curin+4] + 3 * src[curin]) / 2.0);
00448       kc = ((float)(src[curin+4] + src[curin]) / 2.0) - (float)src[curin+2];
00449       /*    y1 = src[curin+1]  y2 = src[curin+3]    y3 = src[curin+5]    */
00450       ha = (float)src[curin+1];
00451       hb = (float)(2.0*src[curin+3]) - ((float)(src[curin+5] + 3 * src[curin+1]) / 2.0);
00452       hc = ((float)(src[curin+5] + src[curin+1]) / 2.0) - (float)src[curin+3];
00453     }
00454     lframe = (long)((ka + (kb + kc * resarr320to441lx[cc]) * 
00455                      resarr320to441lx[cc]) * volume);
00456     dest[c] = (IN_DATATYPE)CLIP16BIT(lframe);
00457     lframe = (long)((ha + (hb + hc * resarr320to441lx[cc]) * 
00458                      resarr320to441lx[cc]) * volume);
00459     dest[c+1] = (IN_DATATYPE)CLIP16BIT(lframe);
00460     
00461     if (cc == 441) {
00462       modul += 441;
00463       disp += 320 * 2;
00464     }
00465   }
00466 
00467   return (tnum);
00468 }
00469 #endif
00470 
00471 int resample_mono_44(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00472                      unsigned int num, float volume) {
00473   unsigned int c,cc;
00474   
00475   for(c=0;c<num;c++) {
00476     cc = c<<1;    
00477     dest[cc] = dest[cc+1] = (IN_DATATYPE) (src[c]*volume);
00478   }
00479   
00480   /* return numbero OF FRAMES */
00481   return(num<<1);
00482 
00483 }
00484 
00485 int resample_stereo_44(IN_DATATYPE *dest, IN_DATATYPE *src, IN_DATATYPE *prev,
00486                      unsigned int num, float volume) {
00487   unsigned int c;
00488   for(c=0;c<num;c++)
00489     dest[c] = (IN_DATATYPE) (src[c]*volume);
00490 
00491   return(num);
00492 }
00493 
00494 int mixxx_stereo_44_novol(int *dest, short *chan, int num) {
00495   for(int c=0;c<num<<1;c++)
00496     dest[c] = (int) dest[c] + chan[c];  
00497   return(num);
00498 }

Generated on Sat Apr 17 17:38:48 2004 for MuSE by doxygen1.3