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 FSDefineSound

    java.lang.Object
      com.flagstone.transform.FSTransformObject
          com.flagstone.transform.FSMovieObject
              com.flagstone.transform.FSDefineObject
                  com.flagstone.transform.FSDefineSound

All Implemented Interfaces:
  java.lang.Cloneable

    public class FSDefineSound

extends FSDefineObject

FSDefineSound is used to define a sound that will be played when a given event occurs.

Three different types of object are used to play an event sound:

- The FSDefineSound object that contains the sampled sound.
- A FSSound object that defines how the sound fades in and out, whether it repeats and also defines an envelope for more sophisticated control over how the sound is played.
- A FSStartSound object that signals the Flash Player to begin playing the sound.

An FSDefineSound object contains the following attributes:

Attributes
type | Identifies the data structure when it is encoded. Read-only.
identifier | An unique identifier for this object in the range 1..65535.
format | The format of the sound data - FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.PCM or FSDefineSound.NELLYMOSER
playbackRate | The rate the sound will be played in Hertz: 5512, 11025, 22050 or 44100
playbackChannels | The number of channels in the sound, typically 1 (mono) or 2 (stereo).
playbackSampleSize | The number of bytes in a sample: 1 or 2.
sampleCount | The number of samples in the sound.
soundLength | The number of bytes in the sound data.
sound | The encoded sound data.

Five 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 - compressed MPEG Audio Layer-3.
- NELLYMOSER - compressed Nellymoser Asao format supporting low bit-rate sound for improving synchronisation between the sound and frame rate of movies.

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

# History

The FSDefineSound class represents the DefineSound structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1. Flash 3 added support for MP3 and the Nellymoser Asao format was added in Flash 6.

Field Summary

Fields inherited from class com.flagstone.transform.FSDefineObject
`identifier`

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
`FSDefineSound(FSCoder coder)` Construct an FSDefineSound object, initalising it with values decoded from an encoded object.
`FSDefineSound(FSDefineSound obj)` Constructs an FSDefineSound object by copying values from an existing object.
`FSDefineSound(int anIdentifier, int aFormat, int rate, int channels, int sampleSize, int count, byte[] bytes)` Constructs an FSDefineSound object specifying the unique identifier and all the parameters required to describe 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.
`java.lang.Object` | `clone()` Creates a deep copy of the entire object.
`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 compression format used, either FSSound.NATIVE_PCM, FSSound.PCM or FSSound.ADPCM (all Flash 1), FSSound.MP3 (Flash 4+) or FSSound.NELLYMOSER (Flash 6+).
`int` | `getPlaybackChannels()` Gets the number of sound channels, 1 (Mono) or 2 (Stereo).
`int` | `getPlaybackRate()` Gets the rate at which the sound will be played, in Hz: 5512, 11025, 22050 or 44100.
`int` | `getPlaybackSampleSize()` Gets the size of an uncompressed sample in bytes.
`int` | `getSampleCount()` Gets the number of samples in the sound data.
`byte[]` | `getSoundData()` Gets the sound data.
`int` | `length(FSCoder coder)`
`void` | `setFormat(int encoding)` Sets the compression format used, either FSSound.NATIVE_PCM, FSSound.ADPCM or FSSound.PCM from Flash 1 onwards, FSSound.MP3 from Flash 4 onwards, or FSSound.NELLYMOSER from Flash 6 onwards.
`void` | `setPlaybackChannels(int channels)` Sets the number of channels defined in the sound.
`void` | `setPlaybackRate(int rate)` Sets the sampling rate in Hertz.
`void` | `setPlaybackSampleSize(int sampleSize)` Sets the sample size in bytes.
`void` | `setSampleCount(int count)` Sets the number of samples in the sound data.
`void` | `setSoundData(byte[] bytes)` Sets the sound data.

Methods inherited from class com.flagstone.transform.FSDefineObject
`getIdentifier, setIdentifier`

Methods inherited from class com.flagstone.transform.FSMovieObject
`getType`

Methods inherited from class com.flagstone.transform.FSTransformObject
`name, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### FSDefineSound

    public FSDefineSound(FSCoder coder)

  Construct an FSDefineSound object, initalising it with values decoded from an encoded object.

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

### FSDefineSound

    public FSDefineSound(int anIdentifier,
                         int aFormat,
                         int rate,
                         int channels,
                         int sampleSize,
                         int count,
                         byte[] bytes)

  Constructs an FSDefineSound object specifying the unique identifier and all the parameters required to describe the sound.

  Parameters:
    `anIdentifier` - the unique identifier for this sound.
    `aFormat` - the encoding format for the sound. For Flash 1 the formats may be FSSound.NATIVE_PCM, FSSound.PCM or FSSound.ADPCM. For Flash 4 or later include FSSound.MP3 and Flash 6 or later include FSSound.NELLYMOSER.
    `rate` - the number of samples per second that the sound is played at , either 5512, 11025, 22050 or 44100.
    `channels` - the number of channels in the sound, either 1 (Mono) or 2 (Stereo).
    `sampleSize` - the size of an uncompressed sound sample in bits, either 8 or 16.
    `count` - the number of samples in the sound data.
    `bytes` - the sound data.

### FSDefineSound

    public FSDefineSound(FSDefineSound obj)

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

  Parameters:
    `obj` - an FSDefineSound object.

Method Detail

### getFormat

    public int getFormat()

  Gets the compression format used, either FSSound.NATIVE_PCM, FSSound.PCM or FSSound.ADPCM (all Flash 1), FSSound.MP3 (Flash 4+) or FSSound.NELLYMOSER (Flash 6+).

  Returns:
    a constant defining the type of compression.

### getPlaybackRate

    public int getPlaybackRate()

  Gets the rate at which the sound will be played, in Hz: 5512, 11025, 22050 or 44100.

  Returns:
    the rate at which the sound was sampled.

### getPlaybackChannels

    public int getPlaybackChannels()

  Gets the number of sound channels, 1 (Mono) or 2 (Stereo).

  Returns:
    the number of channels.

### getPlaybackSampleSize

    public int getPlaybackSampleSize()

  Gets the size of an uncompressed sample in bytes.

  Returns:
    the number of bytes per sample when the sound is uncompressed.

### getSampleCount

    public int getSampleCount()

  Gets the number of samples in the sound data.

  Returns:
    the number of sound samples.

### getSoundData

    public byte[] getSoundData()

  Gets the sound data.

  Returns:
    an array of bytes containing the sampled sound.

### setFormat

    public void setFormat(int encoding)

  Sets the compression format used, either FSSound.NATIVE_PCM, FSSound.ADPCM or FSSound.PCM from Flash 1 onwards, FSSound.MP3 from Flash 4 onwards, or FSSound.NELLYMOSER from Flash 6 onwards.

  Parameters:
    `encoding` - the format for the sound.

### setPlaybackRate

    public void setPlaybackRate(int rate)

  Sets the sampling rate in Hertz. Must be one of: 5512, 11025, 22050 or 44100.

  Parameters:
    `rate` - the rate at which the sounds is played in Hz.

### setPlaybackChannels

    public void setPlaybackChannels(int channels)

  Sets the number of channels defined in the sound.

  Parameters:
    `channels` - the number of channels in the sound, either 1 (Mono) or 2 (Stereo).

### setPlaybackSampleSize

    public void setPlaybackSampleSize(int sampleSize)

  Sets the sample size in bytes. Must be either 1 or 2.

  Parameters:
    `sampleSize` - the size of sound samples in bytes.

### setSampleCount

    public void setSampleCount(int count)

  Sets the number of samples in the sound data.

  Parameters:
    `count` - the number of samples for the sound.

### setSoundData

    public void setSoundData(byte[] bytes)

  Sets the sound data.

  Parameters:
    `bytes` - the sound data.

### clone

    public java.lang.Object clone()

  Description copied from class: `FSTransformObject`
  Creates a deep copy of the entire object.

  Overrides:
    `clone` in class `FSTransformObject`
  Returns:
    a copy of the object.

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

### encode

    public void encode(FSCoder coder)

  Overrides:
    `encode` in class `FSDefineObject`

### decode

    public void decode(FSCoder coder)

  Overrides:
    `decode` in class `FSDefineObject`

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