DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
src/mt32/freeverb/allpass.cpp
00001 // Allpass filter implementation
00002 //
00003 // Written by Jezar at Dreampoint, June 2000
00004 // http://www.dreampoint.co.uk
00005 // This code is public domain
00006 
00007 #include "allpass.h"
00008 
00009 allpass::allpass()
00010 {
00011         bufidx = 0;
00012 }
00013 
00014 void allpass::setbuffer(float *buf, int size)
00015 {
00016         buffer = buf;
00017         bufsize = size;
00018 }
00019 
00020 void allpass::mute()
00021 {
00022         for (int i=0; i<bufsize; i++)
00023                 buffer[i]=0;
00024 }
00025 
00026 void allpass::setfeedback(float val)
00027 {
00028         feedback = val;
00029 }
00030 
00031 float allpass::getfeedback()
00032 {
00033         return feedback;
00034 }
00035 
00036 void allpass::deletebuffer()
00037 {
00038         delete[] buffer;
00039         buffer = 0;
00040 }
00041 
00042 
00043 void allpass::saveState( std::ostream &stream )
00044 {
00045         stream.write(reinterpret_cast<const char*>(&feedback), sizeof(feedback) );
00046         stream.write(reinterpret_cast<const char*>(buffer), (std::streamsize)((size_t)bufsize * sizeof(float)) );
00047         stream.write(reinterpret_cast<const char*>(&bufsize), sizeof(bufsize) );
00048         stream.write(reinterpret_cast<const char*>(&bufidx), sizeof(bufidx) );
00049 }
00050 
00051 
00052 void allpass::loadState( std::istream &stream )
00053 {
00054         stream.read(reinterpret_cast<char*>(&feedback), sizeof(feedback) );
00055         stream.read(reinterpret_cast<char*>(buffer), (std::streamsize)((size_t)bufsize * sizeof(float)) );
00056         stream.read(reinterpret_cast<char*>(&bufsize), sizeof(bufsize) );
00057         stream.read(reinterpret_cast<char*>(&bufidx), sizeof(bufidx) );
00058 }