41 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
42 |
|
|
43 |
/** |
/** |
44 |
* This is a filter similar to the ones from Gigasampler. |
* These are filters similar to the ones from Gigasampler. |
45 |
*/ |
*/ |
46 |
class Filter { |
class Filter { |
47 |
protected: |
protected: |
105 |
this->cutoff = cutoff; |
this->cutoff = cutoff; |
106 |
} |
} |
107 |
|
|
108 |
|
inline void SetParameters(biquad_param_t* base, biquad_param_t* main, bq_t cutoff, bq_t resonance, bq_t fs) { |
109 |
|
BasicBPFilter.SetParameters(base, cutoff, 0.7, fs); |
110 |
|
switch (Type) { |
111 |
|
case ::gig::vcf_type_highpass: |
112 |
|
HPFilter.SetParameters(main, cutoff, 1.0 - resonance * LSF_BW, fs); |
113 |
|
break; |
114 |
|
case ::gig::vcf_type_bandpass: |
115 |
|
BPFilter.SetParameters(main, cutoff, 1.0 - resonance * LSF_BW, fs); |
116 |
|
break; |
117 |
|
case ::gig::vcf_type_lowpass: |
118 |
|
LPFilter.SetParameters(main, cutoff, 1.0 - resonance * LSF_BW, fs); |
119 |
|
break; |
120 |
|
} |
121 |
|
this->scale = 1.0f - resonance * 0.7f; |
122 |
|
this->resonance = resonance; |
123 |
|
this->cutoff = cutoff; |
124 |
|
} |
125 |
|
|
126 |
inline bq_t Apply(const bq_t in) { |
inline bq_t Apply(const bq_t in) { |
127 |
return (Enabled) ? pFilter->Apply(in) * this->scale + |
return (Enabled) ? pFilter->Apply(in) * this->scale + |
128 |
BasicBPFilter.ApplyFB(in, this->resonance * LSF_FB) * this->resonance |
BasicBPFilter.ApplyFB(in, this->resonance * LSF_FB) * this->resonance |
129 |
: in; |
: in; |
130 |
} |
} |
131 |
|
|
132 |
|
inline bq_t Apply(biquad_param_t* base, biquad_param_t* main, const bq_t in) { |
133 |
|
return (Enabled) ? pFilter->Apply(main, in) * this->scale + |
134 |
|
BasicBPFilter.ApplyFB(base, in, this->resonance * LSF_FB) * this->resonance |
135 |
|
: in; |
136 |
|
} |
137 |
}; |
}; |
138 |
|
|
139 |
}} //namespace LinuxSampler::gig |
}} //namespace LinuxSampler::gig |