File: slap_delay.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 (143 lines) | stat: -rw-r--r-- 6,415 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
/*
 * 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-slap-delay
 * Created on: 3 авг. 2021 г.
 *
 * lsp-plugins-slap-delay 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-slap-delay 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-slap-delay. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef PRIVATE_PLUGINS_SLAP_DELAY_H_
#define PRIVATE_PLUGINS_SLAP_DELAY_H_

#include <lsp-plug.in/plug-fw/plug.h>
#include <lsp-plug.in/dsp-units/ctl/Bypass.h>
#include <lsp-plug.in/dsp-units/util/ShiftBuffer.h>
#include <lsp-plug.in/dsp-units/filters/Equalizer.h>

#include <private/meta/slap_delay.h>

namespace lsp
{
    namespace plugins
    {
        /**
         * Slap Delay Plugin series
         */
        class slap_delay: public plug::Module
        {
            protected:
                enum proc_mode_t
                {
                    M_OFF,
                    M_TIME,
                    M_DISTANCE
                };

                typedef struct mono_processor_t
                {
                    dspu::Equalizer         sEqualizer;

                    float                   fGain[2];   // Amount of gain for left and right input channels
                } mono_processor_t;

                typedef struct processor_t
                {
                    mono_processor_t        vDelay[2];

                    size_t                  nDelay;     // Delay
                    size_t                  nNewDelay;  // New delay
                    size_t                  nMode;      // Operating mode

                    plug::IPort            *pMode;      // Operating mode port
                    plug::IPort            *pEq;        // Equalizer
                    plug::IPort            *pTime;      // Delay in time units
                    plug::IPort            *pDistance;  // Delay in distance units
                    plug::IPort            *pFrac;      // Fraction
                    plug::IPort            *pDenom;     // Denominator
                    plug::IPort            *pPan[2];    // Pan of left and right input channels
                    plug::IPort            *pGain;      // Gain of the delay line
                    plug::IPort            *pLowCut;    // Low-cut flag
                    plug::IPort            *pLowFreq;   // Low-cut frequency
                    plug::IPort            *pHighCut;   // High-cut flag
                    plug::IPort            *pHighFreq;  // Low-cut frequency
                    plug::IPort            *pSolo;      // Solo control
                    plug::IPort            *pMute;      // Mute control
                    plug::IPort            *pPhase;     // Phase control
                    plug::IPort            *pFreqGain[meta::slap_delay_metadata::EQ_BANDS];      // Gain for each band of the Equalizer
                } processor_t;

                typedef struct channel_t
                {
                    dspu::Bypass            sBypass;    // Bypass
                    float                   fGain[2];   // Panning gain
                    float                  *vRender;    // Rendering buffer
                    float                  *vOut;       // Output buffer
                    plug::IPort            *pOut;       // Output port
                } channel_t;

                typedef struct input_t
                {
                    dspu::ShiftBuffer       sBuffer;    // Shift buffer of input data
                    float                  *vIn;        // Input data
                    plug::IPort            *pIn;        // Input port
                    plug::IPort            *pPan;       // Panning
                } input_t;

            protected:
                size_t              nInputs;        // Mono/Stereo mode flag
                input_t            *vInputs;        // Inputs

                processor_t         vProcessors[meta::slap_delay_metadata::MAX_PROCESSORS];    // Processors
                channel_t           vChannels[2];

                float              *vTemp;          // Temporary buffer for processing
                bool                bMono;          // Mono output flag

                plug::IPort        *pBypass;        // Bypass
                plug::IPort        *pTemp;          // Temperature
                plug::IPort        *pDry;           // Dry signal amount
                plug::IPort        *pWet;           // Wet signal amount
                plug::IPort        *pDryMute;       // Dry mute
                plug::IPort        *pWetMute;       // Wet mute
                plug::IPort        *pOutGain;       // Output gain
                plug::IPort        *pMono;          // Mono output
                plug::IPort        *pPred;          // Pre-delay
                plug::IPort        *pStretch;       // Time stretch
                plug::IPort        *pTempo;         // Tempo
                plug::IPort        *pSync;          // Sync tempo
                plug::IPort        *pRamping;       // Ramping mode

                uint8_t            *vData;          // Allocated data

            public:
                slap_delay(const meta::plugin_t *metadata);
                virtual ~slap_delay();

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

                virtual bool        set_position(const plug::position_t *pos);
                virtual void        update_settings();
                virtual void        update_sample_rate(long sr);

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

#endif /* PRIVATE_PLUGINS_SLAP_DELAY_H_ */