[4668] | 1 | //filter_add.c: |
---|
[979] | 2 | |
---|
| 3 | /* |
---|
[4708] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011 |
---|
[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 | |
---|
| 28 | int roardsp_add_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { |
---|
[3001] | 29 | struct roardsp_amp * self = roar_mm_malloc(sizeof(struct roardsp_amp)); |
---|
[979] | 30 | |
---|
| 31 | if ( self == NULL ) |
---|
| 32 | return -1; |
---|
| 33 | |
---|
| 34 | memset(self, 0, sizeof(struct roardsp_amp)); |
---|
| 35 | |
---|
| 36 | filter->inst = (void*) self; |
---|
| 37 | |
---|
[1141] | 38 | roardsp_filter_reset(filter, ROARDSP_RESET_FULL); |
---|
[979] | 39 | |
---|
| 40 | return 0; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | int roardsp_add_calc16 (struct roardsp_filter * filter, void * data, size_t samples) { |
---|
| 44 | struct roardsp_amp * self = (struct roardsp_amp *) filter->inst; |
---|
| 45 | int16_t * samp = (int16_t *) data; |
---|
| 46 | size_t i; |
---|
| 47 | |
---|
| 48 | for (i = 0; i < samples; i++) { |
---|
| 49 | samp[i] += self->mul / self->div; |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | return 0; |
---|
| 53 | } |
---|
| 54 | |
---|
[1141] | 55 | int roardsp_add_reset (struct roardsp_filter * filter, int what) { |
---|
| 56 | struct roardsp_amp * self; |
---|
| 57 | |
---|
| 58 | if ( filter == NULL ) |
---|
| 59 | return -1; |
---|
| 60 | |
---|
| 61 | if ( filter->inst == NULL ) |
---|
| 62 | return -1; |
---|
| 63 | |
---|
| 64 | self = filter->inst; |
---|
| 65 | |
---|
| 66 | switch (what) { |
---|
| 67 | case ROARDSP_RESET_NONE: |
---|
| 68 | case ROARDSP_RESET_STATE: |
---|
| 69 | return 0; |
---|
| 70 | break; |
---|
| 71 | case ROARDSP_RESET_FULL: |
---|
| 72 | self->mul = 0; |
---|
| 73 | self->div = 1; |
---|
| 74 | return 0; |
---|
| 75 | break; |
---|
| 76 | default: |
---|
| 77 | return -1; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | return -1; |
---|
| 81 | } |
---|
| 82 | |
---|
[979] | 83 | //ll |
---|