Saga
Saga Game Engine
Loading...
Searching...
No Matches
audioEngine.h File Reference
#include "fmod.h"
#include "fmod_studio.h"
#include <map>
#include <string>
#include <glm/vec3.hpp>
#include <memory>
Include dependency graph for audioEngine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Saga::AudioImplementation
 Stores data for implementing the Audio Engine. This includes various maps to fmod events and banks, as well as a reference to FMOD_STUDIO_SYSTEM. More...
 
struct  Saga::AudioEngine::ParameterValue
 Value of a parameter in FMOD. Whenever a parameter is retrieved from an event (or globally), it will be in this form. More...
 
struct  Saga::AudioEngine::EventAttributes
 A collection of vectors that specify an object in 3D space. This allows the AudioEngine to determine where listeners as well as AudioEventInstance are situated in space. More...
 

Namespaces

namespace  Saga
 
namespace  Saga::AudioEngine
 This contains a collection of methods that interfaces with the FMOD studio API to play audio.
 

Typedefs

using Saga::AudioEventInstance = FMOD_STUDIO_EVENTINSTANCE *
 An audio instance equivalent to an instance of a sound. Can be start and stop. For correct 3D positioning of an instance, make sure to update the 3D position every frame.
 

Functions

bool Saga::AudioEngine::init ()
 Initialize the Audio Engine. Must be called before any other audio operation.
 
void Saga::AudioEngine::update ()
 Update the Audio Engine. Needs to be run every frame for accurate result.
 
bool Saga::AudioEngine::release ()
 Release the Audio Engine. Must be called after init, and no audio operation should work after this call.
 
void Saga::AudioEngine::loadBank (const std::string &bankFileName, FMOD_STUDIO_LOAD_BANK_FLAGS flags=FMOD_STUDIO_LOAD_BANK_NORMAL)
 Load a bank of audio. By default, sample data will not be loaded. It is important that both the bank files and bank's strings file are loaded before events can be played.
 
void Saga::AudioEngine::unloadBank (const std::string &bankName)
 Unload bank.
 
void Saga::AudioEngine::loadEvent (const std::string &eventName, bool loadSampleData=false)
 Load an event from a loaded bank.
 
void Saga::AudioEngine::loadSampleData (const std::string &eventName)
 Load an event's sample data, allowing for event instances to be spawned and play instantaneously. For every call to load, you must call unload after. Loads and unloads are reference-counted, so the event's data won't completely unload until every load is followed by an unload.
 
void Saga::AudioEngine::unloadSampleData (const std::string &eventName)
 Unload an event's sample data.
 
AudioEventInstance Saga::AudioEngine::playEvent (const std::string &eventName)
 Play an event. If this event is not loaded, loadEvent will be called.
 
AudioEventInstance Saga::AudioEngine::createInstance (const std::string &eventName)
 Create an instance of a sound event. If this event has not been loaded, loadEvent will be called.
 
void Saga::AudioEngine::playEvent (AudioEventInstance event)
 Play an event.
 
void Saga::AudioEngine::stopEvent (AudioEventInstance event, bool immediate=false)
 Stop an event that's playing.
 
void Saga::AudioEngine::releaseEvent (AudioEventInstance event)
 Release an event instance. After this, the event instance is unusable.
 
void Saga::AudioEngine::releaseAllEventInstances (const std::string &eventName)
 Release all event instances associated with this event.
 
void Saga::AudioEngine::unloadEvent (const std::string &eventName, bool unloadSampleData=false)
 Unload an event. This effectively removes the ability to create instances of the event until it is loaded again.
 
void Saga::AudioEngine::setParameter (AudioEventInstance instance, const std::string &parameterName, float value)
 Set a parameter on an event instance.
 
ParameterValue Saga::AudioEngine::getParameter (AudioEventInstance instance, const std::string &parameterName)
 Get the value of an event.
 
void Saga::AudioEngine::setLabeledParameter (AudioEventInstance instance, const std::string &parameterName, std::string label)
 Set a parameter on an event instance to a labeled value.
 
std::string Saga::AudioEngine::getLabeledParameter (AudioEventInstance instance, const std::string &parameterName)
 Get the label-value of a parameter.
 
void Saga::AudioEngine::setGlobalParameter (const std::string &parameterName, float value)
 Set a global parameter.
 
ParameterValue Saga::AudioEngine::getGlobalParameter (const std::string &parameterName)
 Get the value of a global parameter.
 
void Saga::AudioEngine::setGlobalLabeledParameter (const std::string &parameterName, std::string label)
 Set the value of a global parameter by label.
 
std::string Saga::AudioEngine::getGlobalLabeledParameter (const std::string &parameterName)
 Get the label value of a global parameter.
 
void Saga::AudioEngine::setListenerData (const EventAttributes &attributes)
 Set the 3D position of the listener.
 
void Saga::AudioEngine::set3DAttributes (AudioEventInstance instance, const EventAttributes &attributes)
 Set the 3D attributes of an audio event instance.
 
FMOD_VECTOR Saga::AudioEngine::vectorToFmod (const glm::vec3 &vPosition)
 Convert a glm vector to an fmod vector.
 

Variables

const int Saga::AudioEngine::maxChannels = 32
 Maximum channels we will use for FMOD. Usually you don't need that many (probably 4-5 would be ok).