-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaudio.h
41 lines (33 loc) · 939 Bytes
/
audio.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
#ifndef _AUDIO_H_
#define _AUDIO_H_
#include <alsa/asoundlib.h>
#include <thread>
#define DEFAULT_PLAYBACK_VOLUME 100
#define DEFAULT_CAPTURE_VOLUME 80
#define MAX_VOLUME 100
#define SAMPLE_RATE 44100
#define NUM_CHANNELS 1
/* The enum AudioMode is used when initializing an Audio class.
* It is now being used in derived class AudioRecorder and AudioPlayer.
*/
enum AudioMode {
CAPTURE,
PLAYBACK
};
class Audio {
public:
Audio(AudioMode mode);
virtual ~Audio();
void setPlaybackVolume(int newVolume);
void setCaptureVolume(int newVolume);
// int getVolume() const { return volume; }
unsigned long getFrameSize() const { return playbackBufferSize; }
protected:
int volume;
unsigned long playbackBufferSize;
snd_pcm_t *handle;
std::thread threadObj;
// Defining an abstract function which must be overwritten in derived class
virtual void doThread() = 0;
};
#endif