SpatialSoundPool


object SpatialSoundPool


Provides spatial audio extensions on the framework SoundPool class.

Summary

Constants

const Int

Indicates the failure of a play method.

Public functions

Int
getSpatialSourceType(session: Session, soundPool: SoundPool, streamId: Int)
Int
play(
    session: Session,
    soundPool: SoundPool,
    soundID: Int,
    attributes: SoundFieldAttributes,
    volume: @FloatRange(from = 0.0, to = 1.0) Float,
    priority: @IntRange(from = 0) Int,
    loop: @IntRange(from = -1) Int,
    rate: @FloatRange(from = 0.5, to = 2.0) Float
)

Plays a spatialized sound effect as a sound field.

Int
play(
    session: Session,
    soundPool: SoundPool,
    soundID: Int,
    params: PointSourceParams,
    volume: @FloatRange(from = 0.0, to = 1.0) Float,
    priority: @IntRange(from = 0) Int,
    loop: @IntRange(from = -1) Int,
    rate: @FloatRange(from = 0.5, to = 2.0) Float
)

Plays a spatialized sound effect emitted from the Entity in the PointSourceParams.

Constants

PLAY_FAILED

Added in 1.0.0-alpha07
const val PLAY_FAILED = 0: Int

Indicates the failure of a play method.

Public functions

getSpatialSourceType

Added in 1.0.0-alpha07
fun getSpatialSourceType(session: Session, soundPool: SoundPool, streamId: Int): Int
Parameters
session: Session

The current Session instance.

soundPool: SoundPool

The SoundPool to use to get its SourceType.

streamId: Int

a streamID returned by the SoundPool.play or either play method in this object.

Returns
Int

The SpatializerConstants.SourceType for the given streamID.

play

Added in 1.0.0-alpha07
fun play(
    session: Session,
    soundPool: SoundPool,
    soundID: Int,
    attributes: SoundFieldAttributes,
    volume: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f,
    priority: @IntRange(from = 0) Int = 0,
    loop: @IntRange(from = -1) Int = 0,
    rate: @FloatRange(from = 0.5, to = 2.0) Float = 1.0f
): Int

Plays a spatialized sound effect as a sound field.

Parameters
session: Session

The current Session instance.

soundPool: SoundPool

The SoundPool to use to the play the sound.

soundID: Int

a soundId returned by the SoundPool.load function.

attributes: SoundFieldAttributes

SoundFieldAttributes to configure the sound source.

volume: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

value (range = 0.0 to 1.0)

priority: @IntRange(from = 0) Int = 0

stream priority (0 = lowest priority)

loop: @IntRange(from = -1) Int = 0

loop mode (0 = no loop, -1 = loop forever, N = loop N times)

rate: @FloatRange(from = 0.5, to = 2.0) Float = 1.0f

playback rate (1.0 = normal playback, range 0.5 to 2.0)

Returns
Int

non-zero streamID if successful, PLAY_FAILED if failed

play

Added in 1.0.0-alpha07
fun play(
    session: Session,
    soundPool: SoundPool,
    soundID: Int,
    params: PointSourceParams,
    volume: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f,
    priority: @IntRange(from = 0) Int = 0,
    loop: @IntRange(from = -1) Int = 0,
    rate: @FloatRange(from = 0.5, to = 2.0) Float = 1.0f
): Int

Plays a spatialized sound effect emitted from the Entity in the PointSourceParams.

Parameters
session: Session

The current Session instance.

soundPool: SoundPool

The SoundPool to use to the play the sound.

soundID: Int

a soundId returned by the SoundPool.load function.

params: PointSourceParams

PointSourceParams to configure the sound source.

volume: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

value (range = 0.0 to 1.0)

priority: @IntRange(from = 0) Int = 0

stream priority (0 = lowest priority)

loop: @IntRange(from = -1) Int = 0

loop mode (0 = no loop, -1 = loop forever, N = loop N times)

rate: @FloatRange(from = 0.5, to = 2.0) Float = 1.0f

playback rate (1.0 = normal playback, range 0.5 to 2.0)

Returns
Int

non-zero streamID if successful, PLAY_FAILED if failed.