QcPositionalVoices Class
The mixer voices of positional sounds with where they sound, so that their loudness and stereo position follow the listener while they play (a thunder roll or an explosion lasts seconds, and the listener turns and walks meanwhile), and at most a few voices of one sound at a time, so that dozens of sources of the same sound (flowing water all around) never pile up. More...
| Header: | #include <clientcore/sound/QcPositionalVoices.h> |
Public Types
| struct | Tracked |
Public Functions
| void | clear() |
| QcAudioMixer::VoiceId | start(QcAudioMixer &mixer, std::shared_ptr<const QcSampleBuffer> buffer, const QString &key, const QcSoundSpatial::Source &source, const QcAudioMixer::PlayParameters ¶meters) |
| void | track(QcAudioMixer::VoiceId id, const QString &key, const QcSoundSpatial::Source &source) |
| void | update(QcAudioMixer &mixer, const QcSoundSpatial::Listener &listener) |
| const QList<QcPositionalVoices::Tracked> & | voices() const |
Static Public Members
| const int | maxPerKey |
| const int | maxTracked |
| float | stackedGain(int playing) |
Detailed Description
Not thread-safe; update() runs with the mixer locked.
Member Function Documentation
void QcPositionalVoices::clear()
Forgets every tracked voice.
[static] float QcPositionalVoices::stackedGain(int playing)
Returns the gain of a new explosion voice while playing others still sound: 1/sqrt(playing + 1).
QcAudioMixer::VoiceId QcPositionalVoices::start(QcAudioMixer &mixer, std::shared_ptr<const QcSampleBuffer> buffer, const QString &key, const QcSoundSpatial::Source &source, const QcAudioMixer::PlayParameters ¶meters)
Starts buffer in mixer as a voice of key heard from source with parameters and tracks it. When maxPerKey voices of key play already, the oldest fades out (QcAudioMixer::fadeOut), unless the mixer would refuse the new one anyway. A new explosion is quieter by stackedGain() of the explosions still playing, so that a chain of blasts does not sit in the limiter for seconds (decision E-879). Returns the voice, 0 when the mixer refused it.
void QcPositionalVoices::track(QcAudioMixer::VoiceId id, const QString &key, const QcSoundSpatial::Source &source)
Tracks the voice id of key heard from source, already started in the mixer; 0 is ignored.
void QcPositionalVoices::update(QcAudioMixer &mixer, const QcSoundSpatial::Listener &listener)
Places every tracked voice still playing in mixer anew for listener; forgets the others.
const QList<QcPositionalVoices::Tracked> &QcPositionalVoices::voices() const
Returns the tracked voices, the oldest first.
Member Variable Documentation
const int QcPositionalVoices::maxPerKey
Voices of one sound key that play at once; a further one replaces the oldest.
const int QcPositionalVoices::maxTracked
Never more than the mixer has voices; the oldest entry goes first.