Package com.jme3.audio
Class AudioStream
java.lang.Object
com.jme3.util.NativeObject
com.jme3.audio.AudioData
com.jme3.audio.AudioStream
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable
AudioStream is an implementation of AudioData that acquires the
audio from an InputStream. Audio can be streamed from network, hard drive
etc. It is assumed the data coming from the input stream is uncompressed.-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.audio.AudioData
AudioData.DataType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatprotected booleanprotected int[]protected InputStreamprotected booleanprotected intFields inherited from class com.jme3.audio.AudioData
bitsPerSample, channels, sampleRateFields inherited from class com.jme3.util.NativeObject
handleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the stream, releasing all data relating to it.Creates a shallow clone of this GL Object.voiddeleteObject(Object rendererObject) Deletes the GL object from the GPU when it is no longer used.floatintgetId()intgetId(int index) int[]getIds()longReturns a unique ID for this NativeObject.intvoidinitIds(int count) booleanisEOF()booleanintreadSamples(byte[] buf) Reads samples from the stream.intreadSamples(byte[] buf, int offset, int length) Reads samples from the stream.voidCalled when the GL context is restarted to reset all IDs.voidsetId(int id) Sets the ID of the NativeObject.voidsetId(int index, int id) voidsetIds(int[] ids) voidsetTime(float time) voidsetUnqueuedBufferBytes(int unqueuedBuffers) voidupdateData(InputStream in, float duration) Methods inherited from class com.jme3.audio.AudioData
getBitsPerSample, getChannels, getSampleRate, setupFormatMethods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, clone, deleteNativeBuffers, dispose, getWeakRef, isUpdateNeeded, setUpdateNeeded, toString
-
Field Details
-
in
-
duration
protected float duration -
open
protected boolean open -
eof
protected boolean eof -
ids
protected int[] ids -
unqueuedBuffersBytes
protected int unqueuedBuffersBytes
-
-
Constructor Details
-
AudioStream
public AudioStream() -
AudioStream
protected AudioStream(int[] ids)
-
-
Method Details
-
updateData
-
readSamples
public int readSamples(byte[] buf, int offset, int length) Reads samples from the stream. The format of the data depends on the getSampleRate(), getChannels(), getBitsPerSample() values.- Parameters:
buf- Buffer where to read the samplesoffset- The offset in the buffer where to read sampleslength- The length inside the buffer where to read samples- Returns:
- number of bytes read.
-
readSamples
public int readSamples(byte[] buf) Reads samples from the stream.- Parameters:
buf- Buffer where to read the samples- Returns:
- number of bytes read.
- See Also:
-
getDuration
public float getDuration()- Specified by:
getDurationin classAudioData- Returns:
- the duration in seconds of the audio clip.
-
getId
public int getId()- Overrides:
getIdin classNativeObject- Returns:
- The ID of the object. Should not be used by user code in most cases.
-
setId
public void setId(int id) Description copied from class:NativeObjectSets the ID of the NativeObject. This method is used in Renderer and must not be called by the user.- Overrides:
setIdin classNativeObject- Parameters:
id- The ID to set
-
initIds
public void initIds(int count) -
getId
public int getId(int index) -
setId
public void setId(int index, int id) -
getIds
public int[] getIds() -
setIds
public void setIds(int[] ids) -
getDataType
- Specified by:
getDataTypein classAudioData- Returns:
- The data type, either
BufferorStream.
-
resetObject
public void resetObject()Description copied from class:NativeObjectCalled when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.- Specified by:
resetObjectin classNativeObject
-
deleteObject
Description copied from class:NativeObjectDeletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObjectin classNativeObject- Parameters:
rendererObject- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObjectCreates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClonein classNativeObject- Returns:
- a new instance
-
isEOF
public boolean isEOF() -
close
public void close()Closes the stream, releasing all data relating to it. Reading from the stream will return eof.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isSeekable
public boolean isSeekable() -
getUnqueuedBufferBytes
public int getUnqueuedBufferBytes() -
setUnqueuedBufferBytes
public void setUnqueuedBufferBytes(int unqueuedBuffers) -
setTime
public void setTime(float time) -
getUniqueId
public long getUniqueId()Description copied from class:NativeObjectReturns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueIdin classNativeObject- Returns:
- unique ID for this NativeObject.
-