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 Summary
Fields Modifier and Type Field Description (package private) byte[]buffer(package private) intdataOffset(package private) intfmtOffset
-
Method Summary
All 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
-
fmtOffset
int fmtOffset
-
dataOffset
int dataOffset
-
buffer
byte[] buffer
-
-
Constructor Detail
-
WavBuffer
public WavBuffer(byte[] content)
Create from already existing byte array.- Parameters:
content- a WAV format byte array, starting with a RIFF header
-
WavBuffer
public 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
-
findHeader
public 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
-
getSampleRate
public float getSampleRate()
-
getSampleSizeInBits
public int getSampleSizeInBits()
-
getChannels
public int getChannels()
-
getBigEndian
public boolean getBigEndian()
-
getSigned
public boolean getSigned()
-
getDataStart
public int getDataStart()
Offset to the first data byte in the buffer.- Returns:
- first data byte offset.
-
getDataSize
public int getDataSize()
Size of the data segment in bytes.- Returns:
- data size in bytes.
-
getDataEnd
public int getDataEnd()
Offset to the last data byte in the buffer. One more than this points to the next header.- Returns:
- data end value.
-
twoByte
int twoByte(int index)
-
fourByte
int fourByte(int index)
-
getByteArray
public byte[] getByteArray()
-
-