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 SummaryNested classes/interfaces inherited from class com.jme3.audio.AudioDataAudioData.DataType
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected floatprotected booleanprotected int[]protected InputStreamprotected booleanprotected intFields inherited from class com.jme3.audio.AudioDatabitsPerSample, channels, sampleRateFields inherited from class com.jme3.util.NativeObjecthandleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AudioDatagetBitsPerSample, getChannels, getSampleRate, setupFormatMethods inherited from class com.jme3.util.NativeObjectclearUpdateNeeded, clone, deleteNativeBuffers, dispose, getWeakRef, isUpdateNeeded, setUpdateNeeded, toString
- 
Field Details- 
in
- 
durationprotected float duration
- 
openprotected boolean open
- 
eofprotected boolean eof
- 
idsprotected int[] ids
- 
unqueuedBuffersBytesprotected int unqueuedBuffersBytes
 
- 
- 
Constructor Details- 
AudioStreampublic AudioStream()
- 
AudioStreamprotected AudioStream(int[] ids) 
 
- 
- 
Method Details- 
updateData
- 
readSamplespublic 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 samples
- offset- The offset in the buffer where to read samples
- length- The length inside the buffer where to read samples
- Returns:
- number of bytes read.
 
- 
readSamplespublic int readSamples(byte[] buf) Reads samples from the stream.- Parameters:
- buf- Buffer where to read the samples
- Returns:
- number of bytes read.
- See Also:
 
- 
getDurationpublic float getDuration()- Specified by:
- getDurationin class- AudioData
- Returns:
- the duration in seconds of the audio clip.
 
- 
getIdpublic int getId()- Overrides:
- getIdin class- NativeObject
- Returns:
- The ID of the object. Should not be used by user code in most cases.
 
- 
setIdpublic 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 class- NativeObject
- Parameters:
- id- The ID to set
 
- 
initIdspublic void initIds(int count) 
- 
getIdpublic int getId(int index) 
- 
setIdpublic void setId(int index, int id) 
- 
getIdspublic int[] getIds()
- 
setIdspublic void setIds(int[] ids) 
- 
getDataType- Specified by:
- getDataTypein class- AudioData
- Returns:
- The data type, either BufferorStream.
 
- 
resetObjectpublic 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 class- NativeObject
 
- 
deleteObjectDescription 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 class- NativeObject
- Parameters:
- rendererObject- The renderer to be used to delete the object
 
- 
createDestructableCloneDescription copied from class:NativeObjectCreates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
- createDestructableClonein class- NativeObject
- Returns:
- a new instance
 
- 
isEOFpublic boolean isEOF()
- 
closepublic void close()Closes the stream, releasing all data relating to it. Reading from the stream will return eof.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
isSeekablepublic boolean isSeekable()
- 
getUnqueuedBufferBytespublic int getUnqueuedBufferBytes()
- 
setUnqueuedBufferBytespublic void setUnqueuedBufferBytes(int unqueuedBuffers) 
- 
setTimepublic void setTime(float time) 
- 
getUniqueIdpublic long getUniqueId()Description copied from class:NativeObjectReturns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
- getUniqueIdin class- NativeObject
- Returns:
- unique ID for this NativeObject.
 
 
-