VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae_device_dummy.hpp
Go to the documentation of this file.
1#ifndef _VAE_DEVICE_DUMMY
2#define _VAE_DEVICE_DUMMY
3
4#include "./vae_device.hpp"
5
6namespace vae { namespace core {
7 /**
8 * @brief Backend without functionality
9 */
10 class DeviceDummy final : public Device {
11 public:
13 Backend& backend, const EngineConfig& config
14 ) : Device(backend, config) { }
15
16 bool openDevice(bool input = false) override {
18 postInit();
19 return true;
20 }
21
22 bool openDevice(DeviceInfo& device) override {
23 // there's only one device
24 TKLB_ASSERT(device.id == 0)
25 return openDevice(false);
26 }
27
28 bool closeDevice() override { return true; }
29
30 /**
31 * @brief Simulate the callback from the audio device
32 *
33 * @tparam T
34 * @param from
35 * @param to
36 * @param frames
37 */
38 template <typename T>
39 void swapBufferInterleaved(const T* from, T* to, Size frames) {
40 mWorker.swapBufferInterleaved<T>(from, to, frames);
41 }
42 };
43
44 class BackendDummy : public Backend {
46 public:
48 static BackendDummy backend;
49 return backend;
50 }
51
52 unsigned int getDeviceCount() override { return 1; }
53
54 DeviceInfo getDevice(unsigned int id) override {
55 TKLB_ASSERT(id == 0) // there's only one device
56 DeviceInfo info;
57 info.channelsIn = 2;
58 info.channelsOut = 2;
59 tklb::memory::stringCopy(info.name, "Dummy Device", sizeof(DeviceInfo::name));
61 return info;
62 }
63
64 const char* getName() const override { return "dummy"; };
65
67 return getDevice(0);
68 };
69
71 return getDevice(0);
72 };
73
74 Device* createDevice(const EngineConfig& config) override {
75 return new DeviceDummy(*this, config);
76 }
77 };
78} } // VAE::core
79
80#endif // _VAE_DEVICE_DUMMY
#define TKLB_ASSERT(condition)
Wrap assertions.
Definition: TAssert.h:18
Device * createDevice(const EngineConfig &config) override
Creates a device instance for this backend.
DeviceInfo getDevice(unsigned int id) override
Returns a spefic device info for index.
const char * getName() const override
Returns name of the api.
unsigned int getDeviceCount() override
Gets number of devices, needed to iterate them.
static BackendDummy & instance()
DeviceInfo getDefaultOutputDevice() override
DeviceInfo getDefaultInputDevice() override
Backend interface used to query devices before creating a actual device object.
Definition: vae_backend.hpp:14
Backend without functionality.
bool closeDevice() override
Closes the currently open device.
DeviceDummy(Backend &backend, const EngineConfig &config)
void swapBufferInterleaved(const T *from, T *to, Size frames)
Simulate the callback from the audio device.
bool openDevice(bool input=false) override
Tries to open the default audio device whith desired in out channels.
bool openDevice(DeviceInfo &device) override
Opens a specific audio device.
Interface for audio devices.
Definition: vae_device.hpp:18
AudioThreadWorker mWorker
Definition: vae_device.hpp:102
const EngineConfig & mConfig
Definition: vae_device.hpp:24
void init(Size sampleRate, Uchar channelsIn, Uchar channelsOut, Size bufferSize)
initializes buffers, queues and resamplers if needed Has to be called in openDevice once the samplera...
Definition: vae_device.hpp:114
static void stringCopy(char *dst, const char *src, size_t size, bool terminate=true)
Definition: TMemoryUtil.hpp:26
constexpr Size MaxBlock
Maximum block size.
Definition: vae.hpp:276
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
Basic struct describing a audio device.
Definition: vae.hpp:102
unsigned char channelsIn
Definition: vae.hpp:108
unsigned char channelsOut
Definition: vae.hpp:109
char name[255]
Device name reported from backend.
Definition: vae.hpp:105
int id
Negative values for invalid device.
Definition: vae.hpp:103
char api[4]
API abbreviation.
Definition: vae.hpp:106
Settings for the engine defined at EnginePimpl::init.
Definition: vae.hpp:157
Size internalSampleRate
Samplerate requested from device.
Definition: vae.hpp:168
void swapBufferInterleaved(const T *from, T *to, Size frames)
Called from audio backend to push in interleaved audio data.
Definition: vae_device.hpp:64