@Override public long write(RandomAccessFile out) throws IOException, RcBwfException { if (this.getAXml().trim().length() == 0) { return 0L; } long chunkStartPtr = out.getFilePointer(); this.setChunkSize(0L); long chunkHeaderSize = super.write(out); long chunkDataSize = RcRiffFile.writeUtf8(out, this.getAXml().trim()); long chunkEndPtr = out.getFilePointer(); out.seek(chunkStartPtr + RcRiffChunk.SIZE_OF_CHUNK_ID); RcRiffFile.writeUnsignedInt(out, chunkDataSize); out.seek(chunkEndPtr); return chunkHeaderSize + chunkDataSize; }
bytesWritten += RcRiffFile.writeUnsignedInt(out, this.flags); bytesWritten += RcRiffFile.writeUnsignedInt(out, this.labelChunkIdentifier); RcRiffFile.writeUnsignedInt(out, this.userData1); bytesWritten += 4; RcRiffFile.writeUnsignedInt(out, this.userData2); bytesWritten += 4; RcRiffFile.writeUnsignedInt(out, this.userData3); bytesWritten += 4; RcRiffFile.writeUnsignedInt(out, this.userData4); bytesWritten += 4;
private long writeStringChunk(RandomAccessFile out, String id, String value) throws UnsupportedEncodingException, IOException { long bytesWritten = 0L; bytesWritten += RcRiffFile.writeAscii(out, id); bytesWritten += RcRiffFile.writeUnsignedInt(out, value.length() + 1); bytesWritten += RcRiffFile.writeAscii(out, value); bytesWritten += RcRiffFile.writeNullBytes(out, 1); bytesWritten += this.align(out, bytesWritten); return bytesWritten; }
public long write(RandomAccessFile out) throws IOException, RcBwfException { String exPrefix = "Unable to write RIFF chunk - "; if (this.getChunkId() == null) { throw new IOException( exPrefix + "chunk id is null"); } if (this.getChunkId().length() != RcRiffChunk.SIZE_OF_CHUNK_ID) { throw new IOException( exPrefix + "chunk id must be " + RcRiffChunk.SIZE_OF_CHUNK_ID + " characters in length."); } long chunkHeaderSize = 0L; // Write chunk id //System.out.println("Writing " + this.getChunkId() + " at " + out.getFilePointer()); chunkHeaderSize += RcRiffFile.writeAscii(out, this.getChunkId()); // Write chunk size //System.out.println("Writing " + this.getChunkSize() + " at " + out.getFilePointer()); chunkHeaderSize += RcRiffFile.writeUnsignedInt(out, this.getChunkSize()); return chunkHeaderSize; }
/** * Updates the marker chunk. * * Note: The file must have been opened read / write and the maker chunk * must be the last chunk in the BWF file. * * @throws IOException * @throws RcBwfException */ public void updateMarkerChunk() throws IOException, RcBwfException { if (!this.canUpdateMarkerChunk()) { throw new IOException("The marker chunk is not updatable."); } // Overwrite marker chunk long sizeBefore = this.rcRiffMarkerChunk.getChunkSize(); this.in.seek(this.rcRiffMarkerChunk.getPtr()); this.rcRiffMarkerChunk.write(in); long sizeAfter = this.rcRiffMarkerChunk.getChunkSize(); long sizeDiff = sizeAfter - sizeBefore; this.rcRiffHeaderChunk.setChunkSize(this.rcRiffHeaderChunk.getChunkSize() + sizeDiff); // Update header this.in.seek(4); RcRiffFile.writeUnsignedInt(in, this.rcRiffHeaderChunk.getChunkSize()); // Trim file length if necessary if (sizeDiff < 0) { long length = this.in.length(); this.in.setLength(length + sizeDiff); } }
chunkDataSize += RcRiffFile.writeUnsignedInt(out, this.getSamplesPerSec()); chunkDataSize += RcRiffFile.writeUnsignedInt(out, this.getAvgBytesPerSec()); long chunkEndPtr = out.getFilePointer(); out.seek(chunkStartPtr + RcRiffChunk.SIZE_OF_CHUNK_ID); RcRiffFile.writeUnsignedInt(out, this.getChunkSize()); out.seek(chunkEndPtr);
RcRiffFile.writeUnsignedInt(out, chunkDataSize); out.seek(chunkEndPointer);
RcRiffFile.writeUnsignedInt( out, bytesWritten -
riffSize -= RcRiffBextChunk.SIZE_OF_CHUNK_SIZE; out.seek(4); RcRiffFile.writeUnsignedInt(out, riffSize);