ESPHome  2024.4.1
microphone.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/helpers.h"
5 
6 namespace esphome {
7 namespace microphone {
8 
9 enum State : uint8_t {
14 };
15 
16 class Microphone {
17  public:
18  virtual void start() = 0;
19  virtual void stop() = 0;
20  void add_data_callback(std::function<void(const std::vector<int16_t> &)> &&data_callback) {
21  this->data_callbacks_.add(std::move(data_callback));
22  }
23  virtual size_t read(int16_t *buf, size_t len) = 0;
24 
25  bool is_running() const { return this->state_ == STATE_RUNNING; }
26  bool is_stopped() const { return this->state_ == STATE_STOPPED; }
27 
28  protected:
30 
32 };
33 
34 } // namespace microphone
35 } // namespace esphome
void add_data_callback(std::function< void(const std::vector< int16_t > &)> &&data_callback)
Definition: microphone.h:20
CallbackManager< void(const std::vector< int16_t > &)> data_callbacks_
Definition: microphone.h:31
virtual size_t read(int16_t *buf, size_t len)=0
std::string size_t len
Definition: helpers.h:292
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7