com.jsyn.data
Class SequentialDataCommon

java.lang.Object
  extended by com.jsyn.data.SequentialDataCommon
All Implemented Interfaces:
SequentialData
Direct Known Subclasses:
AudioSample, SegmentedEnvelope

public abstract class SequentialDataCommon
extends java.lang.Object
implements SequentialData

Abstract base class for envelopes and samples that adds sustain and release loops.


Constructor Summary
SequentialDataCommon()
           
 
Method Summary
abstract  int getChannelsPerFrame()
           
 int getNumFrames()
           
abstract  double getRateScaler(int index, double synthesisRate)
          Get rate to play the data.
 int getReleaseBegin()
           
 int getReleaseEnd()
           
 int getSustainBegin()
           
 int getSustainEnd()
           
abstract  double readDouble(int index)
          Read a value at the given index.
 void setReleaseBegin(int releaseBegin)
           
 void setReleaseEnd(int releaseEnd)
           
 void setSustainBegin(int sustainBegin)
           
 void setSustainEnd(int sustainEnd)
           
abstract  void writeDouble(int index, double value)
          Write a value at the given index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequentialDataCommon

public SequentialDataCommon()
Method Detail

writeDouble

public abstract void writeDouble(int index,
                                 double value)
Description copied from interface: SequentialData
Write a value at the given index. Values are organized by frame. So index = ((channelsPerFrame*frameIndex)+channelIndex)

Specified by:
writeDouble in interface SequentialData

readDouble

public abstract double readDouble(int index)
Description copied from interface: SequentialData
Read a value at the given index.

Specified by:
readDouble in interface SequentialData

getRateScaler

public abstract double getRateScaler(int index,
                                     double synthesisRate)
Description copied from interface: SequentialData
Get rate to play the data. In an envelope this correspond to the inverse of the frame duration and would vary frame to frame. For an audio sample it is 1.0.

Specified by:
getRateScaler in interface SequentialData
Returns:
rate to scale the playback speed.

getChannelsPerFrame

public abstract int getChannelsPerFrame()
Specified by:
getChannelsPerFrame in interface SequentialData
Returns:
For a stereo sample, return 2.

getSustainBegin

public int getSustainBegin()
Specified by:
getSustainBegin in interface SequentialData
Returns:
Beginning of sustain loop or -1 if no loop.

getSustainEnd

public int getSustainEnd()
Specified by:
getSustainEnd in interface SequentialData
Returns:
End of sustain loop or -1 if no loop.

getReleaseBegin

public int getReleaseBegin()
Specified by:
getReleaseBegin in interface SequentialData
Returns:
Beginning of release loop or -1 if no loop.

getReleaseEnd

public int getReleaseEnd()
Specified by:
getReleaseEnd in interface SequentialData
Returns:
End of release loop or -1 if no loop.

setSustainBegin

public void setSustainBegin(int sustainBegin)

setSustainEnd

public void setSustainEnd(int sustainEnd)

setReleaseBegin

public void setReleaseBegin(int releaseBegin)

setReleaseEnd

public void setReleaseEnd(int releaseEnd)

getNumFrames

public int getNumFrames()
Specified by:
getNumFrames in interface SequentialData
Returns:
The number of valid frames that can be read.