This is a part of the Kinetiszer project.

Dependents:   SoundEngine

Committer:
Clemo
Date:
Tue Oct 28 12:19:22 2014 +0000
Revision:
0:5a419ba2726d
Error & warning free (I believe as I don't know how to clean).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:5a419ba2726d 1 /*
Clemo 0:5a419ba2726d 2 Copyright 2013 Paul Soulsby www.soulsbysynths.com
Clemo 0:5a419ba2726d 3 This file is part of Atmegatron.
Clemo 0:5a419ba2726d 4
Clemo 0:5a419ba2726d 5 Atmegatron is free software: you can redistribute it and/or modify
Clemo 0:5a419ba2726d 6 it under the terms of the GNU General Public License as published by
Clemo 0:5a419ba2726d 7 the Free Software Foundation, either version 3 of the License, or
Clemo 0:5a419ba2726d 8 (at your option) any later version.
Clemo 0:5a419ba2726d 9
Clemo 0:5a419ba2726d 10 Atmegatron is distributed in the hope that it will be useful,
Clemo 0:5a419ba2726d 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
Clemo 0:5a419ba2726d 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Clemo 0:5a419ba2726d 13 GNU General Public License for more details.
Clemo 0:5a419ba2726d 14
Clemo 0:5a419ba2726d 15 You should have received a copy of the GNU General Public License
Clemo 0:5a419ba2726d 16 along with Atmegatron. If not, see <http://www.gnu.org/licenses/>.
Clemo 0:5a419ba2726d 17 */
Clemo 0:5a419ba2726d 18
Clemo 0:5a419ba2726d 19 //***15 Biquad filter algorithms***
Clemo 0:5a419ba2726d 20
Clemo 0:5a419ba2726d 21 #ifndef __FILTER_H__
Clemo 0:5a419ba2726d 22 #define __FILTER_H__
Clemo 0:5a419ba2726d 23
Clemo 0:5a419ba2726d 24
Clemo 0:5a419ba2726d 25 //the filter types
Clemo 0:5a419ba2726d 26 #define FILT_OFF 0
Clemo 0:5a419ba2726d 27 #define FILT_LPF 1
Clemo 0:5a419ba2726d 28 #define FILT_HPF 2
Clemo 0:5a419ba2726d 29 #define FILT_BPF 3
Clemo 0:5a419ba2726d 30 #define FILT_NOTCH 4
Clemo 0:5a419ba2726d 31 #define FILT_PEAK10 5
Clemo 0:5a419ba2726d 32 #define FILT_PEAK30 6
Clemo 0:5a419ba2726d 33 #define FILT_PEAK100 7
Clemo 0:5a419ba2726d 34 #define FILT_LS10 8
Clemo 0:5a419ba2726d 35 #define FILT_LS30 9
Clemo 0:5a419ba2726d 36 #define FILT_HS10 10
Clemo 0:5a419ba2726d 37 #define FILT_HS30 11
Clemo 0:5a419ba2726d 38 #define FILT_BUTLPF 12
Clemo 0:5a419ba2726d 39 #define FILT_BUTHPF 13
Clemo 0:5a419ba2726d 40 #define FILT_BESLPF 14
Clemo 0:5a419ba2726d 41 #define FILT_BESHPF 15
Clemo 0:5a419ba2726d 42
Clemo 0:5a419ba2726d 43 //These constants are used to define the MAXIMUM amount the env and lfo can effect the filter cutoff.
Clemo 0:5a419ba2726d 44 //The default max (for both env and lfo) is:
Clemo 0:5a419ba2726d 45 //********multiplier = 4***********
Clemo 0:5a419ba2726d 46 #define FILT_MAX 1.386294361119891f //ln(multiplier)
Clemo 0:5a419ba2726d 47 #define FILT_MULT 64 //multipler used for calculating lookup table (256 / multiplier)
Clemo 0:5a419ba2726d 48 #define FILT_BS 6UL //bitshift amount when multiplying fc by filt lfo amt. log2(FILT_MULT)
Clemo 0:5a419ba2726d 49
Clemo 0:5a419ba2726d 50 #define SQRT2 1.414213562373095f //squareroot 2 - useful!
Clemo 0:5a419ba2726d 51 #define PI 3.141592653589793f
Clemo 0:5a419ba2726d 52
Clemo 0:5a419ba2726d 53 #define MINQ 0.5f //minimum value of Q (default = 0.5)
Clemo 0:5a419ba2726d 54 #define MULTQ 0.076470588235294f //multiplier to convert from filt_q(0-255) to real Q (0.5-20) = (20 - 0.5)/255;
Clemo 0:5a419ba2726d 55
Clemo 0:5a419ba2726d 56 #define abs(a) (a)>=0? (a) : -(a)
Clemo 0:5a419ba2726d 57
Clemo 0:5a419ba2726d 58
Clemo 0:5a419ba2726d 59 void Filt_Let_Fc(byte newfc);
Clemo 0:5a419ba2726d 60 byte Filt_Get_Fc(void);
Clemo 0:5a419ba2726d 61 void Filt_Let_Q(byte newq);
Clemo 0:5a419ba2726d 62 byte Filt_Get_Q(void);
Clemo 0:5a419ba2726d 63 void Filt_Let_Type(byte newtype);
Clemo 0:5a419ba2726d 64 byte Filt_Get_Type(void);
Clemo 0:5a419ba2726d 65 void Filt_Let_GainAdj(boolean newadj);
Clemo 0:5a419ba2726d 66 boolean Filt_Get_GainAdj(void);
Clemo 0:5a419ba2726d 67 void Filt_CalcVals(void);
Clemo 0:5a419ba2726d 68 void LPValCalculator(void);
Clemo 0:5a419ba2726d 69 void HPValCalculator(void);
Clemo 0:5a419ba2726d 70 void BPSkirtValCalculator(void);
Clemo 0:5a419ba2726d 71 void NotchValCalculator(void);
Clemo 0:5a419ba2726d 72 void PeakingEQValCalculator(void);
Clemo 0:5a419ba2726d 73 void LowShelfValCalculator(void);
Clemo 0:5a419ba2726d 74 void HighShelfValCalculator(void);
Clemo 0:5a419ba2726d 75 void ButterworthLPCalculator(void);
Clemo 0:5a419ba2726d 76 void ButterworthHPCalculator(void);
Clemo 0:5a419ba2726d 77 void BesselLPCalculator(void);
Clemo 0:5a419ba2726d 78 void BesselHPCalculator(void);
Clemo 0:5a419ba2726d 79 void Filt_Process(void);
Clemo 0:5a419ba2726d 80 float Biquad_process(float bi0);
Clemo 0:5a419ba2726d 81 void Filt_Let_LFOAmt(byte newamt);
Clemo 0:5a419ba2726d 82 byte Filt_Get_LFOAmt(void);
Clemo 0:5a419ba2726d 83 byte Filt_Get_LFOGain(void);
Clemo 0:5a419ba2726d 84 void Filt_Let_FenvAmt(byte newamt);
Clemo 0:5a419ba2726d 85 byte Filt_Get_FenvAmt(void);
Clemo 0:5a419ba2726d 86 byte Filt_Get_FenvGain(void);
Clemo 0:5a419ba2726d 87
Clemo 0:5a419ba2726d 88
Clemo 0:5a419ba2726d 89 #endif // __FILTER_H__