12# define USE_VARIANTS (__cplusplus >= 201703L)
44 LOGI(
"addEffect -> Number of effects: %d", (
int)
size());
61 for (
int j=0;j<
size();j++){
94template <
class GeneratorT>
105 for (
int j=0;j<copy.
size();j++){
106 effects.addEffect(copy[j]->clone());
108 LOGI(
"Number of effects %d -> %d", copy.
size(), this->size());
119 setInput(* (
new GeneratorT(input, channels, volume)));
129 for (
int j=0;j<
effects.size();j++){
155 LOGI(
"addEffect -> Number of effects: %d",
size());
164 for (
int j=0; j<
size; j++){
165 sample =
effects[j]->process(sample);
261 bool bits_ok =
sizeof(T)==
info.bits_per_sample/8
262 || (
info.bits_per_sample==24 &&
sizeof(T)==
sizeof(
int24_t));
267 LOGE(
"bits_per_sample not consistent: %d",
info.bits_per_sample);
295 size_t result =
p_io->readBytes((uint8_t*)data, len);
296 int frames = result /
sizeof(T) /
info.channels;
297 T* samples = (T*) data;
299 for (
int f=0;f<frames;f++){
300 for (
int ch=0;ch<
info.channels;ch++){
301 T &sample = samples[f*
info.channels+ch];
303 for (
int j=0; j<chain.
size(); j++){
304 sample = chain[j]->process(sample);
318 size_t write(
const uint8_t *data,
size_t len)
override {
322 int frames = len /
sizeof(T) /
info.channels;
323 int total_samples = frames *
info.channels;
329 for (
int f=0;f<frames;f++){
330 const T* p_buffer = ((
const T*)data) + (f*
info.channels);
331 T* p_frame_out = out + (f*
info.channels);
332 for (
int ch=0;ch<
info.channels;ch++){
333 T sample = p_buffer[ch];
335 for (
int j=0; j<chain.
size(); j++){
336 sample = chain[j]->process(sample);
338 p_frame_out[ch] = sample;
342 size_t written_samples = 0;
345 }
else if (
p_out!=
nullptr){
348 return written_samples *
sizeof(T);
352 if (
p_io==
nullptr)
return 0;
353 return p_io->available();
357 if (
p_out!=
nullptr)
return p_out->availableForWrite();
358 if (
p_io!=
nullptr)
return p_io->availableForWrite();
364 else if (
p_io!=
nullptr)
p_io->flush();
376 LOGI(
"addEffect -> Number of effects: %d", (
int)
size());
397 LOGE(
"Invalid channel %d or begin() not yet called", channel);
463 for (
int ch=0; ch<
info.channels; ch++){
464 for (
int j=0; j<
effects.size(); j++){
471#if USE_VARIANTS || defined(DOXYGEN)
510 switch(
info.bits_per_sample){
521 LOGE(
"Unspported bits_per_sample: %d",
info.bits_per_sample);
524 if (
p_out !=
nullptr) {
525 std::visit( [
this](
auto&& e) {
return e.setOutput(*
p_out);},
variant );
527 if (
p_io !=
nullptr) {
528 std::visit( [
this](
auto&& e) {
return e.setStream(*
p_io);},
variant );
530 return std::visit( [
this](
auto&& e) {
return e.begin(
info);},
variant );
534 std::visit( [](
auto&& e) {e.end();},
variant );
558 return std::visit( [data, len](
auto&& e) {
return e.readBytes(data, len);},
variant );
565 size_t write(
const uint8_t *data,
size_t len)
override {
566 return std::visit( [data, len](
auto&& e) {
return e.write(data, len);},
variant );
570 return std::visit( [](
auto&& e) {
return e.available();},
variant );
574 return std::visit( [](
auto&& e) {
return e.availableForWrite();},
variant );
578 std::visit( [](
auto&& e) {e.flush();},
variant );
588 std::visit( [effect](
auto&& e) {e.addEffect(effect);},
variant );
598 std::visit( [channel, effect](
auto&& e) {e.addEffect(channel, effect);},
variant );
603 std::visit( [](
auto&& e) {e.clear();},
variant );
608 return std::visit( [](
auto&& e) {
return e.size();},
variant );
613 return std::visit( [idx](
auto&& e) {
return e[idx];},
variant );
618 return std::visit( [
id](
auto&& e) {
return e.findEffect(
id);},
variant );
628 return std::visit( [](
auto&& e) {
return e.channelCount();},
variant );