EMIPLIB
Public Member Functions | Protected Member Functions

MIPAudio3DBase Class Reference

Base class for 3D audio components. More...

#include <mipaudio3dbase.h>

Inheritance diagram for MIPAudio3DBase:
Inheritance graph
[legend]
Collaboration diagram for MIPAudio3DBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void setRightHanded (bool f=true)
 Changes between left and right handed coordinate systems.
bool setSourcePosition (uint64_t sourceID, real_t pos[3])
 Set the position of a particular source.
bool setOwnPosition (real_t pos[3], real_t frontDirection[3], real_t upDirection[3])
 Store your own position and orientation.
void setDistanceFactor (real_t distFact)
 Set a scale factor for calculated distances.

Protected Member Functions

 MIPAudio3DBase (const std::string &compName)
 Constructor to be used by derived classes.
void cleanUp ()
 Cleans the table of source positions, resets your own position, etc.
void expirePositionalInfo ()
 Remove old entries from the source table.
bool getPositionalInfo (uint64_t sourceID, real_t *azimuth, real_t *elevation, real_t *distance)
 Obtain relative positional information for a specific source.
void convolve (float *pDestStereo, int numDestFrames, float scale, const float *pSrcMono, int numSrcFrames, const float *pLeftFilter, int numLeftFrames, const float *pRightFilter, int numRightFrames)
 Performs a convolution.

Detailed Description

This class provides some functions for 3D audio components. You can set the position of a source and your own position and orientation. The distance unit is assumed to be one meter, but if your application works on a different scale, a scale factor can be installed to compensate. Finally, the class provides an implementation of the convolution product.


Constructor & Destructor Documentation

MIPAudio3DBase::MIPAudio3DBase ( const std::string &  compName) [protected]

Member Function Documentation

void MIPAudio3DBase::cleanUp ( ) [protected]
void MIPAudio3DBase::convolve ( float *  pDestStereo,
int  numDestFrames,
float  scale,
const float *  pSrcMono,
int  numSrcFrames,
const float *  pLeftFilter,
int  numLeftFrames,
const float *  pRightFilter,
int  numRightFrames 
) [inline, protected]

Using this function, a convolution product can be calculated to obtain a 3D effect.

Parameters:
pDestStereoAn array in which the calculated stereo sound will be stored.
numDestFramesThe number of frames which can fit in the destination array.
scaleA scale factor with which the left and right filters should be multilied.
pSrcMonoThe mono input sound.
numSrcFramesThe number of input frames.
pLeftFilterThe filter data for the left channel.
numLeftFramesThe number of frames in the left channel filter.
pRightFilterThe filter data for the right channel.
numRightFramesThe number of frames in the right channel filter.
void MIPAudio3DBase::expirePositionalInfo ( ) [protected]

Using this function, old entries can be removed from the source table. Only when one minute has passed since the last check, a new check is performed.

bool MIPAudio3DBase::getPositionalInfo ( uint64_t  sourceID,
real_t *  azimuth,
real_t *  elevation,
real_t *  distance 
) [protected]

Based on the position of the source with ID sourceID and your own positional information, the azimuth, elevation and distance are calculated. The meaning of azimuth and elevation are illustrated in the following figure:

sound3d.png
void MIPAudio3DBase::setDistanceFactor ( real_t  distFact) [inline]

With this function, you can set a scale factor to convert distances in your application to distances which can be interpreted in units of meters.

bool MIPAudio3DBase::setOwnPosition ( real_t  pos[3],
real_t  frontDirection[3],
real_t  upDirection[3] 
)

Using this function, you can store information about your own position and orientation. The frontDirection and upDirection vectors need not be orthogonal and need not be normalized.

void MIPAudio3DBase::setRightHanded ( bool  f = true) [inline]

By default, a left handed OpenGL-like coordinate system is used. Using this function you can change this behavior.

bool MIPAudio3DBase::setSourcePosition ( uint64_t  sourceID,
real_t  pos[3] 
)

Using this function, the position of a particular source is stored in a table. Note that entries older than one minute are deleted from the table, so the function should be called on a regular basis, even if the source is not moving.


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