SpatialSoundPool


public static class SpatialSoundPool


Provides spatial audio extensions on the framework SoundPool class.

Summary

Constants

static final int

Indicates the failure of a play method.

Public fields

static @NonNull SpatialSoundPool

Public methods

static final int
getSpatialSourceType(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int streamId
)
static final int
play(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int soundID,
    @NonNull SoundFieldAttributes attributes,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    @IntRange(from = -1) int loop,
    @FloatRange(from = 0.5, to = 2.0) float rate
)

Plays a spatialized sound effect as a sound field.

static final int
play(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int soundID,
    @NonNull PointSourceParams params,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    @IntRange(from = -1) int loop,
    @FloatRange(from = 0.5, to = 2.0) float rate
)

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

Constants

PLAY_FAILED

Added in 1.0.0-alpha07
public static final int PLAY_FAILED = 0

Indicates the failure of a play method.

Public fields

INSTANCE

Added in 1.0.0-alpha07
public static @NonNull SpatialSoundPool INSTANCE

Public methods

getSpatialSourceType

Added in 1.0.0-alpha07
public static final int getSpatialSourceType(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int streamId
)
Parameters
@NonNull Session session

The current Session instance.

@NonNull SoundPool soundPool

The SoundPool to use to get its SourceType.

int streamId

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
public static final int play(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int soundID,
    @NonNull SoundFieldAttributes attributes,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    @IntRange(from = -1) int loop,
    @FloatRange(from = 0.5, to = 2.0) float rate
)

Plays a spatialized sound effect as a sound field.

Parameters
@NonNull Session session

The current Session instance.

@NonNull SoundPool soundPool

The SoundPool to use to the play the sound.

int soundID

a soundId returned by the SoundPool.load function.

@NonNull SoundFieldAttributes attributes

SoundFieldAttributes to configure the sound source.

@FloatRange(from = 0.0, to = 1.0) float volume

value (range = 0.0 to 1.0)

@IntRange(from = 0) int priority

stream priority (0 = lowest priority)

@IntRange(from = -1) int loop

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

@FloatRange(from = 0.5, to = 2.0) float rate

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
public static final int play(
    @NonNull Session session,
    @NonNull SoundPool soundPool,
    int soundID,
    @NonNull PointSourceParams params,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    @IntRange(from = -1) int loop,
    @FloatRange(from = 0.5, to = 2.0) float rate
)

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

Parameters
@NonNull Session session

The current Session instance.

@NonNull SoundPool soundPool

The SoundPool to use to the play the sound.

int soundID

a soundId returned by the SoundPool.load function.

@NonNull PointSourceParams params

PointSourceParams to configure the sound source.

@FloatRange(from = 0.0, to = 1.0) float volume

value (range = 0.0 to 1.0)

@IntRange(from = 0) int priority

stream priority (0 = lowest priority)

@IntRange(from = -1) int loop

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

@FloatRange(from = 0.5, to = 2.0) float rate

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

Returns
int

non-zero streamID if successful, PLAY_FAILED if failed.