xyginext  0.2.0
Second generation of xygine game creation framework
Public Member Functions | List of all members
xy::AudioScape Class Referencefinal

Contains one or more definitions used to create AudioEmitter components. Similarly to the SpriteSheet class used for loading Sprites from configuration files, AudioScapes can be used to define the settings used to create AudioEmitter components. AudioScape files usually have the extension *.xas with the following ConfigFile compatible layout: More...

#include <AudioScape.hpp>

Public Member Functions

 AudioScape (AudioResource &rx)
 Constructor. More...
 
bool loadFromFile (const std::string &path)
 Attempts to load an AudioScape file from the given path. More...
 
bool saveToFile (const std::string &path)
 Saves the AudioScape configuration to a given path. AudioScape files normally have the extension *.xas.
 
AudioEmitter getEmitter (const std::string &name) const
 Returns an AudioEmitter configured with the given name from the loaded confugration, if it exists, else returns an Uninitialised AudioEmitter. Use AudioEmitter::hasSource() to check validity of the returned emitter.
 
void addEmitter (const std::string &name, const AudioEmitter &emitter)
 Adds an emitter configuration to the AudioScape. More...
 

Detailed Description

Contains one or more definitions used to create AudioEmitter components. Similarly to the SpriteSheet class used for loading Sprites from configuration files, AudioScapes can be used to define the settings used to create AudioEmitter components. AudioScape files usually have the extension *.xas with the following ConfigFile compatible layout:

audio_scape NAME
{
emitter NAME_ONE
{
path = "STR_PATH_TO_FILE"
streaming = BOOL
pitch = FLOAT
volume = FLOAT
relative_listener = BOOL
min_distance = FLOAT
attenuation = FLOAT
looped = BOOL
mixer_channel = INT
}
emitter NAME_TWO
{
path = "STR_PATH_TO_FILE"
streaming = BOOL
pitch = FLOAT
volume = FLOAT
relative_listener = BOOL
min_distance = FLOAT
attenuation = FLOAT
looped = BOOL
mixer_channel = INT
}
}

Emitter properties are optional (except path and streaming) and any omitted properties will fall back to their default values.

Constructor & Destructor Documentation

◆ AudioScape()

xy::AudioScape::AudioScape ( AudioResource rx)
explicit

Constructor.

Parameters
rxReference to an AudioResource object used to cache any non-streamed audio files.

Member Function Documentation

◆ addEmitter()

void xy::AudioScape::addEmitter ( const std::string &  name,
const AudioEmitter emitter 
)

Adds an emitter configuration to the AudioScape.

Parameters
nameName of the AudioEmitter as it appears in the configuration. If an emitter with the name already exists then it will be overwritten.
emitterAn AudioEmitter whose current settings will be saved in the configuration file.

◆ loadFromFile()

bool xy::AudioScape::loadFromFile ( const std::string &  path)

Attempts to load an AudioScape file from the given path.

Parameters
pathString containing the path to the *.xas file to load
Returns
bool true if successful else false