LMMS
Loading...
Searching...
No Matches
EqEffect.h
Go to the documentation of this file.
1/* eqeffect.h - defination of EqEffect class.
2*
3* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
4*
5* This file is part of LMMS - https://lmms.io
6*
7* This program is free software; you can redistribute it and/or
8* modify it under the terms of the GNU General Public
9* License as published by the Free Software Foundation; either
10* version 2 of the License, or (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this program (see COPYING); if not, write to the
19* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20* Boston, MA 02110-1301 USA.
21*
22*/
23
24#ifndef EQEFFECT_H
25#define EQEFFECT_H
26
27#include "Effect.h"
28#include "EqControls.h"
29#include "EqFilter.h"
30
31#include <algorithm>
32
33
34namespace lmms
35{
36
37
38class EqEffect : public Effect
39{
40public:
41 EqEffect( Model * parent , const Descriptor::SubPluginFeatures::Key * key );
42 ~EqEffect() override = default;
43
44 ProcessStatus processImpl(SampleFrame* buf, const f_cnt_t frames) override;
45
47 {
48 return &m_eqControls;
49 }
50 inline void gain( SampleFrame* buf, const f_cnt_t frames, float scale, SampleFrame* peak )
51 {
52 peak[0][0] = 0.0f; peak[0][1] = 0.0f;
53 for( f_cnt_t f = 0; f < frames; ++f )
54 {
55 auto & sf = buf[f];
56
57 // Apply gain to sample frame
58 sf[0] *= scale;
59 sf[1] *= scale;
60
61 // Update peaks
62 peak[0][0] = std::max(peak[0][0], (float)fabs(sf[0]));
63 peak[0][1] = std::max(peak[0][1], (float)fabs(sf[1]));
64 }
65 }
66
67private:
69
74
76
81
83
88
89 float m_inGain;
90 float m_outGain;
91
92 float linearPeakBand(float minF, float maxF, EqAnalyser*, int);
93
94 inline float bandToFreq ( int index , int sampleRate )
95 {
96 return index * sampleRate / ( MAX_BANDS * 2 );
97 }
98
99 void setBandPeaks( EqAnalyser * fft , int );
100};
101
102
103} // namespace lmms
104
105#endif // EQEFFECT_H
Definition EffectControls.h:44
Effect(const Plugin::Descriptor *_desc, Model *_parent, const Descriptor::SubPluginFeatures::Key *_key)
Definition Effect.cpp:41
ProcessStatus
Definition Effect.h:147
Definition EqSpectrumView.h:39
Definition EqControls.h:43
EqLp12Filter m_lp12
Definition EqEffect.h:84
float bandToFreq(int index, int sampleRate)
Definition EqEffect.h:94
float m_inGain
Definition EqEffect.h:89
EqHighShelfFilter m_highShelf
Definition EqEffect.h:82
EqEffect(Model *parent, const Descriptor::SubPluginFeatures::Key *key)
Definition EqEffect.cpp:56
EqHp12Filter m_hp481
Definition EqEffect.h:73
float m_outGain
Definition EqEffect.h:90
EqHp12Filter m_hp24
Definition EqEffect.h:71
EqLowShelfFilter m_lowShelf
Definition EqEffect.h:75
ProcessStatus processImpl(SampleFrame *buf, const f_cnt_t frames) override
Definition EqEffect.cpp:67
float linearPeakBand(float minF, float maxF, EqAnalyser *, int)
Definition EqEffect.cpp:282
EqPeakFilter m_para4
Definition EqEffect.h:80
EqPeakFilter m_para3
Definition EqEffect.h:79
EqLp12Filter m_lp480
Definition EqEffect.h:86
EqLp12Filter m_lp481
Definition EqEffect.h:87
EqLp12Filter m_lp24
Definition EqEffect.h:85
EqHp12Filter m_hp12
Definition EqEffect.h:70
void gain(SampleFrame *buf, const f_cnt_t frames, float scale, SampleFrame *peak)
Definition EqEffect.h:50
~EqEffect() override=default
EqPeakFilter m_para1
Definition EqEffect.h:77
EqControls m_eqControls
Definition EqEffect.h:68
EffectControls * controls() override
Definition EqEffect.h:46
void setBandPeaks(EqAnalyser *fft, int)
Definition EqEffect.cpp:304
EqHp12Filter m_hp480
Definition EqEffect.h:72
EqPeakFilter m_para2
Definition EqEffect.h:78
Definition EqFilter.h:368
The EqHp12Filter class A 2 pole High Pass Filter Coefficent calculations from http://www....
Definition EqFilter.h:183
Definition EqFilter.h:331
The EqLp12Filter class. A 2 pole low pass filter Coefficent calculations from http://www....
Definition EqFilter.h:226
The EqPeakFilter class A Peak Filter Coefficent calculations from http://www.musicdsp....
Definition EqFilter.h:266
Definition Model.h:37
const Descriptor::SubPluginFeatures::Key & key() const
Definition Plugin.h:266
Definition SampleFrame.h:41
unsigned f
Definition inflate.c:1572
static uintptr_t parent
Definition pugl.h:1644
Definition AudioAlsa.cpp:35
const int MAX_BANDS
Definition EqSpectrumView.h:37
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43