This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

Magnum::Audio::Source class

Source.

Manages positional audio source.

Constructors, destructors, conversion operators

Source() explicit
Constructor.
~Source()
Destructor.
Source(const Source&) deleted
Copying is not allowed.
Source(Source&& other)
Move constructor.

Public functions

auto operator=(const Source&) -> Source& deleted
Copying is not allowed.
auto operator=(Source&& other) -> Source&
Move assignment.
auto id() const -> ALuint
OpenAL source ID.

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
Source type.
auto setBuffer(Buffer* buffer) -> Source&
Attach buffer.

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.
void play()
Play.
void pause()
Pause.
void stop()
Stop.
void rewind()
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

enum class Magnum::Audio::Source::State: ALint

Source state.

Enumerators
Initial

Initial state (default)

Playing

The source is playing

Paused

The source is paused

Stopped

The source is stopped

Function documentation

Magnum::Audio::Source::Source() explicit

Constructor.

Creates OpenAL source object.

Magnum::Audio::Source::~Source()

Destructor.

Deletes OpenAL source object.

Vector3 Magnum::Audio::Source::position() const

Position.

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.

Vector3 Magnum::Audio::Source::velocity() const

Velocity.

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.

Float Magnum::Audio::Source::gain() const

Gain.

Source& Magnum::Audio::Source::setGain(Float gain)

Set gain.

Returns Reference to self (for method chaining)

Default is 1.0f, which means that the sound is unattenuated. If set to 0.0f, the source is muted.

Float Magnum::Audio::Source::minGain() const

Minimal gain to clamp to.

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.

Float Magnum::Audio::Source::maxGain() const

Maximal gain to clamp to.

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(Float distance)

Set reference distance.

Returns Reference to self (for method chaining)

Default is 1.0f. Distance at which the listener will experience gain() (or minGain(), maxGain() if gain was clamped).

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.

Vector3 Magnum::Audio::Source::direction() const

Direction.

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.

Float Magnum::Audio::Source::pitch() const

Pitch.

Source& Magnum::Audio::Source::setPitch(Float pitch)

Set pitch.

Returns Reference to self (for method chaining)

Default is 1.0f.

Type Magnum::Audio::Source::type() const

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::Static, if detached, changes source type to Type::Undetermined. The buffer must be already filled with data.

State Magnum::Audio::Source::state() const

State.

void Magnum::Audio::Source::play()

Play.

void Magnum::Audio::Source::pause()

Pause.

void Magnum::Audio::Source::stop()

Stop.

void Magnum::Audio::Source::rewind()

Rewind.

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.