55template <
typename T =
int16_t>
68 for (
size_t j = 0;
j < size;
j++) {
106template <
typename T =
int16_t>
119 T *sample = (
T *)
src;
124 for (
size_t j = 0;
j < size;
j++) {
131 for (
size_t j = 0;
j < size;
j++) {
165 if (size == 0)
return;
181 for (
size_t j = 0;
j < size;
j++) {
283template <
typename T =
int16_t>
291 T *sample = (
T *)
src;
292 for (
size_t j = 0;
j < size;
j++) {
294 *sample = *(sample + 1);
295 *(sample + 1) =
temp;
322template <
typename T =
int16_t>
327 this->channels = channels;
349 if (left_empty && !right_empty) {
350 T *sample = (
T *)
src;
351 for (
size_t j = 0;
j < size;
j++) {
352 *sample = *(sample + 1);
355 }
else if (!left_empty && right_empty) {
356 T *sample = (
T *)
src;
357 for (
size_t j = 0;
j < size;
j++) {
358 *(sample + 1) = *sample;
367 bool is_setup =
false;
368 bool left_empty =
true;
369 bool right_empty =
true;
374 for (
int j = 0;
j < size;
j++) {
381 for (
int j = 0;
j < size - 1;
j++) {
389 if (!right_empty || !left_empty) {
405template <
typename T =
int16_t>
412 T *sample = (
T *)
src;
413 for (
int i = 0; i < size; i++) {
415 *sample = *sample + 0x8000;
433template <
typename T =
int16_t>
457 size_t result_size = 0;
458 T *result = (
T *)target;
459 T *source = (
T *)
src;
462 for (
int i = 0; i < frame_count; i++) {
465 *result++ = *source++;
466 result_size +=
sizeof(
T);
474 result_size +=
sizeof(
T);
505 return cr8.convert(target,
src, size);
509 return cr16.convert(target,
src, size);
513 return cr24.convert(target,
src, size);
517 return cr32.convert(target,
src, size);
533template <
typename T =
int16_t>
561 LOGE(
"Buffer size %d is not a multiple of the number of channels %d",
566 int frame_count = size / (
sizeof(
T) *
channels);
568 T *p_source = (
T *)
src;
569 size_t result_size = 0;
571 for (
int i = 0; i < frame_count; i++) {
577 result_size +=
sizeof(
T);
582 LOGD(
"decimate %d: %d -> %d bytes",
factor, (
int)size, (
int)result_size);
591 LOGE(
"Number of channels must be > 0");
595 LOGE(
"Decimation factor must be > 0");
638 if (
state !=
nullptr) {
647 if (
state ==
nullptr) {
662 LOGE(
"Number of bits %d not supported.",
bits);
678 template <
typename T>
693 LOGE(
"Number of channels must be > 0");
697 LOGE(
"Decimation factor must be > 0");
725template <
typename T =
int16_t>
750template <
typename T =
int16_t>
789 LOGE(
"Buffer size %d is not a multiple of the number of channels %d",
795 T *p_source = (
T *)
src;
796 size_t result_size = 0;
797 int sample_count = size / (
sizeof(
T) *
channels);
799 for (
int sample = 0; sample < sample_count; sample++) {
810 result_size +=
sizeof(
T);
816 LOGD(
"bin %d: processed %d samples, %d remaining, %d > %d bytes",
binSize,
827 LOGE(
"Number of channels must be > 0");
831 LOGE(
"Bin size must be > 0");
894 if (
state !=
nullptr) {
903 if (
state ==
nullptr) {
918 LOGE(
"Number of bits %d not supported.",
bits);
932 template <
typename T>
948 LOGE(
"Number of channels must be > 0");
952 LOGE(
"Bin size must be > 0");
984template <
typename T =
int16_t>
994 LOGD(
"channel subtract %d samples, %d bytes", (
int)(size /
sizeof(
T)),
998 if (size % (
sizeof(
T) * 2) > 0) {
999 LOGE(
"Buffer size is not even");
1007 T *p_source = (
T *)
src;
1009 for (
int i = 0; i < sample_count; i++) {
1011 auto tmp = *p_source++;
1016 return sizeof(
T) * sample_count;
1046 LOGE(
"Number of bits %d not supported.",
bits);
1064template <
typename T =
int16_t,
typename SumT =
float>
1072 int samples = size /
sizeof(
T);
1104template <
typename T =
int16_t,
typename AvgT =
float>
1114 if (size % (
sizeof(
T) * 2) > 0) {
1115 LOGE(
"Buffer size is not even");
1123 T *p_source = (
T *)
src;
1125 for (
int i = 0; i < sample_count; i++) {
1128 AvgT tmp = *p_source++;
1133 LOGD(
"channel average %d samples, %d bytes", sample_count, (
int)size);
1135 return sizeof(
T) * sample_count;
1162#ifdef PREFER_FIXEDPOINT
1194 LOGE(
"Number of bits %d not supported.",
bits);
1217template <
typename T =
int16_t>
1232 LOGE(
"Number of channels needs to be even");
1255 if (size % (
sizeof(
T) *
channels) > 0) {
1256 LOGE(
"Buffer size needs to be multiple of channels");
1261 T *p_source = (
T *)
src;
1262 size_t result_size = 0;
1263 int sample_count = size / (
sizeof(
T) *
channels);
1265 for (
int sample = 0; sample < sample_count; sample++) {
1276 :
static_cast<T>(
diff);
1277 result_size +=
sizeof(
T);
1284 "bin & channel subtract %d: processed %d samples, %d remaining, %d > "
1297 LOGE(
"Number of channels must be > 0");
1301 LOGE(
"Bin size must be > 0");
1353 LOGE(
"Number of channels needs to be even");
1372 if (
state !=
nullptr) {
1381 if (
state ==
nullptr) {
1396 LOGE(
"Number of bits %d not supported.",
bits);
1410 template <
typename T>
1426 LOGE(
"Number of channels must be > 0");
1430 LOGE(
"Bin size must be > 0");
1453template <
typename T =
int16_t>
1474 size_t result_size = 0;
1475 T *result = (
T *)target;
1476 T *source = (
T *)
src;
1478 for (
int i = 0; i < frame_count; i++) {
1483 result_size +=
sizeof(
T);
1488 result_size +=
sizeof(
T);
1509template <
typename T =
int16_t>
1561template <
typename T =
int16_t>
1584 for (
int i = 0; i < converters.size(); i++) {
1585 converters[i]->convert(
src, size);
1606 int len =
inBits / 8 * n;
1623 for (
int j = 0;
j < n;
j++) {
1630 for (
int j = 0;
j < n;
j++) {
1637 for (
int j = 0;
j < n;
j++) {
1651 int32_t result =
static_cast<float>(value) /
1667template <
typename T =
int16_t>
1674 for (
size_t j = 0;
j < size;
j++) {
1690template <
typename T,
typename FT>
1707 LOGE(
"Invalid channel nummber %d - max channel is %d", channel,
1721 int count = size /
channels /
sizeof(
T);
1722 T *sample = (
T *)
src;
1723 for (
size_t j = 0;
j < count;
j++) {
1724 for (
int channel = 0; channel <
channels; channel++) {
1725 if (
filters[channel] !=
nullptr) {
1726 *sample =
filters[channel]->process(*sample);
1739 if (newChannels ==
channels)
return;
1763template <
typename T =
int16_t>
1778 size_t sample_count = size /
sizeof(
T);
1780 T *audio = (
T *)data;
1783 T *p_buffer = (
T *)data;
1784 for (
int j = 0;
j < sample_count;
j++) {
1788 *p_buffer++ = audio[
j];
1794 LOGI(
"filtered silence from %d -> %d", (
int)size, (
int)
write_size);
1814 this->priorLastAudioPos =
n + 1;
1815 this->active =
n > 0;
1820 for (
int j = 0;
j <
n;
j++) {
1841template <
typename T =
int16_t>
1866 T first = values[channel];
1900template <
typename T =
int16_t>
1916 int sample_count = size /
sizeof(
T);
1933 for (
int frame = 0; frame <
frameCount; ++frame) {
1934 if (factor >= 0.8) {
1939 values[pos +
ch] = factor * values[pos +
ch];
1948 for (
int frame =
frameCount - 1; frame >= 0; --frame) {
1949 if (factor >= 0.8) {
1954 values[pos +
ch] = factor * values[pos +
ch];
1968template <
typename T,
size_t Cn,
size_t Cx,
size_t S>
1975 size_t samples = (size /
Cn) /
sizeof(
T);
1976 for (
size_t s = 0;
s < samples;
s++) {
1979 for (
size_t c = 0;
c <
Cn;
c++) {
1985 if (_max_val <
chan[
s *
Cn]) {
1991 if (
now - _prev_ms > 1000) {
1993 LOGI(
"CopyChannels samples: %u, amplitude: %d", _counter, _max_val);
1997 return samples *
Cn *
sizeof(
T);
2011template <
typename T =
int16_t>
2016 int samples = size /
sizeof(
T);
2017 for (
int j = 0;
j < samples;
j++) {
2029template <
typename T =
int16_t>
2047 int samples = size /
sizeof(
T);
2049 for (
int j = 0;
j < samples;
j++) {
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define assert(T)
Definition avr.h:10
virtual size_t readBytes(uint8_t *data, size_t len)
Definition Arduino.h:140
virtual int available()
Definition Arduino.h:139
FillLeftAndRightStatus
Configure ConverterFillLeftAndRight.
Definition BaseConverter.h:310
@ LeftIsEmpty
Definition BaseConverter.h:310
@ RightIsEmpty
Definition BaseConverter.h:310
@ Auto
Definition BaseConverter.h:310