src/audio/SDL_audiocvt.c
changeset 11592 61260a51fc60
parent 11591 c79a9f64ddb2
child 11593 b5e404b928ea
equal deleted inserted replaced
11591:c79a9f64ddb2 11592:61260a51fc60
   482 SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
   482 SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
   483                         const float *lpadding, const float *rpadding,
   483                         const float *lpadding, const float *rpadding,
   484                         const float *inbuf, const int inbuflen,
   484                         const float *inbuf, const int inbuflen,
   485                         float *outbuf, const int outbuflen)
   485                         float *outbuf, const int outbuflen)
   486 {
   486 {
       
   487     const double finrate = (double) inrate;
   487     const float outtimeincr = 1.0f / ((float) outrate);
   488     const float outtimeincr = 1.0f / ((float) outrate);
   488     const float ratio = ((float) outrate) / ((float) inrate);
   489     const float ratio = ((float) outrate) / ((float) inrate);
   489     const int paddinglen = ResamplerPadding(inrate, outrate);
   490     const int paddinglen = ResamplerPadding(inrate, outrate);
   490     const int framelen = chans * (int)sizeof (float);
   491     const int framelen = chans * (int)sizeof (float);
   491     const int inframes = inbuflen / framelen;
   492     const int inframes = inbuflen / framelen;
   496     float outtime = 0.0f;
   497     float outtime = 0.0f;
   497     int i, j, chan;
   498     int i, j, chan;
   498 
   499 
   499     for (i = 0; i < outframes; i++) {
   500     for (i = 0; i < outframes; i++) {
   500         const int srcindex = (int) (outtime * inrate);
   501         const int srcindex = (int) (outtime * inrate);
   501         const float finrate = (float) inrate;
       
   502         const float intime = ((float) srcindex) / finrate;
   502         const float intime = ((float) srcindex) / finrate;
   503         const float innexttime = ((float) (srcindex + 1)) / finrate;
   503         const float innexttime = ((float) (srcindex + 1)) / finrate;
   504 
   504 
   505         const float interpolation1 = 1.0f - (innexttime - outtime) / (innexttime - intime);
   505         const float interpolation1 = 1.0f - (innexttime - outtime) / (innexttime - intime);
   506         const int filterindex1 = (int) (interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
   506         const int filterindex1 = (int) (interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);