com.groovemanager.sampled.waveform
Class ByteArrayWaveForm

java.lang.Object
  extended by com.groovemanager.sampled.waveform.AbstractWaveForm
      extended by com.groovemanager.sampled.waveform.ByteArrayWaveForm
All Implemented Interfaces:
WaveForm

public class ByteArrayWaveForm
extends AbstractWaveForm

A ByteArrayWaveForm reads its displayable data directly from a given array of audio data. This can be very memory consuming so that ByteArrayWaveForms should only be used for small amounts of audio data. This implementation will only read the most signifigant byte of each sample. For AudioFormats where this byte doesn´t represent more or less the real amplitude, this implementation should not be used.

Author:
Manu Robledo

Field Summary
protected  byte[] data
          The audio data
protected  javax.sound.sampled.AudioFormat format
          The format of the audio data
protected  int fSize
          The frame size of the audio format
protected  int sSize
          The frame size of the audio format
 
Fields inherited from class com.groovemanager.sampled.waveform.AbstractWaveForm
channels, displayWidth, intervallSize, nullWave, position, realLength
 
Constructor Summary
ByteArrayWaveForm(byte[] data, javax.sound.sampled.AudioFormat format)
          Construct a new ByteArrayWaveForm
 
Method Summary
 byte getMax(int channel)
          Get the maximum value at the current read position in the given channel
 byte getMin(int channel)
          Get the minimum value at the current read position in the given channel
 
Methods inherited from class com.groovemanager.sampled.waveform.AbstractWaveForm
canProvide, getAdditionalToString, getChannels, getData, getDisplayableLength, getIntervallSize, getPosition, getRealLength, getRealPosition, getZoomFactor, next, rewind, setPosition, setRealPosition, subWaveForm, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected byte[] data
The audio data


format

protected javax.sound.sampled.AudioFormat format
The format of the audio data


fSize

protected int fSize
The frame size of the audio format


sSize

protected int sSize
The frame size of the audio format

Constructor Detail

ByteArrayWaveForm

public ByteArrayWaveForm(byte[] data,
                         javax.sound.sampled.AudioFormat format)
Construct a new ByteArrayWaveForm

Parameters:
data - The audio data to display
format - The format of the given audio data
Method Detail

getMax

public byte getMax(int channel)
Description copied from interface: WaveForm
Get the maximum value at the current read position in the given channel

Parameters:
channel - the zero-based index of the channel
Returns:
the maximum value at this position as byte

getMin

public byte getMin(int channel)
Description copied from interface: WaveForm
Get the minimum value at the current read position in the given channel

Parameters:
channel - the zero-based index of the channel
Returns:
the minimum value at this position as byte