[661] | 1 | //filterchain.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - August 2008 |
---|
| 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 |
---|
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include "libroardsp.h" |
---|
| 26 | |
---|
[663] | 27 | int roardsp_fchain_init (struct roardsp_filterchain * chain) { |
---|
| 28 | if ( chain == NULL ) |
---|
| 29 | return -1; |
---|
| 30 | |
---|
| 31 | memset((void*)chain, 0, sizeof(struct roardsp_filterchain)); |
---|
| 32 | return 0; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | int roardsp_fchain_uninit(struct roardsp_filterchain * chain) { |
---|
| 36 | int i; |
---|
| 37 | int ret = 0; |
---|
| 38 | |
---|
| 39 | if ( chain == NULL ) |
---|
| 40 | return -1; |
---|
| 41 | |
---|
| 42 | for (i = 0; i < chain->filters; i++) { |
---|
| 43 | if ( roardsp_filter_uninit(chain->filter[i]) == -1 ) |
---|
| 44 | ret = -1; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | if ( roardsp_fchain_init(chain) == -1 ) |
---|
| 48 | ret = -1; |
---|
| 49 | |
---|
| 50 | return ret; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | int roardsp_fchain_add (struct roardsp_filterchain * chain, struct roardsp_filter * filter) { |
---|
| 54 | if ( chain == NULL ) |
---|
| 55 | return -1; |
---|
| 56 | |
---|
| 57 | if ( chain->filters < ROARDSP_MAX_FILTERS_PER_CHAIN ) { |
---|
| 58 | chain->filter[chain->filters++] = filter; |
---|
| 59 | return 0; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | return -1; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | int roardsp_fchain_calc (struct roardsp_filterchain * chain, void * data, size_t len) { |
---|
| 66 | int i; |
---|
| 67 | int ret = 0; |
---|
| 68 | |
---|
| 69 | if ( chain == NULL ) |
---|
| 70 | return -1; |
---|
| 71 | |
---|
| 72 | for (i = 0; i < chain->filters; i++) { |
---|
| 73 | if ( roardsp_filter_calc(chain->filter[i], data, len) == -1 ) |
---|
| 74 | ret = -1; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | return ret; |
---|
| 78 | } |
---|
[661] | 79 | |
---|
[679] | 80 | int roardsp_fchain_num (struct roardsp_filterchain * chain) { |
---|
| 81 | if ( chain == NULL ) |
---|
| 82 | return -1; |
---|
| 83 | |
---|
| 84 | return chain->filters; |
---|
| 85 | } |
---|
| 86 | |
---|
[661] | 87 | //ll |
---|