Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.flagstone.transform
Class FSSoundStreamHead

    java.lang.Object
      com.flagstone.transform.FSTransformObject
          com.flagstone.transform.FSMovieObject
              com.flagstone.transform.FSSoundStreamHead

All Implemented Interfaces:
  java.lang.Cloneable

    public class FSSoundStreamHead

extends FSMovieObject

FSSoundStreamHead defines the format of a streaming sound, identifying the encoding scheme, the rate at which the sound will be played and the size of the decoded samples.

The actual sound is streamed used the FSSoundStreamBlock class which contains the data for each frame in a movie.

Attributes
type | Identifies the data structure when it is encoded. Read-only.
format | The format of the encoded sound data - FSSound.PCM (Little0endian byte order), FSSound.ADPCM, or FSSound.NATIVE_PCM (Big-endian or Little-Endian byte order depending on the platform where the sound was generated.).
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 rate at which the streaming sound was samples - 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 FSSoundStreamBlock object.
latency | Latency defines the number of samples to skip only when playing sounds encoded with the MP3 format.

Four encoded formats for the sound data are supported:

- NATIVE_PCM - uncompressed Pulse Code Modulated: samples are either 1 or 2 bytes. For two-byte samples the byte order is dependent on the platform on which the Flash Player is hosted. Sounds created on a platform which supports big-endian byte order will not be played correctly when listened to on a platform which supports little-endian byte order.
- PCM - uncompressed Pulse Code Modulated: samples are either 1 or 2 bytes with the latter presented in Little-Endian byte order. This ensures that sounds can be played across different platforms.
- ADPCM - compressed ADaptive Pulse Code Modulated: samples are encoded and compressed by comparing the difference between successive sound sample which dramatically reduces the size of the encoded sound when compared to the uncompressed PCM formats. Use this format whenever possible.
- MP3 - MPEG Layer 3 encoded sound.

Constants representing the different formats are defined in the FSSound class.

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. The different sets of attributes that identify how the sound will be played compared to the way it was encoded 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 FSSoundStreamHead class represents the SoundStreamHead structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.

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
`FSSoundStreamHead(FSCoder coder)` Construct an FSSoundStreamHead object, initialising it with values decoded from an encoded object.
`FSSoundStreamHead(FSSoundStreamHead obj)` Constructs an FSSoundStreamHead object by copying values from an existing object.
`FSSoundStreamHead(int playRate, int playChannels, int playSize, int streamingRate, int streamingChannels, int streamingSize, int streamingCount, int latency)` Constructs an FSSoundStreamHead 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

### FSSoundStreamHead

    public FSSoundStreamHead(FSCoder coder)

  Construct an FSSoundStreamHead object, initialising it with values decoded from an encoded object.

  Parameters:
    `coder` - an FSCoder containing the binary data.

### FSSoundStreamHead

    public FSSoundStreamHead(int playRate,
                             int playChannels,
                             int playSize,
                             int streamingRate,
                             int streamingChannels,
                             int streamingSize,
                             int streamingCount,
                             int latency)

  Constructs an FSSoundStreamHead object specifying all the parameters required to define the sound.

  Parameters:
    `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 in bytes, either 1 or 2.
    `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.

### FSSoundStreamHead

    public FSSoundStreamHead(FSSoundStreamHead obj)

  Constructs an FSSoundStreamHead object by copying values from an existing object.

  Parameters:
    `obj` - an FSSoundStreamHead object.

Method Detail

### getFormat

    public int getFormat()

  Gets the streaming sound format. For the FSSoundStreamHead class supports ADPCM or MP3 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.ADPCM or FSSound.MP3.

### 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`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD