source: roaraudio/libroardsp/filter.c @ 667:118ff4887f7e

Last change on this file since 667:118ff4887f7e was 667:118ff4887f7e, checked in by phi, 16 years ago

added dummy entrys to filter list

File size: 2.9 KB
Line 
1//filter.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
27struct _roardsp_filterlist {
28 int id;
29 char * name;
30 int (*  init      )(struct roardsp_filter * filter, struct roar_stream * stream, int id);
31 int (*uninit      )(struct roardsp_filter * filter);
32 int (*calc  [5][3])(struct roardsp_filter * filter, void * data, size_t samples);
33} _roardsp_filterlist[] = {
34 {ROARDSP_FILTER_AMP, "AMP", NULL, NULL, {
35           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}},
36 {ROARDSP_FILTER_LOWP, "Lowpass", NULL, NULL, {
37           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}},
38 {ROARDSP_FILTER_HIGHP, "Highpass", NULL, NULL, {
39           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}},
40 {-1, NULL, NULL, NULL, {{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}
41};
42
43int    roardsp_filter_str2id(char * str) {
44 struct _roardsp_filterlist * l = _roardsp_filterlist;
45
46 while ( l->id != -1 ) {
47  if ( strcasecmp(l->name, str) == 0 )
48   return l->id;
49 }
50
51 return -1;
52}
53
54char * roardsp_filter_id2str(int id) {
55 struct _roardsp_filterlist * l = _roardsp_filterlist;
56
57 while ( l->id != -1 ) {
58  if ( l->id == id )
59   return l->name;
60 }
61
62 return NULL;
63}
64
65int roardsp_filter_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
66 if ( filter == NULL )
67  return -1;
68
69 memset(filter, 0, sizeof(struct roardsp_filter));
70
71 filter->channels = stream->info.channels;
72 filter->bits     = stream->info.bits;
73
74 return -1;
75}
76
77int roardsp_filter_uninit(struct roardsp_filter * filter) {
78 int ret = 0;
79
80 if ( filter == NULL )
81  return -1;
82
83 if ( filter->uninit )
84  ret = filter->uninit(filter);
85
86 memset(filter, 0, sizeof(struct roardsp_filter));
87
88 return ret;
89}
90
91int roardsp_filter_calc  (struct roardsp_filter * filter, void * data, size_t len) {
92 int ret = 0;
93
94 if ( filter == NULL )
95  return -1;
96
97 if ( filter->calc )
98  ret = filter->calc(filter, data, len);
99
100 return ret;
101}
102
103//ll
Note: See TracBrowser for help on using the repository browser.