SAL
A C++ library for spatial audio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
sal::Microphone Class Referenceabstract

#include <microphone.h>

Inheritance diagram for sal::Microphone:
sal::AmbisonicsMic sal::MemorylessMic sal::MicrophoneArray sal::MonoMic sal::StereoMicrophone sal::MemorylessMonoMic sal::UniformArray< T > sal::MemorylessMonoMic sal::BinauralMic sal::GainMic sal::TanMic sal::TrigMic sal::CircularArray< T > sal::GainMic sal::TanMic sal::TrigMic sal::DatabaseBinauralMic sal::SphericalHeadMic

Public Member Functions

 Microphone (mcl::Point position, mcl::Quaternion orientation=mcl::Quaternion::Identity())
 
mcl::Point position () const noexcept
 
virtual void SetPosition (const mcl::Point &position) noexcept
 
mcl::Quaternion orientation () const noexcept
 
virtual void SetOrientation (const mcl::Quaternion &orientation) noexcept
 
void SetHandedness (const mcl::Handedness handedness) noexcept
 
void AddPlaneWave (const MonoBuffer &signal, const mcl::Point &point, Buffer &output_buffer) noexcept
 
void AddPlaneWave (const Sample *input_data, const Int num_samples, const mcl::Point &point, Buffer &output_buffer) noexcept
 
void AddPlaneWave (const Sample input_sample, const mcl::Point &point, Buffer &output_buffer) noexcept
 
void AddPlaneWave (const MonoBuffer &input_buffer, const mcl::Point &point, const Int wave_id, Buffer &output_buffer) noexcept
 
void AddPlaneWave (const Sample input_sample, const mcl::Point &point, const Int wave_id, Buffer &output_buffer) noexcept
 
virtual void AddPlaneWave (const Sample *input_data, const Int num_samples, const mcl::Point &point, const Int wave_id, Buffer &output_buffer) noexcept
 
virtual bool IsCoincident () const noexcept=0
 
virtual Int num_channels () const noexcept=0
 
virtual bool IsOmni () const noexcept
 
mcl::Point GetRelativePoint (const mcl::Point &point) const noexcept
 
virtual void Reset () noexcept
 
virtual ~Microphone ()
 
virtual void AddPlaneWaveRelative (const MonoBuffer &signal, const mcl::Point &point, const Int wave_id, Buffer &output_buffer) noexcept
 
virtual void AddPlaneWaveRelative (const Sample *input_data, const Int num_samples, const mcl::Point &point, const Int wave_id, Buffer &output_buffer) noexcept=0
 

Static Public Member Functions

static bool Test ()
 

Protected Attributes

mcl::Handedness handedness_
 

Friends

class MicrophoneArray
 

Constructor & Destructor Documentation

sal::Microphone::Microphone ( mcl::Point  position,
mcl::Quaternion  orientation = mcl::Quaternion::Identity() 
)

position is the position of the microphone, and orientation is a quaternion describing the microphone rotation. A microphone generally has its acoustical axis on the x-axis. We are using a spherical coordinate system with the convention that theta is the angle formed with the z-axis, and phi is the angle formed on the projection on the x-y plane with the x-axis. The x-axis corresponds to (r, theta, phi) = (r, pi/2, 0).

An example on the use of this function is as follow: if you don't want to change its orientation, then you should use a Quaternion::Identical(). Otherwise, if you want to rotate it around the z-axis (i.e. a rotation on the horizontal plane), then you should use mcl::AxAng2Quat(0,0,1,angle) with angle in radians.

Methods with wave_id as a parameter imply that the user should explicitly tell the mic to Tick, i.e. to inform it that we are working on a new sample. Methods without wave_id (i.e. assuming there is a single plane wave incoming) do this automatically.

virtual sal::Microphone::~Microphone ( )
inlinevirtual

Member Function Documentation

void sal::Microphone::AddPlaneWave ( const MonoBuffer signal,
const mcl::Point &  point,
Buffer output_buffer 
)
noexcept

We do not implement directly the case of a single plane wave because in most situations the microphone is recording many plane waves at the same time. This method should only be called in case of a single plane wave impinging on the microphone. For multiple plane waves, you need to explicitly specify the wave_id.

void sal::Microphone::AddPlaneWave ( const Sample input_data,
const Int  num_samples,
const mcl::Point &  point,
Buffer output_buffer 
)
noexcept
void sal::Microphone::AddPlaneWave ( const Sample  input_sample,
const mcl::Point &  point,
Buffer output_buffer 
)
noexcept
void sal::Microphone::AddPlaneWave ( const MonoBuffer input_buffer,
const mcl::Point &  point,
const Int  wave_id,
Buffer output_buffer 
)
noexcept

We need to keep track of the wave_id because some microphones (e.g. kemar) need to do some filtering on the signal longer than one sample. The function Tick tells the microphone to advance in time. The microphone objects need to keep track of each plane wave. Hence, the first time it sees a new wave_id, it will allocate a new filter for it.

void sal::Microphone::AddPlaneWave ( const Sample  input_sample,
const mcl::Point &  point,
const Int  wave_id,
Buffer output_buffer 
)
noexcept
virtual void sal::Microphone::AddPlaneWave ( const Sample input_data,
const Int  num_samples,
const mcl::Point &  point,
const Int  wave_id,
Buffer output_buffer 
)
virtualnoexcept

Reimplemented in sal::MicrophoneArray.

void sal::Microphone::AddPlaneWaveRelative ( const MonoBuffer signal,
const mcl::Point &  point,
const Int  wave_id,
Buffer output_buffer 
)
virtualnoexcept
virtual void sal::Microphone::AddPlaneWaveRelative ( const Sample input_data,
const Int  num_samples,
const mcl::Point &  point,
const Int  wave_id,
Buffer output_buffer 
)
pure virtualnoexcept

This is implemented by the specific type of microphones. mcl::Point in this case is relative to the microphone reference system. This is the most important function of this object. This filters the sample sample as a function of the position from where the sound is incoming point. Info for developer: the directivity should preferably have a maximum in the direction of the x-axis For anthropomorphic directivities, the facing direction is the x-axis. An arrow going from the jaw trough the skull and up should preferrably be in the direction of plus-z-axis. Other choices could be made, as long as the conventions are kept at higher levels.

Implemented in sal::MicrophoneArray, sal::MemorylessMonoMic, sal::AmbisonicsMic, and sal::BinauralMic.

Point sal::Microphone::GetRelativePoint ( const mcl::Point &  point) const
noexcept

This method translates point in the reference system of the mic.

virtual bool sal::Microphone::IsCoincident ( ) const
pure virtualnoexcept
virtual bool sal::Microphone::IsOmni ( ) const
inlinevirtualnoexcept

Reimplemented in sal::GainMic.

virtual Int sal::Microphone::num_channels ( ) const
pure virtualnoexcept
Quaternion sal::Microphone::orientation ( ) const
noexcept

Returns current orientation of the microphone

Point sal::Microphone::position ( ) const
noexcept

Returns current position of the microphone

virtual void sal::Microphone::Reset ( )
inlinevirtualnoexcept

Resets the state of the microphone (if any).

Reimplemented in sal::BinauralMic.

void sal::Microphone::SetHandedness ( const mcl::Handedness  handedness)
noexcept

Set handedness of reference system

void sal::Microphone::SetOrientation ( const mcl::Quaternion &  orientation)
virtualnoexcept

Set microphone orientation

Reimplemented in sal::CircularArray< T >, and sal::MicrophoneArray.

void sal::Microphone::SetPosition ( const mcl::Point &  position)
virtualnoexcept

Set microphone position

Reimplemented in sal::MicrophoneArray.

bool sal::Microphone::Test ( )
static

Friends And Related Function Documentation

friend class MicrophoneArray
friend

Member Data Documentation

mcl::Handedness sal::Microphone::handedness_
protected

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