Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::Sound Class Reference

Audio class that represents a sound. More...

Inheritance diagram for Nz::Sound:
Nz::SoundEmitter

Public Member Functions

 Sound (const SoundBuffer *soundBuffer)
 Constructs a Sound object. More...
 
 Sound (const Sound &sound)
 Constructs a Sound object which is a copy of another. More...
 
 Sound (Sound &&)=default
 
 ~Sound ()
 Destructs the object and calls Stop. More...
 
void EnableLooping (bool loop) override
 Enables the looping of the music. More...
 
const SoundBufferGetBuffer () const
 Gets the internal buffer. More...
 
UInt32 GetDuration () const override
 Gets the duration of the sound. More...
 
UInt32 GetPlayingOffset () const override
 Gets the current offset in the sound. More...
 
SoundStatus GetStatus () const override
 Gets the status of the music. More...
 
bool IsLooping () const override
 Checks whether the sound is looping. More...
 
bool IsPlayable () const
 Checks whether the sound is playable. More...
 
bool IsPlaying () const
 Checks whether the sound is playing. More...
 
bool LoadFromFile (const String &filePath, const SoundBufferParams &params=SoundBufferParams())
 Loads the sound from file. More...
 
bool LoadFromMemory (const void *data, std::size_t size, const SoundBufferParams &params=SoundBufferParams())
 Loads the sound from memory. More...
 
bool LoadFromStream (Stream &stream, const SoundBufferParams &params=SoundBufferParams())
 Loads the sound from stream. More...
 
void Pause () override
 Pauses the sound.
 
void Play () override
 Plays the music. More...
 
void SetBuffer (const SoundBuffer *buffer)
 Sets the internal buffer. More...
 
void SetPlayingOffset (UInt32 offset)
 Sets the playing offset for the sound. More...
 
void Stop () override
 Stops the sound.
 
Soundoperator= (const Sound &)=delete
 
Soundoperator= (Sound &&)=default
 TODO?
 
- Public Member Functions inherited from Nz::SoundEmitter
virtual ~SoundEmitter ()
 Destructs the object.
 
void EnableSpatialization (bool spatialization)
 Enables spatialization. More...
 
float GetAttenuation () const
 Gets the attenuation. More...
 
float GetMinDistance () const
 Gets the minimum distance to hear. More...
 
float GetPitch () const
 Gets the pitch. More...
 
Vector3f GetPosition () const
 Gets the position of the emitter. More...
 
Vector3f GetVelocity () const
 Gets the velocity of the emitter. More...
 
float GetVolume () const
 Gets the volume of the emitter. More...
 
bool IsSpatialized () const
 Checks whether the sound emitter has spatialization enabled. More...
 
void SetAttenuation (float attenuation)
 Sets the attenuation. More...
 
void SetMinDistance (float minDistance)
 Sets the minimum distance to hear. More...
 
void SetPitch (float pitch)
 Sets the pitch. More...
 
void SetPosition (const Vector3f &position)
 Sets the position of the emitter. More...
 
void SetPosition (float x, float y, float z)
 Sets the position of the emitter. More...
 
void SetVelocity (const Vector3f &velocity)
 Sets the velocity of the emitter. More...
 
void SetVelocity (float velX, float velY, float velZ)
 Sets the velocity of the emitter. More...
 
void SetVolume (float volume)
 Sets the volume of the emitter. More...
 
SoundEmitteroperator= (const SoundEmitter &)=delete
 
SoundEmitteroperator= (SoundEmitter &&)=delete
 TODO.
 

Additional Inherited Members

- Protected Member Functions inherited from Nz::SoundEmitter
 SoundEmitter ()
 Constructs a SoundEmitter object.
 
 SoundEmitter (const SoundEmitter &emitter)
 Constructs a SoundEmitter object which is a copy of another. More...
 
 SoundEmitter (SoundEmitter &&)=delete
 
SoundStatus GetInternalStatus () const
 Gets the status of the sound emitter. More...
 
- Protected Attributes inherited from Nz::SoundEmitter
unsigned int m_source
 

Detailed Description

Audio class that represents a sound.

Remarks
Module Audio needs to be initialized to use this class

Constructor & Destructor Documentation

◆ Sound() [1/2]

Nz::Sound::Sound ( const SoundBuffer soundBuffer)

Constructs a Sound object.

Parameters
soundBufferBuffer to read sound from

◆ Sound() [2/2]

Nz::Sound::Sound ( const Sound sound)

Constructs a Sound object which is a copy of another.

Parameters
soundSound to copy

◆ ~Sound()

Nz::Sound::~Sound ( )

Destructs the object and calls Stop.

See also
Stop

Member Function Documentation

◆ EnableLooping()

void Nz::Sound::EnableLooping ( bool  loop)
overridevirtual

Enables the looping of the music.

Parameters
loopShould sound loop

Implements Nz::SoundEmitter.

◆ GetBuffer()

const SoundBuffer * Nz::Sound::GetBuffer ( ) const

Gets the internal buffer.

Returns
Internal buffer

◆ GetDuration()

UInt32 Nz::Sound::GetDuration ( ) const
overridevirtual

Gets the duration of the sound.

Returns
Duration of the music in milliseconds
Remarks
Produces a NazaraError if there is no buffer

Implements Nz::SoundEmitter.

◆ GetPlayingOffset()

UInt32 Nz::Sound::GetPlayingOffset ( ) const
overridevirtual

Gets the current offset in the sound.

Returns
Offset in milliseconds (works with entire seconds)

Implements Nz::SoundEmitter.

◆ GetStatus()

SoundStatus Nz::Sound::GetStatus ( ) const
overridevirtual

Gets the status of the music.

Returns
Enumeration of type SoundStatus (Playing, Stopped, ...)

Implements Nz::SoundEmitter.

◆ IsLooping()

bool Nz::Sound::IsLooping ( ) const
overridevirtual

Checks whether the sound is looping.

Returns
true if it is the case

Implements Nz::SoundEmitter.

◆ IsPlayable()

bool Nz::Sound::IsPlayable ( ) const

Checks whether the sound is playable.

Returns
true if it is the case

◆ IsPlaying()

bool Nz::Sound::IsPlaying ( ) const

Checks whether the sound is playing.

Returns
true if it is the case

◆ LoadFromFile()

bool Nz::Sound::LoadFromFile ( const String filePath,
const SoundBufferParams &  params = SoundBufferParams() 
)

Loads the sound from file.

Returns
true if loading is successful
Parameters
filePathPath to the file
paramsParameters for the sound
Remarks
Produces a NazaraError if loading failed

◆ LoadFromMemory()

bool Nz::Sound::LoadFromMemory ( const void *  data,
std::size_t  size,
const SoundBufferParams &  params = SoundBufferParams() 
)

Loads the sound from memory.

Returns
true if loading is successful
Parameters
dataRaw memory
sizeSize of the memory
paramsParameters for the sound
Remarks
Produces a NazaraError if loading failed

◆ LoadFromStream()

bool Nz::Sound::LoadFromStream ( Stream stream,
const SoundBufferParams &  params = SoundBufferParams() 
)

Loads the sound from stream.

Returns
true if loading is successful
Parameters
streamStream to the sound
paramsParameters for the sound
Remarks
Produces a NazaraError if loading failed

◆ Play()

void Nz::Sound::Play ( )
overridevirtual

Plays the music.

Remarks
Produces a NazaraError if the sound is not playable with NAZARA_AUDIO_SAFE defined

Implements Nz::SoundEmitter.

◆ SetBuffer()

void Nz::Sound::SetBuffer ( const SoundBuffer buffer)

Sets the internal buffer.

Parameters
bufferInternal buffer
Remarks
Produces a NazaraError if buffer is invalid with NAZARA_AUDIO_SAFE defined

◆ SetPlayingOffset()

void Nz::Sound::SetPlayingOffset ( UInt32  offset)

Sets the playing offset for the sound.

Parameters
offsetOffset in the sound in milliseconds

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