Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

echofilter_generic.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: echofilter_generic.cpp,v 1.1 2001/03/06 15:09:26 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #ifdef WIN32
00016 #pragma warning (disable:4786)
00017 #endif
00018 
00019 #include "echofilter_generic.h"
00020 #include <memory.h>
00021 
00022 CL_EchoFilter::CL_EchoFilter(int buffer_size, int shift_factor)
00023 {
00024         impl = new CL_EchoFilter_Generic;
00025         impl->buffer_size = buffer_size;
00026         impl->shift_factor = shift_factor;
00027         impl->pos = 0;
00028 
00029         impl->buffer = new int[buffer_size*2];
00030         memset(impl->buffer, 0, sizeof(int)*buffer_size*2);
00031 }
00032 
00033 CL_EchoFilter::~CL_EchoFilter()
00034 {
00035         delete[] impl->buffer;
00036         delete impl;
00037 }
00038 
00039 void CL_EchoFilter::filter(int *data, int size)
00040 {
00041         int *buffer = impl->buffer;
00042         int &pos = impl->pos;
00043         int &buffer_size = impl->buffer_size;
00044         int &shift_factor = impl->shift_factor;
00045 
00046         for (int i=0; i<size*2; i++)
00047         {
00048                 buffer[pos] /= shift_factor;
00049                 buffer[pos] += data[i];
00050                 data[i] = buffer[pos];
00051                 pos++;
00052                 if (pos == buffer_size) pos = 0;
00053         }
00054 }

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001