2#include "debugtrace.hpp"
5#include "lasp_config.h"
10#if LASP_HAS_RTAUDIO == 1
13#if LASP_HAS_PORTAUDIO == 1
16using rte = std::runtime_error;
24#if LASP_HAS_ULDAQ == 1
25 if (devinfo.
api.
apicode == LASP_ULDAQ_APICODE) {
29#if LASP_HAS_RTAUDIO == 1
31 if (devinfo.
api.
apicode == LASP_RTAUDIO_APICODE) {
35#if LASP_HAS_PORTAUDIO == 1
36 if (devinfo.
api.
apicode == LASP_PORTAUDIO_APICODE) {
40 throw rte(
string(
"Unable to match Device API: ") + devinfo.
api.
apiname);
49 throw rte(
"Duplex mode enabled, but no input channels enabled");
53 throw rte(
"Duplex mode enabled, but no output channels enabled");
57 throw rte(
"Output monitoring only allowed when running in duplex mode");
62 "Output monitor flag set, but device does not have output monitor");
65 if (!config.
match(devinfo)) {
66 throw rte(
"DaqConfiguration does not match device info");
70 "Number of enabled input channels is higher than device capability");
74 "Number of enabled output channels is higher than device capability");
106 return std::count(enchannels.cbegin(), enchannels.cend(),
true);
116 res.push_back(ch.enabled);
123 res.push_back(ch.enabled);
Configuration of a DAQ device.
std::vector< DaqChannel > enabledInChannels(const bool include_monitor=true) const
Return list of enabled input channels.
int dataTypeIndex
Required datatype for output, should be present in the list.
std::vector< DaqChannel > inchannel_config
Channel configuration for input channels.
bool monitorOutput
If set to true and if the device has this capability, the output channels are added as input channels...
int sampleRateIndex
Index in list of sample rates that are available for the device.
std::vector< DaqChannel > outchannel_config
Channel configuration for output channels.
bool match(const DeviceInfo &devinfo) const
Check to see whether the DAQ configuration matches with the device. This means, some basic checks are...
const DataTypeDescriptor & dtypeDescr() const
More elaborate description of the datatypes.
us neninchannels(bool include_monitorchannels=true) const
Returns the number of enabled input channels.
boolvec eninchannels(const bool include_monitor=true) const
Create a vector of boolean values of the enabled input channels.
static std::unique_ptr< Daq > createDaq(const DeviceInfo &devinfo, const DaqConfiguration &config)
Create a Daq based on given device info and configuration.
bool duplexMode() const
Whether the device runs in duplex mode (both input and output), or false if only input / only output.
double samplerate() const
Returns current sample rate.
DataTypeDescriptor::DataType dataType() const
Returns datatype (enum) corresponding to the datatype of the samples.
boolvec enoutchannels() const
Create an array of booleans for each enabled output channel.
dvec inputRangeForEnabledChannels(const bool include_monitor=true) const
Returns the input range for each channel. Maximum allowed absolute value of the signal that can pass ...
Daq(const DeviceInfo &devinfo, const DaqConfiguration &config)
us nenoutchannels() const
Returns the number of enabled output channels.
Descriptor for data types containing more detailed information.
DataType
Basic data types coming from a DAQ that we can deal with. The naming will be self-explainging.
Structure containing device info parameters.
unsigned ninchannels
The number of input channels available for the device.
unsigned noutchannels
The number of output channels available for the device.
dvec availableSampleRates
Available sample rates the device can run on.
std::vector< DataTypeDescriptor::DataType > availableDataTypes
The available data types the device can output.
DaqApi api
Backend API corresponding to device.
bool hasInternalOutputMonitor
Whether the device has an internal monitor of the output signal. If true, the device is able to monit...
dvec availableInputRanges
Available ranges for the input, i.e. +/- 1V and/or +/- 10 V etc.
std::vector< double > dvec
const std::map< DataTypeDescriptor::DataType, const DataTypeDescriptor > dtype_map
std::vector< bool > boolvec
std::unique_ptr< Daq > createPortAudioDevice(const DeviceInfo &devinfo, const DaqConfiguration &config)
Method called from Daq::createDaq.
std::unique_ptr< Daq > createRtAudioDevice(const DeviceInfo &devinfo, const DaqConfiguration &config)
Method called from Daq::createDaq.
std::unique_ptr< Daq > createUlDaqDevice(const DeviceInfo &devinfo, const DaqConfiguration &config)
size_t us
We often use boolean values.