3 #include "AudioTools/AudioCodecs/AudioCodecsBase.h"
26 p_print = &out_stream;
38 p_print = &out_stream;
44 p_print = &out_stream;
48 virtual size_t write(
const uint8_t *data,
size_t len)
override {
49 if (p_print==
nullptr)
return 0;
50 int samples = len/
sizeof(float);
51 buffer.resize(samples);
52 float* p_float = (
float*) data;
53 for (
int j=0;j<samples;j++){
54 buffer[j] = p_float[j]*32767;
56 return p_print->write((uint8_t*)buffer.data(), samples*
sizeof(int16_t)) * 2;
59 virtual operator bool()
override {
60 return p_print!=
nullptr;;
64 Print *p_print=
nullptr;
65 Vector<int16_t> buffer;
89 p_print = &out_stream;
93 const char*
mime()
override{
115 virtual size_t write(
const uint8_t *data,
size_t len)
override {
116 if (p_print==
nullptr)
return 0;
117 int16_t *pt16 = (int16_t*)data;
118 size_t samples = len /
sizeof(int16_t);
119 buffer.resize(samples);
120 for (
size_t j=0;j<samples;j++){
121 buffer[j] =
static_cast<float>(pt16[j]) / 32768.0;
123 return p_print->write((uint8_t*)buffer.data(), samples*
sizeof(float));
126 operator bool()
override {
135 Print* p_print=
nullptr;;
136 volatile bool is_open;
137 Vector<float> buffer;