summaryrefslogtreecommitdiff
path: root/map65/soundin.h
blob: 0f45acea25f058dd1d35a02c3c27ddab74ca3068 (plain)
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
#ifndef SOUNDIN_H
#define SOUNDIN_H

#include <QtCore>
#include <QtNetwork/QUdpSocket>
#include <QDebug>
#include <atomic>
#include <valarray>

#include "half_symbol_scheduler.h"

class MainWindow;  //Forward declaration

// Thread gets audio data from soundcard and signals when a buffer of
// specified size is available.
class SoundInThread : public QThread
{
  Q_OBJECT
  bool quitExecution;           // if true, thread exits gracefully
  double m_rate;                // sample rate
  unsigned bufSize;             // user's buffer size

protected:
  virtual void run();

public:
  std::atomic_bool m_dataSinkBusy;

  SoundInThread():
    quitExecution(false),
    m_rate(0),
    bufSize(0),
    m_dataSinkBusy(false)
  {
  }

  void setSwapIQ(bool b);
  void setScale(qint32 n);
  void setPort(qint32 n);
  void setInputDevice(qint32 n);
  void setRate(double rate);
  void setBufSize(unsigned bufSize);
  void setNetwork(bool b);
  void setMonitoring(bool b);
  void setFadd(double x);
  void setNrx(int n);
  void setForceCenterFreqBool(bool b);
  void setForceCenterFreqMHz(double d);
  void setPeriod(int n);
  int  nrx();
  int  mhsym();

signals:
  void bufferAvailable(std::valarray<qint16> samples, double rate);
  void readyForFFT(int k);
  void error(const QString& message);
  void status(const QString& message);

public slots:
  void quit();

private:
  MainWindow* m_mainWindow;
  void inputUDP();

  double m_fAdd;
  bool   m_net;
  bool   m_monitoring;
  bool   m_bForceCenterFreq;
  bool   m_IQswap;
  double m_dForceCenterFreq;
  qint32 m_nrx;
  qint32 m_hsym;
  qint32 m_nDevIn;
  qint32 m_udpPort;
  qint32 m_TRperiod;
  qint32 m_TRperiod0;
  qint32 m_dB;

  QUdpSocket *udpSocket;
};

extern "C" {
  void recvpkt_(int* nsam, quint16* iblk, qint8* nrx, int* k, double s1[],
                double s2[], double s3[]);
}

#endif // SOUNDIN_H