arduino-audio-tools
Loading...
Searching...
No Matches
OutputTest.h
Go to the documentation of this file.
1#pragma once
2#include "Print.h"
3
4namespace audio_tools {
5
12class OutputTest : public Print {
13 public:
14 OutputTest() = default;
15
16 size_t write(uint8_t c) override { return write(&c, 1); }
17
18 size_t write(const uint8_t *buffer, size_t size) override {
19 char hex_start[31] = {0};
20 char hex_end[31] = {0};
21 size_t start_count = size < 10 ? size : 10;
22 for (size_t i = 0; i < start_count; ++i) {
23 snprintf(hex_start + i * 3, 4, "%02X ", buffer[i]);
24 }
25 if (size > 10) {
26 size_t end_count = (size - 10) < 10 ? (size - 10) : 10;
27 for (size_t i = 0; i < end_count; ++i) {
28 snprintf(hex_end + i * 3, 4, "%02X ", buffer[size - end_count + i]);
29 }
30 }
31 LOGI("OutputTest: write() len=%u first=[%s] last=[%s]",
32 (unsigned)size, hex_start, hex_end);
33 return size;
34 }
35};
36
37} // namespace audio_tools
#define LOGI(...)
Definition AudioLoggerIDF.h:28
Definition Arduino.h:56
Print sink that logs the length and a hex preview (first/last 10 bytes) of every write() call instead...
Definition OutputTest.h:12
size_t write(const uint8_t *buffer, size_t size) override
Definition OutputTest.h:18
size_t write(uint8_t c) override
Definition OutputTest.h:16
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6