-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_logger.h
72 lines (52 loc) · 1.67 KB
/
audio_logger.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
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
/*! \file audio_logger.h
* \brief Enter description here.
* \author Georgi Gerganov
*/
#pragma once
#include "constants.h"
#include "common.h"
#include <memory>
#include <array>
#include <vector>
#include <functional>
class AudioLogger {
public:
using Sample = TSampleF;
using Frame = std::array<Sample, kSamplesPerFrame>;
using Record = std::vector<Frame>;
using Callback = std::function<void(const Record & frames)>;
struct Parameters {
Callback callback;
int32_t captureId = -1;
int32_t nChannels = -1;
int64_t sampleRate = -1;
// Sample Type
// todo : support for other sample types
enum ESampleType {
F32SYS,
};
ESampleType sampleType = F32SYS;
// Filter
enum EFilter {
None = 0,
FirstOrderHighPass,
SecondOrderButterworthHighPass,
};
EFilter filter = SecondOrderButterworthHighPass;
float freqCutoff_Hz = -1.0f;
};
AudioLogger();
~AudioLogger();
bool install(Parameters && parameters);
bool terminate();
bool addFrame(const Sample * stream);
bool record(float bufferSize_s, int32_t nPrevFrames);
bool pause();
bool resume();
bool isValidBufferSize(float bufferSize_s) const;
private:
struct Data;
std::unique_ptr<Data> data_;
Data & getData() { return *data_; }
const Data & getData() const { return *data_; }
};