forked from ggerganov/kbd-audio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_logger.h
38 lines (30 loc) · 892 Bytes
/
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
/*! \file audio_logger.h
* \brief Enter description here.
* \author Georgi Gerganov
*/
#pragma once
#include "constants.h"
#include <memory>
#include <array>
#include <vector>
#include <functional>
class AudioLogger {
public:
using Sample = float;
using Frame = std::array<Sample, kSamplesPerFrame>;
using Record = std::vector<Frame>;
using Callback = std::function<void(const Record & frames)>;
AudioLogger();
~AudioLogger();
bool install(int64_t sampleRate, Callback callback, int captureId = 0);
bool terminate();
bool addFrame(const Sample * stream);
bool record(float bufferSize_s);
bool recordSym(float bufferSize_s);
bool pause();
bool resume();
private:
struct Data;
std::unique_ptr<Data> data_;
Data & getData() { return *data_; }
};