Opens a specific audio device.
The device struct may be altered to match the actual hardware. (sampleRate, bufferSize and channel count)
60 VAE_ERROR(
"Failed to open deivce with index out of bounds")
65 RtAudio::StreamParameters inParams, outParams;
66 inParams.deviceId = device.
id;
67 inParams.nChannels = device.channelsIn;
68 outParams.deviceId = device.
id;
69 outParams.nChannels = device.channelsOut;
70 if (device.bufferSize == 0) {
74 RtAudioErrorType result;
77 result =
mAudio.openStream(
78 outParams.nChannels ? &outParams :
nullptr,
79 inParams.nChannels ? &inParams :
nullptr,
80 RTAUDIO_FLOAT32, device.sampleRate,
85 if (result != RTAUDIO_NO_ERROR) {
86 VAE_ERROR(
"Failed to open RtAudio device with code %i", result)
90 device.sampleRate =
mAudio.getStreamSampleRate();
91 device.channelsIn = inParams.nChannels;
92 device.channelsOut = outParams.nChannels;
95 device.sampleRate, device.channelsIn, device.channelsOut,
100 result =
mAudio.startStream();
103 if (result != RTAUDIO_NO_ERROR) {
104 VAE_ERROR(
"Failed to open RtAudio device with code %i", result)
virtual Size getDeviceCount()=0
Gets number of devices, needed to iterate them.
AudioThreadWorker mWorker
const EngineConfig & mConfig
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...
static int AudioCallback(void *out, void *in, unsigned int frames, double streamTime, RtAudioStreamStatus status, void *data)
Function called from the RtAudio thread.
Using template interfaces isn't an option so this simply defines a default Convolver type.
T clamp(const T &v, const T &_min, const T &_max)
constexpr unsigned char MaxChannels
Maximum channel count used to pre allocate buffers.
unsigned int Size
How the elements are addressed in the heapbuffer.
Size preferredBufferSize
Buffer size that will be requested from device.
#define VAE_ERROR(msg,...)