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 02110-1301 USA
22 #ifndef CALF_MODULES_DELAY_H
23 #define CALF_MODULES_DELAY_H
35 #include "plugin_tools.h"
37 namespace calf_plugins
{
39 struct ladspa_plugin_info
;
41 /**********************************************************************
42 * REVERB by Krzysztof Foltman
43 **********************************************************************/
45 class reverb_audio_module
: public audio_module
<reverb_metadata
>
50 dsp::simple_delay
<131072, dsp::stereo_sample
<float> > pre_delay
;
51 dsp::onepole
<float> left_lo
, right_lo
, left_hi
, right_hi
;
53 dsp::gain_smoothing amount
, dryamount
;
55 float meter_wet
, meter_out
;
58 void params_changed();
59 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
61 void set_sample_rate(uint32_t sr
);
65 /**********************************************************************
66 * VINTAGE DELAY by Krzysztof Foltman
67 **********************************************************************/
69 class vintage_delay_audio_module
: public audio_module
<vintage_delay_metadata
>
72 // 1MB of delay memory per channel... uh, RAM is cheap
73 enum { MAX_DELAY
= 262144, ADDR_MASK
= MAX_DELAY
- 1 };
74 enum { MIXMODE_STEREO
, MIXMODE_PINGPONG
, MIXMODE_LR
, MIXMODE_RL
};
75 float buffers
[2][MAX_DELAY
];
76 int bufptr
, deltime_l
, deltime_r
, mixmode
, medium
, old_medium
;
77 /// number of table entries written (value is only important when it is less than MAX_DELAY, which means that the buffer hasn't been totally filled yet)
80 dsp::gain_smoothing amt_left
, amt_right
, fb_left
, fb_right
, dry
, chmix
;
82 dsp::biquad_d2 biquad_left
[2], biquad_right
[2];
86 vintage_delay_audio_module();
88 void params_changed();
91 void set_sample_rate(uint32_t sr
);
93 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
99 /**********************************************************************
100 * COMPENSATION DELAY LINE by Vladimir Sadovnikov
101 **********************************************************************/
103 // The maximum distance for knobs
104 #define COMP_DELAY_MAX_DISTANCE (100.0 * 100.0 + 100.0 * 1.0 + 1.0)
105 // The actual speed of sound in normal conditions
106 #define COMP_DELAY_SOUND_SPEED_KM_H(temp) 1.85325 * (643.95 * std::pow(((temp + 273.15) / 273.15), 0.5))
107 #define COMP_DELAY_SOUND_SPEED_CM_S(temp) (COMP_DELAY_SOUND_SPEED_KM_H(temp) * (1000.0 * 100.0) /* cm/km */ / (60.0 * 60.0) /* s/h */)
108 #define COMP_DELAY_SOUND_FRONT_DELAY(temp) (1.0 / COMP_DELAY_SOUND_SPEED_CM_S(temp))
109 // The maximum delay may be reached by this plugin
110 #define COMP_DELAY_MAX_DELAY (COMP_DELAY_MAX_DISTANCE*COMP_DELAY_SOUND_FRONT_DELAY(50))
112 class comp_delay_audio_module
: public audio_module
<comp_delay_metadata
>
117 uint32_t buf_size
; // guaranteed to be power of 2
122 comp_delay_audio_module();
123 virtual ~comp_delay_audio_module();
125 void params_changed();
128 void set_sample_rate(uint32_t sr
);
129 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
132 /**********************************************************************
133 * HAAS enhancer by Vladimir Sadovnikov
134 **********************************************************************/
135 #define HAAS_ENHANCER_MAX_DELAY (10 * 0.001) /* 10 MSec */
137 class haas_enhancer_audio_module
: public audio_module
<haas_enhancer_metadata
>
142 uint32_t buf_size
; // guaranteed to be power of 2
148 uint32_t m_source
, s_delay
[2];
149 float s_bal_l
[2], s_bal_r
[2];
151 haas_enhancer_audio_module();
152 virtual ~haas_enhancer_audio_module();
154 void params_changed();
157 void set_sample_rate(uint32_t sr
);
158 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
161 /**********************************************************************
163 **********************************************************************/
165 class reverse_delay_audio_module
: public audio_module
<reverse_delay_metadata
>
168 enum { MAX_DELAY
= 6144000, ADDR_MASK
= MAX_DELAY
- 1 };
169 float buffers
[2][MAX_DELAY
];
171 dsp::overlap_window ow
[2];
172 int deltime_l
, deltime_r
;
174 dsp::gain_smoothing fb_val
, dry
, width
;
176 float feedback_buf
[2];
180 uint32_t line_state_old
;
182 reverse_delay_audio_module();
184 void params_changed();
187 void set_sample_rate(uint32_t sr
);
188 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);