Class BitInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.unascribed.ears.common.util.BitInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BitInputStream extends FilterInputStream
  • Constructor Details

    • BitInputStream

      public BitInputStream(InputStream input)
  • Method Details

    • readBit

      public int readBit() throws IOException
      Throws:
      IOException
    • readBoolean

      public boolean readBoolean() throws IOException
      Throws:
      IOException
    • read

      public int read() throws IOException
      Reads the next byte of data from the stream. As per the InputStream contract, if the end of the stream has been reached, -1 is returned. No guarantees are made about byte alignment unless align() has been called since the last bitwise read operation.
      Overrides:
      read in class FilterInputStream
      Throws:
      IOException
    • readL

      public long readL(int bits) throws IOException
      Throws:
      IOException
    • read

      public int read(int bits) throws IOException
      Throws:
      IOException
    • readSAM

      public int readSAM(int bits) throws IOException
      Reads a sign-and-magnitude signed number of the given length (excluding sign bit)
      Throws:
      IOException
    • readSAMUnit

      public float readSAMUnit(int bits) throws IOException
      Reads a sign-and-magnitude signed number of the given length (excluding sign bit), then divides it by the max value, giving a unit value from -1 to 1.
      Throws:
      IOException
    • readUnit

      public float readUnit(int bits) throws IOException
      Throws:
      IOException
    • align

      public void align() throws IOException
      Aligns the read marker to the start of the next byte. If the marker is already at the beginning of a byte, this method does nothing.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes this Stream. Also closes the underlying Stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException