Resampler { public double[] perform(double[] buffer, int len) { int size = (int)((double)F/f * len); double signal[] = new double[size]; double dx = 1./(double)f; double dX = 1./(double)F; signal[0] = buffer[0]; double k = 0; for (int i = 1; i < size - 1; i++) { double X = i * dX; int p = (int)(X/dx); int q = p + 1; k = (buffer[q] - buffer[p])/dx; double x = p * dx; signal[i] = buffer[p] + (X - x) * k; } signal[size - 1] = buffer[len - 1] + ((size - 1) *dX - (len -1)*dx) *k; return signal; } Resampler(int f, int F); double[] perform(double[] buffer, int len);  }
@Test public void testPerform() { double[] res = resampler.perform(line, line.length); assertEquals(8192, res.length); for (int i = 0; i < res.length - 1; i++) { double K = (res[i + 1] - res[i]) / (1./(double)F); assertTrue(Math.abs(K - k) < 0.1); } }