Package toxi.audio
Class AudioSource
java.lang.Object
toxi.geom.Vec3D
toxi.audio.AudioSource
- All Implemented Interfaces:
Comparable<ReadonlyVec3D>
,ReadonlyVec3D
A wrapper for
AudioBuffer
s and similar to the built in JOAL
net.java.games.sound3d.Source, though less restrictive. The class extends
Vec3D
and so can be used to position the sound in 3D space (provided
the underlying audio hardware does support 3D audio). Unfortunately due to
OpenAL's limitations only mono samples can be positioned in that way. Stereo
samples will can only manipulated in terms of gain/volume.
If the position of an AudioSource is changed via the public x,y,z vector
components, the updatePosition()
method needs to be called
afterwards in order to reflect the changes in the OpenAL context.
-
Nested Class Summary
Nested classes/interfaces inherited from class toxi.geom.Vec3D
Vec3D.Axis
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAudioSource
(net.java.games.joal.AL al, int id) AudioSource
(net.java.games.joal.AL al, int id, AudioBuffer buf) -
Method Summary
Modifier and TypeMethodDescriptionboolean
delete()
Deletes this source, and free its resources.Gets the buffer associated with this source.int
Gets the number of buffers already processed on this source.final float[]
final int
getID()
final int
final float[]
final float[]
final boolean
final int
length()
play()
rewind()
setBuffer
(AudioBuffer buffer) Sets the buffer associated with this source.setDirection
(float[] d) setDirection
(float xx, float yy, float zz) setDirection
(Vec3D dir) setGain
(float gain) setLooping
(boolean state) setOffset
(int off) setPitch
(float pitch) setPosition
(float[] p) setPosition
(float xx, float yy, float zz) setPosition
(Vec3D p) setReferenceDistance
(float d) setVelocity
(float[] v) setVelocity
(float xx, float yy, float zz) setVelocity
(Vec3D p) stop()
toString()
Methods inherited from class toxi.geom.Vec3D
abs, add, add, add, addSelf, addSelf, addSelf, angleBetween, angleBetween, clear, compareTo, constrain, constrain, copy, cross, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, dot, equals, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getCartesian, getClosestAxis, getComponent, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getMapped, getNormalized, getNormalizedTo, getReciprocal, getReflected, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getRoundedTo, getSignum, getSpherical, hashCode, headingXY, headingXZ, headingYZ, immutable, interpolateTo, interpolateTo, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isMajorAxis, isZeroVector, jitter, jitter, jitter, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, reflect, rotateAroundAxis, rotateX, rotateY, rotateZ, roundTo, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, setX, setXY, setY, setZ, shuffle, signum, snapToAxis, sub, sub, sub, subSelf, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, to4D, to4D, toArray, toArray4, toCartesian, toSpherical, x, y, z
-
Constructor Details
-
AudioSource
public AudioSource(net.java.games.joal.AL al, int id) -
AudioSource
-
-
Method Details
-
delete
public boolean delete()Deletes this source, and free its resources. Note, this method does NOT release the associated audio buffer. If you want to remove a source including its wave data useJOALUtil.deleteSource(AudioSource, boolean)
instead.- Returns:
- true, if source was removed successfully
-
getBuffer
Gets the buffer associated with this source.- Returns:
- the buffer associated with this source
-
getBuffersProcessed
public int getBuffersProcessed()Gets the number of buffers already processed on this source.- Returns:
- the number of buffers already processed on this source.
-
getDirection
public final float[] getDirection() -
getID
public final int getID() -
getOffset
public final int getOffset() -
getPosition
public final float[] getPosition() -
getVelocity
public final float[] getVelocity() -
isLooping
public final boolean isLooping() -
length
public final int length() -
play
-
rewind
-
setBuffer
Sets the buffer associated with this source.- Parameters:
buffer
- the buffer associated with this source
-
setDirection
-
setDirection
-
setDirection
-
setGain
-
setLooping
-
setOffset
-
setPitch
-
setPosition
-
setPosition
-
setPosition
-
setReferenceDistance
-
setVelocity
-
setVelocity
-
setVelocity
-
stop
-
toString
-
updatePosition
-