Implementation of IAudioManager wrapping the C API of FMOD and FMOD Studio. FMOD uses audio banks generated with FMOD Studio instead of plain audio files.
More...
#include <FMODWrapper.h>
|
| | FMODWrapper (FS::PackCatalog *catalog, Scripting::ScriptingManager *scriptingManager) |
| virtual void | Update (const float &dt) override |
| | Updates the FMOD system and dispatches safely the timeline marker events.
|
| virtual void | LoadAudio (const std::string &path) override |
| | Loads the .bank and .strings.bank files generated by FMOD Studio.
|
| virtual void | UnloadAudio (const std::string &path) override |
| | Unloads a loaded audio bank. If the audio bank didn't exist or wasn't loaded, it does nothing. This also clears the cached buses with SetMixerVolume/SetBusVolume, as they depend on the bank.
|
| virtual void | PlayBGM (const std::string &eventName) override |
| | Plays an FMOD event after stopping (if applicable) previous started BGMs.
|
| virtual void | PauseBGM () override |
| | Pauses current BGM without changing the timeline position.
|
| virtual void | ResumeBGM () override |
| | Resumes the BGM on the previous timeline position.
|
| virtual void | StopBGM () override |
| | Stops the BGM, essentially resetting its state.
|
| virtual void | SkipToTimelinePosition (const int &ms) override |
| | If playing a BGM, moves the timeline position of the song to the specified point in time.
|
| virtual void | PlayOneShot (const std::string &eventName) override |
| | Plays an audio event without need to stop previous audio events. This is meant to play short SFX. When an audio is played this way, its data is cached to be played again later.
|
|
void | ClearSoundCache () |
| | Clears the cache generated when playing sounds with PlayOneShot.
|
|
void | ClearBusCache () |
| | Clears the cache generated when setting the volume.
|
| virtual void | SetParameter (const std::string ¶meterName, const float &value) override |
| | Sets a parameter that is used in FMOD Studio for different purposes, like blending musics or applying filters. This requires a bank to be loaded.
|
| virtual void | SetMixerVolume (const std::string &busGroupName, const float &value) override |
| | Sets the volume in an audio bus. This requires a bank to be loaded.
|
Implementation of IAudioManager wrapping the C API of FMOD and FMOD Studio. FMOD uses audio banks generated with FMOD Studio instead of plain audio files.
This class also stablishes a callback to be called whenever a BGM event reaches a timeline marker, useful for coordinating game events with the music.
Guarantees:
- Loaded audio banks can have their events played.
- Audio banks are loaded for as long as the FMODWrapper object is not destroyed and the banks are not unloaded.
- Audio parameters from FMOD studio can be changed.
- Volume can be changed on a per bus basis.
- A callback is dispatched in the LUA environment whenever the BGM reaches a timeline marker. They are put in a queue and called safely in the main thread.
- All FMOD elements are correctly released when the FMODWrapper object is destroyed.
Non-responsible:
- Audio banks are not automatically loaded in any way. LoadAudio has to be called for them to be loaded.
Thread safety:
- FMOD is run in a separate thread.
- Update can not be called in a separate thread because it interacts with the scripting system.
◆ FMODWrapper()
- Parameters
-
| catalog | The file system catalog to load the audio banks from. |
| scriptingManager | The scripting manager module, used specifically by this class to dispatch timeline marker events. |
◆ LoadAudio()
| virtual void Mochi::Audio::FMODWrapper::LoadAudio |
( |
const std::string & | path | ) |
|
|
inlineoverridevirtual |
Loads the .bank and .strings.bank files generated by FMOD Studio.
- Parameters
-
| path | The path or unique identifier of the bank in the catalog, without extension (so master will search for Master.bank and Master.strings.bank) |
Implements Mochi::Audio::IAudioManager.
◆ PauseBGM()
| void Mochi::Audio::FMODWrapper::PauseBGM |
( |
| ) |
|
|
overridevirtual |
◆ PlayBGM()
| void Mochi::Audio::FMODWrapper::PlayBGM |
( |
const std::string & | eventName | ) |
|
|
overridevirtual |
Plays an FMOD event after stopping (if applicable) previous started BGMs.
- Parameters
-
| eventName | Name of the event in FMOD Studio. |
Implements Mochi::Audio::IAudioManager.
◆ PlayOneShot()
| void Mochi::Audio::FMODWrapper::PlayOneShot |
( |
const std::string & | eventName | ) |
|
|
overridevirtual |
Plays an audio event without need to stop previous audio events. This is meant to play short SFX. When an audio is played this way, its data is cached to be played again later.
- Parameters
-
| eventName | Name of the event in FMOD Studio. |
Implements Mochi::Audio::IAudioManager.
◆ ResumeBGM()
| void Mochi::Audio::FMODWrapper::ResumeBGM |
( |
| ) |
|
|
overridevirtual |
◆ SetMixerVolume()
| virtual void Mochi::Audio::FMODWrapper::SetMixerVolume |
( |
const std::string & | busGroupName, |
|
|
const float & | value ) |
|
inlineoverridevirtual |
Sets the volume in an audio bus. This requires a bank to be loaded.
- Parameters
-
| busGroupName | The name of the bus group in FMOD Studio. Use an empty string for the master bus. |
| value | A value between 0f and 1f. |
Implements Mochi::Audio::IAudioManager.
◆ SetParameter()
| void Mochi::Audio::FMODWrapper::SetParameter |
( |
const std::string & | parameterName, |
|
|
const float & | value ) |
|
overridevirtual |
Sets a parameter that is used in FMOD Studio for different purposes, like blending musics or applying filters. This requires a bank to be loaded.
- Parameters
-
| parameterName | The name of the parameter in FMOD Studio. |
| value | The value of the parameter. |
Implements Mochi::Audio::IAudioManager.
◆ SkipToTimelinePosition()
| void Mochi::Audio::FMODWrapper::SkipToTimelinePosition |
( |
const int & | ms | ) |
|
|
overridevirtual |
If playing a BGM, moves the timeline position of the song to the specified point in time.
- Parameters
-
| ms | Time in milliseconds to which move on the song. |
Implements Mochi::Audio::IAudioManager.
◆ StopBGM()
| void Mochi::Audio::FMODWrapper::StopBGM |
( |
| ) |
|
|
overridevirtual |
◆ UnloadAudio()
| virtual void Mochi::Audio::FMODWrapper::UnloadAudio |
( |
const std::string & | path | ) |
|
|
inlineoverridevirtual |
Unloads a loaded audio bank. If the audio bank didn't exist or wasn't loaded, it does nothing. This also clears the cached buses with SetMixerVolume/SetBusVolume, as they depend on the bank.
- Parameters
-
| path | The path or unique identifier of the bank, without extension. |
Implements Mochi::Audio::IAudioManager.
◆ Update()
| void Mochi::Audio::FMODWrapper::Update |
( |
const float & | dt | ) |
|
|
overridevirtual |
The documentation for this class was generated from the following files: