Class OALContext
java.lang.Object
com.blackrook.gloop.openal.OALHandle
com.blackrook.gloop.openal.OALContext
A context handle in OpenAL.
Represents the rendering context.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA single pair of attribute-value.static enumEnumeration of Context creation attributes.static enumDistance Model enumeration for internal OpenAL distance models for attenuating the final gain of a Source in relation to the position/direction of the listener. -
Method Summary
Modifier and TypeMethodDescriptionprotected longallocate()Creates a new Autowah effect.Creates a new Band Pass filter.Allocates a new buffer for loading data into.createBuffer(JSPISoundHandle handle) Allocates a new buffer with data loaded into it.createBuffer(JSPISoundHandle.Decoder dataDecoder) Allocates a new buffer with data loaded into it.createBuffers(int amount) Allocates a new buffer for loading data into.Creates a new Chorus effect.Creates a new Compressor effect.Creates a new Distortion effect.Creates a new Echo effect.Creates a new Auxiliary Effect Slot for adding a filter and effects to Sources.Creates a new Equalizer effect.Creates a new Flanger effect.Creates a new Frequency Shift effect.Creates a new High Pass filter.Creates a new Low Pass filter.Creates a new Pitch Shift effect.Creates a new Reverb effect.Creates a new Ring Modulator effect.Allocates a new source and assigns it internally to the current context.createSource(boolean autoVelocity) Allocates a new source and assigns it internally to the current context.Creates a new Vocal Morpher effect.voiddestroy()Destroys this handle.booleanextensionIsPresent(String extensionName) Checks if an extension is present for this context.getAttributeValue(OALContext.ContextAttribute attribute) Returns the corresponding value of a context attribute used to create this context.floatvoidgetError()Convenience method for checking for an OpenAL error and throwing a SoundException if an error is raised.longintfloatbooleanvoidprocess()Resumes processing of this context.voidsetCurrentDistanceModel(OALContext.DistanceModel currentDistanceModel) voidSets the current context's distance model.voidsetDopplerFactor(float f) Sets the sound environment's Doppler Factor.voidsetSpeedOfSound(float s) Sets the sound environment's speed of sound factor.voidsuspend()Suspends processing of this context.
-
Method Details
-
getHandle
-
isCreated
-
allocate
protected long allocate() -
destroy
-
getAttributeValue
Returns the corresponding value of a context attribute used to create this context.- Parameters:
attribute- the attribute.- Returns:
- the value used, or null if the default was used.
-
getVendorName
- Returns:
- the vendor name for this OpenAL implementation.
-
getVersionName
- Returns:
- the version name for this OpenAL implementation.
-
getRendererName
- Returns:
- the renderer name for this OpenAL implementation.
-
getExtensions
-
extensionIsPresent
Checks if an extension is present for this context. Case-insensitive.- Parameters:
extensionName- the name of the extension.- Returns:
- true if so, false if not.
-
getMaxEffectSlots
public int getMaxEffectSlots()- Returns:
- the max effect slots allowed per source.
-
setCurrentDistanceModel
-
getCurrentDistanceModel
- Returns:
- this device's current distance model.
-
getListener
- Returns:
- this context's listener.
-
getCapabilities
- Returns:
- the capabilities that this context was created with.
-
getError
public void getError()Convenience method for checking for an OpenAL error and throwing a SoundException if an error is raised. -
suspend
public void suspend()Suspends processing of this context. -
process
public void process()Resumes processing of this context. -
createSource
Allocates a new source and assigns it internally to the current context.- Returns:
- the newly allocated source.
- Throws:
SoundException- if the source can't be created.
-
createSource
Allocates a new source and assigns it internally to the current context.- Parameters:
autoVelocity- if true, set auto velocity to on for this Source.- Returns:
- the newly allocated source.
- Throws:
SoundException- if the source can't be created.
-
createBuffer
Allocates a new buffer for loading data into. Buffers are independent of device context.- Returns:
- a newly allocated buffer.
- Throws:
SoundException- if the Buffer can't be allocated somehow.
-
createBuffers
Allocates a new buffer for loading data into. Buffers are independent of device context.- Parameters:
amount- the amount of buffers to create.- Returns:
- a set of newly allocated buffers.
- Throws:
SoundException- if the Buffer can't be allocated somehow.
-
createBuffer
Allocates a new buffer with data loaded into it. All of the sound data readable by the SoundData instance is read into the buffer. If you know that the data being loaded is very long or large, you should consider using a Streaming Source to conserve memory. Buffers are independant of device context.- Parameters:
handle- the handle to the sound data to load into this buffer.- Returns:
- a newly allocated buffer.
- Throws:
IOException- if the data can't be read.SoundException- if the Buffer can't be allocated somehow.
-
createBuffer
Allocates a new buffer with data loaded into it. All of the sound data readable by the SoundDataDecoder instance is read into the buffer. If you know that the data being loaded is very long or large, you should consider using a Streaming Source to conserve memory. Buffers are independent of device context.- Parameters:
dataDecoder- the decoder of the sound data to load into this buffer.- Returns:
- a newly allocated buffer.
- Throws:
IOException- if the data can't be read.SoundException- if the Buffer can't be allocated somehow.
-
createEffectSlot
Creates a new Auxiliary Effect Slot for adding a filter and effects to Sources. These slots can be added to sources. If you have more than one source that uses the same sets of filters and effects, it might be better to bind one slot to more than one source to save memory, especially if you need to alter an effect of filter for more than one sound that is playing.- Returns:
- a new AuxEffectSlot object.
- Throws:
SoundException- if the slot can't be allocated somehow.
-
createAutowahEffect
Creates a new Autowah effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createChorusEffect
Creates a new Chorus effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createCompressorEffect
Creates a new Compressor effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createDistortionEffect
Creates a new Distortion effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createEchoEffect
Creates a new Echo effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createEqualizerEffect
Creates a new Equalizer effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createFlangerEffect
Creates a new Flanger effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createFrequencyShiftEffect
Creates a new Frequency Shift effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createPitchShiftEffect
Creates a new Pitch Shift effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createReverbEffect
Creates a new Reverb effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createRingModulatorEffect
Creates a new Ring Modulator effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createVocalMorpherEffect
Creates a new Vocal Morpher effect.- Returns:
- a new effect of this type with default values set.
- Throws:
SoundException- if the effect can't be created.
-
createHighPassFilter
Creates a new High Pass filter.- Returns:
- a new filter of this type with default values set.
- Throws:
SoundException- if the filter can't be created.
-
createLowPassFilter
Creates a new Low Pass filter.- Returns:
- a new filter of this type with default values set.
- Throws:
SoundException- if the filter can't be created.
-
createBandPassFilter
Creates a new Band Pass filter.- Returns:
- a new filter of this type with default values set.
- Throws:
SoundException- if the filter can't be created.
-
setDopplerFactor
public void setDopplerFactor(float f) Sets the sound environment's Doppler Factor. 0 = disabled.- Parameters:
f- the Doppler factor.
-
getDopplerFactor
public float getDopplerFactor()- Returns:
- the sound environment's Doppler Factor.
-
setSpeedOfSound
public void setSpeedOfSound(float s) Sets the sound environment's speed of sound factor.- Parameters:
s- the speed of sound.
-
getSpeedOfSound
public float getSpeedOfSound()- Returns:
- the sound environment's speed of sound factor.
-
setDistanceModel
Sets the current context's distance model. By default, this is DistanceModel.INVERSE_DISTANCE_CLAMPED.- Parameters:
model- the distance model to use.
-
getDistanceModel
- Returns:
- the current context's distance model.
-