diff options
author | David Robillard <d@drobilla.net> | 2012-08-11 03:28:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-11 03:28:57 +0000 |
commit | 3444a46f4b058f5c0066320914c56bd1b417d06f (patch) | |
tree | a3ad1eae326271ce243c1f49ca413b51be9a4a35 /src/include | |
parent | 1024036481f0847443add3277830aab4fa92de0e (diff) | |
download | blop.lv2-3444a46f4b058f5c0066320914c56bd1b417d06f.tar.gz blop.lv2-3444a46f4b058f5c0066320914c56bd1b417d06f.tar.bz2 blop.lv2-3444a46f4b058f5c0066320914c56bd1b417d06f.zip |
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
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/lp4pole_filter.h | 2 | ||||
-rw-r--r-- | src/include/vector_op.h | 44 |
2 files changed, 45 insertions, 1 deletions
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 <http://www.gnu.org/licenses/>. +*/ + +#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 */ |