SuperTuxKart
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MusicInformation Class Reference

Wrapper around an instance of the Music interface Adds information like composer, song title, etc... More...

#include <music_information.hpp>

Inheritance diagram for MusicInformation:
Inheritance graph
[legend]

Public Member Functions

void addMusicToTracks ()
 
bool isPlaying () const
 
const stringw & getComposer () const
 Returns the composer of the music. More...
 
const stringw & getTitle () const
 Returns the title of the music. More...
 
const std::string & getNormalFilename () const
 Returns the filename of the normal speed music. More...
 
const std::string & getFastFilename () const
 If available, returns the file name of the faster/last-lap music. More...
 
float getMaxPitch () const
 

Static Public Member Functions

static MusicInformationcreate (const std::string &filename)
 A simple factory to create music information files without raising an exception on error, instead a NULL will be returned. More...
 

Private Types

enum  { SOUND_NORMAL, SOUND_FADING, SOUND_FASTER, SOUND_FAST }
 

Private Member Functions

 MusicInformation (const XMLNode *root, const std::string &filename)
 
void update (float dt)
 
void startMusic ()
 Starts the music.
 
void stopMusic ()
 
void pauseMusic ()
 
void resumeMusic ()
 
void setDefaultVolume ()
 
void switchToFastMusic ()
 
void setTemporaryVolume (float volume)
 Overwrites the current volume with a temporary value (used e.g. More...
 
void setMusicWaiting ()
 Sets the music to be waiting, i.e. More...
 

Private Attributes

stringw m_composer
 
stringw m_title
 
std::string m_normal_filename
 
std::string m_fast_filename
 
std::vector< std::string > m_all_tracks
 
bool m_music_waiting
 If music is loaded but hasn't been started yet (MusicManager::startMusic() was told not to start right away). More...
 
bool m_enable_fast
 If faster music is enabled at all (either separate file or using the pitch shift approach). More...
 
float m_gain
 
float m_normal_loop_start
 
float m_fast_loop_start
 
float m_faster_time
 Either time for fading faster music in, or time to change pitch. More...
 
float m_max_pitch
 Maximum pitch for faster music. More...
 
std::mutex m_music_mutex
 
Musicm_normal_music
 
Musicm_fast_music
 
enum MusicInformation:: { ... }  m_mode
 < playing faster music or max pitch reached
 
float m_time_since_faster
 

Static Private Attributes

static const int LOOP_FOREVER =-1
 

Friends

class SFXManager
 

Detailed Description

Wrapper around an instance of the Music interface Adds information like composer, song title, etc...

Delegates many calls to the underlying Music instance.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
SOUND_NORMAL 

normal music is played

SOUND_FADING 

normal music fading out, faster fading in

SOUND_FASTER 

change pitch of normal music

Member Function Documentation

◆ create()

MusicInformation * MusicInformation::create ( const std::string &  filename)
static

A simple factory to create music information files without raising an exception on error, instead a NULL will be returned.

This avoids resource freeing problems if the exception is raised, and simplifies calling code.

Parameters
filenameThe name of a music file.
Returns
The MusicInformation object, or NULL in case of an error.

◆ getComposer()

const stringw& MusicInformation::getComposer ( ) const
inline

Returns the composer of the music.

◆ getFastFilename()

const std::string& MusicInformation::getFastFilename ( ) const
inline

If available, returns the file name of the faster/last-lap music.

◆ getNormalFilename()

const std::string& MusicInformation::getNormalFilename ( ) const
inline

Returns the filename of the normal speed music.

◆ getTitle()

const stringw& MusicInformation::getTitle ( ) const
inline

Returns the title of the music.

◆ setMusicWaiting()

void MusicInformation::setMusicWaiting ( )
inlineprivate

Sets the music to be waiting, i.e.

startMusic still needs to be called. Used to pre-load track music during track loading time.

◆ setTemporaryVolume()

void MusicInformation::setTemporaryVolume ( float  volume)
private

Overwrites the current volume with a temporary value (used e.g.

to fade from normal music to last lap music).

Member Data Documentation

◆ m_enable_fast

bool MusicInformation::m_enable_fast
private

If faster music is enabled at all (either separate file or using the pitch shift approach).

◆ m_faster_time

float MusicInformation::m_faster_time
private

Either time for fading faster music in, or time to change pitch.

◆ m_max_pitch

float MusicInformation::m_max_pitch
private

Maximum pitch for faster music.

◆ m_music_waiting

bool MusicInformation::m_music_waiting
private

If music is loaded but hasn't been started yet (MusicManager::startMusic() was told not to start right away).


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