libsswf: sswf::Envelope Class Reference

# sswf::Envelope Class Reference

An array of volumes for a sound effect. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::Envelope:

List of all members.

## Public Member Functions
| Envelope (const Envelope &envelope)
| Copy an envelope in another one.
| Envelope (unsigned long p, unsigned short l, unsigned short r)
| Initializes an envelope.
unsigned short | Left (void) const
| Retrieve the volume for the left side.
unsigned long | Position (void) const
| Retrieve the position of this envelope.
unsigned short | Right (void) const
| Retrieve the volume for the right side.
void | Save (Data &data) const
| Save an envelope in a Data buffer.
## Private Attributes
unsigned short | f_left
unsigned long | f_position
unsigned short | f_right

## Detailed Description

This class is used to defined volume changes to be used against a sound effect or music.

This is useful if you have several places where you want to place the same sound at different volume levels.

Warning:
  The volume goes from 0 to 32768. Larger values have an undefined result.

See also:
  sswf::SoundInfo

  SWF Alexis' Reference—swf_envelope

## Constructor & Destructor Documentation

Envelope::Envelope | ( | unsigned long | p,
|  | unsigned short | l,
|  | unsigned short | r |
| ) |  |  |

The constructor initializes an envelope with a position and the volume on the left and right sides. If the sound is not stereo, the volume of both sides should be set to the same value.

The left and right volumes go from 0 (mute) to 32768 (max. power). The effect of using values outside this range is undefined.

The position is always defined as if the rate of the sound was 44,100k. So you need to multiply all positions by some value to obtain the correct envelope position.

So, if the rate of the sound is defined a R, the factor you need to use is:

44,100 / rate

In other words:

> rate | factor
> --- | ---
> 5,512 | 8
> 11,025 | 4
> 22,050 | 2
> 44,100 | 1

Also, positions need to be defined between the start and stop positions of the corresponding sswf::SoundInfo (see the sswf::SoundInfo::SetRange(unsigned long start, unsigned long end) function.)

Note that the volume is clamped to the range 0 to 32768.

Bug:
  The Envelope does not know whether the sound it will affect is stereo or mono. This may not be a problem with newer versions of the Macromedia players.

Parameters:

  `[in]` | p | The position where the new volume applies
  `[in]` | l | The volume on the left side (0 to 32768)
  `[in]` | r | The volume on the left side (0 to 32768)

See also:
  sswf::Envelope::Envelope(const Envelope& envelope)

  sswf::SoundInfo

  sswf::SoundInfo::SetRange(unsigned long start, unsigned long end)

  sswf::TagStartSound

  sswf::TagSound

References f_left, f_position, and f_right.

Envelope::Envelope | ( | const Envelope & | envelope | ) |

This function can be used to copy an envelope in another.

See also:
  sswf::Envelope::Envelope(unsigned long p, unsigned short l, unsigned short r)

References f_left, f_position, and f_right.

## Member Function Documentation

unsigned short Envelope::Left | ( | void |  | ) | const

This function returns the volume for the left side.

Returns:
  The left side volume

References f_left.

unsigned long Envelope::Position | ( | void |  | ) | const

This function returns the position of the this envelope.

Returns:
  The position of the envelope

References f_position.

Referenced by sswf::SoundInfo::AddEnvelope().

unsigned short Envelope::Right | ( | void |  | ) | const

This function returns the volume for the right side.

Returns:
  The right side volume

References f_right.

void Envelope::Save | ( | Data & | data | ) | const

This function is used to save an envelope as the SWF player expects. It saves the position, left and then right volumes.

Parameters:

  `[in]` | data | The Data buffer where the envelope is to be saved

References f_left, f_position, f_right, sswf::Data::PutLong(), and sswf::Data::PutShort().

## Member Data Documentation

unsigned short sswf::Envelope::f_left`[private]`

Referenced by Envelope(), Left(), and Save().

unsigned long sswf::Envelope::f_position`[private]`

Referenced by Envelope(), Position(), and Save().

unsigned short sswf::Envelope::f_right`[private]`

Referenced by Envelope(), Right(), and Save().

The documentation for this class was generated from the following files:

- libsswf.h
- libsswf_tag_sound.c++