sswf::TagSound Class Reference

#include <libsswf.h>

Inheritance diagram for sswf::TagSound:

sswf::TagBaseID sswf::TagBase sswf::MemoryManager List of all members.

Public Types

 SOUND_ENDIAN_BIG
 SOUND_ENDIAN_DONTUSE
 SOUND_ENDIAN_LITTLE = 0
 SOUND_ENDIAN_SAME
enum  sound_endian_t {
  SOUND_ENDIAN_LITTLE = 0, SOUND_ENDIAN_BIG, SOUND_ENDIAN_SAME, SOUND_ENDIAN_DONTUSE,
  SOUND_ENDIAN_UNKNOWN
}
 SOUND_ENDIAN_UNKNOWN
 SOUND_FORMAT_ADPCM = 1
 SOUND_FORMAT_MP3 = 2
 SOUND_FORMAT_NELLYMOSER = 6
 SOUND_FORMAT_RAW = 0
enum  sound_format_t {
  SOUND_FORMAT_UNKNOWN = -1, SOUND_FORMAT_RAW = 0, SOUND_FORMAT_ADPCM = 1, SOUND_FORMAT_MP3 = 2,
  SOUND_FORMAT_UNCOMPRESSED = 3, SOUND_FORMAT_NELLYMOSER = 6
}
 SOUND_FORMAT_UNCOMPRESSED = 3
 SOUND_FORMAT_UNKNOWN = -1

Public Member Functions

size_t GetSamplesCount (void) const
virtual ErrorManager::error_code_t Save (Data &data)
 Pre-save all the children tags of this tag.
void Set8Bits (void)
int SetData (const void *data, size_t size, sound_endian_t endian, int width, unsigned int rate, bool stereo)
int SetFilename (const char *filename)
void SetFormat (sound_format_t format)
void SetMono (void)
 TagSound (TagBase *parent)
virtual swf_type_t TypeFlags (void) const
 Retrieve a set of flags desribing the type of the tag.

Static Public Attributes

static const int g_sound_rates [4] = { 5512, 11025, 22050, 44100 }

Private Member Functions

int CheckMP3Header (FILE *f, unsigned char *header, int &frame_size)
int LoadMP3File (FILE *f)
int LoadWaveFile (FILE *f)
virtual ErrorManager::error_code_t PreSave (void)
 Pre-save all the children tags of this tag.
int ReadMP3Header (FILE *f, unsigned char *header)
short ReadSample (const unsigned char *data, unsigned short adjust, int in_fmt)
void Resample (unsigned char *snd, unsigned int out_bytes, const unsigned char *src, size_t size, unsigned int in_bytes, size_t max, double fix, unsigned short adjust, int in_fmt)

Private Attributes

unsigned char * f_data
int f_data_maxsize
int f_data_size
sound_format_t f_format
int f_latency_seek
int f_rate
size_t f_samples
bool f_stereo
int f_width

Static Private Attributes

static const int g_bitrates [2][16]
static const int g_frequencies [4][4]

Classes

struct  sound_wave_t

Member Enumeration Documentation

enum sswf::TagSound::sound_endian_t

Enumerator:
SOUND_ENDIAN_LITTLE 
SOUND_ENDIAN_BIG 
SOUND_ENDIAN_SAME 
SOUND_ENDIAN_DONTUSE 
SOUND_ENDIAN_UNKNOWN 

enum sswf::TagSound::sound_format_t

Enumerator:
SOUND_FORMAT_UNKNOWN 
SOUND_FORMAT_RAW 
SOUND_FORMAT_ADPCM 
SOUND_FORMAT_MP3 
SOUND_FORMAT_UNCOMPRESSED 
SOUND_FORMAT_NELLYMOSER 


Constructor & Destructor Documentation

TagSound::TagSound ( TagBase parent  ) 


Member Function Documentation

int TagSound::CheckMP3Header ( FILE *  f,
unsigned char *  header,
int &  frame_size 
) [private]

size_t TagSound::GetSamplesCount ( void   )  const

int TagSound::LoadMP3File ( FILE *  f  )  [private]

int TagSound::LoadWaveFile ( FILE *  f  )  [private]

ErrorManager::error_code_t TagSound::PreSave ( void   )  [private, virtual]

This function calls the PreSave() function of all the children unless one returns a non-zero value in which case that value will be returned and the process stopped.

This function is aumatically called by the TagHeader and TagSprite in order to pre-save their children.

The PreSave() functions are expected to be used to test whether a tag can be saved. Especially, most tags will call the MinimumVersion() function with the version required to save these tags. This ensures that you can save the entire movie in a valid SWF. Please, see the reference of each tag for more information about what their PreSave() function does.

You should not have to call this function directly.

Returns:
Zero if the PreSave() succeeds; non-zero otherwise

Reimplemented from sswf::TagBase.

int TagSound::ReadMP3Header ( FILE *  f,
unsigned char *  header 
) [private]

short TagSound::ReadSample ( const unsigned char *  data,
unsigned short  adjust,
int  in_fmt 
) [private]

void TagSound::Resample ( unsigned char *  snd,
unsigned int  out_bytes,
const unsigned char *  src,
size_t  size,
unsigned int  in_bytes,
size_t  max,
double  fix,
unsigned short  adjust,
int  in_fmt 
) [private]

ErrorManager::error_code_t TagSound::Save ( Data data  )  [virtual]

The Save() function is the one you want to call to save an SWF movie.

You may use the Save() on any tag, however, if you do so you need to properly initialize the system. For that purpose, you may want to look at the code in the TagHeader::Save(Data& data) function.

Otherwise, you simply have to call the Save() function of the TagHeader. That will save the entire movie with the smallest possible version (or fail if something cannot be saved with the present parameters.)

The TagHeader::Save() function first calls the PreSave() functions, the PreSave2ndPass() and then the Save() functions of all the children.

The other tag Save() function simply save the tag within the specified Data buffer. Note however that the TagSprite will also call the Save() function of all of its children. Yet it does not call the PreSave() functions.

The Save() function saves the movie in a Data buffer. Later you need to save that buffer on disk or some other medium.

Returns:
Zero when the Save() succeeds, non-zero if it fails
See also:
TagBase::PreSave()

TagBase::PreSave2ndPass()

Implements sswf::TagBase.

void TagSound::Set8Bits ( void   ) 

int TagSound::SetData ( const void *  data,
size_t  size,
sound_endian_t  endian,
int  width,
unsigned int  rate,
bool  stereo 
)

int TagSound::SetFilename ( const char *  filename  ) 

void TagSound::SetFormat ( sound_format_t  format  ) 

void TagSound::SetMono ( void   ) 

TagBase::swf_type_t TagSound::TypeFlags ( void   )  const [virtual]

This function returns some flags that can be used to know where to place a tag in a movie, whether a tag is unique, etc.

If a tag has specifics which are not described here, it often can be checked using its name and special handling.

The existing flags are:

SWF_TYPE_DEFINE This is a definition tag (Sprite, Shape...)

SWF_TYPE_CONTROL This is a control tag (ShowFrame, PlaceObject...)

SWF_TYPE_UNIQUE This can be used once throughout the whole movie

SWF_TYPE_START This tag should be at the start of the movie

SWF_TYPE_ONE At most one per frame

SWF_TYPE_REFERENCE This tag references another

SWF_TYPE_HAS_ID This tag has an identifier

SWF_TYPE_SCRIPT This object can accept action scripts

SWF_TYPE_SPRITE This is a sprite (can include other tags)

SWF_TYPE_HEADER The header object

Note:
These flags are constant (actually hard coded!) and will not change between calls. They even rarely change between versions.
Returns:
The set of flags for the given tag
See also:
sswf::TagBase::Name(void) const

Implements sswf::TagBase.


Member Data Documentation

unsigned char* sswf::TagSound::f_data [private]

int sswf::TagSound::f_data_maxsize [private]

int sswf::TagSound::f_data_size [private]

sound_format_t sswf::TagSound::f_format [private]

int sswf::TagSound::f_latency_seek [private]

int sswf::TagSound::f_rate [private]

size_t sswf::TagSound::f_samples [private]

bool sswf::TagSound::f_stereo [private]

int sswf::TagSound::f_width [private]

const int TagSound::g_bitrates [static, private]

Initial value:

{
        { -1, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 },
        { -1, 8,  16, 24, 32, 40, 48, 56,  64,  80,  96, 112, 128, 144, 160, -1 }
}

const int TagSound::g_frequencies [static, private]

Initial value:

{
        { 11025, -1, -1, -1 },
        {    -1, -1, -1, -1 },
        { 22050, -1, -1, -1 },
        { 44100, -1, -1, -1 }
}

const int TagSound::g_sound_rates = { 5512, 11025, 22050, 44100 } [static]


The documentation for this class was generated from the following files:
Generated on Sun May 13 23:29:41 2007 for libsswf by  doxygen 1.4.7