@Override public void readByteArray(final byte[] buffer, final int originalOffset) throws InvalidDataTypeException { int localOffset = originalOffset; int size = getSize(); logger.finest("offset:" + localOffset); //The read has extended further than the defined frame size (ok to extend upto //size because the next datatype may be of length 0.) if (originalOffset > buffer.length-size) { logger.warning("Invalid size for FrameBody"); throw new InvalidDataTypeException("Invalid size for FrameBody"); } this.tempo.readByteArray(buffer, localOffset); localOffset += this.tempo.getSize(); this.timestamp.readByteArray(buffer, localOffset); localOffset += this.timestamp.getSize(); }
public void setTempo(final int tempo) { if (tempo < 0 || tempo > 510) throw new IllegalArgumentException("Tempo must be a positive value less than 511: " + tempo); this.tempo.setValue(tempo); }
@Override public int getSize() { return this.tempo.getSize() + this.timestamp.getSize(); }
public int getTempo() { return ((Number) tempo.getValue()).intValue(); }
@Override public byte[] writeByteArray() { final byte[] typeData = this.tempo.writeByteArray(); final byte[] timeData = this.timestamp.writeByteArray(); if (typeData == null || timeData == null) return null; final byte[] objectData = new byte[typeData.length + timeData.length]; System.arraycopy(typeData, 0, objectData, 0, typeData.length); System.arraycopy(timeData, 0, objectData, typeData.length, timeData.length); return objectData; }
@Override public void setBody(final AbstractTagFrameBody frameBody) { super.setBody(frameBody); this.tempo.setBody(frameBody); this.timestamp.setBody(frameBody); }
public SynchronisedTempoCode(final String identifier, final AbstractTagFrameBody frameBody, final int tempo, final long timestamp) { super(identifier, frameBody); setBody(frameBody); this.tempo.setValue(tempo); this.timestamp.setValue(timestamp); }
@Override public byte[] writeByteArray() { final int size = getSize(); final byte[] arr = new byte[size]; long temp = ID3Tags.getWholeNumber(value); int offset = 0; if (temp >= 0xFF) { arr[offset] = (byte)0xFF; offset++; temp -= 0xFF; } arr[offset] = (byte) (temp & 0xFF); return arr; }