4#include "../../../external/tklb/src/types/audio/resampler/TResampler.hpp"
5#include "../../../external/tklb/src/types/TDelegate.hpp"
7#include "../../../include/vae/vae.hpp"
8#include "../vae_types.hpp"
9#include "../vae_config.hpp"
10#include "../vae_util.hpp"
13namespace vae {
namespace core {
51 Uchar channelsOut = 0;
67 if (from !=
nullptr) {
117 mWorker.channelsOut = channelsOut;
121 if (0 < channelsIn) {
134 if (0 < channelsOut) {
150 if (0 < channelsIn) {
156 if (0 < channelsOut) {
190 "Device destructed. Underruns: %i %i Overruns:%i %i",
bool resize(const Size length, uchar channels)
! Will not keep the contents! Resizes the buffer to the desired length and channel count.
Size validSize() const
Returns the length of actually valid audio in the buffer.
void setFromInterleaved(const T2 *samples, Size length, const uchar channels, Size offsetSrc=0, const Size offsetDst=0)
Set multiple channels from an interleaved array.
ushort sampleRate
Only relevant for resampling and oversampling.
void set(const T2 *samples, Size length, const uchar channel=0, const Size offsetDst=0)
Set a single channel from an array.
Size putInterleaved(T2 *buffer, Size length=0, const Size offset=0) const
Puts the interleaved contents in the target buffer.
Size remaining() const
Returns how many more elements the buffer can hold.
Size push(const AudioBufferTpl< T2, STORAGE2 > &in, Size offsetSrc=0)
Adds validSize() amount of frames to the buffer.
Size pop(AudioBufferTpl< T2, STORAGE2 > &out, const Size elements, Size offsetSrc=0, Size offsetDst=0)
Pops a number of elements in the buffer provided.
Size filled() const
Returns how many elements are in the buffer.
Size estimateNeed(const Size out) const
Estimate how many samples need to be put in to get n samples out.
bool isInitialized() const
Size calculateBufferSize(Size initialSize)
Calculate a buffersize fit for the resampled result.
bool init(uint rateIn, uint rateOut, uint maxBlock=512, uchar maxChannels=2, uchar quality=5)
setup the resampler
Size process(const Buffer &in, Buffer &out)
Resample function Make sure the out buffer has enough space.
Backend interface used to query devices before creating a actual device object.
virtual const char * getName() const =0
Returns name of the api.
virtual DeviceInfo getDefaultOutputDevice()=0
virtual DeviceInfo getDefaultInputDevice()=0
Interface for audio devices.
AudioThreadWorker mWorker
ScratchBuffer mResamplerBufferToDevice
virtual bool openDevice(DeviceInfo &device)=0
Opens a specific audio device.
Size push(const ScratchBuffer &buffer)
Push samples to the audio device.
Size getRealSampleRate() const
Get the Real Sample Rate before resampling.
virtual bool openDevice(bool input=false)
Tries to open the default audio device whith desired in out channels.
const EngineConfig & mConfig
size_t getStreamTime() const
Size getSampleRate() const
Get the sample rate.
Size getChannelsOut() const
static constexpr int _VAE_WORKER_SIZE
virtual bool closeDevice()=0
Closes the currently open device.
Resampler mResamplerToDevice
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...
Size getUnderruns() const
Size getChannelsIn() const
void setCallback(Callback callback)
void pop(ScratchBuffer &buffer)
Get samples form audio device.
Size canPush() const
Return amount of audio frames which can be pushed in buffer ! this is an estimate when resampling !
T max(const T &v1, const T &v2)
constexpr Size MaxBlock
Maximum block size.
const char *const deviceUnderruns
const char *const engineUnderruns
const char *const engineOverruns
std::unique_lock< Mutex > Lock
constexpr int _VAE_DEVICE_SIZE
Contains Typedefinitions and basic structures use by the public API and internally.
unsigned int Size
How the elements are addressed in the heapbuffer.
Basic struct describing a audio device.
Settings for the engine defined at EnginePimpl::init.
Size internalSampleRate
Samplerate requested from device.
Size bufferPeriods
Number of blocks/buffers to processed ahead.
Data shared with audio thread.
void swapBufferInterleaved(const T *from, T *to, Size frames)
Called from audio backend to push in interleaved audio data.
ScratchBuffer resampleBufferFromdevice
VAE_PROFILER_MUTEX(Mutex, mutex, "Device mutex") Uchar channelsOut=0
ScratchBuffer convertBuffer
RingBuffer queueFromDevice
Resampler resamplerFromDevice
#define VAE_DEBUG(msg,...)
#define VAE_PROFILER_SCOPE_NAMED(name)
Profiles a scope and names it.
#define VAE_PROFILER_SCOPE()
Profiles a scope.
#define VAE_PROFILER_PLOT(name, value)
Records a value.
#define VAE_PROFILER_OVERLOAD_NEW()
Overloads new and delete of class to be tracked.
#define VEA_PROFILER_THREAD_NAME(name)
Sets name for current thread.
#define VAE_ASSERT(condition)