PS-80 GrandComp Analyzer 1.2
Loading...
Searching...
No Matches
XYSeriesIODevice Class Reference

A specialized I/O device that bridges raw signal data to the audio hardware. More...

#include <xyseriesiodevice.h>

Inheritance diagram for XYSeriesIODevice:

Public Types

enum class  PlayMode { Waveform , WavFile }
 Operational states for the audio engine. More...

Public Member Functions

 XYSeriesIODevice (QObject *parent=nullptr)
 Constructs the I/O device.
virtual ~XYSeriesIODevice ()=default
 Virtual destructor. Explicitly defaulted to ensure safe polymorphic deletion of derived classes.
 XYSeriesIODevice (const XYSeriesIODevice &)=delete
 Deleted copy constructor to prevent accidental duplication of the audio stream.
XYSeriesIODeviceoperator= (const XYSeriesIODevice &)=delete
 Deleted assignment operator to enforce unique ownership of the I/O state.
void updateTable (const std::vector< float > &data)
 Loads new PCM data into the internal lookup table.
void setFrequency (float hz)
 Sets the fundamental frequency for the Waveform synthesis mode.
qint64 readData (char *data, qint64 maxlen) override
 Core audio callback used by the Qt Audio engine.
qint64 writeData (const char *, qint64) override
 Placeholder for write operations; always returns 0.
bool isSequential () const override
 Indicates that this is a continuous audio stream.
void setPlayMode (PlayMode mode)
 Toggles between the available playback engines.
PlayMode getPlayMode () const
 Returns the current playback mode.
float getCurrentPhase () const
 Returns the current oscillator phase [0, tableSize].
qint64 getCurrentWavIndex () const
 Returns the current sample index in WavFile mode.

Private Attributes

PlayMode m_currentMode = PlayMode::Waveform
std::vector< float > m_table
float m_phase {0.0f}
qint64 m_wavIndex {0}
float m_increment {0.0f}
const float m_sampleRate {44100.0f}

Detailed Description

A specialized I/O device that bridges raw signal data to the audio hardware.

This class implements a real-time playback engine designed for the PS-80 GrandComp. It manages two distinct operational modes: periodic waveform synthesis (oscillation) and linear WAV file streaming.

Member Enumeration Documentation

◆ PlayMode

enum class XYSeriesIODevice::PlayMode
strong

Operational states for the audio engine.

Enumerator
Waveform 

Oscillator mode: Loops the extracted single-cycle.

WavFile 

1:1 Playback mode: Streams the original source data.

Constructor & Destructor Documentation

◆ XYSeriesIODevice() [1/2]

XYSeriesIODevice::XYSeriesIODevice ( QObject * parent = nullptr)
explicit

Constructs the I/O device.

Constructs the device and prepares the I/O interface.

Parameters
parentParent QObject.
  • The device is opened in ReadOnly mode to interface with the Qt Audio output.

◆ ~XYSeriesIODevice()

virtual XYSeriesIODevice::~XYSeriesIODevice ( )
virtualdefault

Virtual destructor. Explicitly defaulted to ensure safe polymorphic deletion of derived classes.

◆ XYSeriesIODevice() [2/2]

XYSeriesIODevice::XYSeriesIODevice ( const XYSeriesIODevice & )
delete

Deleted copy constructor to prevent accidental duplication of the audio stream.

Member Function Documentation

◆ getCurrentPhase()

float XYSeriesIODevice::getCurrentPhase ( ) const
inline

Returns the current oscillator phase [0, tableSize].

◆ getCurrentWavIndex()

qint64 XYSeriesIODevice::getCurrentWavIndex ( ) const
inline

Returns the current sample index in WavFile mode.

◆ getPlayMode()

PlayMode XYSeriesIODevice::getPlayMode ( ) const
inline

Returns the current playback mode.

◆ isSequential()

bool XYSeriesIODevice::isSequential ( ) const
inlineoverride

Indicates that this is a continuous audio stream.

◆ operator=()

XYSeriesIODevice & XYSeriesIODevice::operator= ( const XYSeriesIODevice & )
delete

Deleted assignment operator to enforce unique ownership of the I/O state.

◆ readData()

qint64 XYSeriesIODevice::readData ( char * data,
qint64 maxlen )
override

Core audio callback used by the Qt Audio engine.

Real-time audio processing loop.

  • Reads PCM data from the internal buffer based on the active PlayMode. In Waveform mode, it utilizes phase accumulation to loop the cycle.
  • Parameters
    dataDestination buffer for the audio samples.
    maxlenMaximum number of bytes to read.
    Returns
    qint64 Number of bytes actually read.
  • Depending on the active PlayMode, this function either synthesizes a periodic waveform using linear interpolation or streams raw data.
  1. Periodic Synthesis (Oscillator) Uses linear interpolation between samples to maintain signal integrity at non-integer phase positions.
  1. Linear Playback (WAV Audit) Streams the buffer 1:1. m_wavIndex tracks the position.

◆ setFrequency()

void XYSeriesIODevice::setFrequency ( float hz)

Sets the fundamental frequency for the Waveform synthesis mode.

Calculates the phase increment based on a target frequency.

Parameters
hzTarget frequency in Hertz (e.g., 55.0 for A1).
  • Formula: increment = (Frequency * TableSize) / SampleRate. This ensures pitch accuracy in PlayMode::Waveform.

◆ setPlayMode()

void XYSeriesIODevice::setPlayMode ( PlayMode mode)

Toggles between the available playback engines.

Changes the playback engine state and resets indices.

Parameters
modeThe desired PlayMode.

◆ updateTable()

void XYSeriesIODevice::updateTable ( const std::vector< float > & data)

Loads new PCM data into the internal lookup table.

Updates the internal signal buffer.

Parameters
dataA vector of floating-point samples normalized to [-1.0, 1.0].
dataPCM samples used for both synthesis and linear playback.

◆ writeData()

qint64 XYSeriesIODevice::writeData ( const char * ,
qint64  )
inlineoverride

Placeholder for write operations; always returns 0.

Field Documentation

◆ m_currentMode

PlayMode XYSeriesIODevice::m_currentMode = PlayMode::Waveform
private

Current engine state.

◆ m_increment

float XYSeriesIODevice::m_increment {0.0f}
private

Phase step per sample, derived from frequency.

◆ m_phase

float XYSeriesIODevice::m_phase {0.0f}
private

Phase accumulator for Waveform mode.

◆ m_sampleRate

const float XYSeriesIODevice::m_sampleRate {44100.0f}
private

System sample rate for time-base calculations.

◆ m_table

std::vector<float> XYSeriesIODevice::m_table
private

Internal buffer for PCM signal data.

◆ m_wavIndex

qint64 XYSeriesIODevice::m_wavIndex {0}
private

Current read pointer for WavFile mode.


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