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

Audio class that represents a music. More...

Inheritance diagram for Nz::Music:
Nz::Resource Nz::SoundEmitter

Public Member Functions

 Music (const Music &)=delete
 
 Music (Music &&)=delete
 
 ~Music ()
 Destructs the object and calls Destroy. More...
 
bool Create (SoundStream *soundStream)
 Creates a music with a sound stream. More...
 
void Destroy ()
 Destroys the current music and frees resources. More...
 
void EnableLooping (bool loop) override
 Enables the looping of the music. More...
 
UInt32 GetDuration () const override
 Gets the duration of the music. More...
 
AudioFormat GetFormat () const
 Gets the format of the music. More...
 
UInt32 GetPlayingOffset () const override
 Gets the current offset in the music. More...
 
UInt64 GetSampleCount () const
 Gets the number of samples in the music. More...
 
UInt32 GetSampleRate () const
 Gets the rates of sample in the music. More...
 
SoundStatus GetStatus () const override
 Gets the status of the music. More...
 
bool IsLooping () const override
 Checks whether the music is looping. More...
 
bool OpenFromFile (const String &filePath, const MusicParams &params=MusicParams())
 Opens the music from a file. More...
 
bool OpenFromMemory (const void *data, std::size_t size, const MusicParams &params=MusicParams())
 Opens the music from memory. More...
 
bool OpenFromStream (Stream &stream, const MusicParams &params=MusicParams())
 Loads the music from stream. More...
 
void Pause () override
 Pauses the music. More...
 
void Play () override
 Plays the music. More...
 
void SetPlayingOffset (UInt32 offset)
 Changes the playing offset of the music. More...
 
void Stop () override
 Stops the music. More...
 
Musicoperator= (const Music &)=delete
 
Musicoperator= (Music &&)=delete
 
- Public Member Functions inherited from Nz::Resource
 Resource (const Resource &)=default
 
 Resource (Resource &&) noexcept=default
 
const StringGetFilePath () const
 Gets the file path associated with the resource. More...
 
void SetFilePath (const String &filePath)
 Sets the file path associated with the resource. More...
 
Resourceoperator= (const Resource &)=default
 
Resourceoperator= (Resource &&) noexcept=default
 
- 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 music.

Remarks
Module Audio needs to be initialized to use this class

Constructor & Destructor Documentation

◆ ~Music()

Nz::Music::~Music ( )

Destructs the object and calls Destroy.

See also
Destroy

Member Function Documentation

◆ Create()

bool Nz::Music::Create ( SoundStream soundStream)

Creates a music with a sound stream.

Returns
true if creation was succesful
Parameters
soundStreamSound stream which is the source for the music

◆ Destroy()

void Nz::Music::Destroy ( )

Destroys the current music and frees resources.

Remarks
If the Music is playing, it is stopped first.

◆ EnableLooping()

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

Enables the looping of the music.

Parameters
loopShould music loop
Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ GetDuration()

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

Gets the duration of the music.

Returns
Duration of the music in milliseconds
Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ GetFormat()

AudioFormat Nz::Music::GetFormat ( ) const

Gets the format of the music.

Returns
Enumeration of type AudioFormat (mono, stereo, ...)
Remarks
Music must be valid when calling this function

◆ GetPlayingOffset()

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

Gets the current offset in the music.

Returns
Offset in milliseconds (works with entire seconds)
Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ GetSampleCount()

UInt64 Nz::Music::GetSampleCount ( ) const

Gets the number of samples in the music.

Returns
Count of samples (number of seconds * sample rate * channel count)
Remarks
Music must be valid when calling this function

◆ GetSampleRate()

UInt32 Nz::Music::GetSampleRate ( ) const

Gets the rates of sample in the music.

Returns
Rate of sample in Hertz (Hz)
Remarks
Music must be valid when calling this function

◆ GetStatus()

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

Gets the status of the music.

Returns
Enumeration of type SoundStatus (Playing, Stopped, ...)
Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ IsLooping()

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

Checks whether the music is looping.

Returns
true if it is the case
Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ OpenFromFile()

bool Nz::Music::OpenFromFile ( const String filePath,
const MusicParams &  params = MusicParams() 
)

Opens the music from a file.

Returns
true if the file was successfully opened
Parameters
filePathPath to the file
paramsParameters for the music

◆ OpenFromMemory()

bool Nz::Music::OpenFromMemory ( const void *  data,
std::size_t  size,
const MusicParams &  params = MusicParams() 
)

Opens the music from memory.

Returns
true if loading is successful
Parameters
dataRaw memory
sizeSize of the memory
paramsParameters for the music
Remarks
The memory pointer must stay valid (accessible) as long as the music is playing

◆ OpenFromStream()

bool Nz::Music::OpenFromStream ( Stream stream,
const MusicParams &  params = MusicParams() 
)

Loads the music from stream.

Returns
true if loading is successful
Parameters
streamStream to the music
paramsParameters for the music
Remarks
The stream must stay valid as long as the music is playing

◆ Pause()

void Nz::Music::Pause ( )
overridevirtual

Pauses the music.

Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ Play()

void Nz::Music::Play ( )
overridevirtual

Plays the music.

Plays/Resume the music. If the music is currently playing, resets the playing offset to the beginning offset. If the music is currently paused, resumes the playing. If the music is currently stopped, starts the playing at the previously set playing offset.

Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.

◆ SetPlayingOffset()

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

Changes the playing offset of the music.

If the music is not playing, this sets the playing offset for the next Play call

Parameters
offsetThe offset in milliseconds
Remarks
Music must be valid when calling this function

◆ Stop()

void Nz::Music::Stop ( )
overridevirtual

Stops the music.

Remarks
Music must be valid when calling this function

Implements Nz::SoundEmitter.


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