forked from swh/ladspa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comb_1190.xml
91 lines (77 loc) · 2.53 KB
/
comb_1190.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" ?>
<!DOCTYPE ladspa SYSTEM "ladspa-swh.dtd">
<?xml-stylesheet href="ladspa.css" type="text/css" ?>
<ladspa>
<global>
<meta name="maker" value="Steve Harris <steve@plugin.org.uk>"/>
<meta name="copyright" value="GPL"/>
<meta name="properties" value="HARD_RT_CAPABLE"/>
<code>
#include "ladspa-util.h"
#define COMB_SIZE 0x4000
#define COMB_MASK 0x3FFF
</code>
</global>
<plugin label="comb" id="1190" class="CombPlugin">
<name>Comb Filter</name>
<callback event="instantiate">
sample_rate = s_rate;
comb_tbl = malloc(sizeof(LADSPA_Data) * COMB_SIZE);
comb_pos = 0;
last_offset = 1000;
</callback>
<callback event="activate">
int i;
for (i = 0; i < COMB_SIZE; i++) {
comb_tbl[i] = 0;
}
comb_pos = 0;
last_offset = 1000;
</callback>
<callback event="cleanup">
free(plugin_data->comb_tbl);
</callback>
<callback event="run"><![CDATA[
float offset;
int data_pos;
unsigned long pos;
float xf, xf_step, d_pos, fr, interp;
offset = sample_rate / freq;
offset = f_clamp(offset, 0, COMB_SIZE - 1);
xf_step = 1.0f / (float)sample_count;
xf = 0.0f;
for (pos = 0; pos < sample_count; pos++) {
xf += xf_step;
d_pos = comb_pos - LIN_INTERP(xf, last_offset, offset);
data_pos = f_trunc(d_pos);
fr = d_pos - data_pos;
interp = cube_interp(fr, comb_tbl[(data_pos - 1) & COMB_MASK], comb_tbl[data_pos & COMB_MASK], comb_tbl[(data_pos + 1) & COMB_MASK], comb_tbl[(data_pos + 2) & COMB_MASK]);
comb_tbl[comb_pos] = input[pos] + fb * interp;
buffer_write(output[pos], (input[pos] + interp) * 0.5f);
comb_pos = (comb_pos + 1) & COMB_MASK;
}
plugin_data->comb_pos = comb_pos;
plugin_data->last_offset = offset;
]]></callback>
<port label="freq" dir="input" type="control" hint="default_low">
<name>Band separation (Hz)</name>
<range min="16" max="640"/>
<p>Controls the distance between the filters peaks.</p>
</port>
<port label="fb" dir="input" type="control" hint="default_0">
<name>Feedback</name>
<range min="-0.99" max="0.99"/>
<p>Feedback level, increases the distinctive wooshy phaser sound.</p>
</port>
<port label="input" dir="input" type="audio">
<name>Input</name>
</port>
<port label="output" dir="output" type="audio">
<name>Output</name>
</port>
<instance-data label="comb_tbl" type="LADSPA_Data *"/>
<instance-data label="comb_pos" type="long"/>
<instance-data label="sample_rate" type="long"/>
<instance-data label="last_offset" type="float"/>
</plugin>
</ladspa>