Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
audiorecorderforqt.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #ifndef AUDIORECORDERFORQT_H
21 #define AUDIORECORDERFORQT_H
22 
23 #include "../../core/audio/recorder/audiorecorderadapter.h"
24 #include <QAudioInput>
25 #include <QTimer>
26 #include <mutex>
27 
28 class AudioRecorderForQt : public QObject, public AudioRecorderAdapter
29 {
30  Q_OBJECT
31 
32 
33  // define the data format of the input/output stream
34  // on android float streams are not supported, so we just use
35  // in general a singed int stream
36  // the int data will be scaled to the intervall [0,1] to allow an
37  // internal computation with floats independent on the selected stream
38  // size.
40  typedef int16_t DataFormat;
42  static const DataFormat SIGNAL_SCALING;
43 public:
44  AudioRecorderForQt(QObject *parent);
45  virtual ~AudioRecorderForQt();
46 
47  void init() override;
48  void exit() override;
49 
50  void start() override;
51  void stop() override;
52 
53  virtual void setDeviceInputGain(double volume) override final;
54  virtual double getDeviceInputGain() const override final;
55 
56 public slots:
57  void onReadPacket();
58 
59 private:
60  QAudioInput *mAudioInput;
61  QIODevice *mIODevice;
62  QTimer mReadTimer;
63 };
64 
65 #endif // AUDIORECORDERFORQT_H
Abstract adapter class for recording audio signals.
int16_t DataFormat
Data format of the input/output stream.
void start() override
Start/restart the audio device.
void exit() override
Destroy the audio device.
AudioRecorderForQt(QObject *parent)
void init() override
Inizialize the audio device.
QAudioInput * mAudioInput
virtual void setDeviceInputGain(double volume) overridefinal
virtual double getDeviceInputGain() const overridefinal
static const DataFormat SIGNAL_SCALING
maximal alloed value of the stream
void stop() override
Stop the audio device.