com.jsyn.data
Class SegmentedEnvelope

java.lang.Object
  extended by com.jsyn.data.SequentialDataCommon
      extended by com.jsyn.data.SegmentedEnvelope
All Implemented Interfaces:
SequentialData

public class SegmentedEnvelope
extends SequentialDataCommon

Store an envelope as a series of line segments. Each line is described as a duration and a target value.


Constructor Summary
SegmentedEnvelope(double[] pairs)
           
SegmentedEnvelope(int numFrames)
           
 
Method Summary
 void allocate(int numFrames)
           
 int getChannelsPerFrame()
           
 int getNumFrames()
           
 double getRateScaler(int index, double synthesisPeriod)
          Get rate to play the data.
 void read(double[] data)
           
 void read(int startFrame, double[] data, int startIndex, int numToRead)
           
 double readDouble(int index)
          Read the value of an envelope, not the duration.
 void write(double[] data)
           
 void write(int startFrame, double[] data, int startIndex, int numToWrite)
          Write frames of envelope data.
 void writeDouble(int index, double value)
          Write a value at the given index.
 
Methods inherited from class com.jsyn.data.SequentialDataCommon
getReleaseBegin, getReleaseEnd, getSustainBegin, getSustainEnd, setReleaseBegin, setReleaseEnd, setSustainBegin, setSustainEnd
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentedEnvelope

public SegmentedEnvelope(int numFrames)

SegmentedEnvelope

public SegmentedEnvelope(double[] pairs)
Method Detail

allocate

public void allocate(int numFrames)

write

public void write(int startFrame,
                  double[] data,
                  int startIndex,
                  int numToWrite)
Write frames of envelope data. A frame consists of a duration and a value.

Parameters:
startFrame - Index of frame in envelope to write to.
data - Pairs of duration and value.
startIndex - Index of frame in data[] to read from.
numToWrite - Number of frames (pairs) to write.

read

public void read(int startFrame,
                 double[] data,
                 int startIndex,
                 int numToRead)

write

public void write(double[] data)

read

public void read(double[] data)

readDouble

public double readDouble(int index)
Read the value of an envelope, not the duration.

Specified by:
readDouble in interface SequentialData
Specified by:
readDouble in class SequentialDataCommon

writeDouble

public 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
Specified by:
writeDouble in class SequentialDataCommon

getRateScaler

public double getRateScaler(int index,
                            double synthesisPeriod)
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
Specified by:
getRateScaler in class SequentialDataCommon
Returns:
rate to scale the playback speed.

getChannelsPerFrame

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

getNumFrames

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