TarsosDSPAudioInputStream.java (2589B)
1 /* 2 * _______ _____ _____ _____ 3 * |__ __| | __ \ / ____| __ \ 4 * | | __ _ _ __ ___ ___ ___| | | | (___ | |__) | 5 * | |/ _` | '__/ __|/ _ \/ __| | | |\___ \| ___/ 6 * | | (_| | | \__ \ (_) \__ \ |__| |____) | | 7 * |_|\__,_|_| |___/\___/|___/_____/|_____/|_| 8 * 9 * ------------------------------------------------------------- 10 * 11 * TarsosDSP is developed by Joren Six at IPEM, University Ghent 12 * 13 * ------------------------------------------------------------- 14 * 15 * Info: http://0110.be/tag/TarsosDSP 16 * Github: https://github.com/JorenSix/TarsosDSP 17 * Releases: http://0110.be/releases/TarsosDSP/ 18 * 19 * TarsosDSP includes modified source code by various authors, 20 * for credits and info, see README. 21 * 22 */ 23 24 package be.tarsos.dsp.io; 25 26 import java.io.IOException; 27 28 /** 29 * Decouples the audio input stream 30 * @author Joren Six 31 */ 32 public interface TarsosDSPAudioInputStream { 33 34 /** 35 * Skip a number of bytes before reading the remaining bytes. 36 * @param bytesToSkip The number of bytes to skip. 37 * @return The number of bytes skipped. 38 * @throws IOException If the underlying if an input or output error occurs 39 * #see read 40 */ 41 long skip(long bytesToSkip) throws IOException; 42 43 /** 44 * Reads up to a specified maximum number of bytes of data from the audio 45 * stream, putting them into the given byte array. 46 * <p>This method will always read an integral number of frames. 47 * If <code>len</code> does not specify an integral number 48 * of frames, a maximum of <code>len - (len % frameSize) 49 * </code> bytes will be read. 50 * 51 * @param b the buffer into which the data is read 52 * @param off the offset, from the beginning of array <code>b</code>, at which 53 * the data will be written 54 * @param len the maximum number of bytes to read 55 * @return the total number of bytes read into the buffer, or -1 if there 56 * is no more data because the end of the stream has been reached 57 * @throws IOException if an input or output error occurs 58 * @see #skip 59 */ 60 int read(byte[] b, int off, int len) throws IOException ; 61 62 /** 63 * Closes this audio input stream and releases any system resources associated 64 * with the stream. 65 * @throws IOException if an input or output error occurs 66 */ 67 public void close() throws IOException; 68 69 /** 70 * 71 * @return The format of the underlying audio 72 */ 73 TarsosDSPAudioFormat getFormat(); 74 75 long getFrameLength(); 76 }