source: roaraudio/libroardsp/filterchain.c @ 4708:c9d40761088a

Last change on this file since 4708:c9d40761088a was 4708:c9d40761088a, checked in by phi, 13 years ago

updated copyright statements

File size: 2.6 KB
Line 
1//filterchain.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "libroardsp.h"
27
28int roardsp_fchain_init  (struct roardsp_filterchain * chain) {
29 if ( chain == NULL )
30  return -1;
31
32 memset((void*)chain, 0, sizeof(struct roardsp_filterchain));
33 return 0;
34}
35
36int roardsp_fchain_uninit(struct roardsp_filterchain * chain) {
37 int i;
38 int ret = 0;
39
40 if ( chain == NULL )
41  return -1;
42
43 for (i = 0; i < chain->filters; i++) {
44  if ( roardsp_filter_uninit(chain->filter[i]) == -1 )
45   ret = -1;
46 }
47
48 if ( roardsp_fchain_init(chain) == -1 )
49  ret = -1;
50
51 return ret;
52}
53
54int roardsp_fchain_add   (struct roardsp_filterchain * chain, struct roardsp_filter * filter) {
55 if ( chain == NULL )
56  return -1;
57
58 if ( chain->filters < ROARDSP_MAX_FILTERS_PER_CHAIN ) {
59  chain->filter[chain->filters++] = filter;
60  return 0;
61 }
62
63 return -1;
64}
65
66int roardsp_fchain_calc  (struct roardsp_filterchain * chain, void * data, size_t len) {
67 int i;
68 int ret = 0;
69
70 if ( chain == NULL )
71  return -1;
72
73 for (i = 0; i < chain->filters; i++) {
74  if ( roardsp_filter_calc(chain->filter[i], data, len) == -1 )
75   ret = -1;
76 }
77
78 return ret;
79}
80
81int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what) {
82 int i;
83 int ret = 0;
84/*
85 struct roardsp_filterchain backup[1];
86*/
87
88 if ( chain == NULL )
89  return -1;
90
91/*
92 if ( what == ROARDSP_RESET_FULL ) {
93  if ( roardsp_fchain_init(backup) == -1 )
94   return -1;
95
96  if ( roardsp_fchain_uninit(chain) == -1 )
97   return -1;
98
99  if ( roardsp_fchain_init(chain) == -1 )
100   return -1;
101 } else {
102*/
103  for (i = 0; i < chain->filters; i++) {
104   if ( roardsp_filter_reset(chain->filter[i], what) == -1 )
105    ret = -1;
106  }
107/*
108 }
109*/
110
111 return ret;
112}
113
114int roardsp_fchain_num   (struct roardsp_filterchain * chain) {
115 if ( chain == NULL )
116  return -1;
117
118 return chain->filters;
119}
120
121//ll
Note: See TracBrowser for help on using the repository browser.