Class OALSource
java.lang.Object
com.blackrook.gloop.openal.OALObject
com.blackrook.gloop.openal.OALSource
Encapsulating class for OpenAL sources.
- Author:
- Matthew Tropiano
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final boolean -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSourceListener(OALSourceListener listener) Adds a source listener to this Source.protected final intallocate()Allocates a new type of this object in OpenAL.Returns the buffer dequeued, or null if no Buffer is queued.voidEnqueues a buffer on this Source.voidenqueueBuffers(OALBuffer... buffers) Enqueues a bunch of buffers onto this source in the order specified.protected final voidfree()Destroys this sound source (BUT NOT ATTACHED BUFFER(s)).floatgetGain()floatfloatfloatfloatfloatfloatfloatgetPitch()Gets the pitch factor for this Source.intGets many buffers were processed on this source.intGets how many buffers are queued up for this source.floatfloatprotected final intgetState()Get this source's state.booleanChecks if "auto velocity" is on.booleanIs this Source bound to a Buffer object?booleanChecks if this source loops the playing buffer.booleanisPaused()Is this source paused?booleanIs this source playing?booleanisReady()Is this source ready to play?booleanChecks if this source is relative to the listener.booleanIs this source stopped?voidpause()Pauses this source.voidplay()Plays this source.voidPlays this source and makes the calling thread wait until it ends.voidRemoves all source listeners from the Source.voidremoveSourceListener(OALSourceListener listener) Removes a source listener from this Source.voidreset()Sets this Source's settings to defaults, and releases all buffers bound to it.voidrewind()Rewinds this source.voidsetAutoVelocity(boolean autovel) Enables/Disables automatic velocity calculation.voidEnqueues a single buffer on this Source, making sure that it is the only Buffer enqueued by it.voidsetDirection(float[] f) Sets the Source's direction attributes using an array of values.voidsetDirection(float x, float y, float z) Sets the Source's direction attributes.voidsetEffectSlot(int slot, OALEffectSlot eSlot) Sets an auxiliary effect in a particular slot (nullifies the filter slot).voidsetEffectSlot(int slot, OALEffectSlot effectSlot, OALFilter wetFilter) Sets an auxiliary effect and filter in a particular slot.voidsetEffectSlotFilter(int slot, OALFilter filt) Sets a filter in a particular aux slot (nullifies the effect slot).voidSets the "dry" filter to use for the dry signal for the effects later.voidsetGain(float f) Sets the gain for this Source.voidsetInnerConeAngle(float f) Sets the angle of this Source's inner cone.voidsetLooping(boolean loop) Sets the looping attribute for this Source.voidsetMaxDistance(float f) Sets the maximum distance that Source attenuation can occur.voidsetMaxGain(float f) Sets the maximum gain for this Source.voidsetMinGain(float f) Sets the minimum gain for this Source.voidsetOuterConeAngle(float f) Sets the angle of this Source's outer cone.voidsetOuterConeGain(float f) Sets the gain of this Source when the Listener lies outside of this Source's cone.voidsetPitch(float f) Sets the pitch for this Source.voidsetPitchUsingCents(int cents) Sets the pitch by cents.voidsetPitchUsingSemitones(int semitones) Sets the pitch by semitones.voidsetPosition(float[] f) Sets the Source's position attributes using an array of values.voidsetPosition(float x, float y, float z) Sets the Listener's position attributes.voidsetReferenceDistance(float f) Sets the minimum (reference) distance that Source attenuation can occur.voidsetRelative(boolean rel) Sets the "relative to listener" attribute for this Source.voidsetRolloff(float f) Sets the rolloff factor for this Source.voidsetVelocity(float[] f) Sets the Source's velocity attributes using an array of values.voidsetVelocity(float x, float y, float z) Sets the Source's velocity attributes.voidstop()Stops playing this source.toString()voidMakes the calling thread wait for this source to stop playing.Methods inherited from class OALObject
clearError, destroy, equals, equals, errorCheck, getName, hashCode, requestContext
-
Field Details
-
AUTO_VELOCITY
public static final boolean AUTO_VELOCITY- See Also:
-
NO_AUTO_VELOCITY
public static final boolean NO_AUTO_VELOCITY- See Also:
-
-
Method Details
-
allocate
-
free
-
reset
public void reset()Sets this Source's settings to defaults, and releases all buffers bound to it. -
setEffectSlot
Sets an auxiliary effect in a particular slot (nullifies the filter slot).- Parameters:
slot- the slot to add this to.eSlot- the effect slot to add (can be null).- Throws:
ArrayIndexOutOfBoundsException- if slot is less than 0 or greater than the amount of effect slots.
-
setEffectSlotFilter
Sets a filter in a particular aux slot (nullifies the effect slot).- Parameters:
slot- the slot to add this to.filt- the filter to use on the output of this effect (can be null).- Throws:
ArrayIndexOutOfBoundsException- if slot is less than 0 or greater than the amount of effect slots.
-
setEffectSlot
Sets an auxiliary effect and filter in a particular slot.- Parameters:
slot- the slot to add this to.effectSlot- the effect slot to add (can be null).wetFilter- the filter to use on the output of this effect (can be null).- Throws:
ArrayIndexOutOfBoundsException- if slot is less than 0 or greater than the amount of effect slots.
-
setFilter
Sets the "dry" filter to use for the dry signal for the effects later.- Parameters:
dryFilter- the filter to use (can be null).
-
setPosition
public void setPosition(float x, float y, float z) Sets the Listener's position attributes.- Parameters:
x- the x-axis value.y- the y-axis value.z- the z-axis value.
-
setPosition
public void setPosition(float[] f) Sets the Source's position attributes using an array of values. Values are copied.- Parameters:
f- the float array.
-
setVelocity
public void setVelocity(float x, float y, float z) Sets the Source's velocity attributes.- Parameters:
x- the x-axis value.y- the y-axis value.z- the z-axis value.
-
setVelocity
public void setVelocity(float[] f) Sets the Source's velocity attributes using an array of values. Values are copied.- Parameters:
f- the float array.
-
setDirection
public void setDirection(float x, float y, float z) Sets the Source's direction attributes.- Parameters:
x- the x-axis value.y- the y-axis value.z- the z-axis value.
-
setDirection
public void setDirection(float[] f) Sets the Source's direction attributes using an array of values. Values are copied.- Parameters:
f- the float array.
-
setGain
public void setGain(float f) Sets the gain for this Source.- Parameters:
f- the new gain.
-
setMinGain
public void setMinGain(float f) Sets the minimum gain for this Source. Used in gain attenuation by distance.- Parameters:
f- the new gain.
-
setMaxGain
public void setMaxGain(float f) Sets the maximum gain for this Source. Used in gain attenuation by distance.- Parameters:
f- the new gain.
-
setPitch
public void setPitch(float f) Sets the pitch for this Source.- Parameters:
f- the new pitch.
-
setPitchUsingSemitones
public void setPitchUsingSemitones(int semitones) Sets the pitch by semitones. Setting this to 0 is equivalent to setting the pitch to 1. Every 12 semitones is one octave.- Parameters:
semitones- the amount of semitones of adjustment.
-
setPitchUsingCents
public void setPitchUsingCents(int cents) Sets the pitch by cents. Setting this to 0 is equivalent to setting the pitch to 1. Every 1200 cents is one octave.- Parameters:
cents- the amount of cents of adjustment.
-
setRolloff
public void setRolloff(float f) Sets the rolloff factor for this Source.- Parameters:
f- the new rolloff factor.
-
setOuterConeGain
public void setOuterConeGain(float f) Sets the gain of this Source when the Listener lies outside of this Source's cone.- Parameters:
f- the gain value.
-
setOuterConeAngle
public void setOuterConeAngle(float f) Sets the angle of this Source's outer cone. Sounds heard by the listener outside of this Source's conic projection are attenuated.- Parameters:
f- the angle in degrees.
-
setInnerConeAngle
public void setInnerConeAngle(float f) Sets the angle of this Source's inner cone. Sounds heard by the listener inside of this Source's conic projection are not attenuated.- Parameters:
f- the angle in degrees.
-
setMaxDistance
public void setMaxDistance(float f) Sets the maximum distance that Source attenuation can occur. The algorithm in determining this Source's final gain is dependent upon the current distance model.- Parameters:
f- the maximum distance in units.
-
setReferenceDistance
public void setReferenceDistance(float f) Sets the minimum (reference) distance that Source attenuation can occur. The algorithm in determining this Source's final gain is dependent upon the current distance model.- Parameters:
f- the reference distance in units.
-
setLooping
public void setLooping(boolean loop) Sets the looping attribute for this Source. Looping Sources loop the current queued buffer.- Parameters:
loop- true to set, false to clear.
-
setRelative
public void setRelative(boolean rel) Sets the "relative to listener" attribute for this Source.- Parameters:
rel- true to set, false to clear.
-
isAutoVelocityOn
public boolean isAutoVelocityOn()Checks if "auto velocity" is on.- Returns:
- true of so, false if not.
-
getGain
public float getGain()- Returns:
- the gain scalar for this Source.
-
isLooping
public boolean isLooping()Checks if this source loops the playing buffer.- Returns:
- true of so, false if not.
-
getPitch
public float getPitch()Gets the pitch factor for this Source.- Returns:
- the pitch scalar.
-
isRelative
public boolean isRelative()Checks if this source is relative to the listener.- Returns:
- true if so, false if not.
-
getRolloff
public float getRolloff()- Returns:
- the rolloff factor
-
getMinGain
public float getMinGain() -
getMaxGain
public float getMaxGain() -
getReferenceDistance
public float getReferenceDistance() -
getMaxDistance
public float getMaxDistance() -
getInnerCone
public float getInnerCone() -
getOuterCone
public float getOuterCone() -
getOuterConeGain
public float getOuterConeGain() -
getFilter
-
peekBuffer
- Returns:
- the foremost buffer in the buffer queue.
-
setBuffer
Enqueues a single buffer on this Source, making sure that it is the only Buffer enqueued by it. Ifnullis provided, this clears the buffer assignment. This does NOT check if the Source is currently playing before dequeuing the bound buffers.- Parameters:
b- the Buffer to bind to this Source.
-
dequeueBuffer
Returns the buffer dequeued, or null if no Buffer is queued. Thread safe. This does NOT check if the Source is currently playing.- Returns:
- the buffer dequeued.
-
enqueueBuffers
Enqueues a bunch of buffers onto this source in the order specified.- Parameters:
buffers- the buffers to enqueue.
-
enqueueBuffer
Enqueues a buffer on this Source.- Parameters:
b- the buffer to enqueue.
-
getQueuedBufferCount
public int getQueuedBufferCount()Gets how many buffers are queued up for this source.- Returns:
- the amount of buffers queued.
-
getProcessedBufferCount
public int getProcessedBufferCount()Gets many buffers were processed on this source. This is the amount of buffers that need to be dequeued, filled, and requeued.- Returns:
- the amount of buffers processed.
-
addSourceListener
Adds a source listener to this Source.- Parameters:
listener- the SourceListener to add.
-
removeSourceListener
Removes a source listener from this Source.- Parameters:
listener- the SourceListener to remove.
-
removeAllListeners
public void removeAllListeners()Removes all source listeners from the Source. -
waitForEnd
public void waitForEnd()Makes the calling thread wait for this source to stop playing. Pausing this does not make the thread continue.- See Also:
-
play
public void play()Plays this source. This does nothing if this is not bound to a buffer. -
playAndWait
public void playAndWait()Plays this source and makes the calling thread wait until it ends. Pausing this does not make the thread continue.- See Also:
-
pause
public void pause()Pauses this source. -
stop
public void stop()Stops playing this source. -
rewind
public void rewind()Rewinds this source. -
isPlaying
public boolean isPlaying()Is this source playing?- Returns:
- true if so, false if not.
-
isReady
public boolean isReady()Is this source ready to play?- Returns:
- true if so, false if not.
-
isStopped
public boolean isStopped()Is this source stopped?- Returns:
- true if so, false if not.
-
isPaused
public boolean isPaused()Is this source paused?- Returns:
- true if so, false if not.
-
isBoundToABuffer
public boolean isBoundToABuffer()Is this Source bound to a Buffer object?- Returns:
- true if so, false if not.
-
getState
protected final int getState()Get this source's state. Returns an AL constant.- Returns:
- one of AL_INITIAL, AL_PLAYING, AL_STOPPED, or AL_PAUSED.
-
setAutoVelocity
public void setAutoVelocity(boolean autovel) Enables/Disables automatic velocity calculation.- Parameters:
autovel- should velocity automatically be calculated?
-
toString
-