54template <
typename T =
int16_t>
67 for (
size_t j = 0;
j < size;
j++) {
105template <
typename T =
int16_t>
118 T *sample = (
T *)
src;
123 for (
size_t j = 0;
j < size;
j++) {
130 for (
size_t j = 0;
j < size;
j++) {
164 if (size == 0)
return;
180 for (
size_t j = 0;
j < size;
j++) {
282template <
typename T =
int16_t>
290 T *sample = (
T *)
src;
291 for (
size_t j = 0;
j < size;
j++) {
293 *sample = *(sample + 1);
294 *(sample + 1) =
temp;
321template <
typename T =
int16_t>
326 this->channels = channels;
348 if (left_empty && !right_empty) {
349 T *sample = (
T *)
src;
350 for (
size_t j = 0;
j < size;
j++) {
351 *sample = *(sample + 1);
354 }
else if (!left_empty && right_empty) {
355 T *sample = (
T *)
src;
356 for (
size_t j = 0;
j < size;
j++) {
357 *(sample + 1) = *sample;
366 bool is_setup =
false;
367 bool left_empty =
true;
368 bool right_empty =
true;
373 for (
int j = 0;
j < size;
j++) {
380 for (
int j = 0;
j < size - 1;
j++) {
388 if (!right_empty || !left_empty) {
404template <
typename T =
int16_t>
411 T *sample = (
T *)
src;
412 for (
int i = 0; i < size; i++) {
414 *sample = *sample + 0x8000;
432template <
typename T =
int16_t>
456 size_t result_size = 0;
457 T *result = (
T *)target;
458 T *source = (
T *)
src;
461 for (
int i = 0; i < frame_count; i++) {
464 *result++ = *source++;
465 result_size +=
sizeof(
T);
473 result_size +=
sizeof(
T);
504 return cr8.convert(target,
src, size);
508 return cr16.convert(target,
src, size);
512 return cr24.convert(target,
src, size);
516 return cr32.convert(target,
src, size);
532template <
typename T =
int16_t>
560 LOGE(
"Buffer size %d is not a multiple of the number of channels %d",
565 int frame_count = size / (
sizeof(
T) *
channels);
567 T *p_source = (
T *)
src;
568 size_t result_size = 0;
570 for (
int i = 0; i < frame_count; i++) {
576 result_size +=
sizeof(
T);
581 LOGD(
"decimate %d: %d -> %d bytes",
factor, (
int)size, (
int)result_size);
590 LOGE(
"Number of channels must be > 0");
594 LOGE(
"Decimation factor must be > 0");
637 if (
state !=
nullptr) {
646 if (
state ==
nullptr) {
661 LOGE(
"Number of bits %d not supported.",
bits);
677 template <
typename T>
692 LOGE(
"Number of channels must be > 0");
696 LOGE(
"Decimation factor must be > 0");
724template <
typename T =
int16_t>
749template <
typename T =
int16_t>
788 LOGE(
"Buffer size %d is not a multiple of the number of channels %d",
794 T *p_source = (
T *)
src;
795 size_t result_size = 0;
796 int sample_count = size / (
sizeof(
T) *
channels);
798 for (
int sample = 0; sample < sample_count; sample++) {
809 result_size +=
sizeof(
T);
815 LOGD(
"bin %d: processed %d samples, %d remaining, %d > %d bytes",
binSize,
826 LOGE(
"Number of channels must be > 0");
830 LOGE(
"Bin size must be > 0");
893 if (
state !=
nullptr) {
902 if (
state ==
nullptr) {
917 LOGE(
"Number of bits %d not supported.",
bits);
931 template <
typename T>
947 LOGE(
"Number of channels must be > 0");
951 LOGE(
"Bin size must be > 0");
983template <
typename T =
int16_t>
993 LOGD(
"channel subtract %d samples, %d bytes", (
int)(size /
sizeof(
T)),
997 if (size % (
sizeof(
T) * 2) > 0) {
998 LOGE(
"Buffer size is not even");
1006 T *p_source = (
T *)
src;
1008 for (
int i = 0; i < sample_count; i++) {
1010 auto tmp = *p_source++;
1015 return sizeof(
T) * sample_count;
1045 LOGE(
"Number of bits %d not supported.",
bits);
1063template <
typename T =
int16_t,
typename SumT =
float>
1071 int samples = size /
sizeof(
T);
1103template <
typename T =
int16_t,
typename AvgT =
float>
1113 if (size % (
sizeof(
T) * 2) > 0) {
1114 LOGE(
"Buffer size is not even");
1122 T *p_source = (
T *)
src;
1124 for (
int i = 0; i < sample_count; i++) {
1127 AvgT tmp = *p_source++;
1132 LOGD(
"channel average %d samples, %d bytes", sample_count, (
int)size);
1134 return sizeof(
T) * sample_count;
1161#ifdef PREFER_FIXEDPOINT
1193 LOGE(
"Number of bits %d not supported.",
bits);
1216template <
typename T =
int16_t>
1231 LOGE(
"Number of channels needs to be even");
1254 if (size % (
sizeof(
T) *
channels) > 0) {
1255 LOGE(
"Buffer size needs to be multiple of channels");
1260 T *p_source = (
T *)
src;
1261 size_t result_size = 0;
1262 int sample_count = size / (
sizeof(
T) *
channels);
1264 for (
int sample = 0; sample < sample_count; sample++) {
1275 :
static_cast<T>(
diff);
1276 result_size +=
sizeof(
T);
1283 "bin & channel subtract %d: processed %d samples, %d remaining, %d > "
1296 LOGE(
"Number of channels must be > 0");
1300 LOGE(
"Bin size must be > 0");
1352 LOGE(
"Number of channels needs to be even");
1371 if (
state !=
nullptr) {
1380 if (
state ==
nullptr) {
1395 LOGE(
"Number of bits %d not supported.",
bits);
1409 template <
typename T>
1425 LOGE(
"Number of channels must be > 0");
1429 LOGE(
"Bin size must be > 0");
1452template <
typename T =
int16_t>
1473 size_t result_size = 0;
1474 T *result = (
T *)target;
1475 T *source = (
T *)
src;
1477 for (
int i = 0; i < frame_count; i++) {
1482 result_size +=
sizeof(
T);
1487 result_size +=
sizeof(
T);
1508template <
typename T =
int16_t>
1560template <
typename T =
int16_t>
1583 for (
int i = 0; i < converters.size(); i++) {
1584 converters[i]->convert(
src, size);
1605 int len =
inBits / 8 * n;
1622 for (
int j = 0;
j < n;
j++) {
1629 for (
int j = 0;
j < n;
j++) {
1636 for (
int j = 0;
j < n;
j++) {
1650 int32_t result =
static_cast<float>(value) /
1666template <
typename T =
int16_t>
1673 for (
size_t j = 0;
j < size;
j++) {
1689template <
typename T,
typename FT>
1716 if (
filters[channel] !=
nullptr) {
1721 LOGE(
"Invalid channel nummber %d - max channel is %d", channel,
1728 int count = size /
channels /
sizeof(
T);
1729 T *sample = (
T *)
src;
1730 for (
size_t j = 0;
j < count;
j++) {
1731 for (
int channel = 0; channel <
channels; channel++) {
1732 if (
filters[channel] !=
nullptr) {
1757template <
typename T =
int16_t>
1772 size_t sample_count = size /
sizeof(
T);
1774 T *audio = (
T *)data;
1777 T *p_buffer = (
T *)data;
1778 for (
int j = 0;
j < sample_count;
j++) {
1782 *p_buffer++ = audio[
j];
1788 LOGI(
"filtered silence from %d -> %d", (
int)size, (
int)
write_size);
1808 this->priorLastAudioPos =
n + 1;
1809 this->active =
n > 0;
1814 for (
int j = 0;
j <
n;
j++) {
1835template <
typename T =
int16_t>
1860 T first = values[channel];
1894template <
typename T =
int16_t>
1910 int sample_count = size /
sizeof(
T);
1927 for (
int frame = 0; frame <
frameCount; ++frame) {
1928 if (factor >= 0.8) {
1933 values[pos +
ch] = factor * values[pos +
ch];
1942 for (
int frame =
frameCount - 1; frame >= 0; --frame) {
1943 if (factor >= 0.8) {
1948 values[pos +
ch] = factor * values[pos +
ch];
1962template <
typename T,
size_t Cn,
size_t Cx,
size_t S>
1969 size_t samples = (size /
Cn) /
sizeof(
T);
1970 for (
size_t s = 0;
s < samples;
s++) {
1973 for (
size_t c = 0;
c <
Cn;
c++) {
1979 if (_max_val <
chan[
s *
Cn]) {
1985 if (
now - _prev_ms > 1000) {
1987 LOGI(
"CopyChannels samples: %u, amplitude: %d", _counter, _max_val);
1991 return samples *
Cn *
sizeof(
T);
2005template <
typename T =
int16_t>
2014 int samples = size /
sizeof(
T);
2016 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
FillLeftAndRightStatus
Configure ConverterFillLeftAndRight.
Definition BaseConverter.h:309
@ LeftIsEmpty
Definition BaseConverter.h:309
@ RightIsEmpty
Definition BaseConverter.h:309
@ Auto
Definition BaseConverter.h:309