-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputfeeder.h
84 lines (58 loc) · 1.8 KB
/
outputfeeder.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
/*
This file is part of Waver
Copyright (C) 2021 Peter Papp
Please visit https://launchpad.net/waver for details
*/
#ifndef OUTPUTFEEDER_H
#define OUTPUTFEEDER_H
#include <QAudioFormat>
#include <QAudioOutput>
#include <QByteArray>
#include <QIODevice>
#include <QMutex>
#include <QObject>
#include <QtMath>
#include <QThread>
#include <QTimer>
#include "peakcallback.h"
#ifdef QT_DEBUG
#include <QDebug>
#endif
class OutputFeeder : public QObject
{
Q_OBJECT
public:
explicit OutputFeeder(QByteArray *outputBuffer, QMutex *outputBufferMutex, QAudioFormat audioFormat, QAudioOutput *audioOutput, PeakCallback::PeakCallbackInfo peakCallbackInfo, QObject *parent = nullptr);
void setOutputDevice(QIODevice *outputDevice);
void setWideStereoDelayMillisec(int wideStereoDelayMillisec);
private:
static const qint64 MICROSECONDS_PER_SECOND = 1000 * 1000;
static const int WIDE_STEREO_DELAY_MILLISEC_MAX = 50;
QAudioOutput *audioOutput;
QByteArray *outputBuffer;
QMutex *outputBufferMutex;
QIODevice *outputDevice;
QAudioFormat audioFormat;
PeakCallback::PeakCallbackInfo peakCallbackInfo;
QMutex outputDeviceMutex;
QMutex peakDelaySumMutex;
int channelCount;
int channelIndex;
int frameCount;
int dataType;
int dataBytes;
double int16Min;
double int16Max;
double int16Range;
double sampleMin;
double sampleRange;
double lPeak;
double rPeak;
qint64 peakDelaySum;
int wideStereoDelayMillisec;
int newWideStereoDelayMillisec;
QMutex wideStereoDelayMutex;
public slots:
void run();
};
#endif // OUTPUTFEEDER_H