Om
1.0.0
A universal framework for multimedia simulation
|
A class that stores a directional transfer function for a linear acoustic system. More...
#include <omSoundDirectionalIR.h>
Public Types | |
enum | Representation { SAMPLED = 0, SPHERICAL_HARMONIC = 1 } |
An enum type that specifies the various representations that a directional IR can have. More... | |
enum | Domain { TIME_DOMAIN = 0, FREQUENCY_DOMAIN = 1, FREQUENCY_DOMAIN_MAGNITUDE = 2, FREQUENCY_DOMAIN_MAGNITUDE_PHASE = 3 } |
An enum type that specifies the domain that a directional IR is stored in. More... | |
enum | Phase { ORIGINAL_PHASE = 0, LINEAR_PHASE = 1, MIN_PHASE = 2 } |
An enum type that specifies the phase type of a filter reconstructed from magnitude-only data. More... | |
Public Member Functions | |
DirectionalIR () | |
Create a new default sampled time-domain directional IR of length 256 with no channels. More... | |
DirectionalIR (Size numChannels, Size length, SampleRate sampleRate=SampleRate(44100), Domain domain=TIME_DOMAIN) | |
Create a new sampled directional IR with the specified number of channels. More... | |
DirectionalIR (const DirectionalIR &other) | |
Create a copy of the specified directional IR. More... | |
~DirectionalIR () | |
Destroy a directional IR and release its internal data. More... | |
DirectionalIR & | operator= (const DirectionalIR &other) |
Assign the state of another directional IR to this one. More... | |
Representation | getRepresentation () const |
Return the representation type for this directional IR. More... | |
Domain | getDomain () const |
Return the domain type for this directional IR. More... | |
Bool | setDomain (Domain newDomain) |
Change the domain type for this directional IR. More... | |
Size | getLength () const |
Return the length in samples of this directional IR's time-domain impulse response. More... | |
void | setLength (Size newLength) |
Set the length in samples of this directional IR's time-domain impulse response. More... | |
Size | getChannelCount () const |
Return the number of channels there are in this directional IR. More... | |
ChannelInfo & | getChannelInfo (Index channelIndex) |
Return an object containing information about the channel at the specified index in this directional IR. More... | |
const ChannelInfo & | getChannelInfo (Index channelIndex) const |
Return an object containing information about the channel at the specified index in this directional IR. More... | |
void | setChannelInfo (Index channelIndex, const ChannelInfo &newInfo) |
Set information about the channel at the specified index in this directional IR. More... | |
void | setChannelCount (Size newChannelCount) |
Set the number of channels that are in this directional IR. More... | |
void | clearChannels () |
Remove all channels and samples from this directional IR. More... | |
Size | getSampleCount (Index channelIndex) const |
Return the number of samples there are for the channel at the specified index. More... | |
const Vector3f & | getSampleDirection (Index channelIndex, Index sampleIndex) const |
Return the 3D cartesian vector for the specified sample. More... | |
Float | getSampleDelay (Index channelIndex, Index sampleIndex) const |
Return the delay time in seconds for the specified sample. More... | |
const Float32 * | getSampleData (Index channelIndex, Index sampleIndex) const |
Return the data for the specified sample. More... | |
Bool | addSample (Index channelIndex, const Vector3f &direction, Float delay, const FrequencyData &magnitude) |
Add a new sample of frequency-domain maginitude-only data to this directional IR. More... | |
Bool | addSample (Index channelIndex, const Vector3f &direction, Float delay, const Float32 *sampleData) |
Add a new sample to this directional IR. More... | |
void | clearSamples () |
Clear all of the samples from this directional IR. More... | |
SampleRate | getSampleRate () const |
Return the sample rate that this directional IR is stored in. More... | |
void | setSampleRate (SampleRate newSampleRate) |
Set the sample rate that this directional IR is stored in. More... | |
const Matrix3f & | getOrientation () const |
Return a 3x3 orthonormal rotation matrix indicating the local coordinate basis of this directional IR. More... | |
void | setOrientation (const Matrix3f &newOrientation) |
Set a 3x3 orthonormal rotation matrix indicating the local coordinate basis of this directional IR. More... | |
const UTF8String & | getName () const |
Return a string containing the name of the acoustic system this directional IR was measured from. More... | |
void | setName (const UTF8String &newName) |
Set a string containing the name of the acoustic system this directional IR was measured from. More... | |
const UTF8String & | getDescription () const |
Return a string containing a description of this directional IR. More... | |
void | setDescription (const UTF8String &newDescription) |
Set a string containing a description of this directional IR. More... | |
Size | getSHOrder () const |
Return the spherical harmonic order that is used to represent this directional IR. More... | |
Size | getFilterLength () const |
Return the length of the internal filter data in the current domain type. More... | |
Size | getFilterLength (Domain domain) const |
Return the length of the output filter data in the specified domain type. More... | |
Size | getFilterDataLength () const |
Return the required floating-point storage for the output filter data. More... | |
Size | getFilter (Index channel, Domain domain, Phase phase, math::Interpolation interpolation, const Vector3f &xyz, Float *filterData) const |
Get the interpolated filter for a 3D cartesian direction for the channel with the specified index. More... | |
Size | getFilterSH (Index channel, Domain domain, Phase phase, Size shOrder, const Float *shBasis, Float *filterData) const |
Get the filter for a spherical harmonic basis for the channel with the specified index. More... | |
Bool | convertToSH (const math::SHProjection &projection, DirectionalIR &result) const |
Convert the data for this directional IR to the spherical harmonic representation using the specified parameters. More... | |
Bool | convertDomain (Domain domain, Phase phase, DirectionalIR &result) const |
Convert the data for this directional IR to the specified domain type. More... | |
Static Public Attributes | |
static const om::resources::ResourceType | RESOURCE_TYPE |
The resource type for a directional IR. More... | |
A class that stores a directional transfer function for a linear acoustic system.
Multiple representations and filter domains are supported. The most common is sampled data, where the response is known at discrete direction samples. The data may also be stored in the spherical harmonic basis for more efficient interpolation and less memory usage.
An enum type that specifies the various representations that a directional IR can have.
An enum type that specifies the domain that a directional IR is stored in.
An enum type that specifies the phase type of a filter reconstructed from magnitude-only data.
om::sound::base::DirectionalIR::DirectionalIR | ( | ) |
Create a new default sampled time-domain directional IR of length 256 with no channels.
om::sound::base::DirectionalIR::DirectionalIR | ( | Size | numChannels, |
Size | length, | ||
SampleRate | sampleRate = SampleRate(44100) , |
||
Domain | domain = TIME_DOMAIN |
||
) |
Create a new sampled directional IR with the specified number of channels.
om::sound::base::DirectionalIR::DirectionalIR | ( | const DirectionalIR & | other | ) |
Create a copy of the specified directional IR.
om::sound::base::DirectionalIR::~DirectionalIR | ( | ) |
Destroy a directional IR and release its internal data.
DirectionalIR& om::sound::base::DirectionalIR::operator= | ( | const DirectionalIR & | other | ) |
Assign the state of another directional IR to this one.
|
inline |
Return the representation type for this directional IR.
|
inline |
Return the domain type for this directional IR.
Change the domain type for this directional IR.
The data in ths directional IR is converted to the specified domain. If the method fails because the domain cannot be converted (e.g. if it is in a spherical harmonic representation), the method returns FALSE.
|
inline |
Return the length in samples of this directional IR's time-domain impulse response.
void om::sound::base::DirectionalIR::setLength | ( | Size | newLength | ) |
Set the length in samples of this directional IR's time-domain impulse response.
The data stored in the response is converted so that it has the specified output length. Extra data is truncated or the response resampled if the length changes.
|
inline |
Return the number of channels there are in this directional IR.
|
inline |
Return an object containing information about the channel at the specified index in this directional IR.
|
inline |
Return an object containing information about the channel at the specified index in this directional IR.
|
inline |
Set information about the channel at the specified index in this directional IR.
void om::sound::base::DirectionalIR::setChannelCount | ( | Size | newChannelCount | ) |
Set the number of channels that are in this directional IR.
If the number of channels increases, the new channels are empty. If the number of channels decreases, the last channels are discarded.
void om::sound::base::DirectionalIR::clearChannels | ( | ) |
Remove all channels and samples from this directional IR.
Return the number of samples there are for the channel at the specified index.
|
inline |
Return the 3D cartesian vector for the specified sample.
|
inline |
Return the delay time in seconds for the specified sample.
|
inline |
Return the data for the specified sample.
Bool om::sound::base::DirectionalIR::addSample | ( | Index | channelIndex, |
const Vector3f & | direction, | ||
Float | delay, | ||
const FrequencyData & | magnitude | ||
) |
Add a new sample of frequency-domain maginitude-only data to this directional IR.
The method returns whether or not the sample data was able to be added.
Bool om::sound::base::DirectionalIR::addSample | ( | Index | channelIndex, |
const Vector3f & | direction, | ||
Float | delay, | ||
const Float32 * | sampleData | ||
) |
Add a new sample to this directional IR.
The sample data must be in the same domain as the directional IR and must be at least getFilterLength() floating-point numbers long.
The method returns whether or not the sample data was able to be added.
void om::sound::base::DirectionalIR::clearSamples | ( | ) |
Clear all of the samples from this directional IR.
|
inline |
Return the sample rate that this directional IR is stored in.
|
inline |
Set the sample rate that this directional IR is stored in.
This method does not modify the directional IR data, just the sample rate that the data is interpreted in.
|
inline |
Return a 3x3 orthonormal rotation matrix indicating the local coordinate basis of this directional IR.
This matrix transforms the directions in the directional IR before the filter is interpolated. This allows the HRTF to be rotated to match a given coordinate system convention.
|
inline |
Set a 3x3 orthonormal rotation matrix indicating the local coordinate basis of this directional IR.
This matrix transforms the directions in the directional IR before the filter is interpolated. This allows the HRTF to be rotated to match a given coordinate system convention.
|
inline |
Return a string containing the name of the acoustic system this directional IR was measured from.
|
inline |
Set a string containing the name of the acoustic system this directional IR was measured from.
|
inline |
Return a string containing a description of this directional IR.
|
inline |
Set a string containing a description of this directional IR.
|
inline |
Return the spherical harmonic order that is used to represent this directional IR.
If the representation type is SPHERICAL_HARMONIC, the return value indicates the spherical harmonic order. Otherwise, the return value is 0.
|
inline |
Return the length of the internal filter data in the current domain type.
Return the length of the output filter data in the specified domain type.
The return value indicates the number of valid samples that will be written to the buffer. NOTE: The required storage for the output filter data is retured by getFilterDataLength().
|
inline |
Return the required floating-point storage for the output filter data.
This value may be more than the return value of getFilterLength() because extra space is required for intermediate data.
Size om::sound::base::DirectionalIR::getFilter | ( | Index | channel, |
Domain | domain, | ||
Phase | phase, | ||
math::Interpolation | interpolation, | ||
const Vector3f & | xyz, | ||
Float * | filterData | ||
) | const |
Get the interpolated filter for a 3D cartesian direction for the channel with the specified index.
The filter data buffer must have enough space to hold the number of values returned by getFilterDataLength().
The method returns the number of output samples that were written to the filter data buffer. A return value of 0 indicates that an error occurred.
Size om::sound::base::DirectionalIR::getFilterSH | ( | Index | channel, |
Domain | domain, | ||
Phase | phase, | ||
Size | shOrder, | ||
const Float * | shBasis, | ||
Float * | filterData | ||
) | const |
Get the filter for a spherical harmonic basis for the channel with the specified index.
This method should only be used for directional IRs that have the SPHERICAL_HARMONIC representation type.
NOTE: the SH basis must be specified in the response's local coordinate system if the orientation calibration matrix is not the identity matrix. Therefore, the orientation calbration must be applied externally when building the basis coefficients.
The filter data buffer must have enough space to hold the number of values returned by getFilterDataLength().
The method returns the number of output samples that were written to the filter data buffer. A return value of 0 indicates that an error occurred.
Bool om::sound::base::DirectionalIR::convertToSH | ( | const math::SHProjection & | projection, |
DirectionalIR & | result | ||
) | const |
Convert the data for this directional IR to the spherical harmonic representation using the specified parameters.
Bool om::sound::base::DirectionalIR::convertDomain | ( | Domain | domain, |
Phase | phase, | ||
DirectionalIR & | result | ||
) | const |
Convert the data for this directional IR to the specified domain type.
The output directional IR is initialized with the converted domain data from this response.
|
static |
The resource type for a directional IR.