BaseSound Class Reference

#include <c4d_basesound.h>

Inheritance diagram for BaseSound:

Detailed Description

Cinema 4D sound object.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 BaseSound ()
 
 ~BaseSound ()
 

Alloc/Free

static BaseSoundAlloc ()
 
static void Free (BaseSound *&v)
 

Clone/Copy

BaseSoundGetClone ()
 
BaseSoundGetClonePart (const BaseTime &start, const BaseTime &stop, Bool reverse)
 
Bool CopyTo (BaseSound *dest)
 

Miscellaneous

Bool Init (Int sample_cnt, Float frequency, Int32 channel_cnt)
 
void FlushAll ()
 
BaseBitmapGetBitmap (Int32 width, Int32 height, const BaseTime &start, const BaseTime &stop)
 
BaseBitmapGetBitmap (Int32 width, Int32 height, const BaseTime &start, const BaseTime &stop, const Vector &draw_col, const Vector &back_col)
 
GeListHeadGetMarkerRoot ()
 
void GetSoundInfo (GeSndInfo *info) const
 

Load/Save

Bool Load (const Filename &fn)
 
Bool Save (const Filename &fn)
 

Get/Set Sample

void GetSampleEx (Int32 i, SDataEx *data)
 
void SetSampleEx (Int32 i, const SDataEx &data)
 

Write/Read

Bool WriteIt (HyperFile *hf)
 
Bool ReadIt (HyperFile *hf, Int32 level)
 

Additional Inherited Members

- Public Member Functions inherited from C4DAtom
Int32 GetType () const
 
Int32 GetRealType () const
 
Int32 GetDiskType () const
 
Bool IsInstanceOf (Int32 id) const
 
Int32 GetClassification () const
 
Bool Message (Int32 type, void *data=nullptr)
 
Bool MultiMessage (MULTIMSG_ROUTE flags, Int32 type, void *data)
 
C4DAtomGetClone (COPYFLAGS flags, AliasTrans *trn)
 
Bool CopyTo (C4DAtom *dst, COPYFLAGS flags, AliasTrans *trn)
 
Bool Read (HyperFile *hf, Int32 id, Int32 level)
 
Bool Write (HyperFile *hf)
 
Bool ReadObject (HyperFile *hf, Bool readheader)
 
Bool WriteObject (HyperFile *hf)
 
Bool GetDescription (Description *description, DESCFLAGS_DESC flags)
 
Bool GetParameter (const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
 
Bool SetParameter (const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
 
DynamicDescriptionGetDynamicDescription ()
 
Bool GetEnabling (const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)
 
Bool TranslateDescID (const DescID &id, DescID &res_id, C4DAtom *&res_at)
 
UInt32 GetDirty (DIRTYFLAGS flags) const
 
void SetDirty (DIRTYFLAGS flags)
 
UInt32 GetHDirty (HDIRTYFLAGS mask) const
 
void SetHDirty (HDIRTYFLAGS mask)
 

Constructor & Destructor Documentation

◆ BaseSound()

BaseSound ( )
private

◆ ~BaseSound()

~BaseSound ( )
private

Member Function Documentation

◆ Alloc()

static BaseSound* Alloc ( )
static

Allocates a sound object. Destroy the allocated sound object with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated sound object, or nullptr if the allocation failed.

◆ Free()

static void Free ( BaseSound *&  v)
static

Destructs sound objects allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]vThe sound object to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetClone()

BaseSound* GetClone ( )

Creates a copy of a BaseSound object.

Returns
The cloned sound object, or nullptr if failed. The caller owns the pointed sound object.

◆ GetClonePart()

BaseSound* GetClonePart ( const BaseTime start,
const BaseTime stop,
Bool  reverse 
)

Clones a part of the sound object.

Parameters
[in]startThe start time of the cloned part.
[in]stopThe end time of the cloned part.
[in]reversetrue to revert the cloned part.
Returns
The cloned part of the sound object, or nullptr if failed. The caller owns the pointed sound object.

◆ CopyTo()

Bool CopyTo ( BaseSound dest)

Copy the settings from the object to another BaseSound object.

Parameters
[out]destThe sound object to copy to. The caller owns the pointed sound object.
Returns
true if successful, otherwise false.

◆ Init()

Bool Init ( Int  sample_cnt,
Float  frequency,
Int32  channel_cnt 
)

Creates a sound object and allocates memory for it from the given parameters.

Parameters
[in]sample_cntThe number of samples.
[in]frequencyThe sample frequency.
[in]channel_cntThe number of sound channels.
Returns
true if successful, otherwise false.

◆ FlushAll()

void FlushAll ( )

Frees all resources allocated for the sound object and sets the state to the same as after Alloc().

◆ GetBitmap() [1/2]

BaseBitmap* GetBitmap ( Int32  width,
Int32  height,
const BaseTime start,
const BaseTime stop 
)

Gets the bitmap with the graph of the sound.

Parameters
[in]widthThe number of pixels wide to create the bitmap.
[in]heightThe number of pixels high to create the bitmap.
[in]startThe starting time for the leftmost position in the graph.
[in]stopThe end time that should be displayed at the rightmost position in the graph.
Returns
The bitmap of the sounds graph, or nullptr if failed. The caller owns the pointed bitmap.

◆ GetBitmap() [2/2]

BaseBitmap* GetBitmap ( Int32  width,
Int32  height,
const BaseTime start,
const BaseTime stop,
const Vector draw_col,
const Vector back_col 
)

Gets the bitmap with the graph of the sound.

Parameters
[in]widthThe number of pixels wide to create the bitmap.
[in]heightThe number of pixels high to create the bitmap.
[in]startThe starting time for the leftmost position in the graph.
[in]stopThe end time that should be displayed at the rightmost position in the graph.
[in]draw_colThe draw color.
[in]back_colThe background color.
Returns
The bitmap of the sounds graph, or nullptr if failed. The caller owns the pointed bitmap.

◆ GetMarkerRoot()

GeListHead* GetMarkerRoot ( )

Private.

◆ GetSoundInfo()

void GetSoundInfo ( GeSndInfo info) const

Retrieves the sound information data of the sound object.

Parameters
[out]infoAssigned the sound information. The caller owns the pointed sound information.

◆ Load()

Bool Load ( const Filename fn)

Loads an audio file.

Note
Currently only the WAV file format is supported.
Parameters
[in]fnThe name of the file to load.
Returns
true if successful, otherwise false.

◆ Save()

Bool Save ( const Filename fn)

Saves a sound to an audio file.

Note
Currently only the WAV file format is supported.
Parameters
[in]fnThe name of the file to save.
Returns
true if successful, otherwise false.

◆ GetSampleEx()

void GetSampleEx ( Int32  i,
SDataEx data 
)

Retrieves a sample at a given sample offset.

Note
If the sound is mono then SDataEx::r will be set to the same value as SDataEx::l.
If the sound is 8-bit then the samples will be scaled to 16-bit so the values are always in the range -32768 to +32767.
Parameters
[in]iThe sample position to get the sample from.
[out]dataAssigned the sample data. The caller owns the pointed sample data.

◆ SetSampleEx()

void SetSampleEx ( Int32  i,
const SDataEx data 
)

Sets a sample at a given position in the sound.

Note
If the sound is mono then the sample is set to the average value of the left and right samples set in SDataEx, (SDataEx::l+ SDataEx::r)/2.
If the sound is 8-bit then the values will be scaled from the 16-bit values set in SDataEx.
Parameters
[in]iThe sample position to set.
[in]dataThe sample data to put into the sound.

◆ WriteIt()

Bool WriteIt ( HyperFile hf)

Writes the sound to a hyper file.

Parameters
[in]hfThe hyper file to write to. The caller owns the pointed hyper file.
Returns
true if successful, otherwise false.

◆ ReadIt()

Bool ReadIt ( HyperFile hf,
Int32  level 
)

Reads the sound from a hyper file.

Parameters
[in]hfThe hyper file to read from. The caller owns the pointed hyper file.
[in]levelThe disklevel of the sound to read.
Returns
true if successful, otherwise false.