com.flagstone.transform
Class FSSoundStreamHead2

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

public class FSSoundStreamHead2
extends FSMovieObject

FSSoundStreamHead2 defines an sound compressed using different compression formats that is streamed in tight synchronisation with the movie being played.

The FSSoundStreamHead2 class defines how the streaming sound is played. Objects of the FSSoundStreamBlock class contains the sound data.

When a stream sound is played if the Flash Player cannot render the frames fast enough to maintain synchronisation with the sound being played then frames will be skipped. Normally the player will reduce the frame rate so every frame of a movie is played.

To define the stream sound the parameters for and sampled sound and how it will be played back must be specified:

Attributes
type Identifies the data structure when it is encoded. Read-only.
format The format of the encoded sound data - FSSound.PCM (Little-Endian byte order), FSSound.ADPCM, FSSound.NATIVE_PCM (Big-Endian or Little-Endian byte order depending on the platform where the sound was created), FSSound.MP3 or FSSound.NELLYMOSER
playbackRate The recommended playback rate in Hertz - 5512, 11025, 22050 or 44100.
playbackSampleSize The number of bytes in an uncompressed sample when the sound is played, either 1 or 2.
playbackChannels The recommended number of playback channels: 1 = mono or 2 = stereo.
streamRate The stream sampling rate - 5512, 11025, 22050 or 44100 Hz
streamSampleSize The size of an uncompressed sample in the streaming sound in bytes, either 1 or 2.
streamChannels The number of channels: 1 = mono or 2 = stereo in the streaming sound
streamSampleCount The average number of samples in each sound stream block.
latency Latency defines the number of samples to skip only when playing sounds encoded with the MP3 format.

FSSoundStreamHead2 allows way the sound is played to differ from the way it is encoded and streamed to the player. This allows the Player more control over how the animation is rendered. Reducing the resolution or playback rate can improve synchronisation with the frames displayed.

History

The FSSoundStreamHead2 class represents the SoundStreamHead structure from the Flash specification. It was introduced in Flash 3. Support for the Nellymoser Asao format was added in Flash 6.


Field Summary
 
Fields inherited from class com.flagstone.transform.FSMovieObject
ButtonColorTransform, ButtonSound, DefineBitsPtr, DefineButton, DefineButton2, DefineFont, DefineFont2, DefineImage, DefineImage2, DefineJPEGImage, DefineJPEGImage2, DefineJPEGImage3, DefineMorphShape, DefineMovieClip, DefineShape, DefineShape2, DefineShape3, DefineSound, DefineText, DefineText2, DefineTextField, DefineVideo, DoAction, EnableDebugger, EnableDebugger2, Export, extendLength, FontInfo, FontInfo2, FrameLabel, Free, Import, Initialize, JPEGTables, length, LimitScript, PathsArePostscript, PlaceObject, PlaceObject2, Protect, QuicktimeMovie, RemoveObject, RemoveObject2, SerialNumber, SetBackgroundColor, ShowFrame, SoundStreamBlock, SoundStreamHead, SoundStreamHead2, StartSound, TabOrder, type, VideoFrame
 
Constructor Summary
FSSoundStreamHead2(FSCoder coder)
          Construct an FSSoundStreamHead2 object, initialising it with values decoded from an encoded object.
FSSoundStreamHead2(FSSoundStreamHead2 obj)
          Constructs an FSSoundStreamHead2 object by copying values from an existing object.
FSSoundStreamHead2(int encoding, int playRate, int playChannels, int playSize, int streamingRate, int streamingChannels, int streamingSize, int streamingCount, int latency)
          Constructs an FSSoundStreamHead2 object specifying all the parameters required to define the sound.
 
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 getFormat()
          Gets the streaming sound format.
 int getLatency()
          For MP3 encoded sounds, returns the number of samples to skip when starting to play a sound.
 int getPlaybackChannels()
          Gets the recommended number of playback channels = 1 = mono 2 = stereo.
 int getPlaybackRate()
          Gets the recommended playback rate: 5512, 11025, 22050 or 44100 Hertz.
 int getPlaybackSampleSize()
          Gets the recommended playback sample range in bytes: 1 or 2.
 int getStreamChannels()
          Gets the number of channels, 1 = mono 2 = stereo, in the streaming sound.
 float getStreamRate()
          Gets the sample rate: 5512, 11025, 22050 or 44100 Hz in the streaming sound.
 int getStreamSampleCount()
          Gets the average number of samples in each stream block following.
 int getStreamSampleSize()
          Gets the sample size in bytes: 1 or 2 in the streaming sound.
 int length(FSCoder coder)
           
 void setFormat(int encoding)
          Sets the format for the streaming sound.
 void setLatency(int latency)
          Set the number of samples to skip when starting to play an MP3 encoded sound.
 void setPlaybackChannels(int aNumber)
          Sets the recommended number of playback channels = 1 = mono 2 = stereo.
 void setPlaybackRate(int rate)
          Sets the recommended playback rate in Hz.
 void setPlaybackSampleSize(int playSize)
          Sets the recommended playback sample size in bytes.
 void setStreamChannels(int streamingChannels)
          Sets the number of channels in the streaming sound: 1 = mono 2 = stereo.
 void setStreamRate(int rate)
          Sets the sample rate in Hz for the streaming sound.
 void setStreamSampleCount(int streamingCount)
          Sets the number of samples in each stream block.
 void setStreamSampleSize(int streamingSize)
          Sets the sample size in bytes for the streaming sound.
 
Methods inherited from class com.flagstone.transform.FSMovieObject
getType
 
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

FSSoundStreamHead2

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

Parameters:
coder - an FSCoder containing the binary data.

FSSoundStreamHead2

public FSSoundStreamHead2(int encoding,
                          int playRate,
                          int playChannels,
                          int playSize,
                          int streamingRate,
                          int streamingChannels,
                          int streamingSize,
                          int streamingCount,
                          int latency)
Constructs an FSSoundStreamHead2 object specifying all the parameters required to define the sound.

Parameters:
encoding - the compression format for the sound data, either FSSound.NATIVE_PCM, FSSound.ADPCM, FSSound.MP3, FSSound.PCM or FSSound.NELLYMOSER (Flash 6+ only).
playRate - the recommended rate for playing the sound, either 5512, 11025, 22050 or 44100 Hz.
playChannels - The recommended number of playback channels: 1 = mono or 2 = stereo.
playSize - the recommended uncompressed sample size for playing the sound, either 1 or 2 bytes.
streamingRate - the rate at which the sound was sampled, either 5512, 11025, 22050 or 44100 Hz.
streamingChannels - the number of channels: 1 = mono or 2 = stereo.
streamingSize - the sample size for the sound, either 1 or 2 bytes.
streamingCount - the number of samples in each subsequent FSSoundStreamBlock object.
latency - defines the number of samples to skip only when playing sounds encoded with the MP3 format.

FSSoundStreamHead2

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

Parameters:
obj - an FSSoundStreamHead2 object.
Method Detail

getFormat

public int getFormat()
Gets the streaming sound format. For the FSSoundStreamHead2 class supports NATIVE_PCM, ADPCM, MP3, PCM or NELLYMOSER encoded sound data.

Returns:
the format used to play the sound.

setFormat

public void setFormat(int encoding)
Sets the format for the streaming sound.

Parameters:
encoding - the compression format for the sound data, either FSSound.NATIVE_PCM, FSSound.ADPCM, FSSound.MP3, FSSound.PCM or FSSound.NELLYMOSER.

getPlaybackRate

public int getPlaybackRate()
Gets the recommended playback rate: 5512, 11025, 22050 or 44100 Hertz.

Returns:
the rate at which the sound will be played back.

getPlaybackChannels

public int getPlaybackChannels()
Gets the recommended number of playback channels = 1 = mono 2 = stereo.

Returns:
the number of channels for the sound playback.

getPlaybackSampleSize

public int getPlaybackSampleSize()
Gets the recommended playback sample range in bytes: 1 or 2.

Returns:
the sample size used to play back the sound.

getStreamRate

public float getStreamRate()
Gets the sample rate: 5512, 11025, 22050 or 44100 Hz in the streaming sound.

Returns:
the rate at which the sound was sampled.

getStreamChannels

public int getStreamChannels()
Gets the number of channels, 1 = mono 2 = stereo, in the streaming sound.

Returns:
the number of channels in the sound.

getStreamSampleSize

public int getStreamSampleSize()
Gets the sample size in bytes: 1 or 2 in the streaming sound.

Returns:
the sample size.

getStreamSampleCount

public int getStreamSampleCount()
Gets the average number of samples in each stream block following.

Returns:
the number of sound samples in each following FSSoundStreamBlock object.

setPlaybackRate

public void setPlaybackRate(int rate)
Sets the recommended playback rate in Hz. Must be either: 5512, 11025, 22050 or 44100.

Parameters:
rate - the recommended rate for playing the sound.

setPlaybackChannels

public void setPlaybackChannels(int aNumber)
Sets the recommended number of playback channels = 1 = mono 2 = stereo.

Parameters:
aNumber - the recommended number of playback channels.

setPlaybackSampleSize

public void setPlaybackSampleSize(int playSize)
Sets the recommended playback sample size in bytes. Must be wither 1 or 2.

Parameters:
playSize - the recommended sample size for playing the sound.

setStreamRate

public void setStreamRate(int rate)
Sets the sample rate in Hz for the streaming sound. Must be either: 5512, 11025, 22050 or 44100.

Parameters:
rate - the rate at which the streaming sound was sampled.

setStreamChannels

public void setStreamChannels(int streamingChannels)
Sets the number of channels in the streaming sound: 1 = mono 2 = stereo.

Parameters:
streamingChannels - the number of channels in the streaming sound.

setStreamSampleSize

public void setStreamSampleSize(int streamingSize)
Sets the sample size in bytes for the streaming sound. Must be 1 or 2.

Parameters:
streamingSize - the sample size for the sound.

setStreamSampleCount

public void setStreamSampleCount(int streamingCount)
Sets the number of samples in each stream block.

Parameters:
streamingCount - the number of samples in each subsequent FSSoundStreamBlock object.

getLatency

public int getLatency()
For MP3 encoded sounds, returns the number of samples to skip when starting to play a sound.

Returns:
the number of samples skipped in an MP3 encoded sound Returns 0 for other sound formats.

setLatency

public void setLatency(int latency)
Set the number of samples to skip when starting to play an MP3 encoded sound.

Parameters:
latency - the number of samples to be skipped in an MP3 encoded sound should be 0 for other sound formats.

equals

public boolean equals(java.lang.Object anObject)
Description copied from class: FSMovieObject
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 FSMovieObject
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.

Overrides:
appendDescription in class FSMovieObject
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)
Overrides:
length in class FSMovieObject

encode

public void encode(FSCoder coder)
Overrides:
encode in class FSMovieObject

decode

public void decode(FSCoder coder)
Overrides:
decode in class FSMovieObject