12#ifndef AUDIODEVICE_HPP__
13#define AUDIODEVICE_HPP__
27class AudioDevice :
public QIODevice {
42 static char const *toString(
Channel c) {
61 QString
const s(str.toCaseFolded().trimmed().toLatin1());
65 else if (s ==
"right")
98 return sizeof(qint16) * (Mono == m_channel ? 1 : 2);
112 explicit AudioDevice(QObject *parent =
nullptr) : QIODevice(parent) {}
120 void store(
char const *source,
size_t numFrames, qint16 *dest) {
121 qint16
const *begin(
reinterpret_cast<qint16
const *
>(source));
122 for (qint16
const *i = begin;
136 Q_ASSERT(Both == m_channel);
151 qint16 *
load(qint16
const sample, qint16 *dest) {
Abstract base class for audio devices exposed as a QIODevice.
Definition AudioDevice.h:27
void store(char const *source, size_t numFrames, qint16 *dest)
Copy interleaved source samples into the destination buffer.
Definition AudioDevice.h:120
Channel channel() const
Get the current channel selection used by this device.
Definition AudioDevice.h:109
qint16 * load(qint16 const sample, qint16 *dest)
Expand a sample value into the output buffer for the active channel.
Definition AudioDevice.h:151
Channel
Audio channel selection used by the device.
Definition AudioDevice.h:35
size_t bytesPerFrame() const
Number of bytes per audio frame for the current channel setting.
Definition AudioDevice.h:97
static Channel fromString(QString const &str)
Convert a channel label into an AudioDevice channel value.
Definition AudioDevice.h:60
bool isSequential() const override
Whether this device exposes a sequential data stream.
Definition AudioDevice.h:90
bool initialize(OpenMode mode, Channel channel)
Initialize the device for the specified open mode and channel.
Definition AudioDevice.cpp:12