com.flagstone.transform.sound
Class Envelope.Level

java.lang.Object
  extended by com.flagstone.transform.sound.Envelope.Level
All Implemented Interfaces:
SWFEncodeable
Enclosing class:
Envelope

public final class Envelope.Level
extends Object
implements SWFEncodeable

Level describes the sound levels for stereo sound.

Each Level object contains a sample number in the audio when it is played where the envelope will be applied along with the sound levels for the left and right channels.

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 Level 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.

See Also:
SoundInfo

Constructor Summary
Envelope.Level(int markValue, int leftValue, int rightValue)
          Creates a envelope specifying the mark, left and right sound levels.
Envelope.Level(SWFDecoder coder)
          Creates and initialises a sound Level object using values encoded in the Flash binary format.
 
Method Summary
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 boolean equals(Object object)
           
 int getLeft()
          Get the level of the sound played in the left channel.
 int getMark()
          Get the sample number in the 44.1KHz playback data stream where the level information is applied.
 int getRight()
          Get the level of the sound played in the right channel.
 int hashCode()
           
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Envelope.Level

public Envelope.Level(SWFDecoder coder)
               throws IOException
Creates and initialises a sound Level object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

Envelope.Level

public Envelope.Level(int markValue,
                      int leftValue,
                      int rightValue)
Creates a envelope specifying the mark, left and right sound levels.

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.
Method Detail

getMark

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

Returns:
the sample number where the sound levels will be applied.

getLeft

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

Returns:
the sound level for the left channel.

getRight

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

Returns:
the sound level for the right channel.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.