不韋 呂 / F746_MySoundMachine

Dependencies:   F746_GUI F746_SAI_IO FrequencyResponseDrawer SD_PlayerSkeleton UIT_FFT_Real

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ReverbUnit.hpp Source File

ReverbUnit.hpp

00001 //--------------------------------------------------------------
00002 // Reverb unit: comb filter and all-pass filter
00003 //  2017/04/08, Copyright (c) 2017 MIKAMI, Naoki
00004 //--------------------------------------------------------------
00005 
00006 #ifndef REVERB_UNIT_HPP
00007 #define REVERB_UNIT_HPP
00008 
00009 #include "ReverbUnitBase.hpp"
00010 
00011 namespace Mikami
00012 {
00013     // Reverb unit using comb filter
00014     class CombFilter : public ReverbBase
00015     {
00016     public:
00017         // Constructor
00018         CombFilter(float g, int delay)
00019             : ReverbBase(delay), G_C_(g) {}
00020 
00021         // Execute comb filter with variable delay
00022         float Execute(float x, int n)
00023         {
00024             float yn = Get(n);
00025             Set(x + G_C_*yn);
00026             return yn;
00027          }
00028 
00029     private:
00030         const float G_C_;
00031 
00032         // disallow copy constructor and assignment operator
00033         CombFilter(const CombFilter&);
00034         CombFilter& operator=(const CombFilter&);
00035     };
00036 
00037     // Reverb unit using allpass filter
00038     class AllPassFilter : public ReverbBase
00039     {
00040     public:
00041         // Constructor
00042         AllPassFilter(float g, int delay)
00043             : ReverbBase(delay), G_A_(g) {}
00044 
00045         // Execute allpass filter 
00046         float Execute(float x)
00047         {
00048             float un = x + G_A_*Get();
00049             float yn = -G_A_*un + Get();
00050             Set(un);
00051             return yn;
00052         }
00053 
00054     private:
00055         const float G_A_;
00056 
00057         // disallow copy constructor and assignment operator
00058         AllPassFilter(const AllPassFilter&);
00059         AllPassFilter& operator=(const AllPassFilter&);
00060     };
00061 }
00062 #endif  // REVERB_UNIT_HPP