Class OpusHead

  • All Implemented Interfaces:
    java.lang.AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

    public class OpusHead
    extends org.lwjgl.system.Struct
    implements org.lwjgl.system.NativeResource
    Ogg Opus bitstream information. This contains the basic playback parameters for a stream, and corresponds to the initial ID header packet of an Ogg Opus stream.

    Layout

    
     struct OpusHead {
         int version();
         int channel_count();
         unsigned int pre_skip();
         opus_uint32 input_sample_rate();
         int output_gain();
         int mapping_family();
         int stream_count();
         int coupled_count();
         unsigned char mapping()[255];
     }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  OpusHead.Buffer
      An array of OpusHead structs.
      • Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

        org.lwjgl.system.Pointer.Default
      • Nested classes/interfaces inherited from class org.lwjgl.system.Struct

        org.lwjgl.system.Struct.StructValidation
    • Constructor Summary

      Constructors 
      Constructor Description
      OpusHead​(java.nio.ByteBuffer container)
      Creates a OpusHead instance at the current position of the specified ByteBuffer container.
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • VERSION, CHANNEL_COUNT, PRE_SKIP, INPUT_SAMPLE_RATE, OUTPUT_GAIN, MAPPING_FAMILY, STREAM_COUNT, COUPLED_COUNT, MAPPING

        The struct member offsets.
    • Constructor Detail

      • OpusHead

        public OpusHead​(java.nio.ByteBuffer container)
        Creates a OpusHead instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

        The created instance holds a strong reference to the container object.

    • Method Detail

      • sizeof

        public int sizeof()
        Specified by:
        sizeof in class org.lwjgl.system.Struct
      • version

        public int version()
        the Ogg Opus format version, in the range 0...255.

        The top 4 bits represent a "major" version, and the bottom four bits represent backwards-compatible "minor" revisions. The current specification describes version 1. This library will recognize versions up through 15 as backwards compatible with the current specification. An earlier draft of the specification described a version 0, but the only difference between version 1 and version 0 is that version 0 did not specify the semantics for handling the version field.

      • channel_count

        public int channel_count()
        the number of channels, in the range 1...255.
      • pre_skip

        public int pre_skip()
        the number of samples that should be discarded from the beginning of the stream
      • input_sample_rate

        public int input_sample_rate()
        the sampling rate of the original input.

        All Opus audio is coded at 48 kHz, and should also be decoded at 48 kHz for playback (unless the target hardware does not support this sampling rate). However, this field may be used to resample the audio back to the original sampling rate, for example, when saving the output to a file.

      • output_gain

        public int output_gain()
        the gain to apply to the decoded output, in dB, as a Q8 value in the range -32768...32767.

        The libopusfile API will automatically apply this gain to the decoded output before returning it, scaling it by pow(10,output_gain/(20.0*256)). You can adjust this behavior with OpusFile.op_set_gain_offset(long, int, int).

      • mapping_family

        public int mapping_family()
        the channel mapping family, in the range 0...255.

        Channel mapping family 0 covers mono or stereo in a single stream. Channel mapping family 1 covers 1 to 8 channels in one or more streams, using the Vorbis speaker assignments. Channel mapping family 255 covers 1 to 255 channels in one or more streams, but without any defined speaker assignment.

      • stream_count

        public int stream_count()
        the number of Opus streams in each Ogg packet, in the range 1...255.
      • coupled_count

        public int coupled_count()
        the number of coupled Opus streams in each Ogg packet, in the range 0...127.

        This must satisfy 0 <= coupled_count <= stream_count and coupled_count + stream_count <= 255. The coupled streams appear first, before all uncoupled streams, in an Ogg Opus packet.

      • mapping

        public java.nio.ByteBuffer mapping()
        
        public byte mapping​(int index)
        
        the mapping from coded stream channels to output channels.

        Let index=mapping[k] be the value for channel k. If index < 2*coupled_count, then it refers to the left channel from stream (index/2) if even, and the right channel from stream (index/2) if odd. Otherwise, it refers to the output of the uncoupled stream (index-coupled_count).

      • malloc

        public static OpusHead malloc()
        Returns a new OpusHead instance allocated with memAlloc. The instance must be explicitly freed.
      • calloc

        public static OpusHead calloc()
        Returns a new OpusHead instance allocated with memCalloc. The instance must be explicitly freed.
      • create

        public static OpusHead create()
        Returns a new OpusHead instance allocated with BufferUtils.
      • create

        public static OpusHead create​(long address)
        Returns a new OpusHead instance for the specified memory address.
      • createSafe

        @Nullable
        public static OpusHead createSafe​(long address)
        Like create, but returns null if address is NULL.
      • malloc

        public static OpusHead.Buffer malloc​(int capacity)
        Returns a new OpusHead.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • calloc

        public static OpusHead.Buffer calloc​(int capacity)
        Returns a new OpusHead.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
        Parameters:
        capacity - the buffer capacity
      • create

        public static OpusHead.Buffer create​(int capacity)
        Returns a new OpusHead.Buffer instance allocated with BufferUtils.
        Parameters:
        capacity - the buffer capacity
      • create

        public static OpusHead.Buffer create​(long address,
                                             int capacity)
        Create a OpusHead.Buffer instance at the specified memory.
        Parameters:
        address - the memory address
        capacity - the buffer capacity
      • createSafe

        @Nullable
        public static OpusHead.Buffer createSafe​(long address,
                                                 int capacity)
        Like create, but returns null if address is NULL.
      • malloc

        public static OpusHead malloc​(org.lwjgl.system.MemoryStack stack)
        Returns a new OpusHead instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
      • calloc

        public static OpusHead calloc​(org.lwjgl.system.MemoryStack stack)
        Returns a new OpusHead instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
      • malloc

        public static OpusHead.Buffer malloc​(int capacity,
                                             org.lwjgl.system.MemoryStack stack)
        Returns a new OpusHead.Buffer instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • calloc

        public static OpusHead.Buffer calloc​(int capacity,
                                             org.lwjgl.system.MemoryStack stack)
        Returns a new OpusHead.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • nversion

        public static int nversion​(long struct)
        Unsafe version of version().
      • nchannel_count

        public static int nchannel_count​(long struct)
        Unsafe version of channel_count().
      • npre_skip

        public static int npre_skip​(long struct)
        Unsafe version of pre_skip().
      • ninput_sample_rate

        public static int ninput_sample_rate​(long struct)
        Unsafe version of input_sample_rate().
      • noutput_gain

        public static int noutput_gain​(long struct)
        Unsafe version of output_gain().
      • nmapping_family

        public static int nmapping_family​(long struct)
        Unsafe version of mapping_family().
      • nstream_count

        public static int nstream_count​(long struct)
        Unsafe version of stream_count().
      • ncoupled_count

        public static int ncoupled_count​(long struct)
        Unsafe version of coupled_count().
      • nmapping

        public static java.nio.ByteBuffer nmapping​(long struct)
        Unsafe version of mapping().
      • nmapping

        public static byte nmapping​(long struct,
                                    int index)
        Unsafe version of mapping.