TORCS  1.3.9
The Open Racing Car Simulator
TorcsSound Class Referenceabstract

A generic TORCS sound. More...

#include <TorcsSound.h>

Inheritance diagram for TorcsSound:
Collaboration diagram for TorcsSound:

Public Member Functions

 TorcsSound (int flags=(ACTIVE_VOLUME|ACTIVE_PITCH))
 Consruct a sound. More...
 
virtual ~TorcsSound ()
 Destructor. More...
 
virtual void setVolume (float vol)
 Set the volume. More...
 
virtual void setPitch (float pitch)
 Set the pitch. More...
 
virtual void setLPFilter (float lp)
 Set the filter. More...
 
virtual void setSource (sgVec3 p, sgVec3 u)
 
virtual float getVolume ()
 
virtual float getPitch ()
 
virtual float getLPfilter ()
 
virtual void setReferenceDistance (float dist)
 
virtual void getSource (sgVec3 p, sgVec3 u)
 
virtual void play ()=0
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual void resume ()=0
 
virtual void pause ()=0
 
virtual void update ()=0
 
virtual bool isPlaying ()=0
 
virtual bool isPaused ()=0
 

Protected Attributes

class SoundInterfaceiface
 Handler to the interface. More...
 
int flags
 Flags relating to what effects are to be used. More...
 
float MAX_VOL
 Maximum volume. More...
 
float volume
 Current volume. More...
 
float pitch
 Current pitch. More...
 
float lowpass
 Current low pass filter. More...
 
bool loop
 Whether it's a looping sound. More...
 

Detailed Description

A generic TORCS sound.

The aim is to have a more or less identical interface to sounds, no matter what the backend is. In practice, there are some minor differences across interfaces. In particular, for Plib sounds, setting pitch and volume actually sets the pitch/volume of the sound that we are listening at, while for Openal sounds, it sets only the pitch/volume of the source sound. Thus, the interface is not consistent across backends. Making it consistent is not easily doable because some things simply work too differently. Currently I have traded complexity in TorcsSound for replicating some code in the two SoundInterface implementatins: OpenalSoundInterface and PlibSoundInterface both take into account the individual pecularities of each PlibTorcsSound and OpenalTorcsSound. However, if it is deemed necessary later on, it is possible to make the interface consistent.

Definition at line 53 of file TorcsSound.h.

Constructor & Destructor Documentation

◆ TorcsSound()

TorcsSound::TorcsSound ( int  flags = (ACTIVE_VOLUME|ACTIVE_PITCH))
inline

Consruct a sound.

Definition at line 64 of file TorcsSound.h.

◆ ~TorcsSound()

virtual TorcsSound::~TorcsSound ( )
inlinevirtual

Destructor.

Definition at line 72 of file TorcsSound.h.

Member Function Documentation

◆ getLPfilter()

virtual float TorcsSound::getLPfilter ( )
inlinevirtual

Definition at line 79 of file TorcsSound.h.

◆ getPitch()

virtual float TorcsSound::getPitch ( )
inlinevirtual

Definition at line 78 of file TorcsSound.h.

◆ getSource()

virtual void TorcsSound::getSource ( sgVec3  p,
sgVec3  u 
)
inlinevirtual

Reimplemented in OpenalTorcsSound.

Definition at line 81 of file TorcsSound.h.

◆ getVolume()

virtual float TorcsSound::getVolume ( )
inlinevirtual

Definition at line 77 of file TorcsSound.h.

◆ isPaused()

virtual bool TorcsSound::isPaused ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ isPlaying()

virtual bool TorcsSound::isPlaying ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ pause()

virtual void TorcsSound::pause ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ play()

virtual void TorcsSound::play ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ resume()

virtual void TorcsSound::resume ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ setLPFilter()

void TorcsSound::setLPFilter ( float  lp)
virtual

Set the filter.

Note
Effect not consistent across backends

Reimplemented in OpenalTorcsSound.

Definition at line 35 of file TorcsSound.cpp.

◆ setPitch()

void TorcsSound::setPitch ( float  pitch)
virtual

Set the pitch.

Note
Effect not consistent across backends

Reimplemented in OpenalTorcsSound.

Definition at line 30 of file TorcsSound.cpp.

◆ setReferenceDistance()

virtual void TorcsSound::setReferenceDistance ( float  dist)
inlinevirtual

Reimplemented in OpenalTorcsSound.

Definition at line 80 of file TorcsSound.h.

◆ setSource()

virtual void TorcsSound::setSource ( sgVec3  p,
sgVec3  u 
)
inlinevirtual

Reimplemented in OpenalTorcsSound.

Definition at line 76 of file TorcsSound.h.

◆ setVolume()

void TorcsSound::setVolume ( float  vol)
virtual

Set the volume.

Note
effect not consistent across backends

Reimplemented in OpenalTorcsSound, and PlibTorcsSound.

Definition at line 25 of file TorcsSound.cpp.

◆ start()

virtual void TorcsSound::start ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ stop()

virtual void TorcsSound::stop ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

◆ update()

virtual void TorcsSound::update ( )
pure virtual

Implemented in OpenalTorcsSound, and PlibTorcsSound.

Member Data Documentation

◆ flags

int TorcsSound::flags
protected

Flags relating to what effects are to be used.

Definition at line 56 of file TorcsSound.h.

◆ iface

class SoundInterface* TorcsSound::iface
protected

Handler to the interface.

Definition at line 55 of file TorcsSound.h.

◆ loop

bool TorcsSound::loop
protected

Whether it's a looping sound.

Definition at line 61 of file TorcsSound.h.

◆ lowpass

float TorcsSound::lowpass
protected

Current low pass filter.

Definition at line 60 of file TorcsSound.h.

◆ MAX_VOL

float TorcsSound::MAX_VOL
protected

Maximum volume.

Definition at line 57 of file TorcsSound.h.

◆ pitch

float TorcsSound::pitch
protected

Current pitch.

Definition at line 59 of file TorcsSound.h.

◆ volume

float TorcsSound::volume
protected

Current volume.

Definition at line 58 of file TorcsSound.h.


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