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
audiobase.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 //=============================================================================
21 // Audio base class
22 //=============================================================================
23 
24 #ifndef AUDIOBASE_H
25 #define AUDIOBASE_H
26 
27 #include <vector>
28 #include <cstdint>
29 #include <string>
30 
31 #include "../system/prerequisites.h"
32 
42 
43 class AudioBase
44 {
45 public:
48  typedef double PCMDataType;
49 
51  typedef std::vector<PCMDataType> PacketType;
52 
53 public:
54  AudioBase();
55  virtual ~AudioBase() {}
56 
57  virtual void init() = 0;
58  virtual void exit() = 0;
59 
60  virtual void start() = 0;
61  virtual void stop() = 0;
62 
63  const std::string &getDeviceName() const; // get the device name
64  void setDeviceName(const std::string &n); // set the device name
65  int getSamplingRate() const; // get actual sampling rate
66  virtual void setSamplingRate(int rate); // set actual sampling rate
67  int getChannelCount() const; // get number of channels
68  virtual void setChannelCount(int cnt); // set number of channels
69 
70 private:
71  std::string mAudioDeviceName;
74 };
75 
76 #endif // AUDIOBASE_H
std::vector< PCMDataType > PacketType
Type definition of a PCM packet (vector of PCM values).
Definition: audiobase.h:51
virtual void start()=0
Start/restart the audio device.
AudioBase()
Constructor.
Definition: audiobase.cpp:36
std::string mAudioDeviceName
User-readable string of the used audio device.
Definition: audiobase.h:71
const std::string & getDeviceName() const
Get a readable string of the name of the audio device.
Definition: audiobase.cpp:52
virtual ~AudioBase()
Destructor (no functionality).
Definition: audiobase.h:55
double PCMDataType
Definition: audiobase.h:48
virtual void stop()=0
Stop the audio device.
void setDeviceName(const std::string &n)
Set the device name.
Definition: audiobase.cpp:65
int getChannelCount() const
Get the actual number of channels (1=mono, 2=stereo).
Definition: audiobase.cpp:109
virtual void setChannelCount(int cnt)
Set the number of channels (1=mono, 2=stereo).
Definition: audiobase.cpp:122
int getSamplingRate() const
Get the actual sampling rate.
Definition: audiobase.cpp:78
virtual void exit()=0
Destroy the audio device.
int mChannelCount
Current channel count.
Definition: audiobase.h:73
virtual void init()=0
Inizialize the audio device.
int mSamplingRate
Current sampling rate.
Definition: audiobase.h:72
virtual void setSamplingRate(int rate)
Allow the implementation to change the sampling rate during operation.
Definition: audiobase.cpp:96
Abstract base class for audio interfaces.
Definition: audiobase.h:43