Home Reference Source Repository
import {HrtfSet} from 'binaural/src/sofa/HrtfSet.js'
public class | source

HrtfSet

Container for HRTF set.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Constructs an HRTF set.

Member Summary

Public Members
public set

Set coordinate system for positions.

public get

Get coordinate system for positions.

public get

Get post-filtering flag.

public set

Set post-filtering flag.

public get

Get coordinate system for filter positions.

public set

Set coordinate system for filter positions.

public set

Set filter positions.

public get

Get filter positions.

public get

Test whether an HRTF set is actually loaded.

public get

Get the meta-data from the SOFA URL already loaded.

public get

Get the original name of the HRTF set.

public get

Get the original sample-rate from the SOFA URL already loaded.

public get

Get the URL used to actually load the HRTF set.

Method Summary

Public Methods
public

Apply filter positions to an existing set of HRTF.

public

Export the current HRTF set as a JSON string.

public

load(sourceUrl: String): Promise.<this | Error>

Load an URL and generate the corresponding set of IR buffers.

public

Get the nearest point in the HRTF set, after a successful load.

public

nearestFir(positionRequest: Coordinates): AudioBuffer

Get the FIR AudioBuffer that corresponds to the closest position in the set.

Public Constructors

public constructor(options: Object) source

Constructs an HRTF set. Note that the filter positions are applied during the load of an URL.

Params:

NameTypeAttributeDescription
options Object
options.audioContext AudioContext

mandatory for the creation of FIR audio buffers

options.coordinateSystem CoordinateSystem
  • optional
  • default: 'gl'

HrtfSet#coordinateSystem

options.filterCoordinateSystem CoordinateSystem
  • optional
  • default: options.coordinateSystem

HrtfSet#filterCoordinateSystem

options.filterPositions Array<Coordinates>
  • optional
  • default: undefined

HrtfSet#filterPositions array of positions to filter. Use undefined to use all positions.

options.filterAfterLoad Boolean
  • optional
  • default: false

true to filter after full load of SOFA file, instead of multiple partial loading. HrtfSet#filterAfterLoad

See:

Public Members

public set coordinateSystem(system: CoordinateSystem): * source

Set coordinate system for positions.

public get coordinateSystem: CoordinateSystem: * source

Get coordinate system for positions.

public get filterAfterLoad: Boolean: * source

Get post-filtering flag. When false, try to load a partial set of HRTF.

Return:

Boolean

public set filterAfterLoad(post: Boolean): * source

Set post-filtering flag. When false, try to load a partial set of HRTF.

public get filterCoordinateSystem: * source

Get coordinate system for filter positions.

public set filterCoordinateSystem(system: CoordinateSystem): * source

Set coordinate system for filter positions.

public set filterPositions(positions: Array<Coordinates>): * source

Set filter positions.

public get filterPositions: * source

Get filter positions.

public get isReady: Boolean: * source

Test whether an HRTF set is actually loaded.

Return:

Boolean

false before any successful load, true after.

See:

public get sofaMetaData: Object: * source

Get the meta-data from the SOFA URL already loaded.

Return:

Object

that is undefined before a successfully load.

public get sofaName: String: * source

Get the original name of the HRTF set.

Return:

String

that is undefined before a successfully load.

public get sofaSampleRate: Number: * source

Get the original sample-rate from the SOFA URL already loaded.

Return:

Number

that is undefined before a successfully load.

public get sofaUrl: String: * source

Get the URL used to actually load the HRTF set.

Return:

String

that is undefined before a successfully load.

Public Methods

public applyFilterPositions() source

Apply filter positions to an existing set of HRTF. (After a successful load.)

This is destructive.

See:

public export(): String source

Export the current HRTF set as a JSON string.

When set, this.filterPositions reduce the actual number of filter, and thus the exported set. The coordinate system of the export is this.filterCoordinateSystem.

Return:

String

as a SOFA JSON file.

Throw:

Error

when this.filterCoordinateSystem is unknown.

See:

public load(sourceUrl: String): Promise.<this | Error> source

Load an URL and generate the corresponding set of IR buffers.

Params:

NameTypeAttributeDescription
sourceUrl String

Return:

Promise.<this | Error>

resolve when the URL sucessfully loaded.

public nearest(positionRequest: Coordinates): HrtfSet.nearestType source

Get the nearest point in the HRTF set, after a successful load.

Params:

NameTypeAttributeDescription
positionRequest Coordinates

See:

public nearestFir(positionRequest: Coordinates): AudioBuffer source

Get the FIR AudioBuffer that corresponds to the closest position in the set.

Params:

NameTypeAttributeDescription
positionRequest Coordinates

Return:

AudioBuffer