Package jmri.jmrit.sound
Class WavBuffer
- java.lang.Object
- 
- jmri.jmrit.sound.WavBuffer
 
- 
 public class WavBuffer extends java.lang.Object Wrap a byte array to provide WAV file functionality
- 
- 
Field SummaryFields Modifier and Type Field Description (package private) byte[]buffer(package private) intdataOffset(package private) intfmtOffset
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intfindHeader(int i1, int i2, int i3, int i4)Find a specific header in the .wav fragment.(package private) intfourByte(int index)booleangetBigEndian()byte[]getByteArray()intgetChannels()intgetDataEnd()Offset to the last data byte in the buffer.intgetDataSize()Size of the data segment in bytes.intgetDataStart()Offset to the first data byte in the buffer.floatgetSampleRate()intgetSampleSizeInBits()booleangetSigned()(package private) inttwoByte(int index)
 
- 
- 
- 
Field Detail- 
fmtOffsetint fmtOffset 
 - 
dataOffsetint dataOffset 
 - 
bufferbyte[] buffer 
 
- 
 - 
Constructor Detail- 
WavBufferpublic WavBuffer(byte[] content) Create from already existing byte array.- Parameters:
- content- a WAV format byte array, starting with a RIFF header
 
 - 
WavBufferpublic WavBuffer(java.io.File file) throws java.io.IOException Create from contents of file. The file contents are expected to be in .wav format, starting with a RIFF header.- Parameters:
- file- file containing the .wav.
- Throws:
- java.io.IOException- on error.
 
 
- 
 - 
Method Detail- 
findHeaderpublic int findHeader(int i1, int i2, int i3, int i4) Find a specific header in the .wav fragment.- Parameters:
- i1- index 1.
- i2- index 2.
- i3- index 3.
- i4- index 4.
- Returns:
- offset of the 1st byte of the header in the buffer
 
 - 
getSampleRatepublic float getSampleRate() 
 - 
getSampleSizeInBitspublic int getSampleSizeInBits() 
 - 
getChannelspublic int getChannels() 
 - 
getBigEndianpublic boolean getBigEndian() 
 - 
getSignedpublic boolean getSigned() 
 - 
getDataStartpublic int getDataStart() Offset to the first data byte in the buffer.- Returns:
- first data byte offset.
 
 - 
getDataSizepublic int getDataSize() Size of the data segment in bytes.- Returns:
- data size in bytes.
 
 - 
getDataEndpublic int getDataEnd() Offset to the last data byte in the buffer. One more than this points to the next header.- Returns:
- data end value.
 
 - 
twoByteint twoByte(int index) 
 - 
fourByteint fourByte(int index) 
 - 
getByteArraypublic byte[] getByteArray() 
 
- 
 
-