Source class
#include <Magnum/Audio/Source.h>
Source.
Manages positional audio source.
Constructors, destructors, conversion operators
Public functions
Source positioning
- auto position() const -> Vector3
- Position.
- auto setPosition(const Vector3& position) -> Source&
- Set position.
- auto setPosition(const Vector3i& position) -> Source&
- auto velocity() const -> Vector3
- Velocity.
- auto setVelocity(const Vector3& velocity) -> Source&
- Set velocity.
- auto setVelocity(const Vector3i& velocity) -> Source&
- auto isRelative() const -> bool
- Whether the source is interpreted relative to the listener.
- auto setRelative(bool relative) -> Source&
- Interpret source relatively to listener.
Source behavior
- auto gain() const -> Float
- Gain.
- auto setGain(Float gain) -> Source&
- Set gain.
- auto minGain() const -> Float
- Minimal gain to clamp to.
- auto setMinGain(Float gain) -> Source&
- Set min gain.
- auto maxGain() const -> Float
- Maximal gain to clamp to.
- auto setMaxGain(Float gain) -> Source&
- Set max gain.
- auto referenceDistance() const -> Float
- Reference distance.
- auto setReferenceDistance(Float distance) -> Source&
- Set reference distance.
- auto setReferenceDistance(Int distance) -> Source&
- auto rolloffFactor() const -> Float
- Rolloff factor.
- auto setRolloffFactor(Float factor) -> Source&
- Set rolloff factor.
- auto setRolloffFactor(Int factor) -> Source&
- auto maxDistance() const -> Float
- Maximal distance to clamp to.
- auto setMaxDistance(Float distance) -> Source&
- Set max distance.
- auto setMaxDistance(Int distance) -> Source&
- auto direction() const -> Vector3
- Direction.
- auto setDirection(const Vector3& direction) -> Source&
- Set direction.
- auto setDirection(const Vector3i& direction) -> Source&
- auto innerConeAngle() const -> Deg
- Inner cone angle.
- auto setInnerConeAngle(Deg angle) -> Source&
- Set inner cone angle.
- auto outerConeAngle() const -> Deg
- Outer cone angle.
- auto setOuterConeAngle(Deg angle) -> Source&
- Set outer cone angle.
- auto outerConeGain() const -> Float
- Outer cone gain.
- auto setOuterConeGain(Float multiplier) -> Source&
- Set outer cone gain multiplier.
- auto pitch() const -> Float
- Pitch.
- auto setPitch(Float pitch) -> Source&
- Set pitch.
Buffer management
- enum class Type: ALint { Undetermined = AL_UNDETERMINED, Static = AL_STATIC, Streaming = AL_STREAMING }
- Source type.
- auto type() const -> Type new in 2019.10
- Source type.
- auto setBuffer(Buffer* buffer) -> Source&
- Attach buffer.
-
auto queueBuffers(Containers::
ArrayView<Containers:: Reference<Buffer>> buffers) -> Source& new in 2019.10 - Queue buffers.
-
auto unqueueBuffers(Containers::
ArrayView<Containers:: Reference<Buffer>> buffers) -> std:: size_t new in 2019.10 - Unqueue buffers.
State management
- enum class State: ALint { Initial = AL_INITIAL, Playing = AL_PLAYING, Paused = AL_PAUSED, Stopped = AL_STOPPED }
- Source state.
- auto state() const -> State
- State.
- auto play() -> Source&
- Play.
- auto pause() -> Source&
- Pause.
- auto stop() -> Source&
- Stop.
- auto rewind() -> Source&
- Rewind.
- auto isLooping() const -> bool
- Whether the source is looping.
- auto setLooping(bool loop) -> Source&
- Set source looping.
- auto offsetInSeconds() const -> Float
- Offset in seconds.
- auto setOffsetInSeconds(Float offset) -> Source&
- Set offset in seconds.
- auto offsetInBytes() const -> Int
- Offset in bytes.
- auto setOffsetInBytes(Int offset) -> Source&
- Set offset in bytes.
- auto offsetInSamples() const -> Int
- Offset in samples.
- auto setOffsetInSamples(Int offset) -> Source&
- Set offset in samples.
-
static void play(std::
initializer_list<std:: reference_wrapper<Source>> sources) - Play more sources at once.
-
static void play(const std::
vector<std:: reference_wrapper<Source>>& sources) -
static void pause(std::
initializer_list<std:: reference_wrapper<Source>> sources) - Pause more sources at once.
-
static void pause(const std::
vector<std:: reference_wrapper<Source>>& sources) -
static void stop(std::
initializer_list<std:: reference_wrapper<Source>> sources) - Stop more sources at once.
-
static void stop(const std::
vector<std:: reference_wrapper<Source>>& sources) -
static void rewind(std::
initializer_list<std:: reference_wrapper<Source>> sources) - Rewind more sources at once.
-
static void rewind(const std::
vector<std:: reference_wrapper<Source>>& sources)
Enum documentation
enum class Magnum:: Audio:: Source:: Type: ALint
Source type.
| Enumerators | |
|---|---|
| Undetermined |
Undetermined (default) |
| Static |
Static source |
| Streaming |
Streaming source |
Function documentation
Source& Magnum:: Audio:: Source:: setPosition(const Vector3& position)
Set position.
| Returns | Reference to self (for method chaining) |
|---|
Default is {0.0f, 0.0f, 0.0f}.
Source& Magnum:: Audio:: Source:: setPosition(const Vector3i& position)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Source& Magnum:: Audio:: Source:: setVelocity(const Vector3& velocity)
Set velocity.
| Returns | Reference to self (for method chaining) |
|---|
Default is {0.0f, 0.0f, 0.0f}.
Source& Magnum:: Audio:: Source:: setVelocity(const Vector3i& velocity)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Magnum:: Audio:: Source:: isRelative() const
Whether the source is interpreted relative to the listener.
Source& Magnum:: Audio:: Source:: setRelative(bool relative)
Interpret source relatively to listener.
When enabled, source position, direction and velocity will be interpreted relatively to listener. Default is false.
Source& Magnum:: Audio:: Source:: setMinGain(Float gain)
Set min gain.
| Returns | Reference to self (for method chaining) |
|---|
If effective gain is lower than min gain, min gain is used. Note that this is done before listener gain is applied. Default is 0.0f.
Source& Magnum:: Audio:: Source:: setMaxGain(Float gain)
Set max gain.
| Returns | Reference to self (for method chaining) |
|---|
If effective gain is higher than max gain, max gain is used. Note that this is done before listener gain is applied. Default is 1.0f. If set to 0.0f, the source is muted.
Float Magnum:: Audio:: Source:: referenceDistance() const
Reference distance.
Source& Magnum:: Audio:: Source:: setReferenceDistance(Int distance)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Float Magnum:: Audio:: Source:: rolloffFactor() const
Rolloff factor.
Source& Magnum:: Audio:: Source:: setRolloffFactor(Float factor)
Set rolloff factor.
| Returns | Reference to self (for method chaining) |
|---|
Default is 1.0f.
Source& Magnum:: Audio:: Source:: setRolloffFactor(Int factor)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Float Magnum:: Audio:: Source:: maxDistance() const
Maximal distance to clamp to.
Source& Magnum:: Audio:: Source:: setMaxDistance(Float distance)
Set max distance.
| Returns | Reference to self (for method chaining) |
|---|
Default is max representable value.
Source& Magnum:: Audio:: Source:: setMaxDistance(Int distance)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Source& Magnum:: Audio:: Source:: setDirection(const Vector3& direction)
Set direction.
| Returns | Reference to self (for method chaining) |
|---|
Default is {0.0f, 0.0f, 0.0f}, which means that the source is not directional.
Source& Magnum:: Audio:: Source:: setDirection(const Vector3i& direction)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Deg Magnum:: Audio:: Source:: innerConeAngle() const
Inner cone angle.
Source& Magnum:: Audio:: Source:: setInnerConeAngle(Deg angle)
Set inner cone angle.
| Returns | Reference to self (for method chaining) |
|---|
Has effect only if the source is directional. Default is 360.0_degf.
Deg Magnum:: Audio:: Source:: outerConeAngle() const
Outer cone angle.
Source& Magnum:: Audio:: Source:: setOuterConeAngle(Deg angle)
Set outer cone angle.
| Returns | Reference to self (for method chaining) |
|---|
Has effect only if the source is directional. Default is 360.0_degf.
Float Magnum:: Audio:: Source:: outerConeGain() const
Outer cone gain.
Source& Magnum:: Audio:: Source:: setOuterConeGain(Float multiplier)
Set outer cone gain multiplier.
| Returns | Reference to self (for method chaining) |
|---|
The factor with which the gain is multiplied outside the outer cone. Default is 0.0f.
Type Magnum:: Audio:: Source:: type() const new in 2019.10
Source type.
Source& Magnum:: Audio:: Source:: setBuffer(Buffer* buffer)
Attach buffer.
| Parameters | |
|---|---|
| buffer | Buffer to attach or nullptr |
| Returns | Reference to self (for method chaining) |
If an buffer is attached, changes source type to Type::
Source& Magnum:: Audio:: Source:: queueBuffers(Containers:: ArrayView<Containers:: Reference<Buffer>> buffers) new in 2019.10
Queue buffers.
| Parameters | |
|---|---|
| buffers | Buffers to queue |
| Returns | Reference to self (for method chaining) |
Changes source type to Type::
std:: size_t Magnum:: Audio:: Source:: unqueueBuffers(Containers:: ArrayView<Containers:: Reference<Buffer>> buffers) new in 2019.10
Unqueue buffers.
| Parameters | |
|---|---|
| buffers | Buffers to unqueue |
| Returns | The number of unqueued buffers |
The unqueued buffers will be listed in the prefix of the array. Use Corrade::
bool Magnum:: Audio:: Source:: isLooping() const
Whether the source is looping.
Source& Magnum:: Audio:: Source:: setLooping(bool loop)
Set source looping.
| Returns | Reference to self (for method chaining) |
|---|
Default is false.
Float Magnum:: Audio:: Source:: offsetInSeconds() const
Offset in seconds.
Source& Magnum:: Audio:: Source:: setOffsetInSeconds(Float offset)
Set offset in seconds.
| Returns | Reference to self (for method chaining) |
|---|
Int Magnum:: Audio:: Source:: offsetInBytes() const
Offset in bytes.
Source& Magnum:: Audio:: Source:: setOffsetInBytes(Int offset)
Set offset in bytes.
| Returns | Reference to self (for method chaining) |
|---|
Int Magnum:: Audio:: Source:: offsetInSamples() const
Offset in samples.
Source& Magnum:: Audio:: Source:: setOffsetInSamples(Int offset)
Set offset in samples.
| Returns | Reference to self (for method chaining) |
|---|
static void Magnum:: Audio:: Source:: play(std:: initializer_list<std:: reference_wrapper<Source>> sources)
Play more sources at once.
The operation is guaranteed to be done for all sources at the same time.
static void Magnum:: Audio:: Source:: play(const std:: vector<std:: reference_wrapper<Source>>& sources)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static void Magnum:: Audio:: Source:: pause(std:: initializer_list<std:: reference_wrapper<Source>> sources)
Pause more sources at once.
The operation is guaranteed to be done for all sources at the same time.
static void Magnum:: Audio:: Source:: pause(const std:: vector<std:: reference_wrapper<Source>>& sources)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static void Magnum:: Audio:: Source:: stop(std:: initializer_list<std:: reference_wrapper<Source>> sources)
Stop more sources at once.
The operation is guaranteed to be done for all sources at the same time.
static void Magnum:: Audio:: Source:: stop(const std:: vector<std:: reference_wrapper<Source>>& sources)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static void Magnum:: Audio:: Source:: rewind(std:: initializer_list<std:: reference_wrapper<Source>> sources)
Rewind more sources at once.
The operation is guaranteed to be done for all sources at the same time.
static void Magnum:: Audio:: Source:: rewind(const std:: vector<std:: reference_wrapper<Source>>& sources)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Debug& operator<<(Debug& debug,
Source:: State value)
Debug output operator.
Debug& operator<<(Debug& debug,
Source:: Type value)
Debug output operator.