Class ALHelpers


  • public class ALHelpers
    extends Object
    • Constructor Detail

      • ALHelpers

        public ALHelpers()
    • Method Detail

      • getALFormat

        public static final int getALFormat​(int alChannelLayout,
                                            int alSampleType,
                                            boolean hasSOFTBufferSamples,
                                            AL al,
                                            ALExt alExt)
        Returns a compatible AL buffer format given the AL channel layout and AL sample type. If hasSOFTBufferSamples is true, it will be called to find the closest-matching format from AL_SOFT_buffer_samples.

        Returns ALConstants.AL_NONE if no supported format can be found.

        Parameters:
        alChannelLayout - AL channel layout, see getDefaultALChannelLayout(int)
        alSampleType - AL sample type, see getALSampleType(int, boolean, boolean).
        hasSOFTBufferSamples - true if having extension AL_SOFT_buffer_samples, otherwise false
        al - AL instance
        alExt - ALExt instance
        Returns:
        AL buffer format
      • getDefaultALChannelLayout

        public static final int getDefaultALChannelLayout​(int channelCount)
        Returns the default AL channel layout matching the given channel count, or ALConstants.AL_NONE.
        Parameters:
        channelCount - number of channels
        signed - true if signed number, false for unsigned
        fixedP - true for fixed point value, false for floating point value with a sampleSize of 32 (float) or 64 (double)
      • alChannelLayoutName

        public static final String alChannelLayoutName​(int alChannelLayout)
        Returns the readable name of the given AL channel layout
      • getALSampleType

        public static final int getALSampleType​(int sampleSize,
                                                boolean signed,
                                                boolean fixedP)
        Returns the AL sample type matching the given audio type attributes, or ALConstants.AL_NONE.
        Parameters:
        sampleSize - sample size in bits
        signed - true if signed number, false for unsigned
        fixedP - true for fixed point value, false for floating point value with a sampleSize of 32 (float) or 64 (double)
      • alSampleTypeName

        public static final String alSampleTypeName​(int alSampleType)
        Returns the readable name of the given AL sample type
      • sizeOfALSampleType

        public static final int sizeOfALSampleType​(int alSampleType)
                                            throws IllegalArgumentException
        Returns the byte size of the given AL sample type
        Throws:
        IllegalArgumentException - for unknown alChannelLayout or alSampleType values.
      • samplesToByteCount

        public static final int samplesToByteCount​(int sampleCount,
                                                   int alChannelLayout,
                                                   int alSampleType)
                                            throws IllegalArgumentException
        Parameters:
        sampleCount - number of samples per channel
        alChannelLayout - AL channel layout
        alSampleType - AL sample type
        Returns:
        bytes count required
        Throws:
        IllegalArgumentException - for unknown alChannelLayout or alSampleType values.
      • bytesToSampleCount

        public static final int bytesToSampleCount​(int byteCount,
                                                   int alChannelLayout,
                                                   int alSampleType)