183 lines
6.5 KiB
TypeScript
183 lines
6.5 KiB
TypeScript
export default Source;
|
|
/**
|
|
* ~SourceOptions
|
|
*/
|
|
export type Source = {
|
|
/**
|
|
* The source's initial position (in meters), where origin is the center of
|
|
* the room. Defaults to {@link Utils.DEFAULT_POSITION DEFAULT_POSITION}.
|
|
*/
|
|
position: Float32Array;
|
|
/**
|
|
* The source's initial forward vector. Defaults to
|
|
* {@link Utils.DEFAULT_FORWARD DEFAULT_FORWARD}.
|
|
*/
|
|
forward: Float32Array;
|
|
/**
|
|
* The source's initial up vector. Defaults to
|
|
* {@link Utils.DEFAULT_UP DEFAULT_UP}.
|
|
*/
|
|
up: Float32Array;
|
|
/**
|
|
* Min. distance (in meters). Defaults to
|
|
* {@link Utils.DEFAULT_MIN_DISTANCE DEFAULT_MIN_DISTANCE}.
|
|
*/
|
|
minDistance: number;
|
|
/**
|
|
* Max. distance (in meters). Defaults to
|
|
* {@link Utils.DEFAULT_MAX_DISTANCE DEFAULT_MAX_DISTANCE}.
|
|
*/
|
|
maxDistance: number;
|
|
/**
|
|
* Rolloff model to use, chosen from options in
|
|
* {@link Utils.ATTENUATION_ROLLOFFS ATTENUATION_ROLLOFFS}. Defaults to
|
|
* {@link Utils.DEFAULT_ATTENUATION_ROLLOFF DEFAULT_ATTENUATION_ROLLOFF}.
|
|
*/
|
|
rolloff: string;
|
|
/**
|
|
* Input gain (linear). Defaults to
|
|
* {@link Utils.DEFAULT_SOURCE_GAIN DEFAULT_SOURCE_GAIN}.
|
|
*/
|
|
gain: number;
|
|
/**
|
|
* Directivity alpha. Defaults to
|
|
* {@link Utils.DEFAULT_DIRECTIVITY_ALPHA DEFAULT_DIRECTIVITY_ALPHA}.
|
|
*/
|
|
alpha: number;
|
|
/**
|
|
* Directivity sharpness. Defaults to
|
|
* {@link Utils.DEFAULT_DIRECTIVITY_SHARPNESS * DEFAULT_DIRECTIVITY_SHARPNESS}.
|
|
*/
|
|
sharpness: number;
|
|
/**
|
|
* Source width (in degrees). Where 0 degrees is a point source and 360 degrees
|
|
* is an omnidirectional source. Defaults to
|
|
* {@link Utils.DEFAULT_SOURCE_WIDTH DEFAULT_SOURCE_WIDTH}.
|
|
*/
|
|
sourceWidth: number;
|
|
};
|
|
/**
|
|
* Options for constructing a new Source.
|
|
* @typedef {Object} Source~SourceOptions
|
|
* @property {Float32Array} position
|
|
* The source's initial position (in meters), where origin is the center of
|
|
* the room. Defaults to {@linkcode Utils.DEFAULT_POSITION DEFAULT_POSITION}.
|
|
* @property {Float32Array} forward
|
|
* The source's initial forward vector. Defaults to
|
|
* {@linkcode Utils.DEFAULT_FORWARD DEFAULT_FORWARD}.
|
|
* @property {Float32Array} up
|
|
* The source's initial up vector. Defaults to
|
|
* {@linkcode Utils.DEFAULT_UP DEFAULT_UP}.
|
|
* @property {Number} minDistance
|
|
* Min. distance (in meters). Defaults to
|
|
* {@linkcode Utils.DEFAULT_MIN_DISTANCE DEFAULT_MIN_DISTANCE}.
|
|
* @property {Number} maxDistance
|
|
* Max. distance (in meters). Defaults to
|
|
* {@linkcode Utils.DEFAULT_MAX_DISTANCE DEFAULT_MAX_DISTANCE}.
|
|
* @property {string} rolloff
|
|
* Rolloff model to use, chosen from options in
|
|
* {@linkcode Utils.ATTENUATION_ROLLOFFS ATTENUATION_ROLLOFFS}. Defaults to
|
|
* {@linkcode Utils.DEFAULT_ATTENUATION_ROLLOFF DEFAULT_ATTENUATION_ROLLOFF}.
|
|
* @property {Number} gain Input gain (linear). Defaults to
|
|
* {@linkcode Utils.DEFAULT_SOURCE_GAIN DEFAULT_SOURCE_GAIN}.
|
|
* @property {Number} alpha Directivity alpha. Defaults to
|
|
* {@linkcode Utils.DEFAULT_DIRECTIVITY_ALPHA DEFAULT_DIRECTIVITY_ALPHA}.
|
|
* @property {Number} sharpness Directivity sharpness. Defaults to
|
|
* {@linkcode Utils.DEFAULT_DIRECTIVITY_SHARPNESS
|
|
* DEFAULT_DIRECTIVITY_SHARPNESS}.
|
|
* @property {Number} sourceWidth
|
|
* Source width (in degrees). Where 0 degrees is a point source and 360 degrees
|
|
* is an omnidirectional source. Defaults to
|
|
* {@linkcode Utils.DEFAULT_SOURCE_WIDTH DEFAULT_SOURCE_WIDTH}.
|
|
*/
|
|
/**
|
|
* @class Source
|
|
* @description Source model to spatialize an audio buffer.
|
|
* @param {ResonanceAudio} scene Associated {@link ResonanceAudio
|
|
* ResonanceAudio} instance.
|
|
* @param {Source~SourceOptions} options
|
|
* Options for constructing a new Source.
|
|
*/
|
|
declare class Source {
|
|
constructor(scene: any, options: any);
|
|
_scene: any;
|
|
_position: any;
|
|
_forward: any;
|
|
_up: any;
|
|
_dx: Float32Array;
|
|
_right: Float32Array;
|
|
input: any;
|
|
_directivity: Directivity;
|
|
_toEarly: any;
|
|
_toLate: any;
|
|
_attenuation: Attenuation;
|
|
_encoder: Encoder;
|
|
/**
|
|
* Set source's position (in meters), where origin is the center of
|
|
* the room.
|
|
* @param {Number} x
|
|
* @param {Number} y
|
|
* @param {Number} z
|
|
*/
|
|
setPosition(x: number, y: number, z: number): void;
|
|
_update(): void;
|
|
/**
|
|
* Set source's rolloff.
|
|
* @param {string} rolloff
|
|
* Rolloff model to use, chosen from options in
|
|
* {@linkcode Utils.ATTENUATION_ROLLOFFS ATTENUATION_ROLLOFFS}.
|
|
*/
|
|
setRolloff(rolloff: string): void;
|
|
/**
|
|
* Set source's minimum distance (in meters).
|
|
* @param {Number} minDistance
|
|
*/
|
|
setMinDistance(minDistance: number): void;
|
|
/**
|
|
* Set source's maximum distance (in meters).
|
|
* @param {Number} maxDistance
|
|
*/
|
|
setMaxDistance(maxDistance: number): void;
|
|
/**
|
|
* Set source's gain (linear).
|
|
* @param {Number} gain
|
|
*/
|
|
setGain(gain: number): void;
|
|
/**
|
|
* Set the source's orientation using forward and up vectors.
|
|
* @param {Number} forwardX
|
|
* @param {Number} forwardY
|
|
* @param {Number} forwardZ
|
|
* @param {Number} upX
|
|
* @param {Number} upY
|
|
* @param {Number} upZ
|
|
*/
|
|
setOrientation(forwardX: number, forwardY: number, forwardZ: number, upX: number, upY: number, upZ: number): void;
|
|
/**
|
|
* Set source's position and orientation using a
|
|
* Three.js modelViewMatrix object.
|
|
* @param {Float32Array} matrix4
|
|
* The Matrix4 representing the object position and rotation in world space.
|
|
*/
|
|
setFromMatrix(matrix4: Float32Array): void;
|
|
/**
|
|
* Set the source width (in degrees). Where 0 degrees is a point source and 360
|
|
* degrees is an omnidirectional source.
|
|
* @param {Number} sourceWidth (in degrees).
|
|
*/
|
|
setSourceWidth(sourceWidth: number): void;
|
|
/**
|
|
* Set source's directivity pattern (defined by alpha), where 0 is an
|
|
* omnidirectional pattern, 1 is a bidirectional pattern, 0.5 is a cardiod
|
|
* pattern. The sharpness of the pattern is increased exponentially.
|
|
* @param {Number} alpha
|
|
* Determines directivity pattern (0 to 1).
|
|
* @param {Number} sharpness
|
|
* Determines the sharpness of the directivity pattern (1 to Inf).
|
|
*/
|
|
setDirectivityPattern(alpha: number, sharpness: number): void;
|
|
}
|
|
import Directivity from "./directivity.js";
|
|
import Attenuation from "./attenuation.js";
|
|
import Encoder from "./encoder.js";
|