Constructor

Source

new Source(scene, options)

Source model to spatialize an audio buffer.

Parameter

scene

ResonanceAudio

Associated ResonanceAudio instance.

options

Source~SourceOptions

Options for constructing a new Source.

Property

input

AudioNode

Mono (1-channel) input AudioNode.

Methods

setDirectivityPattern

setDirectivityPattern(alpha, sharpness)

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.

Parameter

alpha

Number

Determines directivity pattern (0 to 1).

sharpness

Number

Determines the sharpness of the directivity pattern (1 to Inf).

setFromMatrix

setFromMatrix(matrix4)

Set source's position and orientation using a Three.js modelViewMatrix object.

Parameter

matrix4

Float32Array

The Matrix4 representing the object position and rotation in world space.

setGain

setGain(gain)

Set source's gain (linear).

Parameter

gain

Number

setMaxDistance

setMaxDistance(maxDistance)

Set source's maximum distance (in meters).

Parameter

maxDistance

Number

setMinDistance

setMinDistance(minDistance)

Set source's minimum distance (in meters).

Parameter

minDistance

Number

setOrientation

setOrientation(forwardX, forwardY, forwardZ, upX, upY, upZ)

Set the source's orientation using forward and up vectors.

Parameter

forwardX

Number

forwardY

Number

forwardZ

Number

upX

Number

upY

Number

upZ

Number

setPosition

setPosition(x, y, z)

Set source's position (in meters), where origin is the center of the room.

Parameter

x

Number

y

Number

z

Number

setRolloff

setRolloff(rolloff)

Set source's rolloff.

Parameter

rolloff

string

Rolloff model to use, chosen from options in ATTENUATION_ROLLOFFS.

setSourceWidth

setSourceWidth(sourceWidth)

Set the source width (in degrees). Where 0 degrees is a point source and 360 degrees is an omnidirectional source.

Parameter

sourceWidth

Number

(in degrees).

Abstract type

SourceOptions

inner

Object

Options for constructing a new Source.

Properties

Parameter

position

Float32Array

The source's initial position (in meters), where origin is the center of the room. Defaults to DEFAULT_POSITION.

forward

Float32Array

The source's initial forward vector. Defaults to DEFAULT_FORWARD.

up

Float32Array

The source's initial up vector. Defaults to DEFAULT_UP.

minDistance

Number

Min. distance (in meters). Defaults to DEFAULT_MIN_DISTANCE.

maxDistance

Number

Max. distance (in meters). Defaults to DEFAULT_MAX_DISTANCE.

rolloff

string

Rolloff model to use, chosen from options in ATTENUATION_ROLLOFFS. Defaults to DEFAULT_ATTENUATION_ROLLOFF.

gain

Number

Input gain (linear). Defaults to DEFAULT_SOURCE_GAIN.

alpha

Number

Directivity alpha. Defaults to DEFAULT_DIRECTIVITY_ALPHA.

sharpness

Number

Directivity sharpness. Defaults to DEFAULT_DIRECTIVITY_SHARPNESS.

sourceWidth

Number

Source width (in degrees). Where 0 degrees is a point source and 360 degrees is an omnidirectional source. Defaults to DEFAULT_SOURCE_WIDTH.