KGameAudioScene Namespace
Exposes general properties of the audio playback context. More...
| Header: | #include <KGameAudioScene> |
Types
| flags | Capabilities |
| enum | Capability { SupportsLowLatencyPlayback, SupportsPositionalPlayback } |
Functions
| KGameAudioScene::Capabilities | capabilities() |
| bool | hasError() |
| QPointF | listenerPos() |
| void | setListenerPos(QPointF pos) |
| void | setVolume(qreal volume) |
| qreal | volume() |
Detailed Description
This namespace exposes general properties of the audio playback context. Actual sounds are represented in this context by KGameSound instances.
The audio scene basically consists of a listener. The position of this listener is relevant when sounds are played at certain positions: The audio channels will then be balanced to make the sound appear to come from that direction.
Because there can only be one listener, all methods in this class are static.
Warning: Not all functionally exposed by the API of this class is guaranteed to be available on the compiled KGameAudio backend. Check KGameAudioScene::capabilities() if in doubt.
Type Documentation
enum KGameAudioScene::Capability
flags KGameAudioScene::Capabilities
This enumeration represents capabilities which may not be provided by every KGameAudio backend.
| Constant | Value | Description |
|---|---|---|
KGameAudioScene::SupportsLowLatencyPlayback | 1 << 0 | Playback starts as soon as KGameSound::start is called. |
KGameAudioScene::SupportsPositionalPlayback | 1 << 1 | Supports sound coming from a certain direction with a distance-depending volume. |
The Capabilities type is a typedef for QFlags<Capability>. It stores an OR combination of Capability values.
Function Documentation
KGameAudioScene::Capabilities KGameAudioScene::capabilities()
Returns which capabilities are supported by the compiled KGameAudio backend.
bool KGameAudioScene::hasError()
Returns whether an error was detected in the audio backend.
Since KGameAudio is typically used by games where audio is not an absolutely vital part of the gameplay, we do not need to fail if sound does not work, or even make some sort of deep analysis why something did not work. The user will notice missing sound, and advanced users may investigate the kWarning() messages. That is usually enough. If not, use this method.
The state of hasError() may theoretically change while the application runs, but in practice, this is very unlikely. (The only tricky part is typically the initial allocation of resources.)
See also KGameSound::hasError().
QPointF KGameAudioScene::listenerPos()
Returns the position of the listener.
See also setListenerPos().
void KGameAudioScene::setListenerPos(QPointF pos)
Sets the position of the listener to pos. The default is (0.0, 0.0), the point of origin.
Note: Effective only if positional playback is supported.
See also listenerPos().
void KGameAudioScene::setVolume(qreal volume)
Sets the master volume for sounds outputted by TagaroAudio to volume. The default is 1.0, which means no volume change, compared to the original sounds. 0.0 means that all sounds are muted.
See also volume().
qreal KGameAudioScene::volume()
Returns the master volume for sounds outputted by TagaroAudio.
See also setVolume().