6#define AudioOutput AudioOutputMozzi
50 if (
cfg.bits_per_sample != 16) {
51 LOGE(
"bits_per_sample must be 16 and not %d",
cfg.bits_per_sample);
73 cfg.output_volume = vol;
80 int samples = len /
sizeof(int16_t);
81 int frames = samples /
cfg.channels;
82 int16_t* data16 = (int16_t*)data;
84 for (
int j = 0; j < frames; j++) {
86 for (
int ch = 0; ch <
cfg.channels; ch++) {
87 data16[idx++] = sample;
90 return idx *
sizeof(int16_t);
94 size_t write(
const uint8_t* data,
size_t len) {
99 return buffer.writeArray(data, len);
106 int16_t result[
cfg.channels] = {0};
108 p_input->readBytes((uint8_t*)&result,
sizeof(int16_t) *
cfg.channels);
110 buffer.readArray((uint8_t*)&result,
sizeof(int16_t) *
cfg.channels);
113 int sample =
avg(result);
132 int16_t
avg(int16_t* values) {
134 for (
int ch = 0; ch <
cfg.channels; ch++) {
137 return total /
cfg.channels;
144 LOGD(
"updateControl");
151 if (result > 32767) result = 32767;
152 if (result < -32768) result = -32768;
AudioOutputMozzi updateAudio()