|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gameframe.sound.RiffWavFile
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.
Field Summary | |
private short[] |
m_aWavBuffer
The wave buffer. |
private int |
m_averageBytePerSecond
The average bytes per second in the RIFF file. |
private int |
m_bitsPerSample
The bits per sample in the RIFF file. |
private int |
m_blockAlignment
The block alignment in the RIFF file. |
private int |
m_bytesPerSample
The bytes per sample value in the RIFF file. |
private int |
m_dataLength
The length of the RIFF data field. |
private int |
m_formatLength
The RIFF format length. |
private java.io.DataInputStream |
m_inputStream
The input stream used for reading the file. |
private short |
m_maxValue
The maximum sample value in the RIFF file. |
private short |
m_minValue
The minimum sample value in the RIFF file. |
private int |
m_numChannels
The number of channels in the RIFF file. |
private int |
m_riffLength
The RIFF length. |
private int |
m_samplesPerSecond
The samples per second in the RIFF file. |
private java.lang.String |
m_strFileName
The name of the file. |
private int |
m_wavFormatTag
The RIFF wave format tag. |
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 | |
private boolean |
findTag(java.io.DataInputStream inStream,
java.lang.String stringToFind)
Tries to find the specified tag from the specified inputstream. |
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. |
private int |
readIntelInt(java.io.DataInputStream inStream)
Reads an "Intel formatted" 32-bit integer from the given data input stream. |
private short |
readIntelShort(java.io.DataInputStream inStream)
Reads an "Intel formatted" 16-bit short from the given data input stream. |
void |
resampleTo(int targetSampleRate)
Sets the sampling rate of this wav data to the given sampling rate |
private short[] |
resampleTo(short[] a16BitData,
int originalSampleRate,
int targetSampleRate)
Resamples the given 16-bit linear PCM sample data from the given sample rate to the given sample rate. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int WAVE_FORMAT_PCM
private java.io.DataInputStream m_inputStream
private short[] m_aWavBuffer
private int m_riffLength
private int m_formatLength
private int m_averageBytePerSecond
private int m_blockAlignment
private int m_bitsPerSample
private int m_wavFormatTag
private int m_numChannels
private int m_samplesPerSecond
private int m_bytesPerSample
private int m_dataLength
private short m_minValue
private short m_maxValue
private java.lang.String m_strFileName
Constructor Detail |
public RiffWavFile()
Method Detail |
public void loadWAV(java.lang.String filename) throws java.io.FileNotFoundException, GameFrameException
filename
- The name of the RIFF WAVE file.public void loadWAVURL(java.lang.String strFileName) throws java.io.FileNotFoundException, GameFrameException
filename
- The name of the RIFF WAVE file.public void loadFromInputStream(java.lang.String strFilename) throws java.io.FileNotFoundException, GameFrameException
public void resampleTo(int targetSampleRate)
frequency
- The target sampling rate.public short[] getPcmData()
public void readHeader() throws GameFrameException
GameFrameException
- Thrown if the header is not correctly read.private short[] resampleTo(short[] a16BitData, int originalSampleRate, int targetSampleRate)
a16BitData
- The linear PCM sample data to be resampled.originalSampleRate
- The original sample rate.targetSampleRate
- The targetted sample rate.private int readIntelInt(java.io.DataInputStream inStream) throws java.io.IOException
inStream
- The input stream to read from.private short readIntelShort(java.io.DataInputStream inStream) throws java.io.IOException
inStream
- The input stream to read from.private boolean findTag(java.io.DataInputStream inStream, java.lang.String stringToFind) throws java.io.IOException
inStream
- The data input stream to read from.tagToFind
- The tag we are looking for.
|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |