1 /* Calf DSP plugin pack
2 * Modulation effect 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_MOD_H
22 #define CALF_MODULES_MOD_H
31 #include "multichorus.h"
32 #include "plugin_tools.h"
35 namespace calf_plugins
{
37 /**********************************************************************
38 * FLANGER by Krzysztof Foltman
39 **********************************************************************/
41 class flanger_audio_module
: public audio_module
<flanger_metadata
>, public frequency_response_line_graph
44 dsp::simple_flanger
<float, 2048> left
, right
;
50 flanger_audio_module() {
53 void set_sample_rate(uint32_t sr
);
54 void params_changed();
58 uint32_t process(uint32_t offset
, uint32_t nsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
) {
59 left
.process(outs
[0] + offset
, ins
[0] + offset
, nsamples
);
60 right
.process(outs
[1] + offset
, ins
[1] + offset
, nsamples
);
61 return outputs_mask
; // XXXKF allow some delay after input going blank
63 bool get_layers(int index
, int generation
, unsigned int &layers
) const;
64 float freq_gain(int subindex
, float freq
) const;
65 bool get_gridline(int index
, int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
66 bool get_graph(int index
, int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
69 /**********************************************************************
70 * PHASER by Krzysztof Foltman
71 **********************************************************************/
73 class phaser_audio_module
: public audio_module
<phaser_metadata
>, public frequency_response_line_graph
76 enum { MaxStages
= 12 };
80 dsp::simple_phaser left
, right
;
81 float x1vals
[2][MaxStages
], y1vals
[2][MaxStages
];
84 phaser_audio_module();
85 void params_changed();
88 void set_sample_rate(uint32_t sr
);
90 uint32_t process(uint32_t offset
, uint32_t nsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
) {
91 left
.process(outs
[0] + offset
, ins
[0] + offset
, nsamples
);
92 right
.process(outs
[1] + offset
, ins
[1] + offset
, nsamples
);
93 return outputs_mask
; // XXXKF allow some delay after input going blank
95 bool get_layers(int index
, int generation
, unsigned int &layers
) const;
96 float freq_gain(int subindex
, float freq
) const;
97 bool get_gridline(int index
, int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
98 bool get_graph(int index
, int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
101 /**********************************************************************
102 * ROTARY SPEAKER by Krzysztof Foltman
103 **********************************************************************/
105 class rotary_speaker_audio_module
: public audio_module
<rotary_speaker_metadata
>
108 /// Current phases and phase deltas for bass and treble rotors
109 uint32_t phase_l
, dphase_l
, phase_h
, dphase_h
;
110 dsp::simple_delay
<1024, float> delay
;
111 dsp::biquad_d2 crossover1l
, crossover1r
, crossover2l
, crossover2r
, damper1l
, damper1r
;
112 dsp::simple_delay
<8, float> phaseshift
;
115 /// Current CC1 (Modulation) value, normalized to [0, 1]
117 /// Current CC64 (Hold) value, normalized to [0, 1]
119 /// Current rotation speed for bass rotor - automatic mode
121 /// Current rotation speed for treble rotor - automatic mode
123 /// Desired speed (0=slow, 1=fast) - automatic mode
125 /// Current rotation speed for bass rotor - manual mode
127 /// Current rotation speed for treble rotor - manual mode
130 int meter_l
, meter_h
;
132 rotary_speaker_audio_module();
133 void set_sample_rate(uint32_t sr
);
138 void params_changed();
140 /// Convert RPM speed to delta-phase
141 uint32_t rpm2dphase(float rpm
);
142 /// Set delta-phase variables based on current calculated (and interpolated) RPM speed
144 void update_speed_manual(float delta
);
145 /// Increase or decrease aspeed towards raspeed, with required negative and positive rate
146 bool incr_towards(float &aspeed
, float raspeed
, float delta_decc
, float delta_acc
);
147 uint32_t process(uint32_t offset
, uint32_t nsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
148 virtual void control_change(int channel
, int ctl
, int val
);
151 /**********************************************************************
152 * MULTI CHORUS by Krzysztof Foltman
153 **********************************************************************/
155 class multichorus_audio_module
: public audio_module
<multichorus_metadata
>, public frequency_response_line_graph
159 dsp::multichorus
<float, dsp::sine_multi_lfo
<float, 8>, dsp::filter_sum
<dsp::biquad_d2
, dsp::biquad_d2
>, 4096> left
, right
;
163 float freq_old
, freq2_old
, q_old
;
164 mutable bool redraw_sine
;
166 multichorus_audio_module();
167 void params_changed();
168 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
171 void set_sample_rate(uint32_t sr
);
172 bool get_graph(int index
, int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
173 float freq_gain(int subindex
, float freq
) const;
174 bool get_dot(int index
, int subindex
, int phase
, float &x
, float &y
, int &size
, cairo_iface
*context
) const;
175 bool get_gridline(int index
, int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
176 bool get_layers(int index
, int generation
, unsigned int &layers
) const;
179 /**********************************************************************
180 * PULSATOR by Markus Schmidt
181 **********************************************************************/
183 class pulsator_audio_module
: public audio_module
<pulsator_metadata
>, public frequency_response_line_graph
{
185 typedef pulsator_audio_module AM
;
187 int mode_old
, amount_old
;
189 dsp::simple_lfo lfoL
, lfoR
;
195 pulsator_audio_module();
198 void params_changed();
199 void set_sample_rate(uint32_t sr
);
203 *params
[param_reset
] = 0.f
;
207 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
208 bool get_graph(int index
, int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
209 bool get_dot(int index
, int subindex
, int phase
, float &x
, float &y
, int &size
, cairo_iface
*context
) const;
210 bool get_gridline(int index
, int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
211 bool get_layers(int index
, int generation
, unsigned int &layers
) const;
215 /**********************************************************************
216 * RING MODULATOR by Markus Schmidt
217 **********************************************************************/
219 class ringmodulator_audio_module
: public audio_module
<ringmodulator_metadata
>, public frequency_response_line_graph
{
222 dsp::simple_lfo lfo1
, lfo2
, modL
, modR
;
228 ringmodulator_audio_module();
231 void params_changed();
232 void set_sample_rate(uint32_t sr
);
236 *params
[param_lfo1_reset
] = 0.f
;
237 *params
[param_lfo2_reset
] = 0.f
;
241 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
242 bool get_graph(int index
, int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
243 bool get_dot(int index
, int subindex
, int phase
, float &x
, float &y
, int &size
, cairo_iface
*context
) const;
244 bool get_gridline(int index
, int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
245 bool get_layers(int index
, int generation
, unsigned int &layers
) const;