# Non-uniform resampling - spacing between output samples given speed factors

I'm working on an implementation of time-varying resampling in python. I've got the windowed sinc interpolation itself working nicely, but can't figure out where exactly to sample my input data for correct results.

Given a curve of speed factors speeds (where 1.0 means no speed change, 2.0 slows down and .5 speeds up the result), I interpolate linearly between speeds[i], speeds[i+1] and then take the cumulative sum of the reciprocal of the result to get my positions.

block_speeds = np.interp(np.linspace(0, 1, num_output_samples), (0, 1),(speeds[i], speeds[i+1])  )
positions = np.cumsum(1/block_speeds)


My ground truth assumption using a different resampling method is repeating every input sample (N * speed) times, and then downsampling everything by N.

The approach outlined above approximates my ground truth for short segments (say 0.01 seconds), but strays from it too much for longer segments (say 1 second).

Any idea how to determine the sample positions for the output more accurately and analytically?

• have you looked at dynamic time warping? – user28715 Feb 3 '18 at 11:24
• Not really. So you would recommend performing a DTW on my speed curve vs. a constant speed of 1? – HENDRIX Feb 3 '18 at 11:35
• ideas are things to try – user28715 Feb 3 '18 at 15:22