public float[] getFrameCubic(int currentSample, float fractionOffset) {
        float[] result = new float[nChannels];
        float a0,a1,a2,a3,mu2;
        float ym1,y0,y1,y2;
        for (int i = 0; i < nChannels; i++) {
            int realCurrentSample = currentSample;
            if(realCurrentSample >= 0 && realCurrentSample < (nFrames - 1)) {
                realCurrentSample--;
                if (realCurrentSample < 0) {
                    ym1 = buf[i][0];
                    realCurrentSample = 0;
                } else {
                    ym1 = buf[i][realCurrentSample++];
                }
                y0 = buf[i][realCurrentSample++];
                if (realCurrentSample >= nFrames) {
                    y1 = buf[i][nFrames - 1];
                } else {
                    y1 = buf[i][realCurrentSample++];
                }
                if (realCurrentSample >= nFrames) {
                    y2 = buf[i][nFrames - 1];
                } else {
                    y2 = buf[i][realCurrentSample];
                }
                mu2 = fractionOffset * fractionOffset;
                a0 = y2 - y1 - ym1 + y0;
                a1 = ym1 - y0 - a0;
                a2 = y1 - ym1;
                a3 = y0;
                result[i] = a0 * fractionOffset * mu2 + a1 * mu2 + a2 * fractionOffset + a3;
            } else {
                result[i] = 0.0f;
            }
        }
        return result;
    }