SFXVoice

Engine/source/sfx/sfxVoice.h

The voice interface provides for playback of sound buffers and positioning of 3D sounds.

More...

Device Control Methods

Return the current playback status (playing, paused, or stopped).

Stop playback on the device.

Start playback on the device.

Pause playback on the device.

_seek(U32 sample)

Set the playback cursor on the device.

Get the playback cursor on the device.

Streaming

The following methods are for streaming voices only.

_resetStream(U32 sampleStartPos, bool triggerUpdate)

Reset streaming of the voice by cloning the current streaming source and letting the resulting stream start from sampleStartPos.

Public Types

Parent 

Protected Attributes

Sound data played back by the voice.

For streaming voices, this keeps track of play start offset after seeking.

Current playback status.

Public Functions

The destructor.

Return the current playback position (in number of samples).

bool

Returns true if the voice is virtualized on the device.

Pauses playback.

play(bool looping)

Starts playback from the current position.

setCone(F32 innerAngle, F32 outerAngle, F32 outerVolume)

Set sound cone of a 3D sound.

Sets the minimum and maximum distances for 3d falloff.

setPitch(F32 pitch)

Sets the pitch scale.

setPosition(U32 sample)

Sets the playback position to the given sample count.

setPriority(F32 priority)

Set the priority of this voice.

Set the reverb properties for playback of this sound.

Set the distance attenuation rolloff factor. Support by device optional.

setTransform(const MatrixF & transform)

Sets the position and orientation for a 3d voice.

Sets the velocity for a 3d voice.

setVolume(F32 volume)

Sets the volume.

stop()

Stops playback and moves the position to the start.

Detailed Description

The voice interface provides for playback of sound buffers and positioning of 3D sounds.

This abstract class is derived from in the different device layers to implement device-specific playback control.

The primary responsibility of this class is to mediate between the user requests (play(), stop(), pause(), setPosition()), the buffer (which may change state asynchronously), and the underlying device playback control (_play(), _stop(), _pause(), _seek()).

Device Control Methods

_status()

Return the current playback status (playing, paused, or stopped).

Default status is stopped.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

_stop()

Stop playback on the device.

note:

Called from both the SFX update thread and the main thread.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

_play()

Start playback on the device.

note:

Called from both the SFX update thread and the main thread.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

_pause()

Pause playback on the device.

note:

Called from both the SFX update thread and the main thread.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

_seek(U32 sample)

Set the playback cursor on the device.

note:

Only used for non-streaming voices.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

_tell()

Get the playback cursor on the device.

When the voice is playing or paused, this method must return a valid sample position. When the voice is stopped, the result of this method is undefined.

For streaming voices that are looping, the sample position must be a total count of the number of samples played so far which thus includes the count of all cycles before the current one. For non-looping voices, this behavior is optional.

note:

This is called for both streaming and non-streaming voices.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

Streaming

The following methods are for streaming voices only.

_resetStream(U32 sampleStartPos, bool triggerUpdate)

Reset streaming of the voice by cloning the current streaming source and letting the resulting stream start from sampleStartPos.

Public Types

typedef void Parent 

Public Friends

Protected Attributes

WeakRefPtr< SFXBuffer > mBuffer 

Sound data played back by the voice.

U32 mOffset 

For streaming voices, this keeps track of play start offset after seeking.

Expressed in number of samples.

SFXStatus mStatus 

Current playback status.

note:

This is maintained on both the sound update thread as well as the main thread.

Public Static Attributes

Signal< void(SFXVoice *) > smVoiceCreatedSignal 
Signal< void(SFXVoice *) > smVoiceDestroyedSignal 

Protected Functions

SFXVoice(SFXBuffer * buffer)

_attachToBuffer()

_onBufferStatusChange(SFXBuffer * buffer, SFXBuffer::Status newStatus)

Hooked up to SFXBuffer::mOnStatusChange of mBuffer.

note:

Called on the SFX update thread.

Public Functions

~SFXVoice()

The destructor.

getFormat()

getPosition()

Reimplemented from: IPositionable

getStatus()

return:

the current playback status.

note:

For streaming voices, the reaction to for the voice to update its status to SFXStatusStopped after the voice has stopped playing depends on the synchronization of the underlying device. If, for example, the underlying device uses periodic updates and doesn't have notifications, then a delay up to the total length of the period time may occur before the status changes. Note that in-between the actual playback stopping and the voice updating its status, the result of getPosition() is undefined.

Reimplemented by: SFXNullVoice

isVirtual()

Returns true if the voice is virtualized on the device.

note:

Always false on devices that do not support voice management.

Reimplemented by: SFXFMODVoice

pause()

Pauses playback.

play(bool looping)

Starts playback from the current position.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setCone(F32 innerAngle, F32 outerAngle, F32 outerVolume)

Set sound cone of a 3D sound.

Parameters:

innerAngle

Inner cone angle in degrees.

outerAngle

Outer cone angle in degrees.

outerVolume

Outer volume factor.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setMinMaxDistance(F32 min, F32 max)

Sets the minimum and maximum distances for 3d falloff.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setPitch(F32 pitch)

Sets the pitch scale.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setPosition(U32 sample)

Reimplemented from: IPositionable

Reimplemented by: SFXNullVoice

setPriority(F32 priority)

Set the priority of this voice.

Default 1.0.

note:

Has no effect on devices that do not support voice management.

Reimplemented by: SFXFMODVoice

setReverb(const SFXSoundReverbProperties & reverb)

Set the reverb properties for playback of this sound.

note:

Has no effect on devices that do not support reverb.

Reimplemented by: SFXFMODVoice

setRolloffFactor(F32 factor)

Set the distance attenuation rolloff factor. Support by device optional.

Reimplemented by: SFXALVoice

setTransform(const MatrixF & transform)

Sets the position and orientation for a 3d voice.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setVelocity(const VectorF & velocity)

Sets the velocity for a 3d voice.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

setVolume(F32 volume)

Sets the volume.

Reimplemented by: SFXDSVoice, SFXFMODVoice, SFXNullVoice, SFXALVoice, SFXXAudioVoice

stop()

Stops playback and moves the position to the start.