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
34 #include "plugin_tools.h"
36 namespace calf_plugins
{
38 struct ladspa_plugin_info
;
40 /**********************************************************************
41 * REVERB by Krzysztof Foltman
42 **********************************************************************/
44 class reverb_audio_module
: public audio_module
<reverb_metadata
>
49 dsp::simple_delay
<131072, dsp::stereo_sample
<float> > pre_delay
;
50 dsp::onepole
<float> left_lo
, right_lo
, left_hi
, right_hi
;
52 dsp::gain_smoothing amount
, dryamount
;
54 float meter_wet
, meter_out
;
57 void params_changed();
58 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
60 void set_sample_rate(uint32_t sr
);
64 /**********************************************************************
65 * VINTAGE DELAY by Krzysztof Foltman
66 **********************************************************************/
68 class vintage_delay_audio_module
: public audio_module
<vintage_delay_metadata
>
71 // 1MB of delay memory per channel... uh, RAM is cheap
72 enum { MAX_DELAY
= 262144, ADDR_MASK
= MAX_DELAY
- 1 };
73 enum { MIXMODE_STEREO
, MIXMODE_PINGPONG
, MIXMODE_LR
, MIXMODE_RL
};
74 float buffers
[2][MAX_DELAY
];
75 int bufptr
, deltime_l
, deltime_r
, mixmode
, medium
, old_medium
;
76 /// 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)
79 dsp::gain_smoothing amt_left
, amt_right
, fb_left
, fb_right
, dry
, chmix
;
81 dsp::biquad_d2 biquad_left
[2], biquad_right
[2];
85 vintage_delay_audio_module();
87 void params_changed();
90 void set_sample_rate(uint32_t sr
);
92 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
98 /**********************************************************************
99 * COMPENSATION DELAY LINE by Vladimir Sadovnikov
100 **********************************************************************/
102 // The maximum distance for knobs
103 #define COMP_DELAY_MAX_DISTANCE (100.0 * 100.0 + 100.0 * 1.0 + 1.0)
104 // The actual speed of sound in normal conditions
105 #define COMP_DELAY_SOUND_SPEED_KM_H(temp) 1.85325 * (643.95 * std::pow(((temp + 273.15) / 273.15), 0.5))
106 #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 */)
107 #define COMP_DELAY_SOUND_FRONT_DELAY(temp) (1.0 / COMP_DELAY_SOUND_SPEED_CM_S(temp))
108 // The maximum delay may be reached by this plugin
109 #define COMP_DELAY_MAX_DELAY (COMP_DELAY_MAX_DISTANCE*COMP_DELAY_SOUND_FRONT_DELAY(50))
111 class comp_delay_audio_module
: public audio_module
<comp_delay_metadata
>
116 uint32_t buf_size
; // guaranteed to be power of 2
120 comp_delay_audio_module();
121 virtual ~comp_delay_audio_module();
123 void params_changed();
126 void set_sample_rate(uint32_t sr
);
127 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);