From 3444a46f4b058f5c0066320914c56bd1b417d06f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Aug 2012 03:28:57 +0000 Subject: Make sum, product, and difference plugins vectorizable. Improve const correctness. git-svn-id: http://svn.drobilla.net/lad/trunk/plugins/blop.lv2@4652 a436a847-0d15-0410-975c-d299462d15a1 --- src/include/lp4pole_filter.h | 2 +- src/include/vector_op.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/include/vector_op.h (limited to 'src/include') diff --git a/src/include/lp4pole_filter.h b/src/include/lp4pole_filter.h index a6b27f1..310fbbe 100644 --- a/src/include/lp4pole_filter.h +++ b/src/include/lp4pole_filter.h @@ -110,7 +110,7 @@ static inline float lp4pole_run(LP4PoleFilter* lpf, float in) { - float abs_in = fabsf(16.0f * in); /* ~24dB unclipped headroom */ + const float abs_in = fabsf(16.0f * in); /* ~24dB unclipped headroom */ lpf->max_abs_in = f_max(lpf->max_abs_in, abs_in); diff --git a/src/include/vector_op.h b/src/include/vector_op.h new file mode 100644 index 0000000..f8ea8dd --- /dev/null +++ b/src/include/vector_op.h @@ -0,0 +1,44 @@ +/* + Apply a C arithmetical operator to two sample buffers. + Copyright 2012 David Robillard + + This is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This software is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this software. If not, see . +*/ + +#ifndef BLOP_VECTOR_OP_H +#define BLOP_VECTOR_OP_H + +#define VECTOR_OP(op, output, input1, input1_is_cv, input2, input2_is_cv) \ + switch ((input1_is_cv << 1) + input2_is_cv) { \ + case 0: /* 00 (control * control) */ \ + output[0] = input1[0] * input2[0]; \ + break; \ + case 1: /* 01 (control * cv) */ \ + for (uint32_t s = 0; s < sample_count; ++s) { \ + output[s] = input1[0] * input2[s]; \ + } \ + break; \ + case 2: /* 10 (cv * control) */ \ + for (uint32_t s = 0; s < sample_count; ++s) { \ + output[s] = input1[s] * input2[0]; \ + } \ + break; \ + case 3: /* 11 (cv * cv) */ \ + for (uint32_t s = 0; s < sample_count; ++s) { \ + output[s] = input1[s] * input2[s]; \ + } \ + break; \ + } + +#endif /* BLOP_VECTOR_OP_H */ -- cgit v1.2.1