DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/mt32/freeverb/allpass.h
00001 // Allpass filter declaration
00002 //
00003 // Written by Jezar at Dreampoint, June 2000
00004 // http://www.dreampoint.co.uk
00005 // This code is public domain
00006 
00007 #ifndef _allpass_
00008 #define _allpass_
00009 #include "denormals.h"
00010 #include "../FileStream.h"
00011 
00012 class allpass
00013 {
00014 public:
00015                         allpass();
00016                 void    setbuffer(float *buf, int size);
00017                 void    deletebuffer();
00018         inline  float   process(float input);
00019                 void    mute();
00020                 void    setfeedback(float val);
00021                 float   getfeedback();
00022 
00023                                         void            saveState( std::ostream &stream );
00024                                         void            loadState( std::istream &stream );
00025 
00026 // private:
00027         float   feedback;
00028         float   *buffer;
00029         int     bufsize;
00030         int     bufidx;
00031 };
00032 
00033 
00034 // Big to inline - but crucial for speed
00035 
00036 inline float allpass::process(float input)
00037 {
00038         float output;
00039         float bufout;
00040 
00041         bufout = undenormalise(buffer[bufidx]);
00042 
00043         output = -input + bufout;
00044         buffer[bufidx] = input + (bufout*feedback);
00045 
00046         if (++bufidx>=bufsize) bufidx = 0;
00047 
00048         return output;
00049 }
00050 
00051 #endif//_allpass