Class OpusBlockHelper


  • public class OpusBlockHelper
    extends Object
    Analyzer for Opus file blocks in the header.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • BLOCK_OFFSET

        public static final int BLOCK_OFFSET
        the offset for block definitions in the header.
        See Also:
        Constant Field Values
      • HEADER_LENGTH

        public static final int HEADER_LENGTH
        maximum length of header (made up value!).
        See Also:
        Constant Field Values
      • BLOCK_DEFINITION_LENGTH

        public static final int BLOCK_DEFINITION_LENGTH
        the block definition length (type, length, offset).
        See Also:
        Constant Field Values
      • BLOCKTYPE_DUMMY

        public static final int BLOCKTYPE_DUMMY
        the dummy block type (???).
        See Also:
        Constant Field Values
      • BLOCKTYPE_TEXT

        public static final int BLOCKTYPE_TEXT
        the text block type.
        See Also:
        Constant Field Values
      • BLOCKTYPE_SPEC_MASK

        public static final int BLOCKTYPE_SPEC_MASK
        the mask for the block type of the main spectrum.
        See Also:
        Constant Field Values
      • BLOCKTYPE_MAIN_MASK

        public static final int BLOCKTYPE_MAIN_MASK
        the mask for the block type of the main spectrum.
        See Also:
        Constant Field Values
      • BLOCKTYPE_INCREMENT_DATA_TO_DPF

        public static final int BLOCKTYPE_INCREMENT_DATA_TO_DPF
        increment from data to DPF block type.
        See Also:
        Constant Field Values
      • END

        public static final byte[] END
        the END character sequence.
      • APT

        public static final byte[] APT
        the APT character sequence.
      • APF

        public static final byte[] APF
        the APF character sequence.
      • AQM

        public static final byte[] AQM
        the AQM character sequence.
      • CNM

        public static final byte[] CNM
        the CNM character sequence.
      • DPF

        public static final byte[] DPF
        the DPF character sequence.
      • NPT

        public static final byte[] NPT
        the NPT character sequence.
      • FXV

        public static final byte[] FXV
        the FXV character sequence.
      • LXV

        public static final byte[] LXV
        the LXV character sequence.
      • CSF

        public static final byte[] CSF
        the CSF character sequence.
      • INS

        public static final byte[] INS
        the INS character sequence.
      • PLF

        public static final byte[] PLF
        the PLF character sequence.
      • OPERATION_MEASURESAMPLE

        public static final String OPERATION_MEASURESAMPLE
        the operation containing the sample ID.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OpusBlockHelper

        public OpusBlockHelper()
    • Method Detail

      • readDefinitions

        public static List<OpusBlockHelper.BlockDefinition> readDefinitions​(File file,
                                                                            adams.core.MessageCollection errors)
        Parses the opus header and returns the blocks definitions.
        Parameters:
        file - the file
        errors - for collecting errors
        Returns:
        the definitions
      • readDefinitions

        public static List<OpusBlockHelper.BlockDefinition> readDefinitions​(byte[] buf,
                                                                            adams.core.MessageCollection errors)
        Parses the opus header and returns the blocks definitions.
        Parameters:
        buf - the file content
        errors - for collecting errors
        Returns:
        the definitions
      • findID

        public static int findID​(byte[] buf,
                                 byte[] id,
                                 int start)
        Locates the first occurrence of the specified ID in the buffer after the starting position.
        Parameters:
        buf - the file content
        id - the block type to find
        start - the starting point
        Returns:
        the start/end, null if failed to detect
      • byteToUnsignedByte

        public static int byteToUnsignedByte​(byte b)
        Convert byte to unsigned byte.
        Parameters:
        b - the byte
        Returns:
        the unsigned byte
      • getLong

        public static long getLong​(byte[] buf,
                                   int offset)
        Returns the long at the specified offset.
        Parameters:
        offset - the offset to use
        Returns:
        the long
      • getDouble

        public static Double getDouble​(byte[] buf,
                                       int offset)
        Returns the double with the given ID.
        Parameters:
        offset - starting pos
        Returns:
        the double value, null if failed to convert
      • getText

        public static String getText​(byte[] buf,
                                     int offset)
        Returns the 0-terminated text at the specified offset.
        Parameters:
        offset - the offset to use
        Returns:
        the text