private DoubleData process(Data input) throws IllegalArgumentException {
assert input instanceof DoubleData;
double[] inFeatures;
DoubleData doubleData = (DoubleData) input;
assert sampleRate == doubleData.getSampleRate();
inFeatures = doubleData.getValues();
// check wether we reached the next insertion point and repeat some parts of the input part if necessary
double[] extFeatures;
long firstSampleNumber = doubleData.getFirstSampleNumber() + numInsertedSamples;
long lastSampleNumber = doubleData.getFirstSampleNumber() + doubleData.getValues().length - 1;
if (nextInsertionPoint >= doubleData.getFirstSampleNumber() && nextInsertionPoint <= lastSampleNumber) {
int insertLength = Math.min(r.nextInt((int) maxRepeatedSamples) + 1, inFeatures.length);
// make sure that after insertion the block-length does not exceed 160 samples because with more SpeechClassifierNT will fail
assert doubleData.getValues().length + insertLength <= 160 : "block too large for next SpeechClassifier";
extFeatures = new double[insertLength + inFeatures.length];
logger.fine("RSR: repeat snippet with length " + insertLength + " at position " + nextInsertionPoint);
// copy the existing block into the new array and replicate the desired snippet inbetween
int startIndex = (int) (nextInsertionPoint - doubleData.getFirstSampleNumber());
System.arraycopy(inFeatures, 0, extFeatures, 0, startIndex);
System.arraycopy(inFeatures, 0, extFeatures, startIndex, insertLength);
System.arraycopy(inFeatures, startIndex, extFeatures, startIndex + insertLength, inFeatures.length - startIndex);
numInsertedSamples += insertLength;
nextInsertionPoint = computeNextInsertionPoint();
} else {
extFeatures = inFeatures;
}
DoubleData extendedData = new DoubleData(extFeatures, doubleData.getSampleRate(),
firstSampleNumber);
return extendedData;
}