template<UnsignedInt dimensions>
Magnum::Audio::Playable class

Playable.

Feature which manages the position, orientation and gain of a Source for an SceneGraph::Object.

Usage

Object3D object;
Source source;
Playable3D playable{object, source};

// ...

object.translate(offset);

// ... and every frame, update the sources positions by cleaning the object:
object.setClean();

Position of the source will be updated to the translation of object when SceneGraph::Object::setClean() is called, which is done in Audio::Listener::update() or Audio::PlayableGroup::setClean() for example.

To manage multiple Playables at once, use PlayableGroup.

Base classes

template<UnsignedInt dimensions, class Derived, class T>
class Magnum::SceneGraph::AbstractGroupedFeature
Base for grouped features.

Constructors, destructors, conversion operators

Playable(SceneGraph::AbstractObject<dimensions, Float>& object, PlayableGroup<dimensions>* group = nullptr) explicit
Constructor.

Public functions

auto source() -> Source&
Source which is managed by this feature.
auto gain() const -> Float
Gain.
auto setGain(const Float gain) -> Playable&
Set gain of the playable and source respecting the PlayableGroups gain.
auto playables() -> PlayableGroup<dimensions>*
Group containing this playable.
auto playables() const -> const PlayableGroup<dimensions>*

Private functions

void clean(const MatrixTypeFor<dimensions, Float>& absoluteTransformationMatrix) override virtual
Clean data based on absolute transformation.

Function documentation

template<UnsignedInt dimensions>
Magnum::Audio::Playable<dimensions>::Playable(SceneGraph::AbstractObject<dimensions, Float>& object, PlayableGroup<dimensions>* group = nullptr) explicit

Constructor.

Parameters
object Object this playable belongs to
group Group this playable belongs to

Creates playable with a source and a forward vector of {0.0f, -1.0f} for 2D and {0.0f, 0.0f, -1.0f} for 3D scenes. This forward vector cannot be changed, the sources orientation and translation can be instead affected by object or via PlayableGroup::setSoundTransformation().

template<UnsignedInt dimensions>
Playable& Magnum::Audio::Playable<dimensions>::setGain(const Float gain)

Set gain of the playable and source respecting the PlayableGroups gain.

Returns Reference to self (for method chaining)

The sources gain is computed as sourceGain = playableGain*groupGain. Default for the playables gain is 1.0f.

template<UnsignedInt dimensions>
PlayableGroup<dimensions>* Magnum::Audio::Playable<dimensions>::playables()

Group containing this playable.

If the playable doesn't belong to any group, returns nullptr.

template<UnsignedInt dimensions>
const PlayableGroup<dimensions>* Magnum::Audio::Playable<dimensions>::playables() const

<This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<UnsignedInt dimensions>
void Magnum::Audio::Playable<dimensions>::clean(const MatrixTypeFor<dimensions, Float>& absoluteTransformationMatrix) override virtual private

Clean data based on absolute transformation.

When object is cleaned and CachedTransformation::Absolute is enabled in setCachedTransformations(), this function is called to recalculate data based on absolute object transformation.

Default implementation does nothing.