# ios - Problems upsampling data using accelerate

After I downsample a vector with a constant decimating factor, I want to upsample the vector back to the original sample rate (after performing some analyses). However, I am struggling with the upsampling.

For the downsampling I apply vDSP_desamp from the Accelerate framework, and for the upsampling I tried to apply vDSP_vlint:

``// Create some test data for input vectorfloat inputData[10] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9};int inputLength = 10;int decimationFactor = 2; // Downsample by factor 2int downSampledLength = inputLength/decimationFactor;// Allocate downsampled output vectorfloat* downSampledData = malloc(downSampledLength*sizeof(float));// Create filter (average samples)float* filter = malloc(decimationFactor*sizeof(float));for (int i = 0; i < decimationFactor; ++i){filter[i] = 1.0/decimationFactor;}// Downsample and averagevDSP_desamp(inputData,(vDSP_Stride) decimationFactor,filter,downSampledData,(vDSP_Length) downSampledLength, // Downsample to 5 samples(vDSP_Length) decimationFactor );free(filter);``

The output of `downSampledData` using this code is:

``0.05, 0.25, 0.45, 0.65, 0.85``

To upsample the (processed) data vector back to the original sample rate I use the following code:

``// For this example downSampledData is just copied to processedData ...float* processedData = malloc(downSampledLength*sizeof(float));processedData = downSampledData;// Create vector used by vDSP_vlint to indicate interpolation constants.float* b = malloc(downSampledLength*sizeof(float));for (int i = 0; i < downSampledLength; i++) {b[i] = i + 0.5;}// Allocate data vector for upsampled datafloat* upSampledData = malloc(inputLength*sizeof(float));// Upsample and interpolatevDSP_vlint (processedData,b,1,upSampledData,1,(vDSP_Length) inputLength, // Resample back to 10 samples(vDSP_Length) downSampledLength);``

However, the output of `upSampledData` is

0.15, 0.35, 0.55, 0.75, 0.43, 0.05, 0.05, 0.05, 0.08, 0.12

which is not correct, apparently. How should I apply `vDSP_vlint`? Or should I use other functions for upsampling the data?