VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae::EnginePimpl Class Reference

Sealed of version of vae::core::Engine. More...

#include <vae_pimpl.hpp>

Collaboration diagram for vae::EnginePimpl:

Public Member Functions

void _VAE_API_EXPORT destroy ()
 
Result _VAE_API_EXPORT init (const EngineConfig &config={})
 Initializes the engine and does most of the upfront allocations. More...
 
Result _VAE_API_EXPORT start ()
 Tries to open default device and start audio thread. More...
 
Result _VAE_API_EXPORT stop ()
 Stops processing and waits for audio thead to clean up. More...
 
void _VAE_API_EXPORT update ()
 Update function needs to be called regularly to handle outbound events and other housekeeping. More...
 
Result _VAE_API_EXPORT 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_API_EXPORT 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...
 
int _VAE_API_EXPORT getActiveVoiceCount ()
 Get the number of currently playing Voices. More...
 
void _VAE_API_EXPORT setMasterVolume (Sample volume)
 Set the global output volume before the limiter. More...
 
bool _VAE_API_EXPORT checkVersion (int major, int minor, int patch)
 Check if the compiled version matches. More...
 
EmitterHandle _VAE_API_EXPORT createEmitter ()
 Creates an emitter and returns the handle. More...
 
EmitterHandle _VAE_API_EXPORT 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_API_EXPORT addEmitter (EmitterHandle h)
 Adds an emitter with a custom handle, can be an internal ID for example. More...
 
Result _VAE_API_EXPORT removeEmitter (EmitterHandle h)
 Unregister a emiter an kill all its voices. More...
 
Result _VAE_API_EXPORT setEmitter (EmitterHandle emitter, const LocationDirection &locDir, float spread)
 Set the Emitter position, orientation and spread. More...
 
Result _VAE_API_EXPORT stopEmitter (EmitterHandle emitter)
 Stop all voices from emitter. More...
 
void _VAE_API_EXPORT setVolume (EmitterHandle emitter, Sample gain)
 Sets the volume of all active voices with this emitter. More...
 
void _VAE_API_EXPORT seek (EmitterHandle emitter, Size time)
 Set the current time of all voices with the emitter. More...
 
void _VAE_API_EXPORT setSpeed (EmitterHandle emitter, float speed)
 Set the playback speed. More...
 
void _VAE_API_EXPORT setLowpass (EmitterHandle emitter, float cutoff)
 Simple lowpass filter for the voices. More...
 
void _VAE_API_EXPORT setHighpass (EmitterHandle emitter, float cutoff)
 Simple highpass filter for the voices. More...
 
ListenerHandle _VAE_API_EXPORT createListener ()
 Create a Listener object. More...
 
Result _VAE_API_EXPORT removeListener (ListenerHandle listener)
 Unregister listener. More...
 
Result _VAE_API_EXPORT setListener (ListenerHandle listener, const LocationOrientation &locOr)
 Set the position of a listener. More...
 
Result _VAE_API_EXPORT loadHRTF (const char *path, Size size=0)
 
Result _VAE_API_EXPORT loadBank (const char *path, Size size=0)
 Load bank from filesystem. More...
 
Result _VAE_API_EXPORT unloadBankFromId (BankHandle bankHandle)
 Unload bank from handle. More...
 
void _VAE_API_EXPORT unloadAllBanks ()
 Unload every bank and data associated with it. More...
 

Static Public Member Functions

static EnginePimpl *_VAE_API_EXPORT create ()
 

Private Member Functions

 EnginePimpl ()
 
 EnginePimpl (const EnginePimpl &)
 
 ~EnginePimpl ()
 

Detailed Description

Sealed of version of vae::core::Engine.

There are a few function, which aren't exported due to the fact that they would pull all the dependencies like tklb::AudioBuffer back in.

See also
vae::core::Engine

Definition at line 28 of file vae_pimpl.hpp.

Constructor & Destructor Documentation

◆ EnginePimpl() [1/2]

vae::EnginePimpl::EnginePimpl ( )
private

◆ EnginePimpl() [2/2]

vae::EnginePimpl::EnginePimpl ( const EnginePimpl )
private

◆ ~EnginePimpl()

vae::EnginePimpl::~EnginePimpl ( )
inlineprivate

Definition at line 31 of file vae_pimpl.hpp.

31{ };

Member Function Documentation

◆ addEmitter()

Result EnginePimpl::addEmitter ( EmitterHandle  h)

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.

Parameters
h
Returns
Result

Definition at line 124 of file vae_pimpl.cpp.

126 {
127 auto& e = *reinterpret_cast<core::Engine*>(this);
128 return e.addEmitter(
129 h
130 );
131}
Central class handling all outside communication.
Definition: vae_engine.hpp:48
Result _VAE_PUBLIC_API addEmitter(EmitterHandle h)
Adds an emitter with a custom handle, can be an internal ID for example.
Definition: vae_engine.hpp:598
Here is the call graph for this function:

◆ checkVersion()

bool EnginePimpl::checkVersion ( int  major,
int  minor,
int  patch 
)

Check if the compiled version matches.

Definition at line 89 of file vae_pimpl.cpp.

93 {
94 auto& e = *reinterpret_cast<core::Engine*>(this);
95 return e.checkVersion(
96 major,
97 minor,
98 patch
99 );
100}
bool _VAE_PUBLIC_API checkVersion(int major, int minor, int patch)
Check if the compiled version matches.
Definition: vae_engine.hpp:550
Here is the call graph for this function:

◆ create()

EnginePimpl * EnginePimpl::create ( )
static

Definition at line 5 of file vae_pimpl.cpp.

5 {
6 auto e = new core::Engine();
7 return reinterpret_cast<EnginePimpl*>(e);
8}
Sealed of version of vae::core::Engine.
Definition: vae_pimpl.hpp:28
Here is the caller graph for this function:

◆ createAutoEmitter()

EmitterHandle EnginePimpl::createAutoEmitter ( BankHandle  bank,
EventHandle  event,
float  maxDist,
const LocationDirection locDir,
float  spread 
)

Emitter which triggers an event once a listener is close enough.

Parameters
bank
event
maxDist
locDir
spread
Returns
EmitterHandle Handle like a normal emitter

Definition at line 107 of file vae_pimpl.cpp.

113 {
114 auto& e = *reinterpret_cast<core::Engine*>(this);
115 return e.createAutoEmitter(
116 bank,
117 event,
118 maxDist,
119 locDir,
120 spread
121 );
122}
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.
Definition: vae_engine.hpp:584
Here is the call graph for this function:

◆ createEmitter()

EmitterHandle EnginePimpl::createEmitter ( )

Creates an emitter and returns the handle.

Returns
EmitterHandle Random handle

Definition at line 102 of file vae_pimpl.cpp.

102 {
103 auto& e = *reinterpret_cast<core::Engine*>(this);
104 return e.createEmitter();
105}
EmitterHandle _VAE_PUBLIC_API createEmitter()
Creates an emitter and returns the handle.
Definition: vae_engine.hpp:570
Here is the call graph for this function:

◆ createListener()

ListenerHandle EnginePimpl::createListener ( )

Create a Listener object.

TODO make listener 0 implicit

Returns
ListenerHandle

Definition at line 219 of file vae_pimpl.cpp.

219 {
220 auto& e = *reinterpret_cast<core::Engine*>(this);
221 return e.createListener();
222}
ListenerHandle _VAE_PUBLIC_API createListener()
Create a Listener object.
Definition: vae_engine.hpp:742
Here is the call graph for this function:

◆ destroy()

void EnginePimpl::destroy ( )

Definition at line 10 of file vae_pimpl.cpp.

10 {
11 auto e = reinterpret_cast<core::Engine*>(this);
12 delete e;
13}

◆ fireEvent()

Result EnginePimpl::fireEvent ( BankHandle  bankHandle,
EventHandle  eventHandle,
EmitterHandle  emitterHandle,
Sample  gain = 1.0,
MixerHandle  mixerHandle = InvalidMixerHandle,
ListenerHandle  listenerHandle = AllListeners 
)

Main mechanism to start and stop sounds.

See also
Event
Parameters
bankHandlebank id where the event is provided
eventHandleid of the event
emitterHandlehandle of the emitter, needed for spatial audio or controlling the voice
gainoptional volume factor
mixerHandleoptional id of mixer channel sound will be routed to, this will override the one set in the event
listenerHandleFor which listener this event will be adible for, default to all
Returns
Result

Definition at line 39 of file vae_pimpl.cpp.

46 {
47 auto& e = *reinterpret_cast<core::Engine*>(this);
48 return e.fireEvent(
49 bankHandle,
50 eventHandle,
51 emitterHandle,
52 gain,
53 mixerHandle,
54 listenerHandle
55 );
56}
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.
Definition: vae_engine.hpp:389
Here is the call graph for this function:

◆ fireGlobalEvent()

Result EnginePimpl::fireGlobalEvent ( GlobalEventHandle  globalHandle,
EmitterHandle  emitterHandle,
Sample  gain = 1.0,
MixerHandle  mixerHandle = InvalidMixerHandle,
ListenerHandle  listenerHandle = AllListeners 
)

Works like fireEvent but with a global Event identifier.

See also
fireEvent
Parameters
globalHandleThe GlobalEventHandle combines both bank and event id
emitterHandleoptional handle of the emitter, needed for spatial audio
gainoptional volume factor
mixerHandleid of mixer channel sound will be routed to, this will override the one set in the event
Returns
Result

Definition at line 58 of file vae_pimpl.cpp.

64 {
65 auto& e = *reinterpret_cast<core::Engine*>(this);
66 return e.fireGlobalEvent(
67 globalHandle,
68 emitterHandle,
69 gain,
70 mixerHandle,
71 listenerHandle
72 );
73}
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.
Definition: vae_engine.hpp:510
Here is the call graph for this function:

◆ getActiveVoiceCount()

int EnginePimpl::getActiveVoiceCount ( )

Get the number of currently playing Voices.

Definition at line 75 of file vae_pimpl.cpp.

75 {
76 auto& e = *reinterpret_cast<core::Engine*>(this);
77 return e.getActiveVoiceCount();
78}
Size _VAE_PUBLIC_API getActiveVoiceCount() const
Get the number of currently playing Voices.
Definition: vae_engine.hpp:529
Here is the call graph for this function:

◆ init()

Result EnginePimpl::init ( const EngineConfig config = {})

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.

See also
start
Parameters
configOptional config to setup the internals.
Returns
Result

Definition at line 15 of file vae_pimpl.cpp.

17 {
18 auto& e = *reinterpret_cast<core::Engine*>(this);
19 return e.init(
20 config
21 );
22}
Result _VAE_PUBLIC_API init(const EngineConfig &config={})
Initializes the engine and does most of the upfront allocations.
Definition: vae_engine.hpp:230
Here is the call graph for this function:

◆ loadBank()

Result EnginePimpl::loadBank ( const char *  path,
Size  size = 0 
)

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.

Parameters
path
Returns
Result

Definition at line 255 of file vae_pimpl.cpp.

258 {
259 auto& e = *reinterpret_cast<core::Engine*>(this);
260 return e.loadBank(
261 path,
262 size
263 );
264}
Result _VAE_PUBLIC_API loadBank(const char *path, Size size=0)
Load bank from filesystem.
Definition: vae_engine.hpp:786
Here is the call graph for this function:

◆ loadHRTF()

Result EnginePimpl::loadHRTF ( const char *  path,
Size  size = 0 
)

Definition at line 244 of file vae_pimpl.cpp.

247 {
248 auto& e = *reinterpret_cast<core::Engine*>(this);
249 return e.loadHRTF(
250 path,
251 size
252 );
253}
Result _VAE_PUBLIC_API loadHRTF(const char *path, Size size=0)
Definition: vae_engine.hpp:763
Here is the call graph for this function:

◆ removeEmitter()

Result EnginePimpl::removeEmitter ( EmitterHandle  h)

Unregister a emiter an kill all its voices.

Parameters
h
Returns
Result

Definition at line 133 of file vae_pimpl.cpp.

135 {
136 auto& e = *reinterpret_cast<core::Engine*>(this);
137 return e.removeEmitter(
138 h
139 );
140}
Result _VAE_PUBLIC_API removeEmitter(EmitterHandle h)
Unregister a emiter an kill all its voices.
Definition: vae_engine.hpp:607
Here is the call graph for this function:

◆ removeListener()

Result EnginePimpl::removeListener ( ListenerHandle  listener)

Unregister listener.

Parameters
listener

Definition at line 224 of file vae_pimpl.cpp.

226 {
227 auto& e = *reinterpret_cast<core::Engine*>(this);
228 return e.removeListener(
229 listener
230 );
231}
Result _VAE_PUBLIC_API removeListener(ListenerHandle listener)
Unregister listener.
Definition: vae_engine.hpp:750
Here is the call graph for this function:

◆ seek()

void EnginePimpl::seek ( EmitterHandle  emitter,
Size  time 
)

Set the current time of all voices with the emitter.

Parameters
emitter
timeTime in samples

Definition at line 175 of file vae_pimpl.cpp.

178 {
179 auto& e = *reinterpret_cast<core::Engine*>(this);
180 return e.seek(
181 emitter,
182 time
183 );
184}
void _VAE_PUBLIC_API seek(EmitterHandle emitter, Size time)
Set the current time of all voices with the emitter.
Definition: vae_engine.hpp:648
Here is the call graph for this function:

◆ setEmitter()

Result EnginePimpl::setEmitter ( EmitterHandle  emitter,
const LocationDirection locDir,
float  spread 
)

Set the Emitter position, orientation and spread.

Parameters
emitterThe emitter
locDirThe desired location
spreadThe width of the panning (if it's spatial and not HRTF)
Returns
Result

Definition at line 142 of file vae_pimpl.cpp.

146 {
147 auto& e = *reinterpret_cast<core::Engine*>(this);
148 return e.setEmitter(
149 emitter,
150 locDir,
151 spread
152 );
153}
Result _VAE_PUBLIC_API setEmitter(EmitterHandle emitter, const LocationDirection &locDir, float spread)
Set the Emitter position, orientation and spread.
Definition: vae_engine.hpp:619
Here is the call graph for this function:

◆ setHighpass()

void EnginePimpl::setHighpass ( EmitterHandle  emitter,
float  cutoff 
)

Simple highpass filter for the voices.

Parameters
emitter
cutoff0-1. 0 doesn't filter, 1 filter the wholespektrum

Definition at line 208 of file vae_pimpl.cpp.

211 {
212 auto& e = *reinterpret_cast<core::Engine*>(this);
213 return e.setHighpass(
214 emitter,
215 cutoff
216 );
217}
void _VAE_PUBLIC_API setHighpass(EmitterHandle emitter, float cutoff)
Simple highpass filter for the voices.
Definition: vae_engine.hpp:675
Here is the call graph for this function:

◆ setListener()

Result EnginePimpl::setListener ( ListenerHandle  listener,
const LocationOrientation locOr 
)

Set the position of a listener.

Parameters
listener
Returns
Result

Definition at line 233 of file vae_pimpl.cpp.

236 {
237 auto& e = *reinterpret_cast<core::Engine*>(this);
238 return e.setListener(
239 listener,
240 locOr
241 );
242}
Result _VAE_PUBLIC_API setListener(ListenerHandle listener, const LocationOrientation &locOr)
Set the position of a listener.
Definition: vae_engine.hpp:759
Here is the call graph for this function:

◆ setLowpass()

void EnginePimpl::setLowpass ( EmitterHandle  emitter,
float  cutoff 
)

Simple lowpass filter for the voices.

Parameters
emitter
cutoff0-1. 0 doesn't filter, 1 filter the wholespektrum

Definition at line 197 of file vae_pimpl.cpp.

200 {
201 auto& e = *reinterpret_cast<core::Engine*>(this);
202 return e.setLowpass(
203 emitter,
204 cutoff
205 );
206}
void _VAE_PUBLIC_API setLowpass(EmitterHandle emitter, float cutoff)
Simple lowpass filter for the voices.
Definition: vae_engine.hpp:666
Here is the call graph for this function:

◆ setMasterVolume()

void EnginePimpl::setMasterVolume ( Sample  volume)

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.

Parameters
volume1.0 is the default, not interpolated for now

Definition at line 80 of file vae_pimpl.cpp.

82 {
83 auto& e = *reinterpret_cast<core::Engine*>(this);
84 return e.setMasterVolume(
85 volume
86 );
87}
void _VAE_PUBLIC_API setMasterVolume(Sample volume)
Set the global output volume before the limiter.
Definition: vae_engine.hpp:543
Here is the call graph for this function:

◆ setSpeed()

void EnginePimpl::setSpeed ( EmitterHandle  emitter,
float  speed 
)

Set the playback speed.

Parameters
emitter
speed1.0 is the default speed, pitch will be affected as well.

Definition at line 186 of file vae_pimpl.cpp.

189 {
190 auto& e = *reinterpret_cast<core::Engine*>(this);
191 return e.setSpeed(
192 emitter,
193 speed
194 );
195}
void _VAE_PUBLIC_API setSpeed(EmitterHandle emitter, float speed)
Set the playback speed.
Definition: vae_engine.hpp:657
Here is the call graph for this function:

◆ setVolume()

void EnginePimpl::setVolume ( EmitterHandle  emitter,
Sample  gain 
)

Sets the volume of all active voices with this emitter.

Parameters
emitter
gain

Definition at line 164 of file vae_pimpl.cpp.

167 {
168 auto& e = *reinterpret_cast<core::Engine*>(this);
169 return e.setVolume(
170 emitter,
171 gain
172 );
173}
void _VAE_PUBLIC_API setVolume(EmitterHandle emitter, Sample gain)
Sets the volume of all active voices with this emitter.
Definition: vae_engine.hpp:639
Here is the call graph for this function:

◆ start()

Result EnginePimpl::start ( )

Tries to open default device and start audio thread.

Call this after start.

See also
init
Returns
Result

Definition at line 24 of file vae_pimpl.cpp.

24 {
25 auto& e = *reinterpret_cast<core::Engine*>(this);
26 return e.start();
27}
Result _VAE_PUBLIC_API start()
Tries to open default device and start audio thread.
Definition: vae_engine.hpp:251
Here is the call graph for this function:

◆ stop()

Result EnginePimpl::stop ( )

Stops processing and waits for audio thead to clean up.

Returns
Result

Definition at line 29 of file vae_pimpl.cpp.

29 {
30 auto& e = *reinterpret_cast<core::Engine*>(this);
31 return e.stop();
32}
Result _VAE_PUBLIC_API stop()
Stops processing and waits for audio thead to clean up.
Definition: vae_engine.hpp:286
Here is the call graph for this function:

◆ stopEmitter()

Result EnginePimpl::stopEmitter ( EmitterHandle  emitter)

Stop all voices from emitter.

Parameters
emitter
Returns
Result

Definition at line 155 of file vae_pimpl.cpp.

157 {
158 auto& e = *reinterpret_cast<core::Engine*>(this);
159 return e.stopEmitter(
160 emitter
161 );
162}
Result _VAE_PUBLIC_API stopEmitter(EmitterHandle emitter)
Stop all voices from emitter.
Definition: vae_engine.hpp:630
Here is the call graph for this function:

◆ unloadAllBanks()

void EnginePimpl::unloadAllBanks ( )

Unload every bank and data associated with it.

Definition at line 275 of file vae_pimpl.cpp.

275 {
276 auto& e = *reinterpret_cast<core::Engine*>(this);
277 return e.unloadAllBanks();
278}
void _VAE_PUBLIC_API unloadAllBanks()
Unload every bank and data associated with it.
Definition: vae_engine.hpp:845
Here is the call graph for this function:

◆ unloadBankFromId()

Result EnginePimpl::unloadBankFromId ( BankHandle  bankHandle)

Unload bank from handle.

Locks audio thread and stops all voices from that bank.

Parameters
bankHandle
Returns
Result

Definition at line 266 of file vae_pimpl.cpp.

268 {
269 auto& e = *reinterpret_cast<core::Engine*>(this);
270 return e.unloadBankFromId(
271 bankHandle
272 );
273}
Result _VAE_PUBLIC_API unloadBankFromId(BankHandle bankHandle)
Unload bank from handle.
Definition: vae_engine.hpp:835
Here is the call graph for this function:

◆ update()

void EnginePimpl::update ( )

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.

See also
EngineConfig::updateInAudioThread

Definition at line 34 of file vae_pimpl.cpp.

34 {
35 auto& e = *reinterpret_cast<core::Engine*>(this);
36 return e.update();
37}
void _VAE_PUBLIC_API update()
Update function needs to be called regularly to handle outbound events and other housekeeping.
Definition: vae_engine.hpp:317
Here is the call graph for this function:

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