@Override public long write(RandomAccessFile out) throws IOException, RcBwfException { this.setChunkSize(320 * this.getMarkerEntries().size()); long bytesWritten = super.write(out); for (RcRiffMarkerEntry e : this.rcRiffMarkerEntryList) { bytesWritten += e.write(out); } return bytesWritten; }
/** * 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); } }
public RcRiffMarkerChunk() { super(); this.setChunkId(RcRiffBwf.RC_RIFF_MARKER_CHUNK_ID); }
@Override public long read(RandomAccessFile in, long ptr, long chunkSize) throws IOException { this.setPtr(ptr); this.setChunkSize(chunkSize); this.rcRiffMarkerEntryList.clear(); if (chunkSize % 320 != 0) { throw new IOException("Marker chunk size must be a multiple of the size of MarkerEntry (320 bytes)."); } long bytesRead = 0; while (bytesRead < chunkSize) { RcRiffMarkerEntry e = new RcRiffMarkerEntry(); bytesRead += e.read(in); this.rcRiffMarkerEntryList.add(e); } return bytesRead; }
rcRiffMarkerChunk = new RcRiffMarkerChunk(); rcRiffBwf.setRcRiffMarkerChunk(rcRiffMarkerChunk); rcRiffMarkerChunk.getMarkerEntries().add(rcRiffMarkerEntry);
public static void listMarkers(File waveFile) throws IOException { RcRiffBwf rcRiffBwf = new RcRiffBwf(waveFile); rcRiffBwf.open(); RcRiffMarkerChunk rcRiffMarkerChunk = rcRiffBwf.getRcRiffMarkerChunk(); int sampleRate = (int) rcRiffBwf.getRcRiffFmtChunk().getSamplesPerSec(); int channels = rcRiffBwf.getRcRiffFmtChunk().getChannels(); long ms; if (rcRiffMarkerChunk != null) { for (RcRiffMarkerEntry e : rcRiffMarkerChunk.getMarkerEntries()) { ms = Math.round((double) e.getSampleOffset().longValue() / (sampleRate / 1000D) / (double) channels); System.out.println(e.getLabelText() + " @ " + formatTime(ms)); } System.out.println("\n" + rcRiffMarkerChunk.getMarkerEntries().size() + " marker entries"); } else { System.out.println("No marker chunk was found."); } rcRiffBwf.close(); }
RcRiffMarkerChunk rcRiffMarkerChunk = new RcRiffMarkerChunk(); riffBytesRead += rcRiffMarkerChunk.read(this.in, ptr, chunkSize);
RcRiffMarkerChunk rcRiffMarkerChunk = new RcRiffMarkerChunk(); rcRiffMarkerChunk.getMarkerEntries().addAll(markerEntries); rcRiffBwf.setRcRiffMarkerChunk(rcRiffMarkerChunk);
for (RcRiffMarkerEntry rcRiffMarkerEntry : rcRiffBwf.getRcRiffMarkerChunk().getMarkerEntries()) {
for (RcRiffMarkerEntry rcRiffMarkerEntry : rcRiffBwf.getRcRiffMarkerChunk().getMarkerEntries()) {
for (RcRiffMarkerEntry e : rcRiffBwf.getRcRiffMarkerChunk().getMarkerEntries()) {