File: graph_equalizer.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (163 lines) | stat: -rw-r--r-- 7,383 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2021 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-plugins-graph-equalizer
 * Created on: 3 авг. 2021 г.
 *
 * lsp-plugins-graph-equalizer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-plugins-graph-equalizer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-plugins-graph-equalizer. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef PRIVATE_PLUGINS_GRAPH_EQUALIZER_H_
#define PRIVATE_PLUGINS_GRAPH_EQUALIZER_H_

#include <lsp-plug.in/plug-fw/plug.h>
#include <lsp-plug.in/plug-fw/core/IDBuffer.h>
#include <lsp-plug.in/dsp-units/ctl/Bypass.h>
#include <lsp-plug.in/dsp-units/filters/Equalizer.h>
#include <lsp-plug.in/dsp-units/util/Analyzer.h>
#include <lsp-plug.in/dsp-units/util/Delay.h>

#include <private/meta/graph_equalizer.h>

namespace lsp
{
    namespace plugins
    {
        /**
         * Graphic Equalizer Plugin Series
         */
        class graph_equalizer: public plug::Module
        {
            public:
                enum eq_mode_t
                {
                    EQ_MONO,
                    EQ_STEREO,
                    EQ_LEFT_RIGHT,
                    EQ_MID_SIDE
                };

            protected:
                enum chart_state_t
                {
                    CS_UPDATE       = 1 << 0,
                    CS_SYNC_AMP     = 1 << 1
                };

                enum fft_position_t
                {
                    FFTP_NONE,
                    FFTP_POST,
                    FFTP_PRE
                };

                typedef struct eq_band_t
                {
                    bool                bSolo;          // Solo
                    size_t              nSync;          // Chart state
                    float              *vTrRe;          // Transfer function (real part)
                    float              *vTrIm;          // Transfer function (imaginary part)

                    plug::IPort        *pGain;          // Gain port
                    plug::IPort        *pSolo;          // Solo port
                    plug::IPort        *pMute;          // Mute port
                    plug::IPort        *pEnable;        // Enable port
                    plug::IPort        *pVisibility;    // Filter visibility
                } eq_band_t;

                typedef struct eq_channel_t
                {
                    dspu::Equalizer     sEqualizer;     // Equalizer
                    dspu::Bypass        sBypass;        // Bypass
                    dspu::Delay         sDryDelay;      // Dry delay

                    size_t              nSync;          // Chart state
                    float               fInGain;        // Input gain
                    float               fOutGain;       // Output gain
                    eq_band_t          *vBands;         // Bands
                    float              *vIn;            // Input buffer
                    float              *vOut;           // Output buffer
                    float              *vDryBuf;        // Dry buffer
                    float              *vBuffer;        // Temporary buffer

                    float              *vTrRe;          // Transfer function (real part)
                    float              *vTrIm;          // Transfer function (imaginary part)

                    plug::IPort        *pIn;            // Input port
                    plug::IPort        *pOut;           // Output port
                    plug::IPort        *pInGain;        // Input gain
                    plug::IPort        *pTrAmp;         // Amplitude chart
                    plug::IPort        *pFft;           // FFT chart
                    plug::IPort        *pVisible;       // Visibility flag
                    plug::IPort        *pInMeter;       // Output level meter
                    plug::IPort        *pOutMeter;      // Output level meter
                } eq_channel_t;

            protected:
                static const float band_frequencies[];

            protected:
                inline dspu::equalizer_mode_t   get_eq_mode();
                void                            dump_channel(dspu::IStateDumper *v, const eq_channel_t *c) const;
                static void                     dump_band(dspu::IStateDumper *v, const eq_band_t *b);

            protected:
                dspu::Analyzer      sAnalyzer;      // Analyzer
                eq_channel_t       *vChannels;      // Equalizer channels
                size_t              nBands;         // Number of bands
                size_t              nMode;          // Equalize mode
                size_t              nFftPosition;   // FFT analysis position
                size_t              nSlope;         // Slope
                bool                bListen;        // Listen
                bool                bMatched;       // Matched transorm/Bilinear transform flag
                float               fInGain;        // Input gain
                float               fZoom;          // Zoom gain
                float              *vFreqs;         // Frequency list
                uint32_t           *vIndexes;       // FFT indexes
                core::IDBuffer     *pIDisplay;      // Inline display buffer

                plug::IPort        *pEqMode;        // Equalizer mode
                plug::IPort        *pSlope;         // Filter slope
                plug::IPort        *pListen;        // Mid-Side listen
                plug::IPort        *pInGain;        // Input gain
                plug::IPort        *pOutGain;       // Output gain
                plug::IPort        *pBypass;        // Bypass
                plug::IPort        *pFftMode;       // FFT mode
                plug::IPort        *pReactivity;    // FFT reactivity
                plug::IPort        *pShiftGain;     // Shift gain
                plug::IPort        *pZoom;          // Graph zoom
                plug::IPort        *pBalance;       // Output balance

            public:
                explicit graph_equalizer(const meta::plugin_t *metadata, size_t bands, size_t mode);
                virtual ~graph_equalizer();

            public:
                virtual void        init(plug::IWrapper *wrapper, plug::IPort **ports);
                virtual void        destroy();

                virtual void        update_settings();
                virtual void        update_sample_rate(long sr);
                virtual void        ui_activated();

                virtual void        process(size_t samples);
                virtual bool        inline_display(plug::ICanvas *cv, size_t width, size_t height);

                virtual void        dump(dspu::IStateDumper *v) const;
        };
    } // namespace plugins
} // namespace lsp

#endif /* PRIVATE_PLUGINS_GRAPH_EQUALIZER_H_ */