gameframe.sound
Class RiffWavFile
java.lang.Object
|
+--gameframe.sound.RiffWavFile
- public class RiffWavFile
- extends java.lang.Object
Class for reading RIFF WAV audio files. Originally taken from my own small audio class
library and changed to only handle the reading as other features are not needed in the
GameFrame context.
- Since:
- GameFrame for Java 0.9
- Version:
- GameFrame for Java 0.9.4
- Author:
- Pasi Keränen 16. May 1999
Field Summary |
static int |
WAVE_FORMAT_PCM
Format tag for Microsoft Pulse Code Modulation (PCM) format (non-proprietary). |
Constructor Summary |
RiffWavFile()
Constructs a new RIFF wave file without any filename. |
Method Summary |
short[] |
getPcmData()
Returns the raw linear PCM sample data in 16-bit mono format.
|
void |
loadFromInputStream(java.lang.String strFilename)
|
void |
loadWAV(java.lang.String filename)
Loads the RIFFF WAVE file from the specified file. |
void |
loadWAVURL(java.lang.String strFileName)
Loads the RIFFF WAVE file from the specified URL. |
void |
readHeader()
Reads and parses the RIFF WAVE header. |
void |
resampleTo(int targetSampleRate)
Sets the sampling rate of this wav data to the given sampling rate |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WAVE_FORMAT_PCM
public static final int WAVE_FORMAT_PCM
- Format tag for Microsoft Pulse Code Modulation (PCM) format (non-proprietary).
RiffWavFile
public RiffWavFile()
- Constructs a new RIFF wave file without any filename.
loadWAV
public void loadWAV(java.lang.String filename)
throws java.io.FileNotFoundException,
GameFrameException
- Loads the RIFFF WAVE file from the specified file.
- Parameters:
filename
- The name of the RIFF WAVE file.- Returns:
- True if load successfull, false if not.
loadWAVURL
public void loadWAVURL(java.lang.String strFileName)
throws java.io.FileNotFoundException,
GameFrameException
- Loads the RIFFF WAVE file from the specified URL.
- Parameters:
filename
- The name of the RIFF WAVE file.
loadFromInputStream
public void loadFromInputStream(java.lang.String strFilename)
throws java.io.FileNotFoundException,
GameFrameException
resampleTo
public void resampleTo(int targetSampleRate)
- Sets the sampling rate of this wav data to the given sampling rate
- Parameters:
frequency
- The target sampling rate.
getPcmData
public short[] getPcmData()
- Returns the raw linear PCM sample data in 16-bit mono format.
Note: Returns the reference to the internal data structure
of this object, modifying the data in the data structure will
propably make this objects state illegal.
- Returns:
- Linear PCM sample data.
readHeader
public void readHeader()
throws GameFrameException
- Reads and parses the RIFF WAVE header. When this method returns
the size of the actual sample data field has been read and
the m_inputStream is about to read the first actual sample
data.
- Returns:
- True if header is can be parsed and format is supported, false otherwise.
- Throws:
GameFrameException
- Thrown if the header is not correctly read.