QtCraft API C++ classes QML types Handbook

QcSoundSpatial Class

Loudness and stereo position of a sound at a world position, heard from a listener's ears. More...

Header: #include <clientcore/sound/QcSoundSpatial.h>

Public Types

struct Listener
struct Placement
struct Source

Static Public Members

float attenuation(double distance, double range)
QcSoundSpatial::Placement hear(const QcSoundSpatial::Source &source, const QcSoundSpatial::Listener &listener)
float pan(const QcVec3 &listener, double yawDegrees, const QcVec3 &source)
const float panWidth
QcSoundSpatial::Placement place(const QcVec3 &listener, double yawDegrees, const QcVec3 &source, double range)
const float rearDamping
QcSoundSpatial::Source source(const QcSoundDefinition &sound, const QcSoundCue &cue)

Detailed Description

Yaw follows the game's convention: 0 looks north (-Z), 90 east (+X).

Member Function Documentation

[static] float QcSoundSpatial::attenuation(double distance, double range)

Returns (1 - distance / range)^2: 1 at the listener and 0 from range on.

[static] QcSoundSpatial::Placement QcSoundSpatial::hear(const QcSoundSpatial::Source &source, const QcSoundSpatial::Listener &listener)

Returns the placement of source for listener, its gain including the source's volume: what a voice of that sound plays with, when it starts and whenever the listener or source moved.

[static] float QcSoundSpatial::pan(const QcVec3 &listener, double yawDegrees, const QcVec3 &source)

Returns the stereo position -panWidth (left) .. panWidth (right) of source for a listener looking along yawDegrees, from the horizontal direction to the source; 0 straight ahead, behind, above or below.

[static] QcSoundSpatial::Placement QcSoundSpatial::place(const QcVec3 &listener, double yawDegrees, const QcVec3 &source, double range)

Returns attenuation, rear damping and pan together of source within range for a listener looking along yawDegrees.

[static] QcSoundSpatial::Source QcSoundSpatial::source(const QcSoundDefinition &sound, const QcSoundCue &cue)

Returns the source of the cue cue of the sound sound.

Member Variable Documentation

const float QcSoundSpatial::panWidth

Share of full left/right a sound exactly to the side gets; the other ear still hears a little.

const float QcSoundSpatial::rearDamping

A sound straight behind the listener loses this share of its loudness.