source: roaraudio/libroardsp/filter.c @ 665:3fea6696e14b

Last change on this file since 665:3fea6696e14b was 665:3fea6696e14b, checked in by phi, 16 years ago

added roardsp_filter_str2id(), roardsp_filter_id2str() and added _roardsp_filterlist[]

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