com.flagstone.transform
Class FSEnvelope

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSEnvelope
All Implemented Interfaces:
java.lang.Cloneable

public class FSEnvelope
extends FSTransformObject

FSEnvelope is used to define an envelope which controls how a particular sound is played over time.

Each FSEnvelope object defines a point in the envelope. The FSSound object contains an array of FSEnvelope objects which define the complete envelope.

Attributes
mark The location in the playback sound data stream where the following level information applies.
left The sound level for the left channel, in the range 0..65535.
right The sound level for the right channel, in the range 0..65535..

The Flash Player plays sounds at a fixed rate of 44.1KHz, therefore sounds sampled at a lower frequency are interpolated with each sample repeated to generated the 44.1Khz playback rate. For example each sample in a sound sampled at 22KHz is played twice to generated the 44.1Khz playback rate.

The envelope defines the sample number (and hence the time) in the playback data stream where the level information applies and not the sample number in the original sound data. For example to set the level 0.1 seconds into a sound that plays for 1 second the value for the mark attribute in the envelope object would be 44100 * 0.1/1.0 = 4410.

History

The FSEnvelope class represents the SoundEnvelope structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.


Constructor Summary
FSEnvelope(FSCoder coder)
          Construct an FSEnvelope object, initialising it with values decoded from an encoded object.
FSEnvelope(FSEnvelope obj)
          Constructs an FSEnvelope object by copying values from an existing object.
FSEnvelope(int markValue, int leftValue, int rightValue)
          Constructs an envelope specifying the mark, left and right values.
 
Method Summary
 void appendDescription(java.lang.StringBuffer buffer, int depth)
          AppendDescription is used to present a string description of the object including all nested objects up to a specified depth.
 void decode(FSCoder coder)
           
 void encode(FSCoder coder)
           
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 int getLeft()
          Gets the level of the sound played in the left channel.
 int getMark()
          Gets the sample number in the 44.1KHz playback data stream where the level information is applied.
 int getRight()
          Gets the level of the sound played in the right channel.
 int length(FSCoder coder)
           
 void setLeft(int leftValue)
          Sets the level for the left sound channel.
 void setMark(int aNumber)
          Sets the sample number in the 44.1KHz playback data stream where the levels for the channels is applied.
 void setRight(int rightValue)
          Sets the level for the right sound channel.
 
Methods inherited from class com.flagstone.transform.FSTransformObject
clone, name, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSEnvelope

public FSEnvelope(FSCoder coder)
Construct an FSEnvelope object, initialising it with values decoded from an encoded object.

Parameters:
coder - an FSCoder containing the binary data.

FSEnvelope

public FSEnvelope(int markValue,
                  int leftValue,
                  int rightValue)
Constructs an envelope specifying the mark, left and right values.

Parameters:
markValue - the sample number in the 44.1KHz playback data stream where the levels for the channels is applied.
leftValue - the level for the left sound channel, in the range 0..65535.
rightValue - the level for the right sound channel, in the range 0..65535.

FSEnvelope

public FSEnvelope(FSEnvelope obj)
Constructs an FSEnvelope object by copying values from an existing object.

Parameters:
obj - an FSEnvelope object.
Method Detail

getMark

public int getMark()
Gets the sample number in the 44.1KHz playback data stream where the level information is applied.

Returns:
the mark value.

getLeft

public int getLeft()
Gets the level of the sound played in the left channel.

Returns:
the left value.

getRight

public int getRight()
Gets the level of the sound played in the right channel.

Returns:
the right value.

setMark

public void setMark(int aNumber)
Sets the sample number in the 44.1KHz playback data stream where the levels for the channels is applied.

Parameters:
aNumber - the mark value.

setLeft

public void setLeft(int leftValue)
Sets the level for the left sound channel.

Parameters:
leftValue - the level for the left sound channel.

setRight

public void setRight(int rightValue)
Sets the level for the right sound channel.

Parameters:
rightValue - the level for the right sound channel.

equals

public boolean equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

Overrides:
equals in class FSTransformObject
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
Description copied from class: FSTransformObject
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Specified by:
appendDescription in class FSTransformObject
Parameters:
buffer - a StringBuffer to which the description of each object is appended.
depth - the maximum level of nesting up to which objects will be displayed.

length

public int length(FSCoder coder)
Specified by:
length in class FSTransformObject

encode

public void encode(FSCoder coder)
Specified by:
encode in class FSTransformObject

decode

public void decode(FSCoder coder)
Specified by:
decode in class FSTransformObject