Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
OpenALDevice Class Reference

This device plays through OpenAL. More...

#include <OpenALDevice.h>

Inheritance diagram for OpenALDevice:
Inheritance graph
[legend]

Public Member Functions

 OpenALDevice (DeviceSpecs specs, int buffersize=AUD_DEFAULT_BUFFER_SIZE, const std::string &name="")
 Opens the OpenAL audio device for playback.
 
virtual DeviceSpecs getSpecs () const
 Returns the specification of the device.
 
virtual std::shared_ptr< IHandleplay (std::shared_ptr< IReader > reader, bool keep=false)
 Plays a sound source.
 
virtual std::shared_ptr< IHandleplay (std::shared_ptr< ISound > sound, bool keep=false)
 Plays a sound source.
 
virtual void stopAll ()
 Stops all playing sounds.
 
virtual void lock ()
 Locks the device.
 
virtual void unlock ()
 Unlocks the previously locked device.
 
virtual float getVolume () const
 Retrieves the overall device volume.
 
virtual void setVolume (float volume)
 Sets the overall device volume.
 
virtual ISynchronizergetSynchronizer ()
 Retrieves the synchronizer for this device, which enables accurate synchronization between audio playback and video playback for example.
 
virtual Vector3 getListenerLocation () const
 Retrieves the listener location.
 
virtual void setListenerLocation (const Vector3 &location)
 Sets the listener location.
 
virtual Vector3 getListenerVelocity () const
 Retrieves the listener velocity.
 
virtual void setListenerVelocity (const Vector3 &velocity)
 Sets the listener velocity.
 
virtual Quaternion getListenerOrientation () const
 Retrieves the listener orientation.
 
virtual void setListenerOrientation (const Quaternion &orientation)
 Sets the listener orientation.
 
virtual float getSpeedOfSound () const
 Retrieves the speed of sound.
 
virtual void setSpeedOfSound (float speed)
 Sets the speed of sound.
 
virtual float getDopplerFactor () const
 Retrieves the doppler factor.
 
virtual void setDopplerFactor (float factor)
 Sets the doppler factor.
 
virtual DistanceModel getDistanceModel () const
 Retrieves the distance model.
 
virtual void setDistanceModel (DistanceModel model)
 Sets the distance model.
 
- Public Member Functions inherited from IDevice
virtual ~IDevice ()
 Destroys the device.
 

Static Public Member Functions

static std::list< std::string > getDeviceNames ()
 Retrieves a list of available hardware devices to open with OpenAL.
 
static void registerPlugin ()
 Registers this plugin.
 

Detailed Description

This device plays through OpenAL.

Constructor & Destructor Documentation

◆ OpenALDevice()

OpenALDevice::OpenALDevice ( DeviceSpecs specs,
int buffersize = AUD_DEFAULT_BUFFER_SIZE,
const std::string & name = "" )

Opens the OpenAL audio device for playback.

Parameters
specsThe wanted audio specification.
buffersizeThe size of the internal buffer.
nameThe name of the device to be opened.
Note
The specification really used for opening the device may differ.
The buffersize will be multiplicated by three for this device.
Exceptions
DeviceExceptionThrown if the audio device cannot be opened.

Member Function Documentation

◆ getDeviceNames()

static std::list< std::string > OpenALDevice::getDeviceNames ( )
static

Retrieves a list of available hardware devices to open with OpenAL.

Returns
The list of devices to open.

◆ getDistanceModel()

virtual DistanceModel OpenALDevice::getDistanceModel ( ) const
virtual

Retrieves the distance model.

Returns
The distance model.

Implements I3DDevice.

◆ getDopplerFactor()

virtual float OpenALDevice::getDopplerFactor ( ) const
virtual

Retrieves the doppler factor.

This value is a scaling factor for the velocity vectors of sources and listener which is used while calculating the doppler effect.

Returns
The doppler factor.

Implements I3DDevice.

◆ getListenerLocation()

virtual Vector3 OpenALDevice::getListenerLocation ( ) const
virtual

Retrieves the listener location.

Returns
The listener location.

Implements I3DDevice.

◆ getListenerOrientation()

virtual Quaternion OpenALDevice::getListenerOrientation ( ) const
virtual

Retrieves the listener orientation.

Returns
The listener orientation as quaternion.

Implements I3DDevice.

◆ getListenerVelocity()

virtual Vector3 OpenALDevice::getListenerVelocity ( ) const
virtual

Retrieves the listener velocity.

Returns
The listener velocity.

Implements I3DDevice.

◆ getSpecs()

virtual DeviceSpecs OpenALDevice::getSpecs ( ) const
virtual

Returns the specification of the device.

Implements IDevice.

◆ getSpeedOfSound()

virtual float OpenALDevice::getSpeedOfSound ( ) const
virtual

Retrieves the speed of sound.

This value is needed for doppler effect calculation.

Returns
The speed of sound.

Implements I3DDevice.

◆ getSynchronizer()

virtual ISynchronizer * OpenALDevice::getSynchronizer ( )
virtual

Retrieves the synchronizer for this device, which enables accurate synchronization between audio playback and video playback for example.

Returns
The synchronizer which will be the DefaultSynchronizer if synchonization is not supported.

Implements IDevice.

◆ getVolume()

virtual float OpenALDevice::getVolume ( ) const
virtual

Retrieves the overall device volume.

Returns
The overall device volume.

Implements IDevice.

◆ lock()

virtual void OpenALDevice::lock ( )
virtual

Locks the device.

Used to make sure that between lock and unlock, no buffers are read, so that it is possible to start, resume, pause, stop or seek several playback handles simultaneously.

Warning
Make sure the locking time is as small as possible to avoid playback delays that result in unexpected noise and cracks.

Implements IDevice.

◆ play() [1/2]

virtual std::shared_ptr< IHandle > OpenALDevice::play ( std::shared_ptr< IReader > reader,
bool keep = false )
virtual

Plays a sound source.

Parameters
readerThe reader to play.
keepWhen keep is true the sound source will not be deleted but set to paused when its end has been reached.
Returns
Returns a handle with which the playback can be controlled. This is nullptr if the sound couldn't be played back.
Exceptions
ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implements IDevice.

◆ play() [2/2]

virtual std::shared_ptr< IHandle > OpenALDevice::play ( std::shared_ptr< ISound > sound,
bool keep = false )
virtual

Plays a sound source.

Parameters
soundThe sound to create the reader for the sound source.
keepWhen keep is true the sound source will not be deleted but set to paused when its end has been reached.
Returns
Returns a handle with which the playback can be controlled. This is nullptr if the sound couldn't be played back.
Exceptions
ExceptionThrown if there's an unexpected (from the device side) error during creation of the reader.

Implements IDevice.

◆ setDistanceModel()

virtual void OpenALDevice::setDistanceModel ( DistanceModel model)
virtual

Sets the distance model.

Parameters
modeldistance model.

Implements I3DDevice.

◆ setDopplerFactor()

virtual void OpenALDevice::setDopplerFactor ( float factor)
virtual

Sets the doppler factor.

This value is a scaling factor for the velocity vectors of sources and listener which is used while calculating the doppler effect.

Parameters
factorThe new doppler factor.

Implements I3DDevice.

◆ setListenerLocation()

virtual void OpenALDevice::setListenerLocation ( const Vector3 & location)
virtual

Sets the listener location.

Parameters
locationThe new location.
Note
The location is not updated with the velocity and remains constant until the next call of this method.

Implements I3DDevice.

◆ setListenerOrientation()

virtual void OpenALDevice::setListenerOrientation ( const Quaternion & orientation)
virtual

Sets the listener orientation.

Parameters
orientationThe new orientation as quaternion.
Note
The coordinate system used is right handed and the listener by default is oriented looking in the negative z direction with the positive y axis as up direction.

Implements I3DDevice.

◆ setListenerVelocity()

virtual void OpenALDevice::setListenerVelocity ( const Vector3 & velocity)
virtual

Sets the listener velocity.

Parameters
velocityThe new velocity.
Note
This velocity does not change the position of the listener over time, it is simply used for the calculation of the doppler effect.

Implements I3DDevice.

◆ setSpeedOfSound()

virtual void OpenALDevice::setSpeedOfSound ( float speed)
virtual

Sets the speed of sound.

This value is needed for doppler effect calculation.

Parameters
speedThe new speed of sound.

Implements I3DDevice.

◆ setVolume()

virtual void OpenALDevice::setVolume ( float volume)
virtual

Sets the overall device volume.

Parameters
volumeThe overall device volume.

Implements IDevice.

◆ stopAll()

virtual void OpenALDevice::stopAll ( )
virtual

Stops all playing sounds.

Implements IDevice.

◆ unlock()

virtual void OpenALDevice::unlock ( )
virtual

Unlocks the previously locked device.

Implements IDevice.


The documentation for this class was generated from the following file: