template<UnsignedInt dimensions>
Listener class
Listener.
Contents
Feature which manages the position, orientation and gain of the OpenAL listener for an SceneGraph::
Usage
Minimal scene setup for a Listener3D will require the following code:
Scene3D scene; Object3D object{&scene}; Listener3D listener{object}; // ... every frame, update the listener to changes in object transformation: listener.update({});
For two dimensional scenes simply replace all 3D
with 2D
.
Using Listener with PlayableGroup
When using PlayableGroup, you can update the listener and groups as follows:
// ... Listener3D listener{object}; PlayableGroup3D group1, group2; // ... and every frame: listener.update({group1, group2});
Active listener
There can only be at the most one active listener at a given time, i.e. the one on which Listener::
AbstractObject::
Sound transformation
Listener::
Base classes
-
template<UnsignedInt dimensions, class T>class Magnum::SceneGraph::AbstractFeature
- Base for object features.
Constructors, destructors, conversion operators
-
Listener(SceneGraph::
AbstractObject<dimensions, Float>& object) explicit - Constructor.
Public functions
- auto soundTransformation() const -> const Matrix4&
- Sound transformation.
- auto setSoundTransformation(const Matrix4& soundTransformation) -> Listener<dimensions>&
- Set sound transformation.
-
void update(std::
initializer_list<std:: reference_wrapper<PlayableGroup<dimensions>>> groups) - Update the listener.
- auto gain() const -> Float
- Listener gain.
- auto setGain(Float gain) -> Listener<dimensions>&
- Set listener gain.
- auto isActive() const -> bool
- Whether this listener is the active listener.
Private functions
- void clean(const MatrixTypeFor<dimensions, Float>& absoluteTransformationMatrix) override virtual
- Clean data based on absolute transformation.
Function documentation
template<UnsignedInt dimensions>
Magnum:: Audio:: Listener<dimensions>:: Listener(SceneGraph:: AbstractObject<dimensions, Float>& object) explicit
Constructor.
Parameters | |
---|---|
object | Object this listener belongs to |
Creates a listener with a forward vector of {0.0f, 0.0f, -1.0f}
and up vector of {0.0f, 1.0f, 0.0f}
. These vectors cannot be changed, the listeners orientation and translation can be instead affected by object
or via Listener::
template<UnsignedInt dimensions>
Listener<dimensions>& Magnum:: Audio:: Listener<dimensions>:: setSoundTransformation(const Matrix4& soundTransformation)
Set sound transformation.
Parameters | |
---|---|
soundTransformation | Transformation for transforming from world to listener space |
Returns | Reference to self (for method chaining) |
template<UnsignedInt dimensions>
void Magnum:: Audio:: Listener<dimensions>:: update(std:: initializer_list<std:: reference_wrapper<PlayableGroup<dimensions>>> groups)
Update the listener.
Parameters | |
---|---|
groups | Groups to update |
Makes this Listener the active listener and calls SceneGraph::
template<UnsignedInt dimensions>
Listener<dimensions>& Magnum:: Audio:: Listener<dimensions>:: setGain(Float gain)
Set listener gain.
Parameters | |
---|---|
gain | Gain |
Returns | Reference to self (for method chaining) |
template<UnsignedInt dimensions>
void Magnum:: Audio:: Listener<dimensions>:: clean(const MatrixTypeFor<dimensions, Float>& absoluteTransformationMatrix) override virtual private
Clean data based on absolute transformation.
When object is cleaned and CachedTransformation::
Default implementation does nothing.