Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends

sp::audio::SoundDevice Class Reference
[Sound System]

#include <spSoundDevice.hpp>

Inheritance diagram for sp::audio::SoundDevice:
sp::audio::DummySoundDevice sp::audio::OpenALSoundDevice sp::audio::OpenSLESSoundDevice sp::audio::WinMMSoundDevice sp::audio::XAudio2SoundDevice

List of all members.

Public Member Functions

virtual ~SoundDevice ()
virtual io::stringc getVersion () const
 Returns the version's name of the sound system.
virtual io::stringc getInterface () const =0
 Returns the interface name of the sound system (e.g. "WinMM", "OpenSL|ES" or "OpenAL 1.1").
void printConsoleHeader ()
 Prints the console header for this sound device.
virtual void updateSounds ()
 Updates all sounds.
virtual SoundcreateSound ()=0
virtual SoundloadSound (const io::stringc &Filename, u8 BufferCount=DEF_SOUND_BUFFERCOUNT)
virtual void deleteSound (Sound *&SoundObject)
 Releases and deletes the Sound object (not the sound file).
virtual SoundEffectcreateSoundEffect ()
virtual void deleteSoundDevice (SoundEffect *&SoundEffectObject)
 Deletes the given sound effect object.
virtual void setListenerPosition (const dim::vector3df &Position)
virtual void setListenerVelocity (const dim::vector3df &Velocity)
virtual void setListenerOrientation (const dim::matrix4f &Orientation)
virtual void setListenerRange (const f32 NearDist, const f32 FarDist, const f32 NearVol, const f32 FarVol)
virtual void getListenerRange (f32 &NearDist, f32 &FarDist, f32 &NearVol, f32 &FarVol) const
virtual void setListenerSpeed (f32 Speed)
 Sets the global listener speed for all sounds. By default 1.0.
virtual f32 getListenerSpeed () const
 Returns the global listener speed for all sounds. By default 1.0.
virtual void setEffectSlot (SoundEffect *Sfx)
SAudioBufferPtr loadAudioPCMBuffer (const io::stringc &Filename)
dim::vector3df getListenerPosition () const
 Returns the listener position. By default (0 | 0 | 0).
dim::vector3df getListenerVelocity () const
 Returns the listener velocity. By default (0 | 0 | 0).
dim::matrix4f getListenerOrientation () const
 Returns the listener orientation. By default the identity matrix.
SoundEffectgetEffectSlot () const
 Returns a pointer to the current effect slot or a null pointer.

Static Public Member Functions

static void setMelodySpeed (f32 Speed)
static void playMelody (const ENoteNames Note, u8 Octave=3, u32 Duration=250, u32 Delay=0)
static void playMelody (io::stringc MelodyCmdStr)

Protected Member Functions

 SoundDevice (const ESoundDevices DeviceType)
virtual void updateSoundVolumetic (Sound *CurSound)

Protected Attributes

ESoundDevices DeviceType_
std::list< Sound * > SoundList_
std::list< SoundEffect * > SoundEffectList_
dim::vector3df ListenerPosition_
dim::vector3df ListenerVelocity_
dim::matrix4f ListenerOrientation_
f32 NearVol_
f32 FarVol_
f32 MiddleVol_
f32 NearDist_
f32 FarDist_
f32 MiddleDist_
f32 ListenerSpeed_
SoundEffectActiveEffectSlot_

Static Protected Attributes

static f32 MelodySpeed_ = 1.0f

Friends

class sp::SoftPixelDevice
class sp::SoftPixelDeviceLinux

Detailed Description

Use this class interface for your sound system.


Constructor & Destructor Documentation

sp::audio::SoundDevice::~SoundDevice (  )  [virtual]
sp::audio::SoundDevice::SoundDevice ( const ESoundDevices  DeviceType  )  [protected]

Member Function Documentation

virtual Sound* sp::audio::SoundDevice::createSound (  )  [pure virtual]

Creates a sound where no sound-file will be loaded.

Returns:
Pointer to the new Sound object.

Implemented in sp::audio::DummySoundDevice, sp::audio::WinMMSoundDevice, sp::audio::OpenALSoundDevice, sp::audio::OpenSLESSoundDevice, and sp::audio::XAudio2SoundDevice.

SoundEffect * sp::audio::SoundDevice::createSoundEffect (  )  [virtual]

Creates a new sound effect. You can exchange the effects for each sound dynamically.

Returns:
Pointer to the new SoundEffect object.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::deleteSound ( Sound *&  SoundObject  )  [virtual]

Releases and deletes the Sound object (not the sound file).

void sp::audio::SoundDevice::deleteSoundDevice ( SoundEffect *&  SoundEffectObject  )  [virtual]

Deletes the given sound effect object.

SoundEffect* sp::audio::SoundDevice::getEffectSlot (  )  const [inline]

Returns a pointer to the current effect slot or a null pointer.

virtual io::stringc sp::audio::SoundDevice::getInterface (  )  const [pure virtual]

Returns the interface name of the sound system (e.g. "WinMM", "OpenSL|ES" or "OpenAL 1.1").

Implemented in sp::audio::DummySoundDevice, sp::audio::WinMMSoundDevice, sp::audio::OpenALSoundDevice, sp::audio::OpenSLESSoundDevice, and sp::audio::XAudio2SoundDevice.

dim::matrix4f sp::audio::SoundDevice::getListenerOrientation (  )  const [inline]

Returns the listener orientation. By default the identity matrix.

dim::vector3df sp::audio::SoundDevice::getListenerPosition (  )  const [inline]

Returns the listener position. By default (0 | 0 | 0).

void sp::audio::SoundDevice::getListenerRange ( f32 NearDist,
f32 FarDist,
f32 NearVol,
f32 FarVol 
) const [virtual]
f32 sp::audio::SoundDevice::getListenerSpeed (  )  const [virtual]

Returns the global listener speed for all sounds. By default 1.0.

dim::vector3df sp::audio::SoundDevice::getListenerVelocity (  )  const [inline]

Returns the listener velocity. By default (0 | 0 | 0).

io::stringc sp::audio::SoundDevice::getVersion (  )  const [virtual]

Returns the version's name of the sound system.

SAudioBufferPtr sp::audio::SoundDevice::loadAudioPCMBuffer ( const io::stringc Filename  ) 

Loads the PCM (pulse-code manipulation) audio raw data from file. This is used internally for OpenAL and XAudio2. But you can use it to read the raw audio data for your own purposes.

Parameters:
[in] Filename Specifies the audio filename. Currently only uncompressed WAV (RIFF WAVE) files are supported.
Returns:
Shared pointer to the SAudioBuffer object.
Note:
You have to delete
See also:
SAudioBuffer
SAudioBufferPtr
Sound * sp::audio::SoundDevice::loadSound ( const io::stringc Filename,
u8  BufferCount = DEF_SOUND_BUFFERCOUNT 
) [virtual]

Loads a sound file from the disk.

Parameters:
Filename,: Filename or path of the sound file which is to be loaded.
BufferCount,: Count of internal sound handles for multiple playback. If 1 you will always hear only one sound when it is played. Use more then one if the sound is to be played several times successively.
void sp::audio::SoundDevice::playMelody ( const ENoteNames  Note,
u8  Octave = 3,
u32  Duration = 250,
u32  Delay = 0 
) [static]

Plays a simple melody using the "Beep" function on Windows and the "beep" command (if installed) on Linux.

Parameters:
Note,: Kind of note which is to be played.
Octave,: Octave number. By default 3 which is the one-line octave.
Duration,: Duration in milliseconds. The programs stops for this time! (Using "Sleep" function on Windows and "usleep" function on Linux)
Delay,: Waiting time after playing (in milliseconds as well).
void sp::audio::SoundDevice::playMelody ( io::stringc  MelodyCmdStr  )  [static]

Plays an array of melodies. This function is using the first "playMelody" function.

Parameters:
MelodyCmdStr,: String with the note commands. The note's name must be in upper case letter (e.g. 'C', 'D', 'DIS', 'FIS' etc). To change the octave you have to write 'O' (for octave) and the number (e.g. "O3" is the default octave). Each command needs to be finished with a semicolon. The time is to be set with 'T' and the number (e.g. "T250" for 250 milliseconds). The delay after playing a melody is to be set with 'S' (for sleeping time) and the duration (e.g. "S100" for 100 milliseconds). Here is an example command string which plays the beginning from the "Super Mario Overworld Theme":

        audio::setMelodySpeed(2);
        audio::playMelody("O3;T250;S10;E;S250;E;E;S10;C;S250;E;S750;G;O2;S0;G;");
void sp::audio::SoundDevice::printConsoleHeader (  ) 

Prints the console header for this sound device.

void sp::audio::SoundDevice::setEffectSlot ( SoundEffect Sfx  )  [virtual]

Sets the effect slot. Currently only one sound effect can be used at a time. But each sound can use this effect individually, i.e. a sound can be played (or emitted) with this active sound effect or not.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::setListenerOrientation ( const dim::matrix4f Orientation  )  [virtual]

Sets the 3D listener orientation.

Parameters:
Orientation,: Transformation matrix which describes the 3D listener's rotation. Use the "getRotationMatrix" function of the active Camera.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::setListenerPosition ( const dim::vector3df Position  )  [virtual]

Sets the 3D listener position.

Parameters:
Position,: 3D position of the listener. Normally the camera position.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::setListenerRange ( const f32  NearDist,
const f32  FarDist,
const f32  NearVol,
const f32  FarVol 
) [virtual]

Sets the 3D listener hearing range.

Parameters:
NearDist,: Distance which must be achieved by the Camera to a 3D sound to hear the sound for "NearVol" (the maximal) volume.
FarDist,: Distance for the "FarVol" (the minimal) volume.
NearVol,: Maximal 3D sound volume.
FarVol,: Minimal 3D sound volume.
void sp::audio::SoundDevice::setListenerSpeed ( f32  Speed  )  [virtual]

Sets the global listener speed for all sounds. By default 1.0.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::setListenerVelocity ( const dim::vector3df Velocity  )  [virtual]

Sets the 3D listener velocity. Used for the doppler effect (not supported yet, implemented for futured sound systems).

Parameters:
Velocity,: Velocity or speed of the movable 3D listener.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::setMelodySpeed ( f32  Speed  )  [static]
void sp::audio::SoundDevice::updateSounds (  )  [virtual]

Updates all sounds.

Reimplemented in sp::audio::OpenALSoundDevice.

void sp::audio::SoundDevice::updateSoundVolumetic ( Sound CurSound  )  [protected, virtual]

Friends And Related Function Documentation

friend class sp::SoftPixelDevice [friend]
friend class sp::SoftPixelDeviceLinux [friend]

Member Data Documentation

f32 sp::audio::SoundDevice::MelodySpeed_ = 1.0f [static, protected]
std::list<Sound*> sp::audio::SoundDevice::SoundList_ [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines