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 FSAudioData

    java.lang.Object
      com.flagstone.transform.FSVideoObject
          com.flagstone.transform.FSAudioData

All Implemented Interfaces:
  java.lang.Cloneable

    public final class FSAudioData

extends FSVideoObject

FSAudioData is used to define sounds for a Flash Video (flv) file. It is similar in function to the FSDefineSound class.

Attributes
timestamp | The time in milliseconds at which the sound will be played. The timestamp is used exclusively for determining when sound or video will be played. Any internal timing information in the audio or video data is ignored.
format | The format of the sound data - NATIVE_PCM, ADPCM, MP3, NELLYMOSER_8K or NELLYMOSER.
playbackRate | The rate the sound will be played in Hertz: 5512, 11025, 22050 or 44100. Note: sounds encoded using the Nellymoser have a fixed playback rate of 8KHz.
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.
sound | The sampled 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.
- 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 or MP3 whenever possible.
- MP3 - compressed MPEG Audio Layer-3.
- NELLYMOSER_8K - compressed Nellymoser Asao format at 8KHz supporting low bit-rate sound for improved synchronisation between the sound and frame rate of movies. This format is not supported in SWF files.
- NELLYMOSER - compressed Nellymoser Asao format supporting low bit-rate sound for improved synchronisation between the sound and frame rate of movies.

# History The FSAudioData class represents the FLV Tag with the Audio Data section from Macromedia's Flash (SWF) File Format Specification. It was added in Flash Video 1.

Field Summary

Fields inherited from class com.flagstone.transform.FSVideoObject
`AudioData, length, MetaData, timestamp, type, VideoData`

Constructor Summary
`FSAudioData(FSCoder coder)` Construct an FSAudioData object and initialise it from encoded data.
`FSAudioData(int timestamp, int aFormat, int rate, int channels, int sampleSize, byte[] bytes)` Constructs an FSAudioData object specifying the parameters required to describe the sound.

Method Summary
`void` | `appendDescription(java.lang.StringBuffer buffer, int depth)`
`java.lang.Object` | `clone()` Creates a deep copy of the entire object.
`boolean` | `equals(java.lang.Object anObject)`
`int` | `getFormat()` Gets the compression format used, either FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.NELLYMOSER_8K or FSDefineSound.NELLYMOSER.
`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 Hertz: 5512, 11025, 22050 or 44100.
`int` | `getPlaybackSampleSize()` Gets the size of an uncompressed sample in bytes.
`byte[]` | `getSoundData()` Gets the sound data.
`void` | `setFormat(int encoding)` Sets the encoding format used, either FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.NELLYMOSER_8K or FSDefineSound.NELLYMOSER.
`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` | `setSoundData(byte[] bytes)` Sets the sound data.

Methods inherited from class com.flagstone.transform.FSVideoObject
`getTimestamp, getType, name, setTimestamp`

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

Constructor Detail

### FSAudioData

    public FSAudioData(FSCoder coder)

  Construct an FSAudioData object and initialise it from encoded data.

  Parameters:
    `coder` - an FSCoder object containing an FSAudioData encoded as binary data.

### FSAudioData

    public FSAudioData(int timestamp,
                       int aFormat,
                       int rate,
                       int channels,
                       int sampleSize,
                       byte[] bytes)

  Constructs an FSAudioData object specifying the parameters required to describe the sound.

  Parameters:
    `timestamp` - time in milliseconds from the start of the file that the sound will be played..
    `aFormat` - the encoding format for the sound, either FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.NELLYMOSER_8K or FSDefineSound.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 bytes, either 1 or 2.
    `bytes` - the sound data.

Method Detail

### getFormat

    public int getFormat()

  Gets the compression format used, either FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.NELLYMOSER_8K or FSDefineSound.NELLYMOSER.

  Returns:
    a constant defining the type of compression.

### setFormat

    public void setFormat(int encoding)

  Sets the encoding format used, either FSDefineSound.NATIVE_PCM, FSDefineSound.ADPCM, FSDefineSound.MP3, FSDefineSound.NELLYMOSER_8K or FSDefineSound.NELLYMOSER.

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

### getPlaybackRate

    public int getPlaybackRate()

  Gets the rate at which the sound will be played, in Hertz: 5512, 11025, 22050 or 44100. Note that the playback rate for NELLYMOSER_8K encoded audio is fixed at 8Khz so the playback rate attribute has no effect.

  Returns:
    the rate at which the sound was sampled.

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

### getPlaybackChannels

    public int getPlaybackChannels()

  Gets the number of sound channels, 1 (Mono) or 2 (Stereo). Both NELLYMOSER_8K and NELLYMOSER are encoded as mono so the playbackChannels attribute has no effect.

  Returns:
    the number of channels.

### 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).

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

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

### getSoundData

    public byte[] getSoundData()

  Gets the sound data.

  Returns:
    an array of bytes containing the sampled 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: `FSVideoObject`
  Creates a deep copy of the entire object.

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

### equals

    public boolean equals(java.lang.Object anObject)

  Overrides:
    `equals` in class `FSVideoObject`

### appendDescription

    public void appendDescription(java.lang.StringBuffer buffer,
                                  int depth)

  Overrides:
    `appendDescription` in class `FSVideoObject`

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