ftp.nice.ch/pub/next/unix/audio/sms.N.bs.tar.gz#/sms/library/interpolateArrays.c

This is interpolateArrays.c in view mode; [Download] [Up]

#include "../sms.h"

/*
 * function to interpolate two arrays, the output is an array in between the
 *  two input ones
 *
 * float *pFArray1       pointer to first array
 * int sizeArray1        size of first array
 * float *pFArray2       pointer to second array
 * int sizeArray2        size of second array
 * float *pFArrayOut     pointer to output array
 * int sizeArrayOut      size of output array
 * float fInterpFactor   interpolation factor
 */
int InterpolateArrays (float *pFArray1, int sizeArray1, float *pFArray2,
                       int sizeArray2, float *pFArrayOut, int sizeArrayOut,
                       float fInterpFactor)
{
  int i;
  float *pFArrayOne, *pFArrayTwo;

  if ((pFArrayOne = (float *) calloc (sizeArrayOut, sizeof(float))) 
       == NULL)
     return -1;
  if ((pFArrayTwo = (float *) calloc (sizeArrayOut, sizeof(float))) 
       == NULL)
     return -1;

  /* make the two array of sizeArrayOut */
  SpectralApprox (pFArray1, sizeArray1, sizeArray1, pFArrayOne, sizeArrayOut,
		  sizeArray1);
  SpectralApprox (pFArray2, sizeArray2, sizeArray2, pFArrayTwo, sizeArrayOut,
		  sizeArray2);

  /* interpolate the two arrays */
  for (i = 0; i < sizeArrayOut; i++)
    pFArrayOut[i] = pFArrayOne[i] + fInterpFactor * 
			(pFArrayTwo[i] - pFArrayOne[i]);

  free (pFArrayOne);
  free (pFArrayTwo);
  return 1;

}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.