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) int
dataOffset
(package private) int
fmtOffset
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
findHeader(int i1, int i2, int i3, int i4)
Find a specific header in the .wav fragment.(package private) int
fourByte(int index)
boolean
getBigEndian()
byte[]
getByteArray()
int
getChannels()
int
getDataEnd()
Offset to the last data byte in the buffer.int
getDataSize()
Size of the data segment in bytes.int
getDataStart()
Offset to the first data byte in the buffer.float
getSampleRate()
int
getSampleSizeInBits()
boolean
getSigned()
(package private) int
twoByte(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()
-
-