@Test
public void testIdentity2() throws Exception
{

    AudioInputStream ais = AudioSystem.getAudioInputStream(PitchFrameProviderTest.class.getResourceAsStream("arctic_a0123.wav"));
    int samplingRate = (int) ais.getFormat().getSampleRate();
    DoubleDataSource signal = new AudioDoubleDataSource(ais);
    double[] origSignal = signal.getAllData();
    signal = new BufferedDoubleDataSource(origSignal);
    DoubleDataSource pitchmarks = new ESTTextfileDoubleDataSource(new InputStreamReader(PitchFrameProviderTest.class.getResourceAsStream("arctic_a0123.pm")));
    double[] origPitchmarks = pitchmarks.getAllData();
    double audioDuration = origSignal.length/(double)samplingRate;
    if (origPitchmarks[origPitchmarks.length-1] < audioDuration) {
        System.out.println("correcting last pitchmark to total audio duration: "+audioDuration);
        origPitchmarks[origPitchmarks.length-1] = audioDuration;
    }
    pitchmarks = new BufferedDoubleDataSource(origPitchmarks);
    PitchFrameProvider pfp = new PitchFrameProvider(new SequenceDoubleDataSource(new DoubleDataSource[] {signal, new BufferedDoubleDataSource(new double[1000])}), pitchmarks, null, samplingRate,
            2, 1);
    double[] result = new double[origSignal.length];
    double[] frame = null;
    int resultPos = 0;
    while ((frame = pfp.getNextFrame()) != null) {
        int toCopy = Math.min(pfp.getFrameShiftSamples(), pfp.validSamplesInFrame());
        System.arraycopy(frame, 0, result, resultPos, toCopy);
        resultPos += toCopy;
    }
    assertTrue("Got back "+resultPos+", expected "+origSignal.length, resultPos==origSignal.length);
    double err = MathUtils.sumSquaredError(origSignal, result);
    assertTrue("Error: " + err, err < 1.E-20);
}