-
Notifications
You must be signed in to change notification settings - Fork 3
/
wfsportaudio.h
126 lines (109 loc) · 3.21 KB
/
wfsportaudio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#pragma once
#include "portaudio.h"
#include "pa_asio.h"
//#include "sndfile.h"
#include <QDebug>
#include <QList>
#include <QStringList>
#include <QAbstractTableModel>
#include <QWidget>
//class PortAudioDeviceModel:public QAbstractTableModel {
// Q_OBJECT
//public:
// PortAudioDeviceModel(QObject *parent);
// ~PortAudioDeviceModel(void);
//private:
// QVariant m_devices[
//class PortAudioConfigModel {
//public:
// PortAudioConfig(void);
// ~PortAudioConfig(void);
// int activeDeviceID;
//
//};
class ChannelModel:public QAbstractTableModel {
Q_OBJECT
public:
PaDeviceIndex paDeviceIndex;
QString paHostName;
QVector<bool> m_channelEnabled;
ChannelModel(QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const { return 2; };
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
void toggle(QModelIndex &index);
signals:;
void editCompleted(const bool);
void configurationChanged(QVector<bool>* channelList);
};
class WFSPortAudio:public QObject
{
Q_OBJECT
public:
WFSPortAudio(QWidget *parent);
~WFSPortAudio(void);
QWidget* controller;
PaStream *stream;
PaError error;
enum EngineState {
ENGINE_IDLE,
ENGINE_WFS,
ENGINE_CHANNEL_TEST
};
EngineState engineState;
struct ChannelTestData {
float toneDuration; //seconds
float toneFrequency;
float gapDuration; //seconds
float envRate;
float env; //envelope
int currentChannel;
int counter;
};
ChannelTestData channelTestData;
QVector<PaStreamParameters *> outputParameters; //we cache outputparams for all devices so we don't have to check again.
QVector<ChannelModel *> channelList;
const PaDeviceInfo *deviceInfo;
int framesPerBuffer;
int sampleRate;
int numDevices;
PaDeviceIndex activeDeviceIndex;
QList<int> outputDeviceIndexList;
QStringList outputDeviceStringList;
/*
Channel Buffer - essentially for deinterleaving
*/
float* channelBuffer;
QVector<bool>* getActiveChannelList() {
return(&(channelList.at(activeDeviceIndex)->m_channelEnabled));
}
void start();
void stop();
void softStart();
void softStop();
int myMemberCallback(const void *input,
void *output,
unsigned long frameCount,
const PaStreamCallbackTimeInfo* paTimeInfo,
PaStreamCallbackFlags statusFlags);
//this is a wrapper function for the member callback, see http://www.portaudio.com/trac/wiki/tips/c%2B%2B
static int myPaCallback(
const void *input, void *output,
unsigned long frameCount,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
{
return ((WFSPortAudio*)userData)->myMemberCallback(input, output, frameCount, timeInfo, statusFlags);
}
void maybeSwitchDevice(PaDeviceIndex i);
void testAllChannels();
void testChannel(int ch);
void showAsio(PaDeviceIndex i, void* h);
signals:
void configurationChanged(QVector<bool>* newChannelList);
//void lockMutex();
//void unlockMutex();
};