/** * Serialize the index. * * @param builder The StringBuilder to serialize to. * @param index The Index to serialize. * @param indentation The current indentation. */ private void serializeIndex(final StringBuilder builder, final Index index, final String indentation) { CueSheetSerializer.logger.entering (CueSheetSerializer.class.getCanonicalName() , "serializeIndex(StringBuilder,Index,String)" , new Object[]{builder, index, indentation} ); builder.append(indentation).append("INDEX"); if (index.getNumber() > -1) { builder.append(' ').append(String.format("%1$02d", index.getNumber())); } if (index.getPosition() != null) { builder.append(' ').append(formatPosition(index.getPosition())); } builder.append('\n'); CueSheetSerializer.logger.exiting (CueSheetSerializer.class.getCanonicalName(), "serializeIndex(StringBuilder,Index,String)"); }
private long indexToSample(Index index, int sampleRate) { // System.out.println(index.getPosition().getTotalFrames() / 75d * sampleRate); return (long) (index.getPosition().getTotalFrames() / 75d * sampleRate); } }
/** * Get the index with the specified number, or null if there is no such index. * @param number The number of the desired index. * @return The index with the specified number, or null if there is no such index. */ public Index getIndex(final int number) { TrackData.logger.entering(TrackData.class.getCanonicalName(), "getIndex(int)"); Index result = null; // Note: we have to pass all indices until we've found the right one, as we don't enforce that indices are sorted. // Normally, this shouldn't be a problem, as there are generally very few indices. (Only rarely more than 2). indexLoop: for (Index index : this.indices) { if (index.getNumber()==number) { result = index; break indexLoop; // No need to continue searching, so break out of the loop. } } TrackData.logger.exiting(TrackData.class.getCanonicalName(), "getIndex(int)", result); return result; }
/** * Serialize the index. * @param parentElement The parent element for the TrackData. * @param index The Index to serialize. */ private void serializeIndex(final Element parentElement, final Index index) { CueSheetToXmlSerializer.logger.entering ( CueSheetToXmlSerializer.class.getCanonicalName() , "serializeIndex(Element,Index)" , new Object[] {parentElement, index} ); Element indexElement = addElement(parentElement, "index", index.getPosition(), true); addAttribute(indexElement, "number", index.getNumber()); CueSheetToXmlSerializer.logger.exiting (CueSheetToXmlSerializer.class.getCanonicalName(), "serializeIndex(Element,Index)"); }