[4668] | 1 | //filter_add.c: |
---|
[979] | 2 | |
---|
| 3 | /* |
---|
[5823] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2013 |
---|
[979] | 5 | * |
---|
| 6 | * This file is part of libroardsp a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroardsp is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[979] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #include "libroardsp.h" |
---|
| 27 | |
---|
[5181] | 28 | #define _calcX(bits) \ |
---|
| 29 | int roardsp_add_calc##bits (struct roardsp_filter * filter, void * data, size_t samples) { \ |
---|
| 30 | struct roardsp_amp * self = (struct roardsp_amp *) filter->inst; \ |
---|
| 31 | int##bits##_t * samp = (int##bits##_t *) data; \ |
---|
| 32 | size_t i; \ |
---|
| 33 | \ |
---|
| 34 | for (i = 0; i < samples; i++) { \ |
---|
| 35 | samp[i] += self->mul / self->div; \ |
---|
| 36 | }; \ |
---|
| 37 | \ |
---|
| 38 | return 0; \ |
---|
[979] | 39 | } |
---|
| 40 | |
---|
[5181] | 41 | _calcX(8) |
---|
| 42 | _calcX(16) |
---|
| 43 | _calcX(32) |
---|
[979] | 44 | |
---|
[1141] | 45 | int roardsp_add_reset (struct roardsp_filter * filter, int what) { |
---|
| 46 | struct roardsp_amp * self; |
---|
| 47 | |
---|
| 48 | if ( filter == NULL ) |
---|
| 49 | return -1; |
---|
| 50 | |
---|
| 51 | if ( filter->inst == NULL ) |
---|
| 52 | return -1; |
---|
| 53 | |
---|
| 54 | self = filter->inst; |
---|
| 55 | |
---|
| 56 | switch (what) { |
---|
| 57 | case ROARDSP_RESET_NONE: |
---|
| 58 | case ROARDSP_RESET_STATE: |
---|
| 59 | return 0; |
---|
| 60 | break; |
---|
| 61 | case ROARDSP_RESET_FULL: |
---|
| 62 | self->mul = 0; |
---|
| 63 | self->div = 1; |
---|
| 64 | return 0; |
---|
| 65 | break; |
---|
| 66 | default: |
---|
| 67 | return -1; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | return -1; |
---|
| 71 | } |
---|
| 72 | |
---|
[979] | 73 | //ll |
---|