VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae_pimpl.cpp
Go to the documentation of this file.
1
2#include "../../include/vae/vae_pimpl.hpp"
3#include "../core/vae_engine.hpp"
4using namespace vae;
6 auto e = new core::Engine();
7 return reinterpret_cast<EnginePimpl*>(e);
8}
9
11 auto e = reinterpret_cast<core::Engine*>(this);
12 delete e;
13}
14
16 const EngineConfig& config
17) {
18 auto& e = *reinterpret_cast<core::Engine*>(this);
19 return e.init(
20 config
21 );
22}
23
25 auto& e = *reinterpret_cast<core::Engine*>(this);
26 return e.start();
27}
28
30 auto& e = *reinterpret_cast<core::Engine*>(this);
31 return e.stop();
32}
33
35 auto& e = *reinterpret_cast<core::Engine*>(this);
36 return e.update();
37}
38
40 BankHandle bankHandle,
41 EventHandle eventHandle,
42 EmitterHandle emitterHandle,
43 Sample gain,
44 MixerHandle mixerHandle,
45 ListenerHandle listenerHandle
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}
57
59 GlobalEventHandle globalHandle,
60 EmitterHandle emitterHandle,
61 Sample gain,
62 MixerHandle mixerHandle,
63 ListenerHandle listenerHandle
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}
74
76 auto& e = *reinterpret_cast<core::Engine*>(this);
77 return e.getActiveVoiceCount();
78}
79
81 Sample volume
82) {
83 auto& e = *reinterpret_cast<core::Engine*>(this);
84 return e.setMasterVolume(
85 volume
86 );
87}
88
90 int major,
91 int minor,
92 int patch
93) {
94 auto& e = *reinterpret_cast<core::Engine*>(this);
95 return e.checkVersion(
96 major,
97 minor,
98 patch
99 );
100}
101
103 auto& e = *reinterpret_cast<core::Engine*>(this);
104 return e.createEmitter();
105}
106
108 BankHandle bank,
109 EventHandle event,
110 float maxDist,
111 const LocationDirection& locDir,
112 float spread
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}
123
126) {
127 auto& e = *reinterpret_cast<core::Engine*>(this);
128 return e.addEmitter(
129 h
130 );
131}
132
135) {
136 auto& e = *reinterpret_cast<core::Engine*>(this);
137 return e.removeEmitter(
138 h
139 );
140}
141
143 EmitterHandle emitter,
144 const LocationDirection& locDir,
145 float spread
146) {
147 auto& e = *reinterpret_cast<core::Engine*>(this);
148 return e.setEmitter(
149 emitter,
150 locDir,
151 spread
152 );
153}
154
156 EmitterHandle emitter
157) {
158 auto& e = *reinterpret_cast<core::Engine*>(this);
159 return e.stopEmitter(
160 emitter
161 );
162}
163
165 EmitterHandle emitter,
166 Sample gain
167) {
168 auto& e = *reinterpret_cast<core::Engine*>(this);
169 return e.setVolume(
170 emitter,
171 gain
172 );
173}
174
176 EmitterHandle emitter,
177 Size time
178) {
179 auto& e = *reinterpret_cast<core::Engine*>(this);
180 return e.seek(
181 emitter,
182 time
183 );
184}
185
187 EmitterHandle emitter,
188 float speed
189) {
190 auto& e = *reinterpret_cast<core::Engine*>(this);
191 return e.setSpeed(
192 emitter,
193 speed
194 );
195}
196
198 EmitterHandle emitter,
199 float cutoff
200) {
201 auto& e = *reinterpret_cast<core::Engine*>(this);
202 return e.setLowpass(
203 emitter,
204 cutoff
205 );
206}
207
209 EmitterHandle emitter,
210 float cutoff
211) {
212 auto& e = *reinterpret_cast<core::Engine*>(this);
213 return e.setHighpass(
214 emitter,
215 cutoff
216 );
217}
218
220 auto& e = *reinterpret_cast<core::Engine*>(this);
221 return e.createListener();
222}
223
225 ListenerHandle listener
226) {
227 auto& e = *reinterpret_cast<core::Engine*>(this);
228 return e.removeListener(
229 listener
230 );
231}
232
234 ListenerHandle listener,
235 const LocationOrientation& locOr
236) {
237 auto& e = *reinterpret_cast<core::Engine*>(this);
238 return e.setListener(
239 listener,
240 locOr
241 );
242}
243
245 const char* path,
246 Size size
247) {
248 auto& e = *reinterpret_cast<core::Engine*>(this);
249 return e.loadHRTF(
250 path,
251 size
252 );
253}
254
256 const char* path,
257 Size size
258) {
259 auto& e = *reinterpret_cast<core::Engine*>(this);
260 return e.loadBank(
261 path,
262 size
263 );
264}
265
267 BankHandle bankHandle
268) {
269 auto& e = *reinterpret_cast<core::Engine*>(this);
270 return e.unloadBankFromId(
271 bankHandle
272 );
273}
274
276 auto& e = *reinterpret_cast<core::Engine*>(this);
277 return e.unloadAllBanks();
278}
279
280
281extern "C" EnginePimpl* create() {
282 return EnginePimpl::create();
283}
Sealed of version of vae::core::Engine.
Definition: vae_pimpl.hpp:28
static EnginePimpl *_VAE_API_EXPORT create()
Definition: vae_pimpl.cpp:5
Result _VAE_API_EXPORT loadBank(const char *path, Size size=0)
Load bank from filesystem.
Definition: vae_pimpl.cpp:255
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.
Definition: vae_pimpl.cpp:107
void _VAE_API_EXPORT unloadAllBanks()
Unload every bank and data associated with it.
Definition: vae_pimpl.cpp:275
EmitterHandle _VAE_API_EXPORT createEmitter()
Creates an emitter and returns the handle.
Definition: vae_pimpl.cpp:102
Result _VAE_API_EXPORT loadHRTF(const char *path, Size size=0)
Definition: vae_pimpl.cpp:244
Result _VAE_API_EXPORT addEmitter(EmitterHandle h)
Adds an emitter with a custom handle, can be an internal ID for example.
Definition: vae_pimpl.cpp:124
ListenerHandle _VAE_API_EXPORT createListener()
Create a Listener object.
Definition: vae_pimpl.cpp:219
void _VAE_API_EXPORT setMasterVolume(Sample volume)
Set the global output volume before the limiter.
Definition: vae_pimpl.cpp:80
void _VAE_API_EXPORT setVolume(EmitterHandle emitter, Sample gain)
Sets the volume of all active voices with this emitter.
Definition: vae_pimpl.cpp:164
void _VAE_API_EXPORT update()
Update function needs to be called regularly to handle outbound events and other housekeeping.
Definition: vae_pimpl.cpp:34
Result _VAE_API_EXPORT init(const EngineConfig &config={})
Initializes the engine and does most of the upfront allocations.
Definition: vae_pimpl.cpp:15
void _VAE_API_EXPORT setSpeed(EmitterHandle emitter, float speed)
Set the playback speed.
Definition: vae_pimpl.cpp:186
void _VAE_API_EXPORT seek(EmitterHandle emitter, Size time)
Set the current time of all voices with the emitter.
Definition: vae_pimpl.cpp:175
Result _VAE_API_EXPORT stop()
Stops processing and waits for audio thead to clean up.
Definition: vae_pimpl.cpp:29
Result _VAE_API_EXPORT removeEmitter(EmitterHandle h)
Unregister a emiter an kill all its voices.
Definition: vae_pimpl.cpp:133
Result _VAE_API_EXPORT setEmitter(EmitterHandle emitter, const LocationDirection &locDir, float spread)
Set the Emitter position, orientation and spread.
Definition: vae_pimpl.cpp:142
bool _VAE_API_EXPORT checkVersion(int major, int minor, int patch)
Check if the compiled version matches.
Definition: vae_pimpl.cpp:89
Result _VAE_API_EXPORT unloadBankFromId(BankHandle bankHandle)
Unload bank from handle.
Definition: vae_pimpl.cpp:266
void _VAE_API_EXPORT destroy()
Definition: vae_pimpl.cpp:10
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.
Definition: vae_pimpl.cpp:39
int _VAE_API_EXPORT getActiveVoiceCount()
Get the number of currently playing Voices.
Definition: vae_pimpl.cpp:75
void _VAE_API_EXPORT setHighpass(EmitterHandle emitter, float cutoff)
Simple highpass filter for the voices.
Definition: vae_pimpl.cpp:208
Result _VAE_API_EXPORT stopEmitter(EmitterHandle emitter)
Stop all voices from emitter.
Definition: vae_pimpl.cpp:155
Result _VAE_API_EXPORT removeListener(ListenerHandle listener)
Unregister listener.
Definition: vae_pimpl.cpp:224
void _VAE_API_EXPORT setLowpass(EmitterHandle emitter, float cutoff)
Simple lowpass filter for the voices.
Definition: vae_pimpl.cpp:197
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.
Definition: vae_pimpl.cpp:58
Result _VAE_API_EXPORT setListener(ListenerHandle listener, const LocationOrientation &locOr)
Set the position of a listener.
Definition: vae_pimpl.cpp:233
Result _VAE_API_EXPORT start()
Tries to open default device and start audio thread.
Definition: vae_pimpl.cpp:24
Central class handling all outside communication.
Definition: vae_engine.hpp:48
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
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
void _VAE_PUBLIC_API setSpeed(EmitterHandle emitter, float speed)
Set the playback speed.
Definition: vae_engine.hpp:657
EmitterHandle _VAE_PUBLIC_API createEmitter()
Creates an emitter and returns the handle.
Definition: vae_engine.hpp:570
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
void _VAE_PUBLIC_API setLowpass(EmitterHandle emitter, float cutoff)
Simple lowpass filter for the voices.
Definition: vae_engine.hpp:666
Result _VAE_PUBLIC_API init(const EngineConfig &config={})
Initializes the engine and does most of the upfront allocations.
Definition: vae_engine.hpp:230
void _VAE_PUBLIC_API setMasterVolume(Sample volume)
Set the global output volume before the limiter.
Definition: vae_engine.hpp:543
bool _VAE_PUBLIC_API checkVersion(int major, int minor, int patch)
Check if the compiled version matches.
Definition: vae_engine.hpp:550
Size _VAE_PUBLIC_API getActiveVoiceCount() const
Get the number of currently playing Voices.
Definition: vae_engine.hpp:529
Result _VAE_PUBLIC_API removeListener(ListenerHandle listener)
Unregister listener.
Definition: vae_engine.hpp:750
Result _VAE_PUBLIC_API stop()
Stops processing and waits for audio thead to clean up.
Definition: vae_engine.hpp:286
Result _VAE_PUBLIC_API loadBank(const char *path, Size size=0)
Load bank from filesystem.
Definition: vae_engine.hpp:786
Result _VAE_PUBLIC_API loadHRTF(const char *path, Size size=0)
Definition: vae_engine.hpp:763
void _VAE_PUBLIC_API setVolume(EmitterHandle emitter, Sample gain)
Sets the volume of all active voices with this emitter.
Definition: vae_engine.hpp:639
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
Result _VAE_PUBLIC_API start()
Tries to open default device and start audio thread.
Definition: vae_engine.hpp:251
Result _VAE_PUBLIC_API removeEmitter(EmitterHandle h)
Unregister a emiter an kill all its voices.
Definition: vae_engine.hpp:607
void _VAE_PUBLIC_API unloadAllBanks()
Unload every bank and data associated with it.
Definition: vae_engine.hpp:845
Result _VAE_PUBLIC_API unloadBankFromId(BankHandle bankHandle)
Unload bank from handle.
Definition: vae_engine.hpp:835
void _VAE_PUBLIC_API seek(EmitterHandle emitter, Size time)
Set the current time of all voices with the emitter.
Definition: vae_engine.hpp:648
void _VAE_PUBLIC_API update()
Update function needs to be called regularly to handle outbound events and other housekeeping.
Definition: vae_engine.hpp:317
ListenerHandle _VAE_PUBLIC_API createListener()
Create a Listener object.
Definition: vae_engine.hpp:742
void _VAE_PUBLIC_API setHighpass(EmitterHandle emitter, float cutoff)
Simple highpass filter for the voices.
Definition: vae_engine.hpp:675
Result _VAE_PUBLIC_API setListener(ListenerHandle listener, const LocationOrientation &locOr)
Set the position of a listener.
Definition: vae_engine.hpp:759
Result _VAE_PUBLIC_API setEmitter(EmitterHandle emitter, const LocationDirection &locDir, float spread)
Set the Emitter position, orientation and spread.
Definition: vae_engine.hpp:619
Result _VAE_PUBLIC_API stopEmitter(EmitterHandle emitter)
Stop all voices from emitter.
Definition: vae_engine.hpp:630
Contains Typedefinitions and basic structures use by the public API and internally.
Definition: vae.hpp:31
unsigned int Size
How the elements are addressed in the heapbuffer.
Definition: vae.hpp:33
float Sample
Default sample types used where ever possible, changing this means the engine needs to be recompiled,...
Definition: vae.hpp:32
SmallHandle MixerHandle
Definition: vae.hpp:44
SmallHandle BankHandle
Definition: vae.hpp:40
SmallHandle ListenerHandle
Definition: vae.hpp:45
LargeHandle EmitterHandle
Definition: vae.hpp:43
GenericHandle EventHandle
The handle used to address events within a bank.
Definition: vae.hpp:41
Result
Return Types for most engine functions.
Definition: vae.hpp:73
LargeHandle GlobalEventHandle
Used to globally address events, holds space for BankHandle and EventHandle.
Definition: vae.hpp:47
Settings for the engine defined at EnginePimpl::init.
Definition: vae.hpp:157
Emitters have a position and direction vector.
Definition: vae.hpp:121
Listener uses additional up vector.
Definition: vae.hpp:133
EnginePimpl * create()
Definition: vae_pimpl.cpp:281