forked from xiaozhi/xiaozhi-esp32
34 lines
765 B
C
34 lines
765 B
C
|
|
#ifndef AUDIO_PROCESSOR_H
|
||
|
|
#define AUDIO_PROCESSOR_H
|
||
|
|
|
||
|
|
#include <esp_afe_sr_models.h>
|
||
|
|
#include <freertos/FreeRTOS.h>
|
||
|
|
#include <freertos/task.h>
|
||
|
|
#include <freertos/event_groups.h>
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
#include <vector>
|
||
|
|
#include <functional>
|
||
|
|
|
||
|
|
class AudioProcessor {
|
||
|
|
public:
|
||
|
|
AudioProcessor();
|
||
|
|
~AudioProcessor();
|
||
|
|
|
||
|
|
void Input(const int16_t* data, int size);
|
||
|
|
void Start();
|
||
|
|
void Stop();
|
||
|
|
bool IsRunning();
|
||
|
|
void OnOutput(std::function<void(std::vector<int16_t>&& data)> callback);
|
||
|
|
|
||
|
|
private:
|
||
|
|
EventGroupHandle_t event_group_ = nullptr;
|
||
|
|
esp_afe_sr_data_t* afe_communication_data_ = nullptr;
|
||
|
|
std::vector<int16_t> input_buffer_;
|
||
|
|
std::function<void(std::vector<int16_t>&& data)> output_callback_;
|
||
|
|
|
||
|
|
void AudioProcessorTask();
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|