PS-80 GrandComp Analyzer 1.2
Loading...
Searching...
No Matches
xyseriesiodevice.h
Go to the documentation of this file.
1/****************************************************************************
2** Original work Copyright (C) 2016 The Qt Company Ltd.
3** Modified work Copyright (c) 2026 Patrik Källback
4**
5** This file is based on the Qt Charts examples but has been heavily
6** modified for the PS-80 GrandComp Analyzer project.
7**
8** @file xyseriesiodevice.h
9** @brief Custom QIODevice for dual-mode audio playback and signal analysis.
10** @author Patrik Källback
11** @version 1.2
12** @license SPDX-License-Identifier: MIT (for modifications)
13** @date 2026-02-17
14****************************************************************************/
15
16#ifndef XYSERIESIODEVICE_H
17#define XYSERIESIODEVICE_H
18
19#include <QtCharts/QChartGlobal>
20#include <QtCore/QIODevice>
21#include <QtCore/QPointF>
22#include <QtCore/QVector>
23#include <vector>
24
33class XYSeriesIODevice : public QIODevice
34{
35 Q_OBJECT
36public:
38 explicit XYSeriesIODevice(QObject *parent = nullptr);
39
43 virtual ~XYSeriesIODevice() = default;
44
47
50
55 void updateTable(const std::vector<float> &data);
56
61 void setFrequency(float hz);
62
71 qint64 readData(char *data, qint64 maxlen) override;
72
74 qint64 writeData(const char * /*data*/, qint64 /*len*/) override { return 0; }
75
77 bool isSequential() const override { return true; }
78
83 enum class PlayMode {
86 };
87
89 void setPlayMode(PlayMode mode);
90
93
95 float getCurrentPhase() const { return m_phase; }
96
98 qint64 getCurrentWavIndex() const { return m_wavIndex; }
99
100private:
102 std::vector<float> m_table;
103 float m_phase{0.0f};
104 qint64 m_wavIndex{0};
105 float m_increment{0.0f};
106 const float m_sampleRate{44100.0f};
107};
108
109#endif // XYSERIESIODEVICE_H
qint64 writeData(const char *, qint64) override
Placeholder for write operations; always returns 0.
Definition xyseriesiodevice.h:74
qint64 getCurrentWavIndex() const
Returns the current sample index in WavFile mode.
Definition xyseriesiodevice.h:98
PlayMode m_currentMode
Definition xyseriesiodevice.h:101
PlayMode getPlayMode() const
Returns the current playback mode.
Definition xyseriesiodevice.h:92
XYSeriesIODevice(const XYSeriesIODevice &)=delete
Deleted copy constructor to prevent accidental duplication of the audio stream.
void setPlayMode(PlayMode mode)
Toggles between the available playback engines.
Definition xyseriesiodevice.cpp:108
float getCurrentPhase() const
Returns the current oscillator phase [0, tableSize].
Definition xyseriesiodevice.h:95
qint64 readData(char *data, qint64 maxlen) override
Core audio callback used by the Qt Audio engine.
Definition xyseriesiodevice.cpp:56
qint64 m_wavIndex
Definition xyseriesiodevice.h:104
bool isSequential() const override
Indicates that this is a continuous audio stream.
Definition xyseriesiodevice.h:77
virtual ~XYSeriesIODevice()=default
Virtual destructor. Explicitly defaulted to ensure safe polymorphic deletion of derived classes.
XYSeriesIODevice & operator=(const XYSeriesIODevice &)=delete
Deleted assignment operator to enforce unique ownership of the I/O state.
std::vector< float > m_table
Definition xyseriesiodevice.h:102
float m_phase
Definition xyseriesiodevice.h:103
const float m_sampleRate
Definition xyseriesiodevice.h:106
XYSeriesIODevice(QObject *parent=nullptr)
Constructs the I/O device.
Definition xyseriesiodevice.cpp:21
void updateTable(const std::vector< float > &data)
Loads new PCM data into the internal lookup table.
Definition xyseriesiodevice.cpp:31
void setFrequency(float hz)
Sets the fundamental frequency for the Waveform synthesis mode.
Definition xyseriesiodevice.cpp:41
PlayMode
Operational states for the audio engine.
Definition xyseriesiodevice.h:83
@ WavFile
Definition xyseriesiodevice.h:85
@ Waveform
Definition xyseriesiodevice.h:84
float m_increment
Definition xyseriesiodevice.h:105