IAudioDevice class
#include <nCine/Audio/IAudioDevice.h>
Interface for an audio device backend.
Manages the listener, the pool of audio sources and all active players. Implemented by ALAudioDevice on top of OpenAL and by NullAudioDevice as a silent fallback.
Derived classes
- class ALAudioDevice
- OpenAL implementation of IAudioDevice.
Public types
- enum class PlayerType { Buffer, Stream }
- Player backing type.
Constructors, destructors, conversion operators
- ~IAudioDevice() pure virtual
Public functions
- auto isValid() const -> bool pure virtual
- Returns
trueif the device was initialized successfully. - auto name() const -> const char* pure virtual
- Returns the name of the underlying device.
- auto gain() const -> float pure virtual
- Returns the listener gain (master volume).
- void setGain(float gain) pure virtual
- Sets the listener gain (master volume).
-
auto maxNumPlayers() const -> std::
uint32_t pure virtual - Returns the maximum number of players that can be active at once.
-
auto numPlayers() const -> std::
uint32_t pure virtual - Returns the number of currently active players.
-
auto player(std::
uint32_t index) const -> const IAudioPlayer* pure virtual - Returns the active player at the specified index.
- void stopPlayers() pure virtual
- Stops every player currently playing.
- void pausePlayers() pure virtual
- Pauses every player currently playing.
- void stopPlayers(PlayerType playerType) pure virtual
- Stops every player of the specified type.
- void pausePlayers(PlayerType playerType) pure virtual
- Pauses every player of the specified type.
- void freezePlayers() pure virtual
- Pauses every player currently playing while keeping it registered.
- void unfreezePlayers() pure virtual
- Resumes every player previously paused by freezePlayers().
-
auto registerPlayer(IAudioPlayer* player) -> std::
uint32_t pure virtual - Registers a player so it receives state and buffer queue updates, returning its source id.
- void unregisterPlayer(IAudioPlayer* player) pure virtual
- Unregisters a previously registered player.
- void updatePlayers() pure virtual
- Updates the state of every registered player, including the buffer queue of stream players.
- auto getListenerPosition() const -> const Vector3f& pure virtual
- Returns the 3D position of the listener.
- void updateListener(const Vector3f& position, const Vector3f& velocity) pure virtual
- Updates the position and velocity of the listener.
-
auto nativeFrequency() -> std::
int32_t pure virtual - Returns the native sample rate of the device.
- void suspendDevice() pure virtual
- Suspends the audio device.
- void resumeDevice() pure virtual
- Resumes the audio device.
Constants
-
static std::
uint32_t UnavailableSource constexpr - Value returned by registerPlayer() when no source is available.
- static float LengthToPhysical constexpr
- Scale factor converting game length units to physical (OpenAL) units.
- static float VelocityToPhysical constexpr
- Scale factor converting game velocity units to physical (OpenAL) units.
- static float ReferenceDistance constexpr
- Distance at which attenuation begins, in physical units.
- static float MaxDistance constexpr
- Distance beyond which attenuation no longer increases, in physical units.
Enum documentation
enum class nCine:: IAudioDevice:: PlayerType
Player backing type.
| Enumerators | |
|---|---|
| Buffer |
Player backed by a fully loaded AudioBuffer |
| Stream |
Player decoding an AudioStream on the fly |