com.groovemanager.sampled.waveform
Class EmptyWaveForm

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

public class EmptyWaveForm
extends java.lang.Object
implements WaveForm

This WaveForm implementaion represents an empty WaveForm that has no data to display

Author:
Manu Robledo

Constructor Summary
EmptyWaveForm()
           
 
Method Summary
 boolean canProvide(int begin, int length, int width)
          Tells if this WaveForm sees itself capable of providing a SubWaveForm with the given parameters
 int getChannels()
          Get the number of channels in this WaveForm
 byte[] getData()
          Get the whole Peak data as array.
 int getDisplayableLength()
          Get the total displayable length of this WaveForm.
 int getIntervallSize()
          Get the number of samples of the original Sample which are represented by one step of this WaveForm.
 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
 int getPosition()
          Get the read position of this WaveForm
 int getRealLength()
          Get the Length of the original sample which this WaveForm represents
 int getRealPosition()
          Get the position inside the sample represented by this WaveForm corresponding to the actual read position of this WaveForm.
 double getZoomFactor()
          Get the ratio between the length of the represented Sample and and the displayable length of this WaveForm.
 boolean next()
          Tells the WaveForm to increase its position by one
 void rewind()
          Sets the current read position to the beginning of this WaveForm
 void setChannel(int channel)
           
 void setPosition(int pos)
          Set the read position of this WaveForm
 void setRealPosition(int pos)
          Set the read position of this WaveForm to the value corresponding to the given real position of the represented sample.
 WaveForm subWaveForm(int begin, int length, int width)
          Get a WaveForm Object that represents the part of this WaveForm specified by begin and length and displays this part in the specified width
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyWaveForm

public EmptyWaveForm()
Method Detail

canProvide

public boolean canProvide(int begin,
                          int length,
                          int width)
Description copied from interface: WaveForm
Tells if this WaveForm sees itself capable of providing a SubWaveForm with the given parameters

Specified by:
canProvide in interface WaveForm
Parameters:
begin - The offset to the beginning of this WaveForm. May also be negative.
length - The length in steps of this WaveForm that should be represented by the returned WaveForm.
width - The new width in which the part should be displayed.
Returns:
true if this WaveForm can provide the wanted subWaveForm, false otherwise
See Also:
WaveForm.subWaveForm(int, int, int)

getChannels

public int getChannels()
Description copied from interface: WaveForm
Get the number of channels in this WaveForm

Specified by:
getChannels in interface WaveForm
Returns:
The number of channels (1 or bigger)

getData

public byte[] getData()
Description copied from interface: WaveForm
Get the whole Peak data as array. This method could take very long for WaveForms which don't store their data in such an array. Should be very fast for peak Wave Forms.

Specified by:
getData in interface WaveForm
Returns:
The Peak Data as byte-Array.

getDisplayableLength

public int getDisplayableLength()
Description copied from interface: WaveForm
Get the total displayable length of this WaveForm.

Specified by:
getDisplayableLength in interface WaveForm
Returns:
The length of this WaveForm

getIntervallSize

public int getIntervallSize()
Description copied from interface: WaveForm
Get the number of samples of the original Sample which are represented by one step of this WaveForm. Especially interesting for PeakWaveForms.

Specified by:
getIntervallSize in interface WaveForm
Returns:
The number of samples

getMax

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

Specified by:
getMax in interface WaveForm
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

Specified by:
getMin in interface WaveForm
Parameters:
channel - the zero-based index of the channel
Returns:
the minimum value at this position as byte

getPosition

public int getPosition()
Description copied from interface: WaveForm
Get the read position of this WaveForm

Specified by:
getPosition in interface WaveForm
Returns:
The current read position

getRealLength

public int getRealLength()
Description copied from interface: WaveForm
Get the Length of the original sample which this WaveForm represents

Specified by:
getRealLength in interface WaveForm
Returns:
The length of the original sample in sample frames.

getRealPosition

public int getRealPosition()
Description copied from interface: WaveForm
Get the position inside the sample represented by this WaveForm corresponding to the actual read position of this WaveForm. For WaveForms with a zoom factor of 1.0 this method should behave exactly like getPosition()

Specified by:
getRealPosition in interface WaveForm
Returns:
The position in the original sample

getZoomFactor

public double getZoomFactor()
Description copied from interface: WaveForm
Get the ratio between the length of the represented Sample and and the displayable length of this WaveForm.

Specified by:
getZoomFactor in interface WaveForm
Returns:
getRealLength() / (double)getDisplayableLength()

next

public boolean next()
Description copied from interface: WaveForm
Tells the WaveForm to increase its position by one

Specified by:
next in interface WaveForm
Returns:
true if the end position was not reached before this method call so that the position could be increased, false otherwise. The return value can be used for iteratin over the whole WaveForm like this:
IWaveForm w = ...;
int channel = ...;
w.rewind();
do{
byte min = w.getMin(channel);
byte max = w.getMax(channel);
// ...(do something with those values)
} while(w.next());

rewind

public void rewind()
Description copied from interface: WaveForm
Sets the current read position to the beginning of this WaveForm

Specified by:
rewind in interface WaveForm

setChannel

public void setChannel(int channel)

setPosition

public void setPosition(int pos)
Description copied from interface: WaveForm
Set the read position of this WaveForm

Specified by:
setPosition in interface WaveForm
Parameters:
pos - The new read position

setRealPosition

public void setRealPosition(int pos)
Description copied from interface: WaveForm
Set the read position of this WaveForm to the value corresponding to the given real position of the represented sample. For WaveForms with a zoom factor of 1.0 this method should behave exactly like setPosition(pos)

Specified by:
setRealPosition in interface WaveForm
Parameters:
pos - The new position in the original sample

subWaveForm

public WaveForm subWaveForm(int begin,
                            int length,
                            int width)
Description copied from interface: WaveForm
Get a WaveForm Object that represents the part of this WaveForm specified by begin and length and displays this part in the specified width

Specified by:
subWaveForm in interface WaveForm
Parameters:
begin - The offset to the beginning of this WaveForm. May also be negative.
length - The length in steps of this WaveForm that should be represented by the returned WaveForm.
width - The new width in which the part should be displayed.
Returns:
A WaveForm Object that represents the specified Part of this WaveForm and displays it in the given width. Can also be the same Object with adapted attributes