Class OpusFile


  • public class OpusFile
    extends java.lang.Object

    Introduction

    This is the documentation for the libopusfile C API.

    The libopusfile package provides a convenient high-level API for decoding and basic manipulation of all Ogg Opus audio streams. libopusfile is implemented as a layer on top of Xiph.Org's reference libogg and libopus libraries.

    libopusfile provides several sets of built-in routines for file/stream access, and may also use custom stream I/O routines provided by the embedded environment. There are built-in I/O routines provided for ANSI-compliant stdio (FILE *), memory buffers, and URLs (including file: URLs, plus optionally http: and https: URLs).

    Organization

    The main API is divided into several sections:

    • stream_open_close
    • stream_info
    • stream_decoding
    • stream_seeking

    Several additional sections are not tied to the main API.

    • stream_callbacks
    • header_info
    • error_codes

    Overview

    The libopusfile API always decodes files to 48 kHz. The original sample rate is not preserved by the lossy compression, though it is stored in the header to allow you to resample to it after decoding (the libopusfile API does not currently provide a resampler, but the the Speex resampler is a good choice if you need one). In general, if you are playing back the audio, you should leave it at 48 kHz, provided your audio hardware supports it. When decoding to a file, it may be worth resampling back to the original sample rate, so as not to surprise users who might not expect the sample rate to change after encoding to Opus and decoding.

    Opus files can contain anywhere from 1 to 255 channels of audio. The channel mappings for up to 8 channels are the same as the Vorbis mappings. A special stereo API can convert everything to 2 channels, making it simple to support multichannel files in an application which only has stereo output. Although the libopusfile ABI provides support for the theoretical maximum number of channels, the current implementation does not support files with more than 8 channels, as they do not have well-defined channel mappings.

    Like all Ogg files, Opus files may be "chained". That is, multiple Opus files may be combined into a single, longer file just by concatenating the original files. This is commonly done in internet radio streaming, as it allows the title and artist to be updated each time the song changes, since each link in the chain includes its own set of metadata.

    libopusfile fully supports chained files. It will decode the first Opus stream found in each link of a chained file (ignoring any other streams that might be concurrently multiplexed with it, such as a video stream).

    The channel count can also change between links. If your application is not prepared to deal with this, it can use the stereo API to ensure the audio from all links will always get decoded into a common format. Since libopusfile always decodes to 48 kHz, you do not have to worry about the sample rate changing between links (as was possible with Vorbis). This makes application support for chained files with libopusfile very easy.

    • Method Detail

      • nopus_head_parse

        public static int nopus_head_parse​(long _head,
                                           long _data,
                                           long _len)
        Unsafe version of: head_parse
        Parameters:
        _len - the number of bytes of data in the ID header packet
      • opus_head_parse

        public static int opus_head_parse​(OpusHead _head,
                                          java.nio.ByteBuffer _data)
        Parses the contents of the ID header packet of an Ogg Opus stream.
        Parameters:
        _head - returns the contents of the parsed packet. The contents of this structure are untouched on error. This may be NULL to merely test the header for validity.
        _data - the contents of the ID header packet
        Returns:
        0 on success or a negative value on error:
        • ENOTFORMAT If the data does not start with the "OpusHead" string.
        • EVERSION If the version field signaled a version this library does not know how to parse.
        • EIMPL If the channel mapping family was 255, which general purpose players should not attempt to play.
        • EBADHEADER If the contents of the packet otherwise violate the Ogg Opus specification:
          • Insufficient data
          • Too much data for the known minor versions
          • An unrecognized channel mapping family
          • Zero channels or too many channels
          • Zero coded streams
          • Too many coupled streams, or
          • An invalid channel mapping index
      • nopus_granule_sample

        public static long nopus_granule_sample​(long _head,
                                                long _gp)
        Unsafe version of: granule_sample
      • opus_granule_sample

        public static long opus_granule_sample​(OpusHead _head,
                                               long _gp)
        Converts a granule position to a sample offset for a given Ogg Opus stream.

        The sample offset is simply _gp-_head->pre_skip. Granule position values smaller than OpusHead::pre_skip correspond to audio that should never be played, and thus have no associated sample offset. This function returns -1 for such values. This function also correctly handles extremely large granule positions, which may have wrapped around to a negative number when stored in a signed ogg_int64_t value.

        Parameters:
        _head - the OpusHead information from the ID header of the stream
        _gp - the granule position to convert
        Returns:
        the sample offset associated with the given granule position (counting at a 48 kHz sampling rate), or the special value -1 on error (i.e., the granule position was smaller than the pre-skip amount)
      • nopus_tags_parse

        public static int nopus_tags_parse​(long _tags,
                                           long _data,
                                           long _len)
        Unsafe version of: tags_parse
        Parameters:
        _len - the number of bytes of data in the 'info' header packet
      • opus_tags_parse

        public static int opus_tags_parse​(@Nullable
                                          OpusTags _tags,
                                          java.nio.ByteBuffer _data)
        Parses the contents of the 'comment' header packet of an Ogg Opus stream.
        Parameters:
        _tags - an uninitialized OpusTags structure. This returns the contents of the parsed packet. The contents of this structure are untouched on error. This may be NULL to merely test the header for validity.
        _data - the contents of the 'comment' header packet
        Returns:
        • 0: Success
        • ENOTFORMAT If the data does not start with the "OpusTags" string
        • EBADHEADER If the contents of the packet otherwise violate the Ogg Opus specification
        • EFAULT If there wasn't enough memory to store the tags
      • nopus_tags_copy

        public static int nopus_tags_copy​(long _dst,
                                          long _src)
        Unsafe version of: tags_copy
      • opus_tags_copy

        public static int opus_tags_copy​(OpusTags _dst,
                                         OpusTags _src)
        Performs a deep copy of an OpusTags structure.
        Parameters:
        _dst - the OpusTags structure to copy into. If this function fails, the contents of this structure remain untouched.
        _src - the OpusTags structure to copy from
        Returns:
        • 0: Success
        • EFAULT If there wasn't enough memory to copy the tags
      • nopus_tags_init

        public static void nopus_tags_init​(long _tags)
        Unsafe version of: tags_init
      • opus_tags_init

        public static void opus_tags_init​(OpusTags _tags)
        Initializes an OpusTags structure. This should be called on a freshly allocated OpusTags structure before attempting to use it.
        Parameters:
        _tags - the OpusTags structure to initialize
      • nopus_tags_add

        public static int nopus_tags_add​(long _tags,
                                         long _tag,
                                         long _value)
        Unsafe version of: tags_add
      • opus_tags_add

        public static int opus_tags_add​(OpusTags _tags,
                                        java.nio.ByteBuffer _tag,
                                        java.nio.ByteBuffer _value)
        
        public static int opus_tags_add​(OpusTags _tags,
                                        java.lang.CharSequence _tag,
                                        java.lang.CharSequence _value)
        
        Add a (tag, value) pair to an initialized OpusTags structure.
        Note

        Neither opus_tags_add() nor tags_add_comment support values containing embedded NULs, although the bitstream format does support them. To add such tags, you will need to manipulate the OpusTags structure directly.

        Parameters:
        _tags - the OpusTags structure to add the (tag, value) pair to
        _tag - a NUL-terminated, case-insensitive, ASCII string containing the tag to add (without an '=' character)
        _value - a NUL-terminated UTF-8 containing the corresponding value
        Returns:
        0 on success, or a negative value on failure:
        • EFAULT An internal memory allocation failed
      • nopus_tags_add_comment

        public static int nopus_tags_add_comment​(long _tags,
                                                 long _comment)
        Unsafe version of: tags_add_comment
      • opus_tags_add_comment

        public static int opus_tags_add_comment​(OpusTags _tags,
                                                java.nio.ByteBuffer _comment)
        
        public static int opus_tags_add_comment​(OpusTags _tags,
                                                java.lang.CharSequence _comment)
        
        Add a comment to an initialized OpusTags structure.
        Note

        Neither opus_tags_add_comment() nor tags_add support comments containing embedded NULs, although the bitstream format does support them. To add such tags, you will need to manipulate the OpusTags structure directly.

        Parameters:
        _tags - the OpusTags structure to add the comment to
        _comment - a NUL-terminated UTF-8 string containing the comment in "TAG=value" form
        Returns:
        0 on success, or a negative value on failure:
        • EFAULT An internal memory allocation failed
      • nopus_tags_set_binary_suffix

        public static int nopus_tags_set_binary_suffix​(long _tags,
                                                       long _data,
                                                       int _len)
        Unsafe version of: tags_set_binary_suffix
        Parameters:
        _len - the number of bytes of binary data to append. This may be zero to remove any existing binary suffix data.
      • opus_tags_set_binary_suffix

        public static int opus_tags_set_binary_suffix​(OpusTags _tags,
                                                      @Nullable
                                                      java.nio.ByteBuffer _data)
        Replace the binary suffix data at the end of the packet (if any).
        Parameters:
        _tags - an initialized OpusTags structure
        _data - a buffer of binary data to append after the encoded user comments. The least significant bit of the first byte of this data must be set (to ensure the data is preserved by other editors).
        Returns:
        0 on success, or a negative value on failure:
        • EINVAL _len was negative, or _len was positive but _data was NULL or the least significant bit of the first byte was not set
        • EFAULT An internal memory allocation failed
      • nopus_tags_query

        public static long nopus_tags_query​(long _tags,
                                            long _tag,
                                            int _count)
        Unsafe version of: tags_query
      • opus_tags_query

        @Nullable
        public static java.lang.String opus_tags_query​(OpusTags _tags,
                                                       java.nio.ByteBuffer _tag,
                                                       int _count)
        
        @Nullable
        public static java.lang.String opus_tags_query​(OpusTags _tags,
                                                       java.lang.CharSequence _tag,
                                                       int _count)
        
        Look up a comment value by its tag.
        Parameters:
        _tags - an initialized OpusTags structure
        _tag - the tag to look up
        _count - the instance of the tag.

        The same tag can appear multiple times, each with a distinct value, so an index is required to retrieve them all. The order in which these values appear is significant and should be preserved. Use tags_query_count to get the legal range for the _count parameter.

        Returns:
        a pointer to the queried tag's value.

        This points directly to data in the OpusTags structure. It should not be modified or freed by the application, and modifications to the structure may invalidate the pointer. NULL if no matching tag is found.

      • nopus_tags_query_count

        public static int nopus_tags_query_count​(long _tags,
                                                 long _tag)
        Unsafe version of: tags_query_count
      • opus_tags_query_count

        public static int opus_tags_query_count​(OpusTags _tags,
                                                java.nio.ByteBuffer _tag)
        
        public static int opus_tags_query_count​(OpusTags _tags,
                                                java.lang.CharSequence _tag)
        
        Look up the number of instances of a tag.

        Call this first when querying for a specific tag and then iterate over the number of instances with separate calls to tags_query to retrieve all the values for that tag in order.

        Parameters:
        _tags - an initialized OpusTags structure
        _tag - the tag to look up
        Returns:
        the number of instances of this particular tag
      • nopus_tags_get_binary_suffix

        public static long nopus_tags_get_binary_suffix​(long _tags,
                                                        long _len)
        Unsafe version of: tags_get_binary_suffix
        Parameters:
        _len - returns the number of bytes of binary suffix data returned
      • opus_tags_get_binary_suffix

        @Nullable
        public static java.nio.ByteBuffer opus_tags_get_binary_suffix​(OpusTags _tags)
        Retrieve the binary suffix data at the end of the packet (if any).
        Parameters:
        _tags - an initialized OpusTags structure
        Returns:
        a pointer to the binary suffix data, or NULL if none was present
      • nopus_tags_get_album_gain

        public static int nopus_tags_get_album_gain​(long _tags,
                                                    long _gain_q8)
        Unsafe version of: tags_get_album_gain
      • opus_tags_get_album_gain

        public static int opus_tags_get_album_gain​(OpusTags _tags,
                                                   java.nio.IntBuffer _gain_q8)
        Get the album gain from an R128_ALBUM_GAIN tag, if one was specified. This searches for the first R128_ALBUM_GAIN tag with a valid signed, 16-bit decimal integer value and returns the value. This routine is exposed merely for convenience for applications which wish to do something special with the album gain (i.e., display it). If you simply wish to apply the album gain instead of the header gain, you can use op_set_gain_offset(long, int, int) with an ALBUM_GAIN type and no offset.
        Parameters:
        _tags - an initialized OpusTags structure
        _gain_q8 - the album gain, in 1/256ths of a dB. This will lie in the range [-32768,32767], and should be applied in addition to the header gain. On error, no value is returned, and the previous contents remain unchanged.
        Returns:
        0 on success, or a negative value on failure:
        • FALSE There was no album gain available in the given tags
      • nopus_tags_get_track_gain

        public static int nopus_tags_get_track_gain​(long _tags,
                                                    long _gain_q8)
        Unsafe version of: tags_get_track_gain
      • opus_tags_get_track_gain

        public static int opus_tags_get_track_gain​(OpusTags _tags,
                                                   java.nio.IntBuffer _gain_q8)
        Get the track gain from an R128_TRACK_GAIN tag, if one was specified.

        This searches for the first R128_TRACK_GAIN tag with a valid signed, 16-bit decimal integer value and returns the value. This routine is exposed merely for convenience for applications which wish to do something special with the track gain (i.e., display it). If you simply wish to apply the track gain instead of the header gain, you can use op_set_gain_offset(long, int, int) with an TRACK_GAIN type and no offset.

        Parameters:
        _tags - an initialized OpusTags structure
        _gain_q8 - the track gain, in 1/256ths of a dB. This will lie in the range [-32768,32767], and should be applied in addition to the header gain. On error, no value is returned, and the previous contents remain unchanged.
        Returns:
        0 on success, or a negative value on failure:
        • FALSE There was no track gain available in the given tags
      • nopus_tags_clear

        public static void nopus_tags_clear​(long _tags)
        Unsafe version of: tags_clear
      • opus_tags_clear

        public static void opus_tags_clear​(OpusTags _tags)
        Clears the OpusTags structure.

        This should be called on an OpusTags structure after it is no longer needed. It will free all memory used by the structure members.

        Parameters:
        _tags - the OpusTags structure to clear
      • nopus_tagcompare

        public static int nopus_tagcompare​(long _tag_name,
                                           long _comment)
        Unsafe version of: tagcompare
      • opus_tagcompare

        public static int opus_tagcompare​(java.nio.ByteBuffer _tag_name,
                                          java.nio.ByteBuffer _comment)
        
        public static int opus_tagcompare​(java.lang.CharSequence _tag_name,
                                          java.lang.CharSequence _comment)
        
        Check if _comment is an instance of a _tag_name tag.
        Parameters:
        _tag_name - a NUL-terminated, case-insensitive, ASCII string containing the name of the tag to check for (without the terminating '=' character)
        _comment - the comment string to check
        Returns:
        an integer less than, equal to, or greater than zero if _comment is found respectively, to be less than, to match, or be greater than a "tag=value" string whose tag matches _tag_name
      • nopus_tagncompare

        public static int nopus_tagncompare​(long _tag_name,
                                            int _tag_len,
                                            long _comment)
        Unsafe version of: tagncompare
        Parameters:
        _tag_len - the number of characters in the tag name. This must be non-negative.
      • opus_tagncompare

        public static int opus_tagncompare​(java.nio.ByteBuffer _tag_name,
                                           java.nio.ByteBuffer _comment)
        
        public static int opus_tagncompare​(java.lang.CharSequence _tag_name,
                                           java.lang.CharSequence _comment)
        
        Check if _comment is an instance of a _tag_name tag.

        This version is slightly more efficient than tagcompare if the length of the tag name is already known (e.g., because it is a constant).

        Parameters:
        _tag_name - a case-insensitive ASCII string containing the name of the tag to check for (without the terminating '=' character)
        _comment - the comment string to check
        Returns:
        an integer less than, equal to, or greater than zero if _comment is found respectively, to be less than, to match, or be greater than a "tag=value" string whose tag matches the first _tag_len characters of _tag_name
      • nopus_picture_tag_parse

        public static int nopus_picture_tag_parse​(long _pic,
                                                  long _tag)
        Unsafe version of: picture_tag_parse
      • opus_picture_tag_parse

        public static int opus_picture_tag_parse​(OpusPictureTag _pic,
                                                 java.nio.ByteBuffer _tag)
        
        public static int opus_picture_tag_parse​(OpusPictureTag _pic,
                                                 java.lang.CharSequence _tag)
        
        Parse a single METADATA_BLOCK_PICTURE tag.

        This decodes the BASE64-encoded content of the tag and returns a structure with the MIME type, description, image parameters (if known), and the compressed image data. If the MIME type indicates the presence of an image format we recognize (JPEG, PNG, or GIF) and the actual image data contains the magic signature associated with that format, then the OpusPictureTag::format field will be set to the corresponding format. This is provided as a convenience to avoid requiring applications to parse the MIME type and/or do their own format detection for the commonly used formats. In this case, we also attempt to extract the image parameters directly from the image data (overriding any that were present in the tag, which the specification says applications are not meant to rely on). The application must still provide its own support for actually decoding the image data and, if applicable, retrieving that data from URLs.

        Parameters:
        _pic - returns the parsed picture data.

        No sanitation is done on the type, MIME type, or description fields, so these might return invalid values. The contents of this structure are left unmodified on failure.

        _tag - the METADATA_BLOCK_PICTURE tag contents. The leading "METADATA_BLOCK_PICTURE=" portion is optional, to allow the function to be used on either directly on the values in OpusTags::user_comments or on the return value of tags_query.
        Returns:
        0 on success, or a negative value on failure:
        • ENOTFORMAT The METADATA_BLOCK_PICTURE contents were not valid
        • EFAULT There was not enough memory to store the picture tag contents
      • nopus_picture_tag_init

        public static void nopus_picture_tag_init​(long _pic)
        Unsafe version of: picture_tag_init
      • opus_picture_tag_init

        public static void opus_picture_tag_init​(OpusPictureTag _pic)
        Initializes an OpusPictureTag structure. This should be called on a freshly allocated OpusPictureTag structure before attempting to use it.
        Parameters:
        _pic - the OpusPictureTag structure to initialize
      • nopus_picture_tag_clear

        public static void nopus_picture_tag_clear​(long _pic)
        Unsafe version of: picture_tag_clear
      • opus_picture_tag_clear

        public static void opus_picture_tag_clear​(OpusPictureTag _pic)
        Clears the OpusPictureTag structure.

        This should be called on an OpusPictureTag structure after it is no longer needed. It will free all memory used by the structure members.

        Parameters:
        _pic - the OpusPictureTag structure to clear
      • op_fopen

        public static long op_fopen​(OpusFileCallbacks _cb,
                                    java.nio.ByteBuffer _path,
                                    java.nio.ByteBuffer _mode)
        
        public static long op_fopen​(OpusFileCallbacks _cb,
                                    java.lang.CharSequence _path,
                                    java.lang.CharSequence _mode)
        
        Opens a stream with fopen() and fills in a set of callbacks that can be used to access it.

        This is useful to avoid writing your own portable 64-bit seeking wrappers, and also avoids cross-module linking issues on Windows, where a FILE * must be accessed by routines defined in the same module that opened it.

        Parameters:
        _cb - the callbacks to use for this file. If there is an error opening the file, nothing will be filled in here.
        _path - the path to the file to open. On Windows, this string must be UTF-8 (to allow access to files whose names cannot be represented in the current MBCS code page). All other systems use the native character encoding.
        _mode - the mode to open the file in
        Returns:
        a stream handle to use with the callbacks, or NULL on error
      • op_fdopen

        public static long op_fdopen​(OpusFileCallbacks _cb,
                                     int _fd,
                                     java.nio.ByteBuffer _mode)
        
        public static long op_fdopen​(OpusFileCallbacks _cb,
                                     int _fd,
                                     java.lang.CharSequence _mode)
        
        Opens a stream with fdopen() and fills in a set of callbacks that can be used to access it.

        This is useful to avoid writing your own portable 64-bit seeking wrappers, and also avoids cross-module linking issues on Windows, where a FILE * must be accessed by routines defined in the same module that opened it.

        Parameters:
        _cb - the callbacks to use for this file. If there is an error opening the file, nothing will be filled in here.
        _fd - the file descriptor to open
        _mode - the mode to open the file in
        Returns:
        a stream handle to use with the callbacks, or NULL on error
      • op_mem_stream_create

        public static long op_mem_stream_create​(OpusFileCallbacks _cb,
                                                java.nio.ByteBuffer _data)
        Creates a stream that reads from the given block of memory.

        This block of memory must contain the complete stream to decode. This is useful for caching small streams (e.g., sound effects) in RAM.

        Parameters:
        _cb - the callbacks to use for this stream. If there is an error creating the stream, nothing will be filled in here.
        _data - the block of memory to read from
        Returns:
        a stream handle to use with the callbacks, or NULL on error
      • op_test

        public static int op_test​(@Nullable
                                  OpusHead _head,
                                  java.nio.ByteBuffer _initial_data)
        Test to see if this is an Opus stream.

        For good results, you will need at least 57 bytes (for a pure Opus-only stream). Something like 512 bytes will give more reliable results for multiplexed streams. This function is meant to be a quick-rejection filter. Its purpose is not to guarantee that a stream is a valid Opus stream, but to ensure that it looks enough like Opus that it isn't going to be recognized as some other format (except possibly an Opus stream that is also multiplexed with other codecs, such as video).

        Parameters:
        _head - the parsed ID header contents. You may pass NULL if you do not need this information. If the function fails, the contents of this structure remain untouched.
        _initial_data - an initial buffer of data from the start of the stream
        Returns:
        0 if the data appears to be Opus, or a negative value on error.
        • FALSE There was not enough data to tell if this was an Opus stream or not
        • EFAULT An internal memory allocation failed
        • EIMPL The stream used a feature that is not implemented, such as an unsupported channel family
        • ENOTFORMAT If the data did not contain a recognizable ID header for an Opus stream
        • EVERSION If the version field signaled a version this library does not know how to parse
        • EBADHEADER The ID header was not properly formatted or contained illegal values
      • op_open_file

        public static long op_open_file​(java.nio.ByteBuffer _path,
                                        @Nullable
                                        java.nio.IntBuffer _error)
        
        public static long op_open_file​(java.lang.CharSequence _path,
                                        @Nullable
                                        java.nio.IntBuffer _error)
        
        Open a stream from the given file path.
        Parameters:
        _path - the path to the file to open
        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. The failure code will be EFAULT if the file could not be opened, or one of the other failure codes from op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) otherwise.

        Returns:
        a freshly opened OggOpusFile, or NULL on error
      • op_open_memory

        public static long op_open_memory​(java.nio.ByteBuffer _data,
                                          @Nullable
                                          java.nio.IntBuffer _error)
        Open a stream from a memory buffer.
        Parameters:
        _data - the memory buffer to open
        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. See op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) for a full list of failure codes.

        Returns:
        a freshly opened OggOpusFile, or NULL on error
      • nop_open_callbacks

        public static long nop_open_callbacks​(long _stream,
                                              long _cb,
                                              long _initial_data,
                                              long _initial_bytes,
                                              long _error)
        Parameters:
        _initial_bytes - the number of bytes in _initial_data.

        If the stream is seekable, its current position (as reported by "tell()" at the start of this function) must be equal to _initial_bytes. Otherwise, seeking to absolute positions will generate inconsistent results.

      • op_open_callbacks

        public static long op_open_callbacks​(long _stream,
                                             OpusFileCallbacks _cb,
                                             java.nio.ByteBuffer _initial_data,
                                             @Nullable
                                             java.nio.IntBuffer _error)
        Open a stream using the given set of callbacks to access it.
        Parameters:
        _stream - the stream to read from (e.g., a FILE *). This value will be passed verbatim as the first argument to all of the callbacks.
        _cb - the callbacks with which to access the stream.

        "read()" must be implemented. "seek()" and "tell()" may be NULL, or may always return -1 to indicate a stream is unseekable, but if "seek()" is implemented and succeeds on a particular stream, then "tell()" must also. "close()" may be NULL, but if it is not, it will be called when the OggOpusFile is destroyed by op_free(long). It will not be called if op_open_callbacks() fails with an error.

        _initial_data - an initial buffer of data from the start of the stream.

        Applications can read some number of bytes from the start of the stream to help identify this as an Opus stream, and then provide them here to allow the stream to be opened, even if it is unseekable.

        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. The failure code will be one of:

        • EREAD An underlying read, seek, or tell operation failed when it should have succeeded, or we failed to find data in the stream we had seen before
        • EFAULT There was a memory allocation failure, or an internal library error
        • EIMPL The stream used a feature that is not implemented, such as an unsupported channel family
        • EINVAL "seek()" was implemented and succeeded on this source, but "tell()" did not, or the starting position indicator was not equal to _initial_bytes
        • ENOTFORMAT The stream contained a link that did not have any logical Opus streams in it
        • EBADHEADER A required header packet was not properly formatted, contained illegal values, or was missing altogether
        • EVERSION An ID header contained an unrecognized version number
        • EBADLINK We failed to find data we had seen before after seeking
        • EBADTIMESTAMP The first or last timestamp in a link failed basic validity checks
        Returns:
        a freshly opened OggOpusFile, or NULL on error.

        libopusfile does not take ownership of the stream if the call fails. The calling application is responsible for closing the stream if this call returns an error.

      • op_test_file

        public static long op_test_file​(java.nio.ByteBuffer _path,
                                        @Nullable
                                        java.nio.IntBuffer _error)
        
        public static long op_test_file​(java.lang.CharSequence _path,
                                        @Nullable
                                        java.nio.IntBuffer _error)
        
        Partially open a stream from the given file path.
        Parameters:
        _path - the path to the file to open
        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. The failure code will be EFAULT if the file could not be opened, or one of the other failure codes from op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) otherwise.

        Returns:
        a partially opened OggOpusFile, or NULL on error
      • op_test_memory

        public static long op_test_memory​(java.nio.ByteBuffer _data,
                                          @Nullable
                                          java.nio.IntBuffer _error)
        Partially open a stream from a memory buffer.
        Parameters:
        _data - the memory buffer to open
        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. See op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) for a full list of failure codes.

        Returns:
        a partially opened OggOpusFile, or NULL on error
      • nop_test_callbacks

        public static long nop_test_callbacks​(long _stream,
                                              long _cb,
                                              long _initial_data,
                                              long _initial_bytes,
                                              long _error)
        Parameters:
        _initial_bytes - the number of bytes in _initial_data.

        If the stream is seekable, its current position (as reported by "tell()" at the start of this function) must be equal to _initial_bytes. Otherwise, seeking to absolute positions will generate inconsistent results.

      • op_test_callbacks

        public static long op_test_callbacks​(long _stream,
                                             OpusFileCallbacks _cb,
                                             java.nio.ByteBuffer _initial_data,
                                             @Nullable
                                             java.nio.IntBuffer _error)
        Partially open a stream using the given set of callbacks to access it.

        This tests for Opusness and loads the headers for the first link. It does not seek (although it tests for seekability). You can query a partially open stream for the few pieces of basic information returned by op_serialno(long, int), op_channel_count(long, int), op_head(long, int), and op_tags(long, int) (but only for the first link). You may also determine if it is seekable via a call to op_seekable(long). You cannot read audio from the stream, seek, get the size or duration, get information from links other than the first one, or even get the total number of links until you finish opening the stream with op_test_open(long). If you do not need to do any of these things, you can dispose of it with op_free(long) instead.

        This function is provided mostly to simplify porting existing code that used libvorbisfile. For new code, you are likely better off using op_test(org.lwjgl.util.opus.OpusHead, java.nio.ByteBuffer) instead, which is less resource-intensive, requires less data to succeed, and imposes a hard limit on the amount of data it examines (important for unseekable streams, where all such data must be buffered until you are sure of the stream type).

        Parameters:
        _stream - the stream to read from (e.g., a FILE *). This value will be passed verbatim as the first argument to all of the callbacks.
        _cb - the callbacks with which to access the stream.

        "read()" must be implemented. "seek()" and "tell()" may be NULL, or may always return -1 to indicate a stream is unseekable, but if "seek()" is implemented and succeeds on a particular stream, then "tell()" must also. "close()" may be NULL, but if it is not, it will be called when the OggOpusFile is destroyed by op_free(long). It will not be called if op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) fails with an error.

        _initial_data - an initial buffer of data from the start of the stream.

        Applications can read some number of bytes from the start of the stream to help identify this as an Opus stream, and then provide them here to allow the stream to be tested more thoroughly, even if it is unseekable.

        _error - returns 0 on success, or a failure code on error.

        You may pass in NULL if you don't want the failure code. See op_open_callbacks(long, org.lwjgl.util.opus.OpusFileCallbacks, java.nio.ByteBuffer, java.nio.IntBuffer) for a full list of failure codes.

        Returns:
        a partially opened OggOpusFile, or NULL on error.

        libopusfile does not take ownership of the stream if the call fails. The calling application is responsible for closing the stream if this call returns an error.

      • op_free

        public static void op_free​(long _of)
        Release all memory used by an OggOpusFile.
        Parameters:
        _of - the OggOpusFile to free
      • op_seekable

        public static boolean op_seekable​(long _of)
        Returns whether or not the stream being read is seekable.

        This is true if

        1. The "seek()" and "tell()" callbacks are both non-NULL
        2. The "seek()" callback was successfully executed at least once, and
        3. The "tell()" callback was successfully able to report the position indicator afterwards

        This function may be called on partially-opened streams.

        Parameters:
        _of - the OggOpusFile whose seekable status is to be returned
        Returns:
        a non-zero value if seekable, and 0 if unseekable
      • op_link_count

        public static int op_link_count​(long _of)
        Returns the number of links in this chained stream.

        This function may be called on partially-opened streams, but it will always return 1. The actual number of links is not known until the stream is fully opened.

        Parameters:
        _of - the OggOpusFile from which to retrieve the link count
        Returns:
        for fully-open seekable streams, this returns the total number of links in the whole stream, which will be at least 1. For partially-open or unseekable streams, this always returns 1.
      • op_serialno

        public static int op_serialno​(long _of,
                                      int _li)
        Get the serial number of the given link in a (possibly-chained) Ogg Opus stream.

        This function may be called on partially-opened streams, but it will always return the serial number of the Opus stream in the first link.

        Parameters:
        _of - the OggOpusFile from which to retrieve the serial number
        _li - the index of the link whose serial number should be retrieved. Use a negative number to get the serial number of the current link.
        Returns:
        the serial number of the given link.

        If _li is greater than the total number of links, this returns the serial number of the last link. If the stream is not seekable, this always returns the serial number of the current link.

      • op_channel_count

        public static int op_channel_count​(long _of,
                                           int _li)
        Get the channel count of the given link in a (possibly-chained) Ogg Opus stream.

        This is equivalent to op_head(_of,_li)->channel_count, but is provided for convenience. This function may be called on partially-opened streams, but it will always return the channel count of the Opus stream in the first link.

        Parameters:
        _of - the OggOpusFile from which to retrieve the channel count
        _li - the index of the link whose channel count should be retrieved. Use a negative number to get the channel count of the current link.
        Returns:
        the channel count of the given link.

        If _li is greater than the total number of links, this returns the channel count of the last link. If the stream is not seekable, this always returns the channel count of the current link.

      • op_raw_total

        public static long op_raw_total​(long _of,
                                        int _li)
        Get the total (compressed) size of the stream, or of an individual link in a (possibly-chained) Ogg Opus stream, including all headers and Ogg muxing overhead.

        Warning: If the Opus stream (or link) is concurrently multiplexed with other logical streams (e.g., video), this returns the size of the entire stream (or link), not just the number of bytes in the first logical Opus stream. Returning the latter would require scanning the entire file.

        Parameters:
        _of - the OggOpusFile from which to retrieve the compressed size
        _li - the index of the link whose compressed size should be computed. Use a negative number to get the compressed size of the entire stream.
        Returns:
        the compressed size of the entire stream if _li is negative, the compressed size of link _li if it is non-negative, or a negative value on error.

        The compressed size of the entire stream may be smaller than that of the underlying stream if trailing garbage was detected in the file.

        EINVAL The stream is not seekable (so we can't know the length),#_li wasn't less than the total number of links in the stream, or the stream was only partially open.

      • op_pcm_total

        public static long op_pcm_total​(long _of,
                                        int _li)
        Get the total PCM length (number of samples at 48 kHz) of the stream, or of an individual link in a (possibly-chained) Ogg Opus stream.

        Users looking for op_time_total() should use op_pcm_total() instead. Because timestamps in Opus are fixed at 48 kHz, there is no need for a separate function to convert this to seconds (and leaving it out avoids introducing floating point to the API, for those that wish to avoid it).

        Parameters:
        _of - the OggOpusFile from which to retrieve the PCM offset
        _li - the index of the link whose PCM length should be computed. Use a negative number to get the PCM length of the entire stream.
        Returns:
        the PCM length of the entire stream if _li is negative, the PCM length of link _li if it is non-negative, or a negative value on error.

        EINVAL The stream is not seekable (so we can't know the length), _li wasn't less than the total number of links in the stream, or the stream was only partially open.

      • nop_head

        public static long nop_head​(long _of,
                                    int _li)
        Unsafe version of: op_head(long, int)
      • op_head

        @Nullable
        public static OpusHead op_head​(long _of,
                                       int _li)
        Get the ID header information for the given link in a (possibly chained) Ogg Opus stream.

        This function may be called on partially-opened streams, but it will always return the ID header information of the Opus stream in the first link.

        Parameters:
        _of - the OggOpusFile from which to retrieve the ID header information
        _li - the index of the link whose ID header information should be retrieved. Use a negative number to get the ID header information of the current link. For an unseekable stream, _li is ignored, and the ID header information for the current link is always returned, if available.
        Returns:
        the contents of the ID header for the given link
      • nop_tags

        public static long nop_tags​(long _of,
                                    int _li)
        Unsafe version of: op_tags(long, int)
      • op_tags

        @Nullable
        public static OpusTags op_tags​(long _of,
                                       int _li)
        Get the comment header information for the given link in a (possibly chained) Ogg Opus stream.

        This function may be called on partially-opened streams, but it will always return the tags from the Opus stream in the first link.

        Parameters:
        _of - the OggOpusFile from which to retrieve the comment header information
        _li - the index of the link whose comment header information should be retrieved. Use a negative number to get the comment header information of the current link. For an unseekable stream, _li is ignored, and the comment header information for the current link is always returned, if available.
        Returns:
        the contents of the comment header for the given link, or NULL if this is an unseekable stream that encountered an invalid link
      • op_current_link

        public static int op_current_link​(long _of)
        Retrieve the index of the current link.

        This is the link that produced the data most recently read by op_read_float(long, java.nio.FloatBuffer, java.nio.IntBuffer) or its associated functions, or, after a seek, the link that the seek target landed in. Reading more data may advance the link index (even on the first read after a seek).

        Parameters:
        _of - the OggOpusFile from which to retrieve the current link index
        Returns:
        the index of the current link on success, or a negative value on failure.

        For seekable streams, this is a number between 0 (inclusive) and the value returned by op_link_count(long) (exclusive). For unseekable streams, this value starts at 0 and increments by one each time a new link is encountered (even though op_link_count() always returns 1).

        EINVAL The stream was only partially open.

      • op_bitrate

        public static int op_bitrate​(long _of,
                                     int _li)
        Computes the bitrate of the stream, or of an individual link in a (possibly-chained) Ogg Opus stream.

        The stream must be seekable to compute the bitrate. For unseekable streams, use op_bitrate_instant(long) to get periodic estimates.

        Warning: If the Opus stream (or link) is concurrently multiplexed with other logical streams (e.g., video), this uses the size of the entire stream (or link) to compute the bitrate, not just the number of bytes in the first logical Opus stream. Returning the latter requires scanning the entire file, but this may be done by decoding the whole file and calling op_bitrate_instant() once at the end. Install a trivial decoding callback with op_set_decode_callback(long, org.lwjgl.util.opus.OPDecodeCBFuncI, long) if you wish to skip actual decoding during this process.

        Parameters:
        _of - the OggOpusFile from which to retrieve the bitrate
        _li - the index of the link whose bitrate should be computed. Use a negative number to get the bitrate of the whole stream.
        Returns:
        the bitrate on success, or a negative value on error.

        EINVAL The stream was only partially open, the stream was not seekable, or _li was larger than the number of links.

      • op_bitrate_instant

        public static int op_bitrate_instant​(long _of)
        Compute the instantaneous bitrate, measured as the ratio of bits to playable samples decoded since
        1. the last call to op_bitrate_instant(),
        2. the last seek, or
        3. the start of playback, whichever was most recent.

        This will spike somewhat after a seek or at the start/end of a chain boundary, as pre-skip, pre-roll, and end-trimming causes samples to be decoded but not played.

        Parameters:
        _of - the OggOpusFile from which to retrieve the bitrate
        Returns:
        the bitrate, in bits per second, or a negative value on error:
        • FALSE No data has been decoded since any of the events described above
        • EINVAL The stream was only partially open
      • op_raw_tell

        public static long op_raw_tell​(long _of)
        Obtain the current value of the position indicator for _of.
        Parameters:
        _of - the OggOpusFile from which to retrieve the position indicator
        Returns:
        the byte position that is currently being read from. EINVAL The stream was only partially open.
      • op_pcm_tell

        public static long op_pcm_tell​(long _of)
        Obtain the PCM offset of the next sample to be read.

        If the stream is not properly timestamped, this might not increment by the proper amount between reads, or even return monotonically increasing values.

        Parameters:
        _of - the OggOpusFile from which to retrieve the PCM offset
        Returns:
        the PCM offset of the next sample to be read. EINVAL The stream was only partially open.
      • op_raw_seek

        public static int op_raw_seek​(long _of,
                                      long _byte_offset)
        Seek to a byte offset relative to the compressed data.

        This also scans packets to update the PCM cursor. It will cross a logical bitstream boundary, but only if it can't get any packets out of the tail of the link to which it seeks.

        Parameters:
        _of - the OggOpusFile in which to seek
        _byte_offset - the byte position to seek to. This must be between 0 and op_raw_total(_of, -1) (inclusive).
        Returns:
        0 on success, or a negative error code on failure:
        • EREAD The underlying seek operation failed
        • EINVAL The stream was only partially open, or the target was outside the valid range for the stream
        • ENOSEEK This stream is not seekable
        • EBADLINK Failed to initialize a decoder for a stream for an unknown reason
      • op_pcm_seek

        public static int op_pcm_seek​(long _of,
                                      long _pcm_offset)
        Seek to the specified PCM offset, such that decoding will begin at exactly the requested position.
        Parameters:
        _of - the OggOpusFile in which to seek
        _pcm_offset - the PCM offset to seek to. This is in samples at 48 kHz relative to the start of the stream.
        Returns:
        0 on success, or a negative value on error:
        • EREAD An underlying read or seek operation failed
        • EINVAL The stream was only partially open, or the target was outside the valid range for the stream
        • ENOSEEK This stream is not seekable
        • EBADLINK We failed to find data we had seen before, or the bitstream structure was sufficiently malformed that seeking to the target destination was impossible
      • op_set_decode_callback

        public static void op_set_decode_callback​(long _of,
                                                  OPDecodeCBFuncI _decode_cb,
                                                  long _ctx)
        Sets the packet decode callback function.

        If set, this is called once for each packet that needs to be decoded. This can be used by advanced applications to do additional processing on the compressed or uncompressed data. For example, an application might save the final entropy coder state for debugging and testing purposes, or it might apply additional filters before the downmixing, dithering, or soft-clipping performed by libopusfile, so long as these filters do not introduce any latency.

        A call to this function is no guarantee that the audio will eventually be delivered to the application. libopusfile may discard some or all of the decoded audio data (i.e., at the beginning or end of a link, or after a seek), however the callback is still required to provide all of it.

        Parameters:
        _of - the OggOpusFile on which to set the decode callback
        _decode_cb - the callback function to call. This may be NULL to disable calling the callback.
        _ctx - the application-provided context pointer to pass to the callback on each call
      • op_set_gain_offset

        public static int op_set_gain_offset​(long _of,
                                             int _gain_type,
                                             int _gain_offset_q8)
        Sets the gain to be used for decoded output.

        By default, the gain in the header is applied with no additional offset. The total gain (including header gain and/or track gain, if applicable, and this offset), will be clamped to [-32768,32767]/256 dB. This is more than enough to saturate or underflow 16-bit PCM.

        Note

        The new gain will not be applied to any already buffered, decoded output. This means you cannot change it sample-by-sample, as at best it will be updated packet-by-packet. It is meant for setting a target volume level, rather than applying smooth fades, etc.

        Parameters:
        _of - the OggOpusFile on which to set the gain offset
        _gain_type - one of:
        HEADER_GAIN,ALBUM_GAIN,TRACK_GAINABSOLUTE_GAIN
        _gain_offset_q8 - the gain offset to apply, in 1/256ths of a dB
        Returns:
        0 on success or a negative value on error. EINVAL The _gain_type was unrecognized.
      • nop_read

        public static int nop_read​(long _of,
                                   long _pcm,
                                   int _buf_size,
                                   long _li)
        Parameters:
        _buf_size - the number of values that can be stored in _pcm.

        It is recommended that this be large enough for at least 120 ms of data at 48 kHz per channel (5760 values per channel). Smaller buffers will simply return less data, possibly consuming more memory to buffer the data internally. libopusfile may return less data than requested. If so, there is no guarantee that the remaining data in _pcm will be unmodified.

      • op_read

        public static int op_read​(long _of,
                                  java.nio.ShortBuffer _pcm,
                                  @Nullable
                                  java.nio.IntBuffer _li)
        Reads more samples from the stream.
        Note

        Although _buf_size must indicate the total number of values that can be stored in _pcm, the return value is the number of samples per channel. This is done because

        1. The channel count cannot be known a priori (reading more samples might advance us into the next link, with a different channel count), so _buf_size cannot also be in units of samples per channel
        2. Returning the samples per channel matches the libopus API as closely as we're able
        3. Returning the total number of values instead of samples per channel would mean the caller would need a division to compute the samples per channel, and might worry about the possibility of getting back samples for some channels and not others, and
        4. This approach is relatively fool-proof: if an application passes too small a value to _buf_size, they will simply get fewer samples back, and if they assume the return value is the total number of values, then they will simply read too few (rather than reading too many and going off the end of the buffer)
        Parameters:
        _of - the OggOpusFile from which to read
        _pcm - a buffer in which to store the output PCM samples, as signed native-endian 16-bit values at 48 kHz with a nominal range of [-32768,32767). Multiple channels are interleaved using the Vorbis channel ordering. This must have room for at least _buf_size values.
        _li - the index of the link this data was decoded from.

        You may pass NULL if you do not need this information. If this function fails (returning a negative value), this parameter is left unset.

        Returns:
        the number of samples read per channel on success, or a negative value on failure.

        The channel count can be retrieved on success by calling op_head(_of,*_li). The number of samples returned may be 0 if the buffer was too small to store even a single sample for all channels, or if end-of-file was reached. The list of possible failure codes follows. Most of them can only be returned by unseekable, chained streams that encounter a new link.

        • HOLE There was a hole in the data, and some samples may have been skipped. Call this function again to continue decoding past the hole
        • EREAD An underlying read operation failed. This may signal a truncation attack from an https: source
        • EFAULT An internal memory allocation failed
        • EIMPL An unseekable stream encountered a new link that used a feature that is not implemented, such as an unsupported channel family
        • EINVAL The stream was only partially open
        • ENOTFORMAT An unseekable stream encountered a new link that did not have any logical Opus streams in it
        • EBADHEADER An unseekable stream encountered a new link with a required header packet that was not properly formatted, contained illegal values, or was missing altogether
        • EVERSION An unseekable stream encountered a new link with an ID header that contained an unrecognized version number
        • EBADPACKET Failed to properly decode the next packet
        • EBADLINK We failed to find data we had seen before
        • EBADTIMESTAMP An unseekable stream encountered a new link with a starting timestamp that failed basic validity checks
      • nop_read_float

        public static int nop_read_float​(long _of,
                                         long _pcm,
                                         int _buf_size,
                                         long _li)
        Parameters:
        _buf_size - the number of floats that can be stored in _pcm.

        It is recommended that this be large enough for at least 120 ms of data at 48 kHz per channel (5760 samples per channel). Smaller buffers will simply return less data, possibly consuming more memory to buffer the data internally. If less than _buf_size values are returned, libopusfile makes no guarantee that the remaining data in _pcm will be unmodified.

      • op_read_float

        public static int op_read_float​(long _of,
                                        java.nio.FloatBuffer _pcm,
                                        @Nullable
                                        java.nio.IntBuffer _li)
        Reads more samples from the stream.
        Note

        Although _buf_size must indicate the total number of values that can be stored in _pcm, the return value is the number of samples per channel.

        1. The channel count cannot be known a priori (reading more samples might advance us into the next link, with a different channel count), so _buf_size cannot also be in units of samples per channel,
        2. Returning the samples per channel matches the libopus API as closely as we're able,
        3. Returning the total number of values instead of samples per channel would mean the caller would need a division to compute the samples per channel, and might worry about the possibility of getting back samples for some channels and not others, and
        4. This approach is relatively fool-proof: if an application passes too small a value to _buf_size, they will simply get fewer samples back, and if they assume the return value is the total number of values, then they will simply read too few (rather than reading too many and going off the end of the buffer).
        Parameters:
        _of - the OggOpusFile from which to read
        _pcm - a buffer in which to store the output PCM samples as signed floats at 48 kHz with a nominal range of [-1.0,1.0].

        Multiple channels are interleaved using the Vorbis channel ordering. This must have room for at least _buf_size floats.

        _li - the index of the link this data was decoded from.

        You may pass NULL if you do not need this information. If this function fails (returning a negative value), this parameter is left unset.

        Returns:
        the number of samples read per channel on success, or a negative value on failure.

        The channel count can be retrieved on success by calling op_head(_of,*_li). The number of samples returned may be 0 if the buffer was too small to store even a single sample for all channels, or if end-of-file was reached. The list of possible failure codes follows. Most of them can only be returned by unseekable, chained streams that encounter a new link.

        • HOLE There was a hole in the data, and some samples may have been skipped. Call this function again to continue decoding past the hole
        • EREAD An underlying read operation failed. This may signal a truncation attack from an https: source
        • EFAULT An internal memory allocation failed
        • EIMPL An unseekable stream encountered a new link that used a feature that is not implemented, such as an unsupported channel family
        • EINVAL The stream was only partially open
        • ENOTFORMAT An unseekable stream encountered a new link that did not have any logical Opus streams in it
        • EBADHEADER An unseekable stream encountered a new link with a required header packet that was not properly formatted, contained illegal values, or was missing altogether
        • EVERSION An unseekable stream encountered a new link with an ID header that contained an unrecognized version number
        • EBADPACKET Failed to properly decode the next packet
        • EBADLINK We failed to find data we had seen before
        • EBADTIMESTAMP An unseekable stream encountered a new link with a starting timestamp that failed basic validity checks
      • nop_read_stereo

        public static int nop_read_stereo​(long _of,
                                          long _pcm,
                                          int _buf_size)
        Parameters:
        _buf_size - the number of values that can be stored in _pcm.

        It is recommended that this be large enough for at least 120 ms of data at 48 kHz per channel (11520 values total). Smaller buffers will simply return less data, possibly consuming more memory to buffer the data internally. If less than _buf_size values are returned, libopusfile makes no guarantee that the remaining data in _pcm will be unmodified.

      • op_read_stereo

        public static int op_read_stereo​(long _of,
                                         java.nio.ShortBuffer _pcm)
        Reads more samples from the stream and downmixes to stereo, if necessary.

        This function is intended for simple players that want a uniform output format, even if the channel count changes between links in a chained stream.

        Note

        _buf_size indicates the total number of values that can be stored in _pcm, while the return value is the number of samples per channel, even though the channel count is known, for consistency with op_read(long, java.nio.ShortBuffer, java.nio.IntBuffer).

        Parameters:
        _of - the OggOpusFile from which to read
        _pcm - a buffer in which to store the output PCM samples, as signed native-endian 16-bit values at 48 kHz with a nominal range of [-32768,32767).

        The left and right channels are interleaved in the buffer. This must have room for at least _buf_size values.

        Returns:
        the number of samples read per channel on success, or a negative value on failure.

        The number of samples returned may be 0 if the buffer was too small to store even a single sample for both channels, or if end-of-file was reached. The list of possible failure codes follows. Most of them can only be returned by unseekable, chained streams that encounter a new link.

        • HOLE There was a hole in the data, and some samples may have been skipped. Call this function again to continue decoding past the hole
        • EREAD An underlying read operation failed. This may signal a truncation attack from an https: source
        • EFAULT An internal memory allocation failed
        • EIMPL An unseekable stream encountered a new link that used a feature that is not implemented, such as an unsupported channel family
        • EINVAL The stream was only partially open
        • ENOTFORMAT An unseekable stream encountered a new link that did not have any logical Opus streams in it
        • EBADHEADER An unseekable stream encountered a new link with a required header packet that was not properly formatted, contained illegal values, or was missing altogether
        • EVERSION An unseekable stream encountered a new link with an ID header that contained an unrecognized version number
        • EBADPACKET Failed to properly decode the next packet
        • EBADLINK We failed to find data we had seen before
        • EBADTIMESTAMP An unseekable stream encountered a new link with a starting timestamp that failed basic validity checks
      • nop_read_float_stereo

        public static int nop_read_float_stereo​(long _of,
                                                long _pcm,
                                                int _buf_size)
        Parameters:
        _buf_size - the number of values that can be stored in _pcm.

        It is recommended that this be large enough for at least 120 ms of data at 48 kHz per channel (11520 values total). Smaller buffers will simply return less data, possibly consuming more memory to buffer the data internally. If less than _buf_size values are returned, libopusfile makes no guarantee that the remaining data in _pcm will be unmodified.

      • op_read_float_stereo

        public static int op_read_float_stereo​(long _of,
                                               java.nio.FloatBuffer _pcm)
        Reads more samples from the stream and downmixes to stereo, if necessary.

        This function is intended for simple players that want a uniform output format, even if the channel count changes between links in a chained stream.

        Note

        _buf_size indicates the total number of values that can be stored in _pcm, while the return value is the number of samples per channel, even though the channel count is known, for consistency with op_read_float(long, java.nio.FloatBuffer, java.nio.IntBuffer).

        Parameters:
        _of - the OggOpusFile from which to read
        _pcm - a buffer in which to store the output PCM samples, as signed floats at 48 kHz with a nominal range of [-1.0,1.0].

        The left and right channels are interleaved in the buffer. This must have room for at least _buf_size values.

        Returns:
        the number of samples read per channel on success, or a negative value on failure.

        The number of samples returned may be 0 if the buffer was too small to store even a single sample for both channels, or if end-of-file was reached. The list of possible failure codes follows. Most of them can only be returned by unseekable, chained streams that encounter a new link.

        • HOLE There was a hole in the data, and some samples may have been skipped. Call this function again to continue decoding past the hole
        • EREAD An underlying read operation failed. This may signal a truncation attack from an https: source
        • EFAULT An internal memory allocation failed
        • EIMPL An unseekable stream encountered a new link that used a feature that is not implemented, such as an unsupported channel family
        • EINVAL The stream was only partially open
        • ENOTFORMAT An unseekable stream encountered a new link that that did not have any logical Opus streams in it
        • EBADHEADER An unseekable stream encountered a new link with a required header packet that was not properly formatted, contained illegal values, or was missing altogether
        • EVERSION An unseekable stream encountered a new link with an ID header that contained an unrecognized version number
        • EBADPACKET Failed to properly decode the next packet
        • EBADLINK We failed to find data we had seen before
        • EBADTIMESTAMP An unseekable stream encountered a new link with a starting timestamp that failed basic validity checks