Ring Modulator: Initial rudimentary implementation
[calf.git] / src / calf / modules_limit.h
blobd67e85d1947aca4be0ee14e1e6e2f1e06ae8f051
1 /* Calf DSP plugin pack
2 * Limiter related plugins
4 * Copyright (C) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen and others
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02111-1307, USA.
21 #ifndef CALF_MODULES_LIMIT_H
22 #define CALF_MODULES_LIMIT_H
24 #include <assert.h>
25 #include <limits.h>
26 #include "biquad.h"
27 #include "inertia.h"
28 #include "audio_fx.h"
29 #include "giface.h"
30 #include "metadata.h"
31 #include "plugin_tools.h"
33 namespace calf_plugins {
35 /**********************************************************************
36 * LIMITER by Christian Holschuh and Markus Schmidt
37 **********************************************************************/
39 class limiter_audio_module: public audio_module<limiter_metadata>, public line_graph_iface {
40 private:
41 typedef limiter_audio_module AM;
42 uint32_t asc_led;
43 int mode, mode_old, oversampling_old;
44 dsp::lookahead_limiter limiter;
45 dsp::resampleN resampler[2];
46 vumeters meters;
47 public:
48 uint32_t srate;
49 bool is_active;
50 float limit_old;
51 bool asc_old;
52 float attack_old;
53 limiter_audio_module();
54 void activate();
55 void deactivate();
56 void params_changed();
57 void set_srates();
58 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
59 void set_sample_rate(uint32_t sr);
62 /**********************************************************************
63 * MULTIBAND LIMITER by Markus Schmidt and Christian Holschuh
64 **********************************************************************/
66 class multibandlimiter_audio_module: public audio_module<multibandlimiter_metadata>, public frequency_response_line_graph {
67 private:
68 typedef multibandlimiter_audio_module AM;
69 static const int strips = 4;
70 uint32_t asc_led, cnt;
71 int _mode, mode_old;
72 bool solo[strips];
73 bool no_solo;
74 dsp::lookahead_limiter strip[strips];
75 dsp::lookahead_limiter broadband;
76 dsp::resampleN resampler[strips][2];
77 dsp::crossover crossover;
78 float over;
79 unsigned int pos;
80 unsigned int buffer_size;
81 unsigned int overall_buffer_size;
82 float *buffer;
83 int channels;
84 float striprel[strips];
85 float weight[strips];
86 float weight_old[strips];
87 float limit_old;
88 bool asc_old;
89 float attack_old;
90 float oversampling_old;
91 bool _sanitize;
92 vumeters meters;
93 public:
94 uint32_t srate;
95 bool is_active;
96 multibandlimiter_audio_module();
97 ~multibandlimiter_audio_module();
98 void activate();
99 void deactivate();
100 void params_changed();
101 void set_srates();
102 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
103 void set_sample_rate(uint32_t sr);
104 bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const;
105 bool get_layers(int index, int generation, unsigned int &layers) const;
110 #endif