Class ALHelpers
- java.lang.Object
-
- com.jogamp.openal.util.ALHelpers
-
public class ALHelpers extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
AL_EXT_DOUBLE
static String
AL_EXT_FLOAT32
static String
AL_EXT_MCFORMATS
static 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.static String
AL_SOFT_events
static String
ALC_EXT_thread_local_context
-
Constructor Summary
Constructors Constructor Description ALHelpers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
alChannelLayoutName(int alChannelLayout)
Returns the readable name of the given AL channel layoutstatic String
alSampleTypeName(int alSampleType)
Returns the readable name of the given AL sample typestatic int
bytesToSampleCount(int byteCount, int alChannelLayout, int alSampleType)
static int
getALChannelLayoutChannelCount(int alChannelLayout)
Returns the channel count of the given AL channel layoutstatic 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.static 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.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.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.static int
getALSampleType(int sampleSize, boolean signed, boolean fixedP)
Returns the AL sample type matching the given audio type attributes, orALConstants.AL_NONE
.static AudioFormat
getAudioFormat(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize)
Returns a compatibleAudioFormat
based on given OpenAL channel-layout, sample-type and format, as well as the generic sample-rate and sample-size.static int
getDefaultALChannelLayout(int channelCount)
Returns the default AL channel layout matching the given channel count, orALConstants.AL_NONE
.static 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).static boolean
isALSampleTypeSigned(int alSampleType)
Returns whether the given AL sample type is signedstatic int
samplesToByteCount(int sampleCount, int alChannelLayout, int alSampleType)
static int
sizeOfALSampleType(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
-
-
Method Detail
-
getAudioFormat
public static AudioFormat getAudioFormat(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize)
Returns a compatibleAudioFormat
based on given OpenAL channel-layout, sample-type and format, as well as the generic sample-rate and sample-size.The resulting
AudioFormat
usesAudioFormat.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
AudioFormat
instance 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
hasEXTMcFormats
orhasSOFTBufferSamples
is true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATS
orAL_SOFT_buffer_samples
.Returns
ALConstants.AL_NONE
if 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
hasEXTMcFormats
orhasSOFTBufferSamples
is true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATS
orAL_SOFT_buffer_samples
.Returns
ALConstants.AL_NONE
if 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
hasEXTMcFormats
orhasSOFTBufferSamples
is true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATS
orAL_SOFT_buffer_samples
.Returns
ALConstants.AL_NONE
if 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
hasEXTMcFormats
orhasSOFTBufferSamples
is true, it will be called to find the closest-matching format fromAL_EXT_MCFORMATS
orAL_SOFT_buffer_samples
.Returns
ALConstants.AL_NONE
if 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 IllegalArgumentException
Returns the byte size of the given AL sample type- Throws:
IllegalArgumentException
- for unknownalChannelLayout
oralSampleType
values.
-
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 unknownalChannelLayout
oralSampleType
values.
-
bytesToSampleCount
public static final int bytesToSampleCount(int byteCount, int alChannelLayout, int alSampleType)
-
-