@Test public void testWithSomeLocalChunks() throws Exception { final String author = "AUTH4567"; final String copyright = "(c) 4567"; final String annotation1 = "ANNO1_67890123456789"; final String annotation2 = "ANNO2_67890123456789"; final String name = "NAME456789"; final PseudoChunk[] pseudoChunks = { new PseudoChunk("NAME", name), new PseudoChunk("ANNO", annotation1), new PseudoChunk("ANNO", annotation2), new PseudoChunk("(c) ", copyright), new PseudoChunk("AUTH", author) }; final File aiff = createAIFF("FORM", "AIFF", pseudoChunks); final AiffInfoReader aiffInfoReader = new AiffInfoReader(); try (FileChannel fc = new RandomAccessFile(aiff, "rw").getChannel()) { final GenericAudioHeader audioHeader = aiffInfoReader.read(fc, aiff.getAbsolutePath()); Assert.assertTrue(audioHeader instanceof AiffAudioHeader); final AiffAudioHeader aiffAudioHeader = (AiffAudioHeader)audioHeader; Assert.assertEquals(author, aiffAudioHeader.getAuthor()); Assert.assertEquals(name, aiffAudioHeader.getName()); Assert.assertEquals(copyright, aiffAudioHeader.getCopyright()); Assert.assertEquals(annotation1, aiffAudioHeader.getAnnotations().get(0)); Assert.assertEquals(annotation2, aiffAudioHeader.getAnnotations().get(1)); } aiff.delete(); }
protected GenericAudioHeader read(FileChannel fc, final String fileName) throws CannotReadException, IOException { LOG.log(TRACE, "$1%s Reading AIFF file size:$2%d 0x$2%x", fileName, fc.size()); AiffAudioHeader aiffAudioHeader = new AiffAudioHeader(); final AiffFileHeader fileHeader = new AiffFileHeader(); long noOfBytes = fileHeader.readHeader(fc, aiffAudioHeader, fileName); while (fc.position() < fc.size()) { if (!readChunk(fc, aiffAudioHeader, fileName)) { LOG.log(ERROR, "%s UnableToReadProcessChunk", fileName); break; } } calculateBitRate(aiffAudioHeader); return aiffAudioHeader; }
AiffInfoReader extends AiffChunkReader { protected GenericAudioHeader read(FileChannel fc, final String fileName) throws CannotReadException, IOException { LOG.log(TRACE, "$1%s Reading AIFF file size:$2%d 0x$2%x", fileName, fc.size()); AiffAudioHeader aiffAudioHeader = new AiffAudioHeader(); final AiffFileHeader fileHeader = new AiffFileHeader(); long noOfBytes = fileHeader.readHeader(fc, aiffAudioHeader, fileName); while (fc.position() < fc.size()) { if (!readChunk(fc, aiffAudioHeader, fileName)) { LOG.log(ERROR, "%s UnableToReadProcessChunk", fileName); break; } } calculateBitRate(aiffAudioHeader); return aiffAudioHeader; } }
AiffInfoReader extends AiffChunkReader { protected GenericAudioHeader read(FileChannel fc, final String fileName) throws CannotReadException, IOException { LOG.log(TRACE, "$1%s Reading AIFF file size:$2%d 0x$2%x", fileName, fc.size()); AiffAudioHeader aiffAudioHeader = new AiffAudioHeader(); final AiffFileHeader fileHeader = new AiffFileHeader(); long noOfBytes = fileHeader.readHeader(fc, aiffAudioHeader, fileName); while (fc.position() < fc.size()) { if (!readChunk(fc, aiffAudioHeader, fileName)) { LOG.log(ERROR, "%s UnableToReadProcessChunk", fileName); break; } } calculateBitRate(aiffAudioHeader); return aiffAudioHeader; }  }
AiffInfoReader extends AiffChunkReader { protected GenericAudioHeader read(FileChannel fc, final String fileName) throws CannotReadException, IOException { LOG.log(TRACE, "$1%s Reading AIFF file size:$2%d 0x$2%x", fileName, fc.size()); AiffAudioHeader aiffAudioHeader = new AiffAudioHeader(); final AiffFileHeader fileHeader = new AiffFileHeader(); long noOfBytes = fileHeader.readHeader(fc, aiffAudioHeader, fileName); while (fc.position() < fc.size()) { if (!readChunk(fc, aiffAudioHeader, fileName)) { LOG.log(ERROR, "%s UnableToReadProcessChunk", fileName); break; } } calculateBitRate(aiffAudioHeader); return aiffAudioHeader; }   }
AiffInfoReader extends AiffChunkReader { protected GenericAudioHeader read(FileChannel fc, final String fileName) throws CannotReadException, IOException { LOG.log(TRACE, "$1%s Reading AIFF file size:$2%d 0x$2%x", fileName, fc.size()); AiffAudioHeader aiffAudioHeader = new AiffAudioHeader(); final AiffFileHeader fileHeader = new AiffFileHeader(); long noOfBytes = fileHeader.readHeader(fc, aiffAudioHeader, fileName); while (fc.position() < fc.size()) { if (!readChunk(fc, aiffAudioHeader, fileName)) { LOG.log(ERROR, "%s UnableToReadProcessChunk", fileName); break; } } calculateBitRate(aiffAudioHeader); return aiffAudioHeader; }    }