sessions.add(new Pair<Integer, Integer>(currentStart, i + 1)); currentStart = i + 1; sessions.add(new Pair<Integer, Integer>(currentStart, wavFiles.length)); double avgEnergySession = computeAverageEnergy(wavFiles, session.getFirst(), session.getSecond(), stepsComplete * stepProgress + session.getFirst() * stepProgress / wavFiles.length, stepsComplete * stepProgress + session.getSecond() * stepProgress / wavFiles.length); System.out.printf(Locale.US, "Session at %tc: %d files, avg. Energy: %f\n", wavFiles[session.getFirst()].lastModified(), session.getSecond() - session.getFirst(), avgEnergySession); sessionEnergies.add(avgEnergySession); for (int i = session.getFirst(); i < session.getSecond(); i++) { amplitudeFactors[i] = factor;
try { Pair<ByteBuffer, Long> p = getByteBufferAtTime(0); ByteBuffer bb = p.getFirst(); assert p.getSecond() == 0; while (!haveReadAll) { Datagram dat = getNextDatagram(bb); bb = p.getFirst(); assert p.getSecond() == time; dat = getNextDatagram(bb); if (dat == null) { // no, indeed we cannot read any more
Pair<String, ArrayList<Integer>> returnedPair = new Pair<String, ArrayList<Integer>>(tmpString, pairIntList); return returnedPair;
/** * Get a single datagram from a particular time location, given in the timeline's sampling rate. * * @param targetTimeInSamples * the requested position, in samples. Must be non-negative and less than the total duration of the timeline. * * @return the datagram starting at or overlapping the given time, or null if end-of-file was encountered * @throws IOException * , BufferUnderflowException if no datagram could be created from the data at the given time. */ public Datagram getDatagram(long targetTimeInSamples) throws IOException { Pair<ByteBuffer, Long> p = getByteBufferAtTime(targetTimeInSamples); ByteBuffer bb = p.getFirst(); return getNextDatagram(bb); }
try { Pair<ByteBuffer, Long> p = getByteBufferAtTime(0); ByteBuffer bb = p.getFirst(); assert p.getSecond() == 0; while (!haveReadAll) { Datagram dat = getNextDatagram(bb); bb = p.getFirst(); assert p.getSecond() == time; dat = getNextDatagram(bb); if (dat == null) { // no, indeed we cannot read any more
protected Pair<ByteBuffer, Long> getMappedByteBufferAtTime(long targetTimeInSamples) throws IllegalArgumentException, IOException { assert mappedBB != null; /* Seek for the time index which comes just before the requested time */ IdxField idxFieldBefore = idx.getIdxFieldBefore(targetTimeInSamples); long time = idxFieldBefore.timePtr; int bytePos = (int) (idxFieldBefore.bytePtr - datagramsBytePos); ByteBuffer bb = mappedBB.duplicate(); bb.position(bytePos); time = hopToTime(bb, time, targetTimeInSamples); return new Pair<ByteBuffer, Long>(bb, time); }
/** * Get a single datagram from a particular time location, given in the timeline's sampling rate. * * @param targetTimeInSamples * the requested position, in samples. Must be non-negative and less than the total duration of the timeline. * * @return the datagram starting at or overlapping the given time, or null if end-of-file was encountered * @throws IOException * , BufferUnderflowException if no datagram could be created from the data at the given time. */ public Datagram getDatagram(long targetTimeInSamples) throws IOException { Pair<ByteBuffer, Long> p = getByteBufferAtTime(targetTimeInSamples); ByteBuffer bb = p.getFirst(); return getNextDatagram(bb); }
sessions.add(new Pair<Integer, Integer>(currentStart, i + 1)); currentStart = i + 1; sessions.add(new Pair<Integer, Integer>(currentStart, wavFiles.length)); double avgEnergySession = computeAverageEnergy(wavFiles, session.getFirst(), session.getSecond(), stepsComplete * stepProgress + session.getFirst() * stepProgress / wavFiles.length, stepsComplete * stepProgress + session.getSecond() * stepProgress / wavFiles.length); System.out.printf(Locale.US, "Session at %tc: %d files, avg. Energy: %f\n", wavFiles[session.getFirst()].lastModified(), session.getSecond() - session.getFirst(), avgEnergySession); sessionEnergies.add(avgEnergySession); for (int i = session.getFirst(); i < session.getSecond(); i++) { amplitudeFactors[i] = factor;
protected Pair<ByteBuffer, Long> getMappedByteBufferAtTime(long targetTimeInSamples) throws IllegalArgumentException, IOException { assert mappedBB != null; /* Seek for the time index which comes just before the requested time */ IdxField idxFieldBefore = idx.getIdxFieldBefore(targetTimeInSamples); long time = idxFieldBefore.timePtr; int bytePos = (int) (idxFieldBefore.bytePtr - datagramsBytePos); ByteBuffer bb = mappedBB.duplicate(); bb.position(bytePos); time = hopToTime(bb, time, targetTimeInSamples); return new Pair<ByteBuffer, Long>(bb, time); }
/** * Get a single datagram from a particular time location, given in the timeline's sampling rate. * * @param targetTimeInSamples * the requested position, in samples. Must be non-negative and less than the total duration of the timeline. * * @return the datagram starting at or overlapping the given time, or null if end-of-file was encountered * @throws IOException * , BufferUnderflowException if no datagram could be created from the data at the given time. */ public Datagram getDatagram(long targetTimeInSamples) throws IOException { Pair<ByteBuffer, Long> p = getByteBufferAtTime(targetTimeInSamples); ByteBuffer bb = p.getFirst(); return getNextDatagram(bb); }
return new Pair<ByteBuffer, Long>(bb, time);
return new Pair<ByteBuffer, Long>(bb, time);
private List<Polynomial> fitPolynomialsToSyllables(Sentence s, double[] logF0, int polynomOrder) { List<Polynomial> poly = new ArrayList<Polynomial>(); for (Syllable syl : s) { Pair<Integer, Integer> syllableIndices = getSyllableIndicesInSentenceArray(s, syl, logF0.length); // System.out.println(" -- from "+iSylStart+" to "+iSylEnd + " out of " + logF0.length); double[] sylLogF0 = new double[syllableIndices.getSecond() - syllableIndices.getFirst()]; System.arraycopy(logF0, syllableIndices.getFirst(), sylLogF0, 0, sylLogF0.length); // Now that we have the log F0 curve corresponding to the syllable, fit polynomial: double[] coeffs = Polynomial.fitPolynomial(sylLogF0, polynomOrder); if (coeffs != null) { poly.add(new Polynomial(coeffs)); } else { poly.add(null); } } return poly; }