gameframe.engines.jdk11x
Class CSoundStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.ByteArrayInputStream
|
+--gameframe.engines.jdk11x.CSoundStream
- public class CSoundStream
- extends java.io.ByteArrayInputStream
Implementation of a sound stream that uses an array as the source
for the streamed sound (sample) data.
- Since:
- GameFrame for Java 0.9
- Version:
- GameFrame for Java 0.9.4
Field Summary |
private byte[] |
m_aBuffer
The sound stream buffer. |
private int |
m_siftAmount
The calculated amount to sift to right (to achieve the volume). |
private float |
m_volume
The volume. |
Fields inherited from class java.io.ByteArrayInputStream |
buf, count, isClosed, mark, pos |
Fields inherited from class java.io.InputStream |
SKIP_BUFFER_SIZE, skipBuffer |
Constructor Summary |
CSoundStream(byte[] aBuffer)
Creates a new byte array input stream that reads data from the
specified byte array. |
Method Summary |
byte[] |
getInternalData()
Returns reference to the internal data array that contains the sample data.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads up to len bytes of data into an array of bytes
from this input stream. |
void |
setVolume(float volume)
Sets the volume adjustment to the given value. |
Methods inherited from class java.io.ByteArrayInputStream |
available, close, ensureOpen, mark, markSupported, read, reset, skip |
Methods inherited from class java.io.InputStream |
read |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
m_volume
private float m_volume
- The volume.
m_siftAmount
private int m_siftAmount
- The calculated amount to sift to right (to achieve the volume).
m_aBuffer
private byte[] m_aBuffer
- The sound stream buffer.
CSoundStream
public CSoundStream(byte[] aBuffer)
- Creates a new byte array input stream that reads data from the
specified byte array. The byte array is not copied.
- Parameters:
buffer
- The buffer.
setVolume
public void setVolume(float volume)
- Sets the volume adjustment to the given value.
- Parameters:
volume
- The current volume.
read
public int read(byte[] buffer,
int offset,
int length)
- Reads up to
len
bytes of data into an array of bytes
from this input stream. This read
method cannot block.
- Overrides:
read
in class java.io.ByteArrayInputStream
- Parameters:
buffer
- the buffer into which the data is read.offset
- the start offset of the data.length
- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1
if there is no more data because the end of
the stream has been reached.
getInternalData
public byte[] getInternalData()
- Returns reference to the internal data array that contains the sample data.
Usefull for e.g. making copies of sounds.
- Returns:
- Reference to the internal data array.