AudioNode

lumin. AudioNode

new AudioNode()

Extends

Methods

addChild(a_pChild) → {boolean}

Inherited From:

Adds a child to the current Node, removing it from its current parent.

A child can only have a single Parent

Parameters:
Name Type Description
a_pChild lumin.Node

The Node to add as a child to this Node.

Returns:

true if successful, false if failed

Type
boolean

addMoveCallback(trackopt)

Inherited From:

Adds a client-side callback event to the move list. When the event is reached during the
animation playback, the ServerEventCallback function set in Client will be called
with an event TransformAnimationEventData.

Parameters:
Name Type Attributes Default Description
track number <optional>
0

addResource(resourceID) → {boolean}

AudioNode can have multiple AudioResource(s) associated with it.
The first resource is associated when AudioNode is initialized by calling
createSoundWithLoadefFile or createSoundWithStreamedFile API.
This addResource API may be called to add(associate) more resources. However, it must be
called after initializing the AudioNode with the above mentioned createSoundWithXxxx APIs.

Note that the same resource type must be used when adding additional resources as the one used in
createSoundWithXxxx API
Example:
AudioNode->createSoundWithLoadedFile( loadedFileResourceID_1 ); // Node initialized with "loaded file" type resource.
AudioNode->addResource( loadedFileResourceID_2 ); // OK - adding "loaded file" resource
AudioNode->addResource( streamedFileResourceID_3 ); // ERROR - adding "streamed file" resource
...
Later, when startSound() API is called, it will play any one randomly picked resource sound.

Some use cases:
Example 1:
Using just one AudioNode, an alternative to having multiple AudioNodes for different sounds
playing from the same position(and orientation) but not at the same time(not overlapped).
Just add (associate) multiple resources using this addResource(resID_n) API and call startSound(resID_n)
different times with different resource IDs to play.
NOTE: Intentionally not adding resource if not already added when startSound(resId_n)
is called. This, is to avoid accidentally or easily associating too many resources
which, has performance implications.

Example 2:
Randomly playing different sound(from set of already added resources) each time startSound() is called.
This can be used to repeated sounds with slight variations for realism like, footsteps, breathing,
bullets, etc.. In this case, associate slightly varying audio resources with the same AudioNode and call
audioNode->statrtSound() with no arguments. It will play one randomly picked resource each time
startSound() is called.

Parameters:
Name Type Description
resourceID BigInt

Additional AudioResource ID to be associated with this AudioNode.
Calling addResource on same resource again is okay. The resource is added(associated)
only the first time.

Returns:
  • true, if successful added or already associated.
        false, if the type of resource is not the same type of resource (LoadedFile
        or StreamedFile) as the one when AudioNode was initialized with the resource using
        createSoundWithXxxx API.

NOTE: Associating many resources to one AudioNode will result in slight performance penalty.
So, only associate multiple resources if necessary(eg. playing random sounds) and
do not add resources to AudioNode which will be never used or used only once. If the resource
is not going to be used any more, remove the association using removeResource() API.

Type
boolean

addToLayer(a_layer)

Inherited From:

Adds this node to the specified node layer. Nodes can be members of multiple layers.

Parameters:
Name Type Description
a_layer BigInt

createSoundWithLoadedFile(resourceID, autoDestroyopt, dynamicDecodeopt) → {boolean}

Initializes the AudioNode for using the already loaded resource(keyed on resource ID)
Associates audio resource id with AudioNode.
Also, sets resource related properties.

NOTE: Must be called only once to set the AudioNode's behavior in terms of it's sound resource(s).

Parameters:
Name Type Attributes Default Description
resourceID BigInt

ID of the audio resource which is already created.

autoDestroy boolean <optional>
false

If true, play the sound once and delete the node. If false the audio
node will stay until scenegraph is destroyed.
It is good practice to remove the unused node sooner than later after
it's not required.

dynamicDecode boolean <optional>
false

true = The file resource is compressed and will be decoded when playing.
false = The file\resource is an uncompressed PCM data.

Returns:

bool - Returns true on success else, returns false.

Type
boolean

createSoundWithLoadedFile(resourceIDs, autoDestroyopt, dynamicDecodeopt) → {boolean}

An overload of createSoundWithLoadedFile with a vector of resource IDs.
See the comments for single resource Id overload.
This API will associate all the resource IDs in the vector with the AudioNode.

NOTE: Must be called only once to set the AudioNode's behavior in terms of it's sound resource(s).
PERFORMANCE: Associating many resources to one AudioNode will result in slight performance penalty.
So, only associate multiple resources if necessary(eg. playing random sounds) and
do not add resources to AudioNode which will be never used or used only once. If the resource
is not going to be used any more, remove the association using removeResource() API.

Parameters:
Name Type Attributes Default Description
resourceIDs Array.<BigInt>
autoDestroy boolean <optional>
false
dynamicDecode boolean <optional>
false
Returns:
Type
boolean

createSoundWithStreamedFile(resourceIDs, autoDestroyopt) → {boolean}

An overload of createSoundWithStreamedFile with a vector of resource IDs.
See the comments for single resource Id overload.
This API will associate all the resource IDs in the vector with the AudioNode.

NOTE: Must be called only once to set the AudioNode's behavior in terms of it's sound resource(s).
PERFORMANCE: Associating many resources to one AudioNode will result in slight performance penalty.
So, only associate multiple resources if necessary(eg. playing random sounds) and
do not add resources to AudioNode which will be never used or used only once. If the resource
is not going to be used any more, remove the association using removeResource() API.

Parameters:
Name Type Attributes Default Description
resourceIDs Array.<BigInt>
autoDestroy boolean <optional>
false
Returns:
Type
boolean

createSoundWithStreamedFile(resourceID, autoDestroyopt) → {boolean}

Initializes the AudioNode for loading the audio file chunk at a time in memory.
Associates audio resource(file) with audio node. Also, sets resource related properties.

Parameters:
Name Type Attributes Default Description
resourceID BigInt

resource id of sound resource

autoDestroy boolean <optional>
false

If true, play the sound once and delete the node. If false the audio node will
stay until scenegraph is destroyed.
It is good practice to remove the unused node sooner than later after it's not
required.

Returns:

bool - Returns true on success else, returns false.

Type
boolean

createSoundWithSystemEnum() → {boolean}

Sets the AudioNode for playing the predefined system sounds using the
AudioSytemSound enums.

NOTE: Must be called only once to set the AudioNode's behavior in terms of it's sound resource(s).

1) The node can be the child of some visible node to perceive the sounds
direction coming from that visual artifact\model's location.
-- OR --
2) The node may be the child of RootNode and set the
audioNode->setLocalPosition(x,y,z) to perceive the sounds direction coming
from the arbitrary location specified by x,y,z

Call audionode->playSystemSound(SystemSoundEnum sysSound); to play
the specified system sound from the location specified by #1 or #2 method.

Returns:
Type
boolean

createWithSound(sound, autoDestroyopt)

Creates the AudioNode using the properties set in Sound object.
The Sound object reads it's properties from an XML Sound Model file.
XML Sound Model which, contains AudioNode's properties are created for
various purposes for example, internally, SystemSoundModel.xml is used to define
each system sound's properties.

NOTE: Must be called only once to set the AudioNode's behavior in terms of it's sound resource(s).

Parameters:
Name Type Attributes Default Description
sound lumin.Sound

A Sound object to apply it's properties to this AudioNode.

autoDestroy boolean <optional>
false

Default is false and currently ignored.

delayMove(durationSecs, trackopt)

Inherited From:

Adds a delay to the current move sequence.

Parameters:
Name Type Attributes Default Description
durationSecs number

How long to delay, in seconds.

track number <optional>
0

which animation track to add the delay to.

findChild(name) → {lumin.Node}

Inherited From:

Find the first named child in the node hierarchy, including this Node.

Does a breadth-first search of the child node hierarchy
for the specified named Node and will return the first encountered match,
or nullptr if no named Node found.

Parameters:
Name Type Description
name string

The name to search for.

Returns:
Type
lumin.Node

findChildren(a_type, a_bExactTypeopt, a_bIncludeSelfopt) → {Array.<lumin.Node>}

Inherited From:

Does a breadth-first search of the child node hierarchy
for the specified Node type.

Parameters:
Name Type Attributes Default Description
a_type number

The type of Node to find in the child hierarchy.

a_bExactType boolean <optional>
false

Flag to indicate if the child node must be the exact type or can be derived from the type (default false).

a_bIncludeSelf boolean <optional>
false

Flag to indicate if the search should include this Node (default false).

Returns:

A vector of Node pointers containing the results.

Type
Array.<lumin.Node>

findParent(a_type, a_bExactTypeopt) → {lumin.Node}

Inherited From:

Searches up the tree parentage for the specific Node type.

Parameters:
Name Type Attributes Default Description
a_type number

The type of Node to find in the parent hierarchy.

a_bExactType boolean <optional>
false

Flag to indicate if the parent node must be the exact type or can be derived from the type (default false).

Returns:

The parent node, if found, null if not found.

Type
lumin.Node

getAABB() → {lumin.math.AABB}

Inherited From:

Get the AABB of this Node's full hierarchy, including all descendants,
with all Node transforms applied.

The returned AABB encompasses this Node and all descendant Nodes
and is aligned to the coordinate system the Node resides within,
i.e. the Node's parent coordinate system.
Note, the returned AABB is not guaranteed to be the minimal,
tightest fitting AABB to encompass the Node's descendant hierarchy,
but it will fully enlose the Node's hierarchy.

Returns:

The bounding box

Type
lumin.math.AABB

getAnchorPosition() → {vec3}

Inherited From:

Returns the anchor position of the node.

Returns:

The anchor position.

Type
vec3

getChild(a_iIndex) → {lumin.Node}

Inherited From:

Gets the n'th child from this Node's children

Parameters:
Name Type Description
a_iIndex number

The index of the child.

Returns:

Child Node

Type
lumin.Node

getChildCount() → {number}

Inherited From:

Gets the number of immediate children this Node has

Returns:

Count of immediate child Nodes

Type
number

getCurrentPrismTransform() → {mat4}

Inherited From:

Get the Cached Prism Transform of this Node

Returns:

Transform Matrix

Type
mat4

getCurrentWorldTransform() → {mat4}

Inherited From:

Get the Cached World Transform of this Node

Returns:

Transform Matrix

Type
mat4

getCursorHoverState() → {lumin.CursorHoverState}

Inherited From:

Get the cursor hover state for this Node.

Returns:

the cursor state.

Type
lumin.CursorHoverState

getLocalAABB() → {lumin.math.AABB}

Inherited From:

Get the local AABB of this Node only, not including children,
aligned to this Node's local coordinate system.

A local AABB of math::AABB::EMPTY indicates the Node either
has no visual information or that local AABB is not supported
for the Node.

Note: The local AABB for ModelNodes is currently not supported
and will report math::AABB::EMPTY.

Returns:

The bounding box.

Type
lumin.math.AABB

getLocalPosition() → {vec3}

Inherited From:

Get the Local Position of this Node

Returns:

Position

Type
vec3

getLocalRotation() → {quat}

Inherited From:

Get the Local Rotation of this Node

Returns:

Rotation

Type
quat

getLocalScale() → {vec3}

Inherited From:

Get the Local Scale of this Node

Returns:

Scale

Type
vec3

getLocalTransform() → {mat4}

Inherited From:

Get the Local Transform of this Node

Returns:

Transform Matrix

Type
mat4

getName() → {string}

Inherited From:

Get the name of the Node.

This call returns EMPTY_STRING if the Node's
name has not been set.

Returns:

The name of the Node, if set.

Type
string

getNodeId() → {BigInt}

Inherited From:

Gets the Node Id of this Node

Every Node is assigned a unique ID per Prism

Returns:

Node id of the current Node

Type
BigInt

getNumResources() → {number}

Gets total number of resources associated with this AudioNode.

Returns:

Number of resources.

Type
number

getParent() → {lumin.Node}

Inherited From:

Gets this Node's immediate parent

Returns:

Parent Node, nullptr = no parent

Type
lumin.Node

getParentedBoneName() → {string}

Inherited From:

When parented to a parents bone with setParentedBoneName

Returns:

Parents bone name we are attached to

Type
string

getPrismId() → {BigInt}

Inherited From:

Returns the id of the prism the node belongs to.

Returns:

the prism id (0 = invalid prism)

Type
BigInt

getPrismPosition() → {vec3}

Inherited From:

Get the Prism Position of this Node

Returns:

Position

Type
vec3

getResources() → {Array.<BigInt>}

Gets the list of already associated resource IDs

Returns:

std::vector of already associated resources.

Type
Array.<BigInt>

getRigidBody() → {lumin.PhysicsRigidBody}

Inherited From:

Returns the PhysicsRigidBody attached to the node, if the node is participating in the physics
system.

Returns:

the rigid body

Type
lumin.PhysicsRigidBody

getRoot() → {lumin.RootNode}

Inherited From:

Gets the root node of the node tree this node belongs to.

Returns:

The root node, or nullptr if none.

Type
lumin.RootNode

getSoundPitch() → {number}

Get sound pitch.

Returns:
  • Reference to a float to output current value.
Type
number

getSoundState() → {lumin.AudioState}

Gets the current state of the audio, see enum AudioState.

Returns:
  • Output parameter where the audio state will be stored.
Type
lumin.AudioState

getSoundVolumeLinear() → {number}

Gets the current audio volume.

Returns:
  • Reference to a float to output current value.
Type
number

getSpatialSoundDirection(channel) → {quat}

Get sound direction of a given audio channel.
Direction is relative to audio node's local orientation.

Parameters:
Name Type Description
channel number

Channel index(zero based).

Returns:
  • A quaternion (glm::quat) which gets populated by direction
            of the sound for the given channel.
Type
quat

getSpatialSoundDirectSendLevels(channel) → {lumin.SpatialSoundSendLevels}

Gets the direct send levels for one channel of a sound output.

Multi-channel sounds require the direct send levels to be read
individually for each channel by calling this function once for each
channel. For mono sounds use channel = 0. For stereo sounds use
channel = 0 for left and channel = 1 for right.

Parameters:
Name Type Description
channel number

selects the channel whose direct send levels are being read

Returns:
  • SpatialSoundSendLevels struct to return the levels
Type
lumin.SpatialSoundSendLevels

getSpatialSoundDistanceProperties(channel) → {lumin.SpatialSoundDistanceProperties}

Get spatial sound distance parameters for a given channel.

Parameters:
Name Type Description
channel number

Channel index(zero based).

Returns:
  • Reference to distance properties struct.
            See struct SpatialSoundDistanceProperties
Type
lumin.SpatialSoundDistanceProperties

getSpatialSoundEnable() → {boolean}

Query if spatial sound is enabled or disabled.

Returns:
  • true, Enabled
                       false, Disabled