if (targetRelation == null) {
throw new IllegalStateException
("DiphonePitchmarkGenerator: Target relation does not exist");
}
SampleInfo sampleInfo;
sampleInfo = (SampleInfo) utterance.getObject(SampleInfo.UTT_NAME);
if (sampleInfo == null) {
throw new IllegalStateException
("DiphonePitchmarkGenerator: SampleInfo does not exist");
}
float pos, f0, m = 0;
float lf0 = utterance.getVoice().getPitch();
double time = 0;
int pitchMarks = 0; // how many pitch marks
LPCResult lpcResult;
IntLinkedList timesList = new IntLinkedList();
// first pass to count how many pitch marks will be required
for (Item targetItem = targetRelation.getHead();
targetItem != null; targetItem = targetItem.getNext()) {
FeatureSet featureSet = targetItem.getFeatures();
pos = featureSet.getFloat("pos");
f0 = featureSet.getFloat("f0");
//System.err.println("Target pos="+pos+", f0="+f0);
if (time == pos) {
lf0 = f0;
continue;
}
m = (f0-lf0)/pos;
//System.err.println("m=("+f0+"-"+lf0+")/"+pos+"="+m);
for (; time < pos; pitchMarks++) {
time += 1/(lf0 + (time * m));
//System.err.println("f("+time+")="+((lf0+(time*m))));
// save the time value in a list
timesList.add((int) (time * sampleInfo.getSampleRate()));
}
lf0 = f0;
}
lpcResult = new LPCResult();
// resize the number of frames to the number of pitchmarks