JS8Call-Improved master
Loading...
Searching...
No Matches
AudioDevice Class Reference

Abstract base class for audio devices exposed as a QIODevice. More...

#include <AudioDevice.h>

Inheritance diagram for AudioDevice:
Collaboration diagram for AudioDevice:

Public Types

enum  Channel { Mono , Left , Right , Both }
 Audio channel selection used by the device. More...

Public Member Functions

bool initialize (OpenMode mode, Channel channel)
 Initialize the device for the specified open mode and channel.
bool isSequential () const override
 Whether this device exposes a sequential data stream.
size_t bytesPerFrame () const
 Number of bytes per audio frame for the current channel setting.
Channel channel () const
 Get the current channel selection used by this device.

Static Public Member Functions

static char const * toString (Channel c)
static Channel fromString (QString const &str)
 Convert a channel label into an AudioDevice channel value.

Protected Member Functions

 AudioDevice (QObject *parent=nullptr)
void store (char const *source, size_t numFrames, qint16 *dest)
 Copy interleaved source samples into the destination buffer.
qint16 * load (qint16 const sample, qint16 *dest)
 Expand a sample value into the output buffer for the active channel.

Detailed Description

Abstract base class for audio devices exposed as a QIODevice.

Subclasses implement concrete audio sinks/sources. AudioDevice offers channel selection helpers, frame size calculation and convenience routines to store/load interleaved sample frames.

Member Enumeration Documentation

◆ Channel

Audio channel selection used by the device.

These values are mapped to UI combobox indexes elsewhere; do not reorder or renumber them without updating the UI mappings.

Member Function Documentation

◆ bytesPerFrame()

size_t AudioDevice::bytesPerFrame ( ) const
inline

Number of bytes per audio frame for the current channel setting.

For mono devices this equals the sample size; for stereo it is double.

Here is the caller graph for this function:

◆ channel()

Channel AudioDevice::channel ( ) const
inline

Get the current channel selection used by this device.

The channel determines how interleaved frames are interpreted when storing and loading samples (Mono, Left, Right, or Both).

Returns
The active Channel value used for store/load operations.
Here is the caller graph for this function:

◆ fromString()

Channel AudioDevice::fromString ( QString const & str)
inlinestatic

Convert a channel label into an AudioDevice channel value.

Parameters
strChannel name to parse.
Returns
Matching Channel enum value.

◆ initialize()

bool AudioDevice::initialize ( OpenMode mode,
Channel channel )

Initialize the device for the specified open mode and channel.

Parameters
modeQIODevice open mode (ReadOnly/WriteOnly/etc).
channelChannel selection to use.
Returns
true on successful initialization.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSequential()

bool AudioDevice::isSequential ( ) const
inlineoverride

Whether this device exposes a sequential data stream.

Returns true to indicate the device behaves as a sequential QIODevice (no random access). Consumers should treat the device as a stream of sample data and avoid relying on seeking.

Returns
true when the device is sequential.

◆ load()

qint16 * AudioDevice::load ( qint16 const sample,
qint16 * dest )
inlineprotected

Expand a sample value into the output buffer for the active channel.

Parameters
sampleInput sample value.
destOutput buffer to fill.
Returns
Updated buffer pointer.
Here is the caller graph for this function:

◆ store()

void AudioDevice::store ( char const * source,
size_t numFrames,
qint16 * dest )
inlineprotected

Copy interleaved source samples into the destination buffer.

Parameters
sourceSource data buffer.
numFramesNumber of frames to copy.
destDestination sample buffer.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: