Codec Recorder Interface

[中文]

Public header: #include "brookesia/hal_interface/audio/codec_recorder.hpp"

Class: AudioCodecRecorderIface

API Reference

Header File

Classes

class AudioCodecRecorderIface : public esp_brookesia::hal::Interface

Recording interface exposed by audio-capable devices.

Public Functions

inline AudioCodecRecorderIface(Info info)

Construct an audio recording interface.

Parameters

info[in] Static recording capability information.

virtual ~AudioCodecRecorderIface() = default

Virtual destructor for polymorphic recording interfaces.

virtual bool open() = 0

Open the recording backend.

Returns

true on success; otherwise false.

virtual void close() = 0

Close the recording backend.

virtual bool read_data(uint8_t *data, size_t size) = 0

Read captured audio payload.

Parameters
  • data[out] Destination buffer for captured bytes.

  • size[in] Requested byte count.

Returns

true on success; otherwise false.

virtual bool set_general_gain(float gain) = 0

Set the general gain.

Parameters

gain[in] The gain to set.

Returns

true on success; otherwise false.

virtual bool set_channel_gains(const std::map<uint8_t, float> &gains) = 0

Set the channel gains.

Parameters

gains[in] The channel gains to set.

Returns

true on success; otherwise false.

inline const Info &get_info() const

Get static recording capability information.

Returns

Recording information.

Public Static Attributes

static constexpr const char *NAME = "AudioCodecRecorder"

Interface registry name.

struct Info

Static recording capability information.

Public Members

uint8_t bits

Sample bit width.

uint8_t channels

Number of capture channels.

uint32_t sample_rate

Capture sample rate in Hz.

std::string mic_layout

Microphone layout descriptor.

float general_gain

Global input gain.

std::map<uint8_t, float> channel_gains

Per-channel gain overrides.