source: roaraudio/libroardsp/filter_agc.c @ 3790:1ba31162e041

Last change on this file since 3790:1ba31162e041 was 3790:1ba31162e041, checked in by phi, 14 years ago

fixed copyright

File size: 2.3 KB
Line 
1//filter_agc.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010
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_agc_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
29 struct roardsp_agc * self = roar_mm_malloc(sizeof(struct roardsp_agc));
30
31 if ( self == NULL )
32  return -1;
33
34 memset(self, 0, sizeof(struct roardsp_agc));
35
36 if ( roardsp_filter_new(&(self->amp), stream, ROARDSP_FILTER_AMP) == -1 ) {
37  roar_mm_free(self);
38  return -1;
39 }
40
41 filter->inst = (void*) self;
42
43 if ( roardsp_filter_reset(filter, ROARDSP_RESET_FULL) == -1 ) {
44  roardsp_agc_uninit(filter);
45  return -1;
46 }
47
48 return 0;
49}
50
51int roardsp_agc_uninit (struct roardsp_filter * filter) {
52 struct roardsp_agc * self = filter->inst;
53
54 roardsp_filter_free(self->amp);
55 roar_mm_free(self);
56 return 0;
57}
58
59int roardsp_agc_ctl    (struct roardsp_filter * filter, int cmd, void * data) {
60 struct roardsp_agc * self = filter->inst;
61
62 return -1;
63}
64
65int roardsp_agc_reset  (struct roardsp_filter * filter, int what) {
66 struct roardsp_agc * self = filter->inst;
67
68 switch (what) {
69  case ROARDSP_RESET_NONE:
70    return 0;
71   break;
72  case ROARDSP_RESET_FULL:
73    if ( filter->bits < 4 )
74     return -1;
75
76    self->target_amp = 1 << (filter->bits - 3);
77
78    if ( roardsp_filter_reset(self->amp, ROARDSP_RESET_FULL) == -1 )
79     return -1;
80
81    return -1;
82   break;
83  case ROARDSP_RESET_STATE:
84    if ( roardsp_filter_reset(self->amp, ROARDSP_RESET_STATE) == -1 )
85     return -1;
86    return -1;
87   break;
88  default: return -1;
89 }
90
91 return 0;
92}
93
94//ll
Note: See TracBrowser for help on using the repository browser.