VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
|
Central class handling all outside communication. More...
#include <vae_engine.hpp>
Public Member Functions | |
Engine ()=default | |
Engine (const Engine &)=delete | |
Don't allow any kind of move of copy of the object. More... | |
Engine (const Engine *)=delete | |
Engine (Engine &&)=delete | |
Engine & | operator= (const Engine &)=delete |
Engine & | operator= (Engine &&)=delete |
~Engine () | |
Result | setMixerVolume (BankHandle bank, MixerHandle mixer, Sample volume) |
Set the Mixer Volume. More... | |
Result | muteMixerEffect (BankHandle bank, MixerHandle mixer, Size index, bool mute) |
Bypass a effect in a mixer. More... | |
Result | setMixerEffectParameter (BankHandle bank, MixerHandle mixer, Size index, Size param, Sample value) |
Set the Mixer Effect Parameter. More... | |
ListenerHandle _VAE_PUBLIC_API | createListener () |
Create a Listener object. More... | |
Result _VAE_PUBLIC_API | removeListener (ListenerHandle listener) |
Unregister listener. More... | |
Result _VAE_PUBLIC_API | setListener (ListenerHandle listener, const LocationOrientation &locOr) |
Set the position of a listener. More... | |
Result _VAE_PUBLIC_API | loadHRTF (const char *path, Size size=0) |
Engine Controls | |
Main engine functionality | |
Result _VAE_PUBLIC_API | init (const EngineConfig &config={}) |
Initializes the engine and does most of the upfront allocations. More... | |
Result _VAE_PUBLIC_API | start () |
Tries to open default device and start audio thread. More... | |
Result _VAE_PUBLIC_API | stop () |
Stops processing and waits for audio thead to clean up. More... | |
void _VAE_PUBLIC_API | update () |
Update function needs to be called regularly to handle outbound events and other housekeeping. More... | |
template<typename T > | |
void | process (const SampleIndex frames, T *output, int channels) |
Result _VAE_PUBLIC_API | fireEvent (BankHandle bankHandle, EventHandle eventHandle, EmitterHandle emitterHandle, Sample gain=1.0, MixerHandle mixerHandle=InvalidMixerHandle, ListenerHandle listenerHandle=AllListeners) |
Main mechanism to start and stop sounds. More... | |
Result _VAE_PUBLIC_API | fireGlobalEvent (GlobalEventHandle globalHandle, EmitterHandle emitterHandle, Sample gain=1.0, MixerHandle mixerHandle=InvalidMixerHandle, ListenerHandle listenerHandle=AllListeners) |
Works like fireEvent but with a global Event identifier. More... | |
Size _VAE_PUBLIC_API | getActiveVoiceCount () const |
Get the number of currently playing Voices. More... | |
Size _VAE_PUBLIC_API | getStreamTime () const |
void _VAE_PUBLIC_API | setMasterVolume (Sample volume) |
Set the global output volume before the limiter. More... | |
bool _VAE_PUBLIC_API | checkVersion (int major, int minor, int patch) |
Check if the compiled version matches. More... | |
Emitter manipulation | |
Contains everything related to emitter creation and basic manipulation of voices started from them | |
EmitterHandle _VAE_PUBLIC_API | createEmitter () |
Creates an emitter and returns the handle. More... | |
EmitterHandle _VAE_PUBLIC_API | createAutoEmitter (BankHandle bank, EventHandle event, float maxDist, const LocationDirection &locDir, float spread) |
Emitter which triggers an event once a listener is close enough. More... | |
Result _VAE_PUBLIC_API | addEmitter (EmitterHandle h) |
Adds an emitter with a custom handle, can be an internal ID for example. More... | |
Result _VAE_PUBLIC_API | removeEmitter (EmitterHandle h) |
Unregister a emiter an kill all its voices. More... | |
Result _VAE_PUBLIC_API | setEmitter (EmitterHandle emitter, const LocationDirection &locDir, float spread) |
Set the Emitter position, orientation and spread. More... | |
Result _VAE_PUBLIC_API | stopEmitter (EmitterHandle emitter) |
Stop all voices from emitter. More... | |
void _VAE_PUBLIC_API | setVolume (EmitterHandle emitter, Sample gain) |
Sets the volume of all active voices with this emitter. More... | |
void _VAE_PUBLIC_API | seek (EmitterHandle emitter, Size time) |
Set the current time of all voices with the emitter. More... | |
void _VAE_PUBLIC_API | setSpeed (EmitterHandle emitter, float speed) |
Set the playback speed. More... | |
void _VAE_PUBLIC_API | setLowpass (EmitterHandle emitter, float cutoff) |
Simple lowpass filter for the voices. More... | |
void _VAE_PUBLIC_API | setHighpass (EmitterHandle emitter, float cutoff) |
Simple highpass filter for the voices. More... | |
Ressource Management | |
Everything related to Bank and other ressource loading/unloading | |
Result _VAE_PUBLIC_API | loadBank (const char *path, Size size=0) |
Load bank from filesystem. More... | |
Result | loadBank (Bank &bank) |
Load bank from memory. More... | |
Result | addSource (BankHandle bankHandle, Source &source) |
Add or replace a source in a bank. More... | |
Result | addEvent (BankHandle bankHandle, Event &event) |
Add or replace event in a bank Locks audio thread. More... | |
Result | addMixer (BankHandle bankHandle, Mixer &mixer) |
Result | addBank (Bank &bank) |
Result _VAE_PUBLIC_API | unloadBankFromId (BankHandle bankHandle) |
Unload bank from handle. More... | |
void _VAE_PUBLIC_API | unloadAllBanks () |
Unload every bank and data associated with it. More... | |
Private Types | |
using | Thread = std::thread |
using | ConditionVariable = std::condition_variable |
Private Member Functions | |
void | process () |
Main processing function. More... | |
void | onBufferSwap (Device *device) |
Called from audio device when it needs more audio. More... | |
void | threadedProcess () |
Called from own audio thread, not the device. More... | |
void | onThreadedBufferSwap (Device *device) |
Called from audio device when using seperate audio thread. More... | |
Private Attributes | |
EngineConfig | mConfig |
Config object provided at initlalization. More... | |
VoiceManger | mVoiceManager |
Holds and handle voices. More... | |
SpatialManager | mSpatialManager |
Holds and manages spatial emitters. More... | |
BankManager | mBankManager |
Holds and manages banks. More... | |
Processor | mProcessor |
Default Voice processor. More... | |
MixerProcessor | mMixerProcessor |
Mixer channel processor. More... | |
SpatialProcessor | mSpatialProcessor |
Spatial voice processor. More... | |
ScratchBuffer | mScratchBuffer |
used to combine the signal from all banks and push it to the device More... | |
SampleIndex | mTime = 0 |
Global engine time in samples. More... | |
Time | mTimeFract = 0 |
Global engine time in seconds. More... | |
Sample | mLimiterLastPeak = 1.0 |
Master limiter last peak. More... | |
Sample | mMasterVolume = 1.0 |
Master Colume applied after limiting. More... | |
Device * | mDevice = nullptr |
Output device. More... | |
Thread * | mAudioThread |
Thread processing voices and mixers. More... | |
ConditionVariable | mAudioConsumed |
Notifies the audio thread when more audio is needed. More... | |
std::mutex | mMutex |
Mutex needed to use mAudioConsumed, doesn't actually do anything else. More... | |
bool | mAudioThreadRunning = false |
Central class handling all outside communication.
Can be sealed off by using EnginePimpl instead
Definition at line 48 of file vae_engine.hpp.
|
private |
Definition at line 71 of file vae_engine.hpp.
|
private |
Definition at line 70 of file vae_engine.hpp.
|
default |
|
delete |
Don't allow any kind of move of copy of the object.
|
delete |
|
delete |
|
inline |
Definition at line 209 of file vae_engine.hpp.
Definition at line 825 of file vae_engine.hpp.
|
inline |
Adds an emitter with a custom handle, can be an internal ID for example.
migt be desireable to make EmitterHandle the same size as a pointer so this can simply be the pointer of the entity that is associated with it.
h |
Definition at line 598 of file vae_engine.hpp.
|
inline |
Add or replace event in a bank Locks audio thread.
bankHandle | |
event | Moved and now owned by bank |
Definition at line 817 of file vae_engine.hpp.
|
inline |
Definition at line 821 of file vae_engine.hpp.
|
inline |
Add or replace a source in a bank.
bankHandle | |
source | Moved and now owned by bank |
Definition at line 806 of file vae_engine.hpp.
|
inline |
Check if the compiled version matches.
Definition at line 550 of file vae_engine.hpp.
|
inline |
Emitter which triggers an event once a listener is close enough.
bank | |
event | |
maxDist | |
locDir | |
spread |
Definition at line 584 of file vae_engine.hpp.
|
inline |
Creates an emitter and returns the handle.
Definition at line 570 of file vae_engine.hpp.
|
inline |
Create a Listener object.
TODO make listener 0 implicit
Definition at line 742 of file vae_engine.hpp.
|
inline |
Main mechanism to start and stop sounds.
bankHandle | bank id where the event is provided |
eventHandle | id of the event |
emitterHandle | handle of the emitter, needed for spatial audio or controlling the voice |
gain | optional volume factor |
mixerHandle | optional id of mixer channel sound will be routed to, this will override the one set in the event |
listenerHandle | For which listener this event will be adible for, default to all |
Definition at line 389 of file vae_engine.hpp.
|
inline |
Works like fireEvent but with a global Event identifier.
globalHandle | The GlobalEventHandle combines both bank and event id |
emitterHandle | optional handle of the emitter, needed for spatial audio |
gain | optional volume factor |
mixerHandle | id of mixer channel sound will be routed to, this will override the one set in the event |
Definition at line 510 of file vae_engine.hpp.
|
inline |
Get the number of currently playing Voices.
Definition at line 529 of file vae_engine.hpp.
|
inline |
Definition at line 533 of file vae_engine.hpp.
|
inline |
Initializes the engine and does most of the upfront allocations.
Run this before start !
Everything will be allocated according to the provided config. Loading a Bank will still cause an allocation. If there are already banks loaded, they will be reloaded to have the correct samplerate.
config | Optional config to setup the internals. |
Definition at line 230 of file vae_engine.hpp.
Load bank from memory.
bank | Moved and now owned by the engine |
Definition at line 796 of file vae_engine.hpp.
|
inline |
Load bank from filesystem.
This operation might take a little time but won't lock the audio thread until the bank is inserted. This should be safe to do at any time.
path |
Definition at line 786 of file vae_engine.hpp.
|
inline |
Definition at line 763 of file vae_engine.hpp.
|
inline |
Bypass a effect in a mixer.
bank | |
mixer | |
index | See setMixerEffectParameter |
mute |
Definition at line 704 of file vae_engine.hpp.
|
inlineprivate |
Called from audio device when it needs more audio.
This will do synchronous processing.
device |
Definition at line 163 of file vae_engine.hpp.
|
inlineprivate |
Called from audio device when using seperate audio thread.
This will only notify the adio thread to do work.
device |
Definition at line 189 of file vae_engine.hpp.
|
inlineprivate |
Main processing function.
Called either from onBufferSwap or threadedProcess This does't need to be locked since it only renders the banks. The data accessed from this class will only be used from this thread. The bank however needs to be locks which happens in the bankmanager
Definition at line 86 of file vae_engine.hpp.
|
inline |
Definition at line 348 of file vae_engine.hpp.
|
inline |
Unregister a emiter an kill all its voices.
h |
Definition at line 607 of file vae_engine.hpp.
|
inline |
Unregister listener.
listener |
Definition at line 750 of file vae_engine.hpp.
|
inline |
Set the current time of all voices with the emitter.
emitter | |
time | Time in samples |
Definition at line 648 of file vae_engine.hpp.
|
inline |
Set the Emitter position, orientation and spread.
emitter | The emitter |
locDir | The desired location |
spread | The width of the panning (if it's spatial and not HRTF) |
Definition at line 619 of file vae_engine.hpp.
|
inline |
Simple highpass filter for the voices.
emitter | |
cutoff | 0-1. 0 doesn't filter, 1 filter the wholespektrum |
Definition at line 675 of file vae_engine.hpp.
|
inline |
Set the position of a listener.
listener |
Definition at line 759 of file vae_engine.hpp.
|
inline |
Simple lowpass filter for the voices.
emitter | |
cutoff | 0-1. 0 doesn't filter, 1 filter the wholespektrum |
Definition at line 666 of file vae_engine.hpp.
|
inline |
Set the global output volume before the limiter.
The engine can't clip, but if the output is too load the signal will be squashed in the limiter.
volume | 1.0 is the default, not interpolated for now |
Definition at line 543 of file vae_engine.hpp.
|
inline |
Set the Mixer Effect Parameter.
bank | |
mixer | |
index | which effects slot out of StaticConfig::MaxMixerEffects |
param | which param by index out of StaticConfig::MaxEffectsParameter |
value | value of the parameter from 0 to 1 |
Definition at line 719 of file vae_engine.hpp.
|
inline |
Set the Mixer Volume.
bank | |
mixer | |
volume |
Definition at line 690 of file vae_engine.hpp.
|
inline |
Set the playback speed.
emitter | |
speed | 1.0 is the default speed, pitch will be affected as well. |
Definition at line 657 of file vae_engine.hpp.
|
inline |
Sets the volume of all active voices with this emitter.
emitter | |
gain |
Definition at line 639 of file vae_engine.hpp.
|
inline |
Tries to open default device and start audio thread.
Call this after start.
Definition at line 251 of file vae_engine.hpp.
|
inline |
Stops processing and waits for audio thead to clean up.
Definition at line 286 of file vae_engine.hpp.
|
inline |
Stop all voices from emitter.
emitter |
Definition at line 630 of file vae_engine.hpp.
|
inlineprivate |
Called from own audio thread, not the device.
Definition at line 175 of file vae_engine.hpp.
|
inline |
Unload every bank and data associated with it.
Definition at line 845 of file vae_engine.hpp.
|
inline |
Unload bank from handle.
Locks audio thread and stops all voices from that bank.
bankHandle |
Definition at line 835 of file vae_engine.hpp.
|
inline |
Update function needs to be called regularly to handle outbound events and other housekeeping.
If this isn't called regularly events might be lost and chained events not fired. When EngineConfig::updateInAudioThread is true, this doesn't need to be called manually.
Definition at line 317 of file vae_engine.hpp.
|
private |
Notifies the audio thread when more audio is needed.
Definition at line 73 of file vae_engine.hpp.
|
private |
Thread processing voices and mixers.
Definition at line 72 of file vae_engine.hpp.
|
private |
Definition at line 75 of file vae_engine.hpp.
|
private |
Holds and manages banks.
Definition at line 53 of file vae_engine.hpp.
|
private |
Config object provided at initlalization.
Definition at line 49 of file vae_engine.hpp.
|
private |
Output device.
Definition at line 66 of file vae_engine.hpp.
|
private |
Master limiter last peak.
Definition at line 62 of file vae_engine.hpp.
|
private |
Master Colume applied after limiting.
Definition at line 63 of file vae_engine.hpp.
|
private |
Mixer channel processor.
Definition at line 56 of file vae_engine.hpp.
|
private |
Mutex needed to use mAudioConsumed, doesn't actually do anything else.
Definition at line 74 of file vae_engine.hpp.
|
private |
Default Voice processor.
Definition at line 55 of file vae_engine.hpp.
|
private |
used to combine the signal from all banks and push it to the device
Definition at line 59 of file vae_engine.hpp.
|
private |
Holds and manages spatial emitters.
Definition at line 52 of file vae_engine.hpp.
|
private |
Spatial voice processor.
Definition at line 57 of file vae_engine.hpp.
|
private |
Global engine time in samples.
Definition at line 60 of file vae_engine.hpp.
|
private |
Global engine time in seconds.
Definition at line 61 of file vae_engine.hpp.
|
private |
Holds and handle voices.
Definition at line 51 of file vae_engine.hpp.