com.groovemanager.sampled.waveform
Class UpdatingWaveForm

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

public class UpdatingWaveForm
extends AbstractWaveForm

An updating WaveForm is a WaveForm that ia wrapped around another one and forces to be not re-used by returning false for any call to canProvide()

Author:
Manu Robledo

Field Summary
 WaveForm source
          The wrapped WaveForm
 
Fields inherited from class com.groovemanager.sampled.waveform.AbstractWaveForm
channels, displayWidth, intervallSize, nullWave, position, realLength
 
Constructor Summary
UpdatingWaveForm(WaveForm source)
          Construct a new UpdatingWaveForm
 
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
protected  java.lang.String getAdditionalToString()
          Get an additional String describing this WaveForm.
 int getChannels()
          Get the number of channels in this WaveForm
 int getDisplayableLength()
          Get the total displayable length 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 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.
 
Methods inherited from class com.groovemanager.sampled.waveform.AbstractWaveForm
getData, getIntervallSize, subWaveForm, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

public WaveForm source
The wrapped WaveForm

Constructor Detail

UpdatingWaveForm

public UpdatingWaveForm(WaveForm source)
Construct a new UpdatingWaveForm

Parameters:
source - The WaveForm to be wrapped
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
Overrides:
canProvide in class AbstractWaveForm
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.canProvide(int, int, int)

getAdditionalToString

protected java.lang.String getAdditionalToString()
Description copied from class: AbstractWaveForm
Get an additional String describing this WaveForm. Will be used in toString()

Overrides:
getAdditionalToString in class AbstractWaveForm
Returns:
An optional String describing special characteristics of this WaveForm

getChannels

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

Specified by:
getChannels in interface WaveForm
Overrides:
getChannels in class AbstractWaveForm
Returns:
The number of channels (1 or bigger)
See Also:
WaveForm.getChannels()

getDisplayableLength

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

Specified by:
getDisplayableLength in interface WaveForm
Overrides:
getDisplayableLength in class AbstractWaveForm
Returns:
The length of this WaveForm
See Also:
WaveForm.getDisplayableLength()

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

getPosition

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

Specified by:
getPosition in interface WaveForm
Overrides:
getPosition in class AbstractWaveForm
Returns:
The current read position
See Also:
WaveForm.getPosition()

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
Overrides:
getRealLength in class AbstractWaveForm
Returns:
The length of the original sample in sample frames.
See Also:
WaveForm.getRealLength()

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
Overrides:
getRealPosition in class AbstractWaveForm
Returns:
The position in the original sample
See Also:
WaveForm.getRealPosition()

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
Overrides:
getZoomFactor in class AbstractWaveForm
Returns:
getRealLength() / (double)getDisplayableLength()
See Also:
WaveForm.getZoomFactor()

next

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

Specified by:
next in interface WaveForm
Overrides:
next in class AbstractWaveForm
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());
See Also:
WaveForm.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
Overrides:
rewind in class AbstractWaveForm
See Also:
WaveForm.rewind()

setPosition

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

Specified by:
setPosition in interface WaveForm
Overrides:
setPosition in class AbstractWaveForm
Parameters:
pos - The new read position
See Also:
WaveForm.setPosition(int)

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
Overrides:
setRealPosition in class AbstractWaveForm
Parameters:
pos - The new position in the original sample
See Also:
WaveForm.setRealPosition(int)