Inherits from PXSoundTransform : NSObject
Conforms to NSCopying
PXPooledObject
Declared in PXSoundTransform3D.h
PXSoundTransform3D.m

Overview

Represents the volume, pitch, position, velocity and distance formula for a 3D-ready PXSoundChannel.

The following code creates a sound transform with 120% volume and 80% pitch:

PXSoundTransform3D *transform = [[PXSoundTransform3D alloc] initWithVolume:1.2f pitch:0.8f];
// Volume will be 120% and pitch will be 80%, position[0,0,0] and
// velocity[0,0,0], reference distance and logarithmic exponent is set to
// the defaults described in sound listener.  To access the sound listener
// use [PXSoundMixer soundListener].

Tasks

Other Methods

Other Methods

Properties

logarithmicExponent

The exponent for the logarithmic distance model described in PXSoundMixer. The exponent is ignored if the distance model is set to PXSoundMixerDistanceModel_Linear. For the forumla used please see the referenceDistance description.

@property (nonatomic) float logarithmicExponent

Discussion

Default: [PXSoundMixer soundListener].defaultLogarithmicExponent

The logarithmic exponent can not be negative, the absolute value will be taken before use.

Declared In

PXSoundTransform3D.h

referenceDistance

The reference for how the volume changes based on it’s distance from the listener.

@property (nonatomic) float referenceDistance

Discussion

If the distance model described in PXSoundMixer is set to PXSoundMixerDistanceModel_Linear then the logarithmicExponent is ignored and if a PXSoundChannel is further then the reference distance away from the listener, then the sound will not be heard. Anywhere in between will be linearly distributed. So if the PXSoundChannel is 70% of the reference distance away from the user, then the sound is played at 70% volume.

If the distance model described in PXSoundMixer is set to PXSoundMixerDistanceModel_Logarithmic then the distance volume is calculated based on the following forumla:

distanceVolume = (distance / referenceDistance) ^ (-logarithmicExponent)

The actual volume is computed using the following formula:

playingVolume = volume * distanceVolume * [PXSoundMixer soundTransform].volume

Default: [PXSoundMixer soundListener].defaultReferenceDistance

The reference distance can not be negative, the absolute value will be taken before use.

Declared In

PXSoundTransform3D.h

velocityX

The horizontal coordinate change per second.

@property (nonatomic) float velocityX

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

velocityY

The vertical coordinate change per second.

@property (nonatomic) float velocityY

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

velocityZ

The depth coordinate change per second.

@property (nonatomic) float velocityZ

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

x

The horizontal coordinate.

@property (nonatomic) float x

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

y

The vertical coordinate.

@property (nonatomic) float y

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

z

The depth coordinate.

@property (nonatomic) float z

Discussion

Default: 0.0f

Declared In

PXSoundTransform3D.h

Class Methods

soundTransform3DWithVolume:pitch:

Creates a 3D sound transform with the given volume and pitch.

+ (PXSoundTransform3D *)soundTransform3DWithVolume:(float)volume pitch:(float)pitch

Parameters

volume

The amplitude of the sound.

pitch

The frequency of the sound.

Return Value

The created sound transform.

Example:

PXSoundTransform3D *transform = [PXSoundTransform3D soundTransformWithVolume:1.2f pitch:0.8f];
// Volume will be 120% and pitch will be 80%, position[0,0,0] and
// velocity[0,0,0], reference distance and logarithmic exponent is set to
// the defaults described in sound listener.  To access the sound listener
// use [PXSoundMixer soundListener].

Declared In

PXSoundTransform3D.m

Instance Methods

initWithVolume:pitch:

Creates a new 3D sound transform with the given volume and pitch.

- (id)initWithVolume:(float)_volume pitch:(float)_pitch

Parameters

volume

The amplitude of the sound.

pitch

The frequency of the sound.

Example:

PXSoundTransform3D *transform = [[PXSoundTransform3D alloc] initWithVolume:1.2f pitch:0.8f];
// Volume will be 120% and pitch will be 80%, position[0,0,0] and
// velocity[0,0,0], reference distance and logarithmic exponent is set to
// the defaults described in sound listener. To access the sound listener
// use [PXSoundMixer soundListener].

Declared In

PXSoundTransform3D.m

setVelocityX:y:z:

Sets the velocity to (x, y, z).

- (void)setVelocityX:(float)_x y:(float)_y z:(float)_z

Parameters

x

The horizontal coordinate change per second.

y

The vertical coordinate change per second.

z

The depth coordinate change per second.

Example:

PXSoundTransform3D *transform = [PXSoundTransform3D new];
// transform will have a volume of 1.0f and pitch of 1.0f
[transform setVelocityX:-10.0f y:4.1f z:0.0f];
// transform's velocity will now be (-10.0f, 4.1f, 0.0f)

Declared In

PXSoundTransform3D.m

setX:y:z:

Sets the position to (x, y, z).

- (void)setX:(float)_x y:(float)_y z:(float)_z

Parameters

x

The horizontal coordinate.

y

The vertical coordinate.

z

The depth coordinate.

Example:

PXSoundTransform3D *transform = [PXSoundTransform3D new];
// transform will have a volume of 1.0f and pitch of 1.0f
[transform setX:5.0f y:7.0f z:0.0f];
// transform's position will now be (5.0f, 7.0f, 0.0f)

Declared In

PXSoundTransform3D.m