Button: emit slopes (fix for stuck modulaor plug-ins)
[calf.git] / src / calf / modules_dist.h
blob3c97eaa071abd3c7e00c2e1c278511ff738b9443
1 /* Calf DSP plugin pack
2 * Distortion 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_DIST_H
22 #define CALF_MODULES_DIST_H
24 #include <assert.h>
25 #include <limits.h>
26 #include "biquad.h"
27 #include "bypass.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 * SATURATOR by Markus Schmidt
37 **********************************************************************/
39 class saturator_audio_module: public audio_module<saturator_metadata> {
40 private:
41 float hp_pre_freq_old, lp_pre_freq_old;
42 float hp_post_freq_old, lp_post_freq_old;
43 float p_level_old, p_freq_old, p_q_old;
44 float meter_drive;
45 dsp::biquad_d2 lp[2][4], hp[2][4];
46 dsp::biquad_d2 p[2];
47 dsp::tap_distortion dist[2];
48 dsp::bypass bypass;
49 vumeters meters;
50 public:
51 uint32_t srate;
52 bool is_active;
53 saturator_audio_module();
54 void activate();
55 void deactivate();
56 void params_changed();
57 void set_sample_rate(uint32_t sr);
58 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
61 /**********************************************************************
62 * EXCITER by Markus Schmidt
63 **********************************************************************/
65 class exciter_audio_module: public audio_module<exciter_metadata> {
66 private:
67 float freq_old, ceil_old;
68 bool ceil_active_old;
69 float meter_drive;
70 dsp::biquad_d2 hp[2][4];
71 dsp::biquad_d2 lp[2][2];
72 dsp::tap_distortion dist[2];
73 dsp::bypass bypass;
74 vumeters meters;
75 public:
76 uint32_t srate;
77 bool is_active;
78 exciter_audio_module();
79 void activate();
80 void deactivate();
81 void params_changed();
82 void set_sample_rate(uint32_t sr);
83 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
86 /**********************************************************************
87 * BASS ENHANCER by Markus Schmidt
88 **********************************************************************/
90 class bassenhancer_audio_module: public audio_module<bassenhancer_metadata> {
91 private:
92 float freq_old, floor_old;
93 bool floor_active_old;
94 float meter_drive;
95 dsp::biquad_d2 lp[2][4];
96 dsp::biquad_d2 hp[2][2];
97 dsp::tap_distortion dist[2];
98 dsp::bypass bypass;
99 vumeters meters;
100 public:
101 uint32_t srate;
102 bool is_active;
103 bassenhancer_audio_module();
104 void activate();
105 void deactivate();
106 void params_changed();
107 void set_sample_rate(uint32_t sr);
108 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
111 /**********************************************************************
112 * TAPESIMULATOR by Markus Schmidt
113 **********************************************************************/
115 class tapesimulator_audio_module:
116 public audio_module<tapesimulator_metadata>, public frequency_response_line_graph
118 typedef tapesimulator_audio_module AM;
119 bool active;
120 uint32_t clip_inL, clip_inR, clip_outL, clip_outR;
121 float meter_inL, meter_inR, meter_outL, meter_outR;
122 bool mech_old;
123 dsp::biquad_d2 lp[2][2];
124 dsp::biquad_d2 noisefilters[2][3];
125 dsp::transients transients;
126 dsp::bypass bypass;
127 const static int channels = 2;
128 dsp::simple_lfo lfo1, lfo2;
129 float lp_old;
130 mutable float rms, input;
131 public:
132 uint32_t srate;
133 tapesimulator_audio_module();
134 void params_changed();
135 void activate();
136 void set_sample_rate(uint32_t sr);
137 void deactivate();
138 float freq_gain(int index, double freq) const;
139 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
140 bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const;
141 bool get_dot(int index, int subindex, int phase, float &x, float &y, int &size, cairo_iface *context) const;
142 bool get_gridline(int index, int subindex, int phase, float &pos, bool &vertical, std::string &legend, cairo_iface *context) const;
143 bool get_layers(int index, int generation, unsigned int &layers) const;
146 /**********************************************************************
147 * CRUSHER by Markus Schmidt and Christian Holschuh
148 **********************************************************************/
150 class crusher_audio_module:
151 public audio_module<crusher_metadata>, public line_graph_iface
153 private:
154 vumeters meters;
155 dsp::bitreduction bitreduction;
156 dsp::samplereduction samplereduction[2];
157 dsp::simple_lfo lfo;
158 dsp::bypass bypass;
159 float smin, sdiff;
160 public:
161 uint32_t srate;
162 crusher_audio_module();
163 void set_sample_rate(uint32_t sr);
164 void activate();
165 void deactivate();
166 void params_changed();
167 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
168 bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const;
169 bool get_layers(int index, int generation, unsigned int &layers) const;
170 bool get_gridline(int index, int subindex, int phase, float &pos, bool &vertical, std::string &legend, cairo_iface *context) const;
175 #endif