Deluge Firmware
Loading...
Searching...
No Matches
interpolate.h
Go to the documentation of this file.
1/*
2 * Copyright © 2018-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16*/
17
18
19#define numBitsInTableSize 8
20#define rshiftAmount ((24 + INTERPOLATION_MAX_NUM_SAMPLES_MAGNITUDE) - 16 - numBitsInTableSize + 1) // that's (numBitsInInput - 16 - numBitsInTableSize); = 4 for now
21
22#if rshiftAmount >= 0
23uint32_t rshifted = oscPos >> rshiftAmount;
24#else
25uint32_t rshifted = oscPos << (-rshiftAmount);
26#endif
27
28int16_t strength2 = rshifted & 32767;
29
31
33
34
35for (int i = 0; i < (INTERPOLATION_MAX_NUM_SAMPLES >> 3); i++) {
36 int16x8_t value1 = vld1q_s16(&windowedSincKernel[whichKernel][progressSmall][i << 3]);
37 int16x8_t value2 = vld1q_s16(&windowedSincKernel[whichKernel][progressSmall + 1][i << 3]);
38 int16x8_t difference = vsubq_s16(value2, value1);
39 int16x8_t multipliedDifference = vqdmulhq_n_s16(difference, strength2);
40 kernelVector[i] = vaddq_s16(value1, multipliedDifference);
41}
42
43int32x4_t multiplied;
44
45for (int i = 0; i < (INTERPOLATION_MAX_NUM_SAMPLES >> 3); i++) {
46
47 if (i == 0)
48 multiplied = vmull_s16(vget_low_s16(kernelVector[i]), interpolationBuffer[0][i << 1]);
49 else
50 multiplied = vmlal_s16(multiplied, vget_low_s16(kernelVector[i]), interpolationBuffer[0][i << 1]);
51
52 multiplied = vmlal_s16(multiplied, vget_high_s16(kernelVector[i]), interpolationBuffer[0][(i << 1) + 1]);
53}
54
55int32x2_t twosies = vadd_s32(vget_high_s32(multiplied), vget_low_s32(multiplied));
56
57sampleRead[0] = vget_lane_s32(twosies, 0) + vget_lane_s32(twosies, 1);
58
59
60if (numChannelsNow == 2) {
61
62 int32x4_t multiplied;
63
64 for (int i = 0; i < (INTERPOLATION_MAX_NUM_SAMPLES >> 3); i++) {
65
66 if (i == 0)
67 multiplied = vmull_s16(vget_low_s16(kernelVector[i]), interpolationBuffer[1][i << 1]);
68 else
69 multiplied = vmlal_s16(multiplied, vget_low_s16(kernelVector[i]), interpolationBuffer[1][i << 1]);
70
71 multiplied = vmlal_s16(multiplied, vget_high_s16(kernelVector[i]), interpolationBuffer[1][(i << 1) + 1]);
72 }
73
74 int32x2_t twosies = vadd_s32(vget_high_s32(multiplied), vget_low_s32(multiplied));
75
76 sampleRead[1] = vget_lane_s32(twosies, 0) + vget_lane_s32(twosies, 1);
77}
#define INTERPOLATION_MAX_NUM_SAMPLES_MAGNITUDE
Definition: definitions.h:773
#define INTERPOLATION_MAX_NUM_SAMPLES
Definition: definitions.h:772
int progressSmall
Definition: interpolate.h:30
int32x4_t multiplied
Definition: interpolate.h:43
#define numBitsInTableSize
Definition: interpolate.h:19
#define rshiftAmount
Definition: interpolate.h:20
sampleRead[0]
Definition: interpolate.h:57
int16x8_t kernelVector[INTERPOLATION_MAX_NUM_SAMPLES > > 3]
Definition: interpolate.h:32
int16_t strength2
Definition: interpolate.h:28
int32x2_t twosies
Definition: interpolate.h:55
uint32_t rshifted
Definition: interpolate.h:23
const int16_t windowedSincKernel[][17][16]