56 if (
step >= 1.0f)
return false;
74 operator bool()
const {
76 if (step_copy >= 1.0)
return false;
106 virtual float value(
float* y,
float xf) = 0;
125 if (xf == 0.0f)
return y[0];
126 if (xf == 1.0f)
return y[1];
130 return y[x] + dx * (y[x + 1] - y[x]);
153 float ym1py1 = y[x] + y[x + 2];
154 float c0 = 1.0f / 6.0f * ym1py1 + 2.0f / 3.0f * y[x + 1];
155 float c1 = 1.0f / 2.0f * (y[x + 2] - y[x]);
156 float c2 = 1.0f / 2.0f * ym1py1 - y[x + 1];
158 1.0f / 2.0f * (y[x + 1] - y[x + 2]) + 1.0f / 6.0f * (y[x + 3] - y[x]);
159 return ((c3 * dx + c2) * dx + c1) * dx + c0;
183 float c1 = y[x + 2] - 1.0f / 3.0f * y[x] - 1.0f / 2.0f * y[x + 1] -
184 1.0f / 6.0f * y[x + 3];
185 float c2 = 1.0f / 2.0f * (y[x] + y[x + 2]) - y[x + 1];
187 1.0f / 6.0f * (y[x + 3] - y[x]) + 1.0f / 2.0f * (y[x + 1] - y[x + 2]);
188 return ((c3 * dx + c2) * dx + c1) * dx + c0;
212 float c1 = 1.0f / 2.0f * (y[x + 2] - y[x]);
213 float c2 = y[x] - 5.0f / 2.0f * y[x + 1] + 2.0f * y[x + 2] -
214 1.0f / 2.0f * y[x + 3];
216 1.0f / 2.0f * (y[x + 3] - y[x]) + 3.0f / 2.0f * (y[x + 1] - y[x + 2]);
217 return ((c3 * dx + c2) * dx + c1) * dx + c0;
240 float y1mym1 = y[x + 2] - y[x];
241 float c0 = 1.0f / 2.0f * y[x + 1] + 1.0f / 4.0f * (y[x] + y[x + 2]);
242 float c1 = 1.0f / 2.0f * y1mym1;
243 float c2 = 1.0f / 4.0f * (y[x + 3] - y[x + 1] - y1mym1);
244 return (c2 * dx + c1) * dx + c0;
254template <
class TInterpolator>
289 if (channel < 0 || channel >=
_channels) {
290 LOGE(
"Invalid channel index: %d", channel);
309 operator bool()
const {
329template <
class TInterpolator>
439 size_t write(
const uint8_t* data,
size_t len)
override {
440 LOGD(
"ResampleStreamT::write: %d", (
int)len);
445 writeT<int16_t>(
p_print, data, len, written);
448 writeT<int24_t>(
p_print, data, len, written);
451 writeT<int32_t>(
p_print, data, len, written);
489 template <
typename T>
492 if (p_out ==
nullptr)
return 0;
496 return p_out->
write(buffer, bytes);
501 T* data = (T*)buffer;
502 float frame[channels];
503 size_t frames = bytes / (
sizeof(T) * channels);
504 size_t frames_written = 0;
505 for (
size_t i = 0; i < frames; ++i) {
507 for (
int ch = 0; ch < channels; ++ch) {
508 frame[ch] =
static_cast<float>(data[i * channels + ch]);
515 float result[channels];
519 for (
int ch = 0; ch < channels; ++ch) {
520 resultT[ch] = NumberConverter::clipT<T>(result[ch]);
524 size_t to_write =
sizeof(T) * channels;
525 size_t written = p_out->
write((
const uint8_t*)resultT, to_write);
526 if (written != to_write) {
527 LOGE(
"write error %zu -> %zu", to_write, written);
533 return frames_written *
sizeof(T) * channels;
#define TRACEE()
Definition AudioLoggerIDF.h:34
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
virtual size_t write(const uint8_t *data, size_t len)
Definition Arduino.h:120