|
| 1 | +/* |
| 2 | + * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 | + * (C) 2020 Vladimir Sadovnikov <[email protected]> |
| 4 | + * |
| 5 | + * This file is part of lsp-dsp-lib |
| 6 | + * Created on: 13 дек. 2020 г. |
| 7 | + * |
| 8 | + * lsp-dsp-lib is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Lesser General Public License as published by |
| 10 | + * the Free Software Foundation, either version 3 of the License, or |
| 11 | + * any later version. |
| 12 | + * |
| 13 | + * lsp-dsp-lib is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Lesser General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Lesser General Public License |
| 19 | + * along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef LSP_PLUG_IN_DSP_COMMON_INTERPOLATION_LINEAR_H_ |
| 23 | +#define LSP_PLUG_IN_DSP_COMMON_INTERPOLATION_LINEAR_H_ |
| 24 | + |
| 25 | +/** |
| 26 | + * Perform linear interpolation of x values defined by initial points: |
| 27 | + * |
| 28 | + * dst[i] = interp[i] |
| 29 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 30 | + * |
| 31 | + * @param dst destination buffer to store interpolated values |
| 32 | + * @param x0 the x coordinate of first initial point |
| 33 | + * @param y0 the y coordinate of first initial point |
| 34 | + * @param x1 the x coordinate of second initial point |
| 35 | + * @param y1 the y coordinate of second initial point |
| 36 | + * @param x the initial coordinate of X point |
| 37 | + * @param n number of x'es to process |
| 38 | + */ |
| 39 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_set, float *dst, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 40 | + |
| 41 | +/** |
| 42 | + * Perform linear interpolation of x values defined by initial points and multiply |
| 43 | + * them by the samples stored in destination buffer |
| 44 | + * |
| 45 | + * dst[i] = src[i] * interp[i] |
| 46 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 47 | + * |
| 48 | + * @param dst destination buffer to apply multiplication by interpolated values |
| 49 | + * @param x0 the x coordinate of first initial point |
| 50 | + * @param y0 the y coordinate of first initial point |
| 51 | + * @param x1 the x coordinate of second initial point |
| 52 | + * @param y1 the y coordinate of second initial point |
| 53 | + * @param x the initial coordinate of X point |
| 54 | + * @param n number of x'es to process |
| 55 | + */ |
| 56 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_mul2, float *dst, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 57 | + |
| 58 | +/** |
| 59 | + * Perform linear interpolation of x values defined by initial points, multiply |
| 60 | + * them by the samples stored in source buffer and store values to destination buffer |
| 61 | + * |
| 62 | + * dst[i] = src[i] * interp[i] |
| 63 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 64 | + * |
| 65 | + * @param dst destination buffer to store the result |
| 66 | + * @param src source buffer to apply multiplication by interpolated values |
| 67 | + * @param x0 the x coordinate of first initial point |
| 68 | + * @param y0 the y coordinate of first initial point |
| 69 | + * @param x1 the x coordinate of second initial point |
| 70 | + * @param y1 the y coordinate of second initial point |
| 71 | + * @param x the initial coordinate of X point |
| 72 | + * @param n number of x'es to process |
| 73 | + */ |
| 74 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_mul3, float *dst, const float *src, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 75 | + |
| 76 | +/** |
| 77 | + * Perform linear interpolation of x values defined by initial points, multiply |
| 78 | + * them by the samples stored in first source buffer and add values to values |
| 79 | + * stored in the destination buffer: |
| 80 | + * |
| 81 | + * dst[i] = src[i] * interp[i] + dst[i] |
| 82 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 83 | + * |
| 84 | + * @param dst destination buffer to add the result |
| 85 | + * @param src source buffer to apply multiplication by interpolated values |
| 86 | + * @param x0 the x coordinate of first initial point |
| 87 | + * @param y0 the y coordinate of first initial point |
| 88 | + * @param x1 the x coordinate of second initial point |
| 89 | + * @param y1 the y coordinate of second initial point |
| 90 | + * @param x the initial coordinate of X point |
| 91 | + * @param n number of x'es to process |
| 92 | + */ |
| 93 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_fmadd2, float *dst, const float *src, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 94 | + |
| 95 | +/** |
| 96 | + * Perform linear interpolation of x values defined by initial points, multiply |
| 97 | + * them by the samples stored in destination source buffer, add values stored in |
| 98 | + * source buffer and store result in destination buffer |
| 99 | + * |
| 100 | + * dst[i] = dst[i] * interp[i] + src[i] |
| 101 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 102 | + * |
| 103 | + * @param dst destination buffer to add the result |
| 104 | + * @param src source buffer to apply multiplication by interpolated values |
| 105 | + * @param x0 the x coordinate of first initial point |
| 106 | + * @param y0 the y coordinate of first initial point |
| 107 | + * @param x1 the x coordinate of second initial point |
| 108 | + * @param y1 the y coordinate of second initial point |
| 109 | + * @param x the initial coordinate of X point |
| 110 | + * @param n number of x'es to process |
| 111 | + */ |
| 112 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_frmadd2, float *dst, const float *src, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 113 | + |
| 114 | +/** |
| 115 | + * Perform linear interpolation of x values defined by initial points, multiply |
| 116 | + * them by the samples stored in first source buffer, add values from second source |
| 117 | + * buffer and store values to destination buffer |
| 118 | + * |
| 119 | + * dst[i] = src1[i] * interp[i] + src2[i] |
| 120 | + * interp[i] = y0 + ((x[i] - x0) * (y1 - y0)) / (x1 - x0) |
| 121 | + * |
| 122 | + * @param dst destination buffer to store the result |
| 123 | + * @param src1 source buffer to apply multiplication by interpolated values |
| 124 | + * @param src2 source buffer to use for addition |
| 125 | + * @param x0 the x coordinate of first initial point |
| 126 | + * @param y0 the y coordinate of first initial point |
| 127 | + * @param x1 the x coordinate of second initial point |
| 128 | + * @param y1 the y coordinate of second initial point |
| 129 | + * @param x the initial coordinate of X point |
| 130 | + * @param n number of x'es to process |
| 131 | + */ |
| 132 | +LSP_DSP_LIB_SYMBOL(void, lin_inter_fmadd3, float *dst, const float *src1, const float *src2, int32_t x0, float y0, int32_t x1, float y1, int32_t x, uint32_t n); |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | +#endif /* LSP_PLUG_IN_DSP_COMMON_INTERPOLATION_LINEAR_H_ */ |
0 commit comments