forked from paulh002/sdrberry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioOutput.h
More file actions
42 lines (36 loc) · 1009 Bytes
/
AudioOutput.h
File metadata and controls
42 lines (36 loc) · 1009 Bytes
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
#pragma once
#include <string>
#include "RtAudio.h"
#include "Audiodefs.h"
#include "DataBuffer.h"
class AudioOutput :
public RtAudio
{
public:
bool init(std::string device, int pcmrate);
bool open(DataBuffer<Sample> *AudioBuffer);
bool write(SampleVector& samples);
void adjust_gain(SampleVector& samples);
void close();
void stop();
~AudioOutput();
double get_volume() {return m_volume;}
void set_volume(int vol) {m_volume = exp(((double)vol * 6.908)/100.0) / 1000.0; } // log volume
unsigned int get_framesize() {return bufferFrames;}
operator bool() const
{
return (!m_zombie) && m_error.empty();
}
protected:
void samplesToInt16(const SampleVector& samples,
std::vector<std::uint8_t>& bytes);
private:
RtAudio::StreamParameters parameters;
DataBuffer<Sample> *databuffer;
unsigned int sampleRate;
unsigned int bufferFrames; // 256 sample frames
double m_volume {0.5};
string m_error;
bool m_zombie {false};
};
extern AudioOutput *audio_output;