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
Modifier and TypeFieldDescriptionprotected float
protected boolean
protected int[]
protected InputStream
protected boolean
protected int
Fields inherited from class com.jme3.audio.AudioData
bitsPerSample, channels, sampleRate
Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the stream, releasing all data relating to it.Creates a shallow clone of this GL Object.void
deleteObject
(Object rendererObject) Deletes the GL object from the GPU when it is no longer used.float
int
getId()
int
getId
(int index) int[]
getIds()
long
Returns a unique ID for this NativeObject.int
void
initIds
(int count) boolean
isEOF()
boolean
int
readSamples
(byte[] buf) Reads samples from the stream.int
readSamples
(byte[] buf, int offset, int length) Reads samples from the stream.void
Called when the GL context is restarted to reset all IDs.void
setId
(int id) Sets the ID of the NativeObject.void
setId
(int index, int id) void
setIds
(int[] ids) void
setTime
(float time) void
setUnqueuedBufferBytes
(int unqueuedBuffers) void
updateData
(InputStream in, float duration) Methods inherited from class com.jme3.audio.AudioData
getBitsPerSample, getChannels, getSampleRate, setupFormat
Methods 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:
getDuration
in classAudioData
- Returns:
- the duration in seconds of the audio clip.
-
getId
public int getId()- Overrides:
getId
in 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:NativeObject
Sets the ID of the NativeObject. This method is used in Renderer and must not be called by the user.- Overrides:
setId
in 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:
getDataType
in classAudioData
- Returns:
- The data type, either
Buffer
orStream
.
-
resetObject
public void resetObject()Description copied from class:NativeObject
Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.- Specified by:
resetObject
in classNativeObject
-
deleteObject
Description copied from class:NativeObject
Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObject
in classNativeObject
- Parameters:
rendererObject
- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObject
Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClone
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:NativeObject
Returns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueId
in classNativeObject
- Returns:
- unique ID for this NativeObject.
-