Class ALHelpers
- java.lang.Object
-
- com.jogamp.openal.util.ALHelpers
-
public class ALHelpers extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringAL_EXT_debugstatic StringAL_EXT_DOUBLEstatic StringAL_EXT_FLOAT32static StringAL_EXT_MCFORMATSstatic StringAL_SOFT_buffer_samples[openal-soft >= 1.18.0](https://github.com/kcat/openal-soft/blob/master/ChangeLog) - Removed support for the AL_SOFT_buffer_samples and AL_SOFT_buffer_sub_data extensions.static StringAL_SOFT_eventsstatic StringALC_ENUMERATE_ALL_EXTstatic StringALC_ENUMERATION_EXTstatic StringALC_EXT_debugstatic StringALC_EXT_thread_local_contextstatic StringALC_SOFT_system_events
-
Constructor Summary
Constructors Constructor Description ALHelpers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringalChannelLayoutName(int alChannelLayout)Returns the readable name of the given AL channel layoutstatic StringalSampleTypeName(int alSampleType)Returns the readable name of the given AL sample typestatic StringalSourceStateString(int sourceState)Returns givenALConstants.AL_SOURCE_STATEAL.alGetSourcei(int, int, int[], int)} value as a string.static intbytesToSampleCount(int byteCount, int alChannelLayout, int alSampleType)static intgetALChannelLayoutChannelCount(int alChannelLayout)Returns the channel count of the given AL channel layoutstatic intgetALFormat(int alChannelLayout, int alSampleType, AL al, ALExt alExt)Returns a compatible AL buffer format given the AL channel layout and AL sample type.static intgetALFormat(int alChannelLayout, int alSampleType, AL al, ALExt alExt, boolean hasSOFTBufferSamples, boolean hasEXTMcFormats, boolean hasEXTFloat32, boolean hasEXTDouble)Returns a compatible AL buffer format given the AL channel layout and AL sample type.static intgetALFormat(AudioFormat audioFormat, AL al, ALExt alExt)Returns a compatible AL buffer format given theAudioFormat, which determines the AL channel layout and AL sample type.static intgetALFormat(AudioFormat audioFormat, AL al, ALExt alExt, boolean hasSOFTBufferSamples, boolean hasEXTMcFormats, boolean hasEXTFloat32, boolean hasEXTDouble)Returns a compatible AL buffer format given theAudioFormat, which determines the AL channel layout and AL sample type.static intgetALSampleType(int sampleSize, boolean signed, boolean fixedP)Returns the AL sample type matching the given audio type attributes, orALConstants.AL_NONE.static AudioFormatgetAudioFormat(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize)Returns a compatibleAudioFormatbased on given OpenAL channel-layout, sample-type and format, as well as the generic sample-rate and sample-size.static intgetDefaultALChannelLayout(int channelCount)Returns the default AL channel layout matching the given channel count, orALConstants.AL_NONE.static booleanisALSampleTypeFixed(int alSampleType)Returns true if the given AL sample type is a fixed point (byte, short, int, ..) or false if a floating point type (float, double).static booleanisALSampleTypeSigned(int alSampleType)Returns whether the given AL sample type is signedstatic intsamplesToByteCount(int sampleCount, int alChannelLayout, int alSampleType)static intsizeOfALSampleType(int alSampleType)Returns the byte size of the given AL sample type
-
-
-
Field Detail
-
AL_SOFT_buffer_samples
public static final String AL_SOFT_buffer_samples
[openal-soft >= 1.18.0](https://github.com/kcat/openal-soft/blob/master/ChangeLog) - Removed support for the AL_SOFT_buffer_samples and AL_SOFT_buffer_sub_data extensions. Due to conflicts with AL_EXT_SOURCE_RADIUS.- See Also:
- Constant Field Values
-
AL_SOFT_events
public static final String AL_SOFT_events
- See Also:
- Constant Field Values
-
AL_EXT_MCFORMATS
public static final String AL_EXT_MCFORMATS
- See Also:
- Constant Field Values
-
AL_EXT_FLOAT32
public static final String AL_EXT_FLOAT32
- See Also:
- Constant Field Values
-
AL_EXT_DOUBLE
public static final String AL_EXT_DOUBLE
- See Also:
- Constant Field Values
-
ALC_EXT_thread_local_context
public static final String ALC_EXT_thread_local_context
- See Also:
- Constant Field Values
-
ALC_ENUMERATION_EXT
public static final String ALC_ENUMERATION_EXT
- See Also:
- Constant Field Values
-
ALC_ENUMERATE_ALL_EXT
public static final String ALC_ENUMERATE_ALL_EXT
- See Also:
- Constant Field Values
-
ALC_EXT_debug
public static final String ALC_EXT_debug
- See Also:
- Constant Field Values
-
AL_EXT_debug
public static final String AL_EXT_debug
- See Also:
- Constant Field Values
-
ALC_SOFT_system_events
public static final String ALC_SOFT_system_events
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAudioFormat
public static AudioFormat getAudioFormat(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize)
Returns a compatibleAudioFormatbased on given OpenAL channel-layout, sample-type and format, as well as the generic sample-rate and sample-size.The resulting
AudioFormatusesAudioFormat.planar= false andAudioFormat.littleEndian= true.- Parameters:
alChannelLayout- OpenAL channel layoutalSampleType- OpenAL sample typealFormat- OpenAL formatsampleRate- sample rate, e.g. 44100sampleSize- sample size in bits, e.g. 16- Returns:
- a new
AudioFormatinstance or null if parameter are not conclusive or invalid.
-
getALFormat
public static int getALFormat(AudioFormat audioFormat, AL al, ALExt alExt)
Returns a compatible AL buffer format given theAudioFormat, which determines the AL channel layout and AL sample type.If
hasEXTMcFormatsorhasSOFTBufferSamplesis true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATSorAL_SOFT_buffer_samples.Returns
ALConstants.AL_NONEif no supported format can be found.Function uses
AL.alIsExtensionPresent(String), which might be context dependent, otherwise function is context independent.- Parameters:
audioFormat- used to derive AL channel layoutgetDefaultALChannelLayout(int)and AL sample typegetALSampleType(int, boolean, boolean)al- AL instancealExt- ALExt instance- Returns:
- AL buffer format
-
getALFormat
public static int getALFormat(AudioFormat audioFormat, AL al, ALExt alExt, boolean hasSOFTBufferSamples, boolean hasEXTMcFormats, boolean hasEXTFloat32, boolean hasEXTDouble)
Returns a compatible AL buffer format given theAudioFormat, which determines the AL channel layout and AL sample type.If
hasEXTMcFormatsorhasSOFTBufferSamplesis true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATSorAL_SOFT_buffer_samples.Returns
ALConstants.AL_NONEif no supported format can be found.Function is context independent.
- Parameters:
audioFormat- used to derive AL channel layoutgetDefaultALChannelLayout(int)and AL sample typegetALSampleType(int, boolean, boolean)al- AL instancealExt- ALExt instancehasSOFTBufferSamples- true if having extensionAL_SOFT_buffer_samples, otherwise falsehasEXTMcFormats- true if having extensionAL_EXT_MCFORMATS, otherwise falsehasEXTFloat32- true if having extensionAL_EXT_FLOAT32, otherwise falsehasEXTDouble- true if having extensionAL_EXT_DOUBLE, otherwise false- Returns:
- AL buffer format
-
getALFormat
public static final int getALFormat(int alChannelLayout, int alSampleType, AL al, ALExt alExt)Returns a compatible AL buffer format given the AL channel layout and AL sample type.If
hasEXTMcFormatsorhasSOFTBufferSamplesis true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATSorAL_SOFT_buffer_samples.Returns
ALConstants.AL_NONEif no supported format can be found.Function uses
AL.alIsExtensionPresent(String), which might be context dependent, otherwise function is context independent.- Parameters:
alChannelLayout- AL channel layout, seegetDefaultALChannelLayout(int)alSampleType- AL sample type, seegetALSampleType(int, boolean, boolean).al- AL instancealExt- ALExt instance- Returns:
- AL buffer format
-
getALFormat
public static final int getALFormat(int alChannelLayout, int alSampleType, AL al, ALExt alExt, boolean hasSOFTBufferSamples, boolean hasEXTMcFormats, boolean hasEXTFloat32, boolean hasEXTDouble)Returns a compatible AL buffer format given the AL channel layout and AL sample type.If
hasEXTMcFormatsorhasSOFTBufferSamplesis true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATSorAL_SOFT_buffer_samples.Returns
ALConstants.AL_NONEif no supported format can be found.Function is context independent.
- Parameters:
alChannelLayout- AL channel layout, seegetDefaultALChannelLayout(int)alSampleType- AL sample type, seegetALSampleType(int, boolean, boolean).al- AL instancealExt- ALExt instancehasSOFTBufferSamples- true if having extensionAL_SOFT_buffer_samples, otherwise falsehasEXTMcFormats- true if having extensionAL_EXT_MCFORMATS, otherwise falsehasEXTFloat32- true if having extensionAL_EXT_FLOAT32, otherwise falsehasEXTDouble- true if having extensionAL_EXT_DOUBLE, otherwise false- Returns:
- AL buffer format
-
getDefaultALChannelLayout
public static final int getDefaultALChannelLayout(int channelCount)
Returns the default AL channel layout matching the given channel count, orALConstants.AL_NONE.- Parameters:
channelCount- number of channelssigned- true if signed number, false for unsignedfixedP- 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
-
getALChannelLayoutChannelCount
public static final int getALChannelLayoutChannelCount(int alChannelLayout)
Returns the channel count 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, orALConstants.AL_NONE.- Parameters:
sampleSize- sample size in bitssigned- true if signed number, false for unsignedfixedP- 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
-
isALSampleTypeSigned
public static final boolean isALSampleTypeSigned(int alSampleType)
Returns whether the given AL sample type is signed
-
isALSampleTypeFixed
public static final boolean isALSampleTypeFixed(int alSampleType)
Returns true if the given AL sample type is a fixed point (byte, short, int, ..) or false if a floating point type (float, double).
-
sizeOfALSampleType
public static final int sizeOfALSampleType(int alSampleType) throws IllegalArgumentExceptionReturns the byte size of the given AL sample type- Throws:
IllegalArgumentException- for unknownalChannelLayoutoralSampleTypevalues.
-
samplesToByteCount
public static final int samplesToByteCount(int sampleCount, int alChannelLayout, int alSampleType) throws IllegalArgumentException- Parameters:
sampleCount- number of samples per channelalChannelLayout- AL channel layoutalSampleType- AL sample type- Returns:
- bytes count required
- Throws:
IllegalArgumentException- for unknownalChannelLayoutoralSampleTypevalues.
-
bytesToSampleCount
public static final int bytesToSampleCount(int byteCount, int alChannelLayout, int alSampleType)
-
alSourceStateString
public static final String alSourceStateString(int sourceState)
Returns givenALConstants.AL_SOURCE_STATEAL.alGetSourcei(int, int, int[], int)} value as a string.
-
-