Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SoftwareDevice Class Referenceabstract

The software device is a generic device with software mixing. More...

#include <SoftwareDevice.h>

Inheritance diagram for SoftwareDevice:
Inheritance graph
[legend]

Classes

class  SoftwareHandle
 Saves the data for playback. More...
 

Public Member Functions

void setQuality (ResampleQuality quality)
 Sets the resampling quality.
 
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 void setPanning (IHandle *handle, float pan)
 Sets the panning of a specific handle.
 

Protected Member Functions

void create ()
 Initializes member variables.
 
void destroy ()
 Uninitializes member variables.
 
void mix (data_t *buffer, int length)
 Mixes the next samples into the buffer.
 
virtual void playing (bool playing)=0
 This function tells the device, to start or pause playback.
 
void setSpecs (Specs specs)
 Sets the audio output specification of the device.
 
void setSpecs (DeviceSpecs specs)
 Sets the audio output specification of the device.
 
 SoftwareDevice ()
 Empty default constructor.
 

Protected Attributes

DeviceSpecs m_specs
 The specification of the device.
 
std::shared_ptr< Mixerm_mixer
 The mixer.
 
ResampleQuality m_quality
 Resampling quality.
 

Detailed Description

The software device is a generic device with software mixing.

It is a base class for all software mixing classes. Classes implementing this have to:

Constructor & Destructor Documentation

◆ SoftwareDevice()

SoftwareDevice::SoftwareDevice ( )
protected

Empty default constructor.

To setup the device call the function create() and to uninitialize call destroy().

Member Function Documentation

◆ getDistanceModel()

virtual DistanceModel SoftwareDevice::getDistanceModel ( ) const
virtual

Retrieves the distance model.

Returns
The distance model.

Implements I3DDevice.

◆ getDopplerFactor()

virtual float SoftwareDevice::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 SoftwareDevice::getListenerLocation ( ) const
virtual

Retrieves the listener location.

Returns
The listener location.

Implements I3DDevice.

◆ getListenerOrientation()

virtual Quaternion SoftwareDevice::getListenerOrientation ( ) const
virtual

Retrieves the listener orientation.

Returns
The listener orientation as quaternion.

Implements I3DDevice.

◆ getListenerVelocity()

virtual Vector3 SoftwareDevice::getListenerVelocity ( ) const
virtual

Retrieves the listener velocity.

Returns
The listener velocity.

Implements I3DDevice.

◆ getSpecs()

virtual DeviceSpecs SoftwareDevice::getSpecs ( ) const
virtual

Returns the specification of the device.

Implements IDevice.

◆ getSpeedOfSound()

virtual float SoftwareDevice::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 * SoftwareDevice::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.

Reimplemented in CoreAudioDevice, JackDevice, and PulseAudioDevice.

◆ getVolume()

virtual float SoftwareDevice::getVolume ( ) const
virtual

Retrieves the overall device volume.

Returns
The overall device volume.

Implements IDevice.

◆ lock()

virtual void SoftwareDevice::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.

◆ mix()

void SoftwareDevice::mix ( data_t * buffer,
int length )
protected

Mixes the next samples into the buffer.

Parameters
bufferThe target buffer.
lengthThe length in samples to be filled.

◆ play() [1/2]

virtual std::shared_ptr< IHandle > SoftwareDevice::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 > SoftwareDevice::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.

◆ playing()

virtual void SoftwareDevice::playing ( bool playing)
protectedpure virtual

This function tells the device, to start or pause playback.

Parameters
playingTrue if device should playback.
Note
This method is only called when the device is locked.

Implemented in OpenCloseDevice, ReadDevice, ThreadedDevice, JackDevice, PulseAudioDevice, and SDLDevice.

◆ setDistanceModel()

virtual void SoftwareDevice::setDistanceModel ( DistanceModel model)
virtual

Sets the distance model.

Parameters
modeldistance model.

Implements I3DDevice.

◆ setDopplerFactor()

virtual void SoftwareDevice::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 SoftwareDevice::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 SoftwareDevice::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 SoftwareDevice::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.

◆ setPanning()

static void SoftwareDevice::setPanning ( IHandle * handle,
float pan )
static

Sets the panning of a specific handle.

Parameters
handleThe handle to set the panning from.
panThe new panning value, should be in the range [-2, 2].

◆ setQuality()

void SoftwareDevice::setQuality ( ResampleQuality quality)

Sets the resampling quality.

Parameters
qualityResampling quality vs performance setting.

◆ setSpecs() [1/2]

void SoftwareDevice::setSpecs ( DeviceSpecs specs)
protected

Sets the audio output specification of the device.

Parameters
specsThe output specification.

◆ setSpecs() [2/2]

void SoftwareDevice::setSpecs ( Specs specs)
protected

Sets the audio output specification of the device.

Parameters
specsThe output specification.

◆ setSpeedOfSound()

virtual void SoftwareDevice::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 SoftwareDevice::setVolume ( float volume)
virtual

Sets the overall device volume.

Parameters
volumeThe overall device volume.

Implements IDevice.

◆ stopAll()

virtual void SoftwareDevice::stopAll ( )
virtual

Stops all playing sounds.

Implements IDevice.

◆ unlock()

virtual void SoftwareDevice::unlock ( )
virtual

Unlocks the previously locked device.

Implements IDevice.


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