Index: include/libroardsp/libroardsp.h
===================================================================
--- include/libroardsp/libroardsp.h	(revision 3004)
+++ include/libroardsp/libroardsp.h	(revision 3010)
@@ -181,4 +181,5 @@
 struct roardsp_agc {
  struct roardsp_filter * amp;
+ uint32_t target_amp;
 };
 
@@ -196,5 +197,5 @@
 char * roardsp_filter_id2str(int id);
 int    roardsp_filter_new   (struct roardsp_filter ** filter, struct roar_stream * stream, int id);
-#define roardsp_filter_free(x) roar_dsp_filter_uninit((x))
+#define roardsp_filter_free(x) roardsp_filter_uninit((x))
 int    roardsp_filter_init  (struct roardsp_filter *  filter, struct roar_stream * stream, int id);
 int    roardsp_filter_uninit(struct roardsp_filter *  filter);
@@ -263,4 +264,9 @@
 int roardsp_swap_reset  (struct roardsp_filter * filter, int what);
 
+int roardsp_agc_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
+int roardsp_agc_uninit (struct roardsp_filter * filter);
+int roardsp_agc_ctl    (struct roardsp_filter * filter, int cmd, void * data);
+int roardsp_agc_reset  (struct roardsp_filter * filter, int what);
+
 #ifdef _SPEEX_TYPES_H
 int roardsp_speex_prep_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
Index: libroardsp/Makefile
===================================================================
--- libroardsp/Makefile	(revision 2992)
+++ libroardsp/Makefile	(revision 3010)
@@ -7,5 +7,5 @@
 OBJS=libroardsp.o convert.o midside.o poly.o filter.o filterchain.o remove.o transcode.o vio_transcode.o rms.o fader.o mixer.o amp.o
 OLDROAR=midi.o
-FILTER=filter_lowp.o filter_highp.o filter_amp.o filter_quantify.o filter_add.o filter_clip.o filter_downmix.o filter_dcblock.o filter_swap.o filter_speex_prep.o
+FILTER=filter_lowp.o filter_highp.o filter_amp.o filter_quantify.o filter_add.o filter_clip.o filter_downmix.o filter_dcblock.o filter_swap.o filter_agc.o filter_speex_prep.o
 MIDI=synth.o
 CODECS=alaw.o mulaw.o
Index: libroardsp/filter.c
===================================================================
--- libroardsp/filter.c	(revision 3002)
+++ libroardsp/filter.c	(revision 3010)
@@ -54,4 +54,6 @@
  {ROARDSP_FILTER_SWAP, "Swap", roardsp_swap_init, roardsp_swap_uninit, roardsp_swap_ctl, roardsp_swap_reset, {
            {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, roardsp_swap_calc162},{NULL, NULL, NULL},{NULL, NULL, NULL}}},
+ {ROARDSP_FILTER_AGC, "AGC", roardsp_agc_init, roardsp_agc_uninit, roardsp_agc_ctl, roardsp_agc_reset, {
+           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}},
  {ROARDSP_FILTER_SPEEX_PREP, "SpeexPrep", roardsp_speex_prep_init, roardsp_speex_prep_uninit,
                                           roardsp_speex_prep_ctl,  roardsp_speex_prep_reset, {
Index: libroardsp/filter_agc.c
===================================================================
--- libroardsp/filter_agc.c	(revision 3010)
+++ libroardsp/filter_agc.c	(revision 3010)
@@ -0,0 +1,93 @@
+//filter_agc.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
+ *
+ *  This file is part of libroardsp a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  libroardsp is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "libroardsp.h"
+
+int roardsp_agc_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
+ struct roardsp_agc * self = roar_mm_malloc(sizeof(struct roardsp_agc));
+
+ if ( self == NULL )
+  return -1;
+
+ memset(self, 0, sizeof(struct roardsp_agc));
+
+ if ( roardsp_filter_new(&(self->amp), stream, ROARDSP_FILTER_AMP) == -1 ) {
+  roar_mm_free(self);
+  return -1;
+ }
+
+ filter->inst = (void*) self;
+
+ if ( roardsp_filter_reset(filter, ROARDSP_RESET_FULL) == -1 ) {
+  roardsp_agc_uninit(filter);
+  return -1;
+ }
+
+ return 0;
+}
+
+int roardsp_agc_uninit (struct roardsp_filter * filter) {
+ struct roardsp_agc * self = filter->inst;
+
+ roardsp_filter_free(self->amp);
+ roar_mm_free(self);
+ return 0;
+}
+
+int roardsp_agc_ctl    (struct roardsp_filter * filter, int cmd, void * data) {
+ struct roardsp_agc * self = filter->inst;
+
+ return -1;
+}
+
+int roardsp_agc_reset  (struct roardsp_filter * filter, int what) {
+ struct roardsp_agc * self = filter->inst;
+
+ switch (what) {
+  case ROARDSP_RESET_NONE:
+    return 0;
+   break;
+  case ROARDSP_RESET_FULL:
+    if ( filter->bits < 4 )
+     return -1;
+
+    self->target_amp = 1 << (filter->bits - 3);
+
+    if ( roardsp_filter_reset(self->amp, ROARDSP_RESET_FULL) == -1 )
+     return -1;
+
+    return -1;
+   break;
+  case ROARDSP_RESET_STATE:
+    if ( roardsp_filter_reset(self->amp, ROARDSP_RESET_STATE) == -1 )
+     return -1;
+    return -1;
+   break;
+  default: return -1;
+ }
+
+ return 0;
+}
+
+//ll
