-
Notifications
You must be signed in to change notification settings - Fork 52
/
dj_flanger_1438.xml
145 lines (121 loc) · 4.14 KB
/
dj_flanger_1438.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?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><![CDATA[
#include <sys/types.h>
#include "ladspa-util.h"
#define DELAY_TIME 0.005f
]]></code>
</global>
<plugin label="djFlanger" id="1438" class="FlangerPlugin">
<name>DJ flanger</name>
<p>This is a flanger which is more or less typical of DJ mixing desks. Requested by Patrick Shirkey.</p>
<callback event="instantiate"><![CDATA[
int buffer_size = 2048;
fs = s_rate;
while (buffer_size < fs * DELAY_TIME + 3.0f) {
buffer_size *= 2;
}
buffer = calloc(buffer_size, sizeof(LADSPA_Data));
buffer_mask = buffer_size - 1;
buffer_pos = 0;
x = 0.5f;
y = 0.0f;
last_sync = 0;
]]></callback>
<callback event="activate"><![CDATA[
memset(buffer, 0, (buffer_mask + 1) * sizeof(LADSPA_Data));
last_sync = 0;
]]></callback>
<callback event="run"><![CDATA[
unsigned long pos;
const float omega = 6.2831852f / (period * fs);
const float dr = 0.001f * fs * depth;
float fb;
float d;
float dout, out;
unsigned int dof;
if (feedback > 99.0f) {
fb = 0.99f;
} else if (feedback < -99.0f) {
fb = -0.99f;
} else {
fb = feedback * 0.01f;
}
if (sync > 0) {
if (!last_sync) {
x = 0.5f;
y = 0.0f;
}
plugin_data->last_sync = 1;
} else {
plugin_data->last_sync = 0;
}
for (pos = 0; pos < sample_count; pos++) {
/* Write input into delay line */
buffer[buffer_pos] = input[pos];
/* Calcuate delay */
d = (x + 0.5f) * dr;
dof = f_round(d);
//dout = buffer[(buffer_pos - f_round(d)) & buffer_mask];
dout = cube_interp(d - floor(d),
buffer[(buffer_pos - dof - 3) & buffer_mask],
buffer[(buffer_pos - dof - 2) & buffer_mask],
buffer[(buffer_pos - dof - 1) & buffer_mask],
buffer[(buffer_pos - dof) & buffer_mask]);
/* Write output */
out = (buffer[buffer_pos] + dout) * 0.5f;
buffer[buffer_pos] = input[pos] + out * fb;
buffer_write(output[pos], out);
/* Roll ringbuffer */
buffer_pos = (buffer_pos + 1) & buffer_mask;
/* Run LFO */
x -= omega * y;
y += omega * x;
}
plugin_data->x = x;
plugin_data->y = y;
plugin_data->buffer_pos = buffer_pos;
]]></callback>
<callback event="cleanup"><![CDATA[
free(plugin_data->buffer);
]]></callback>
<port label="sync" dir="input" type="control" hint="default_0,toggled">
<name>LFO sync</name>
<p>When turned from off to on it resets the phase of the LFO back to the start of the cycle. Used to sync the LFO to the track.</p>
</port>
<port label="period" dir="input" type="control" hint="default_1">
<name>LFO period (s)</name>
<p>The cycle period of the LFO in seconds.</p>
<range min="0.1" max="32.0"/>
</port>
<port label="depth" dir="input" type="control" hint="default_high">
<name>LFO depth (ms)</name>
<p>The maximum delay the LFO will use to flange, in milliseconds.</p>
<range min="1" max="5"/>
</port>
<port label="feedback" dir="input" type="control" hint="default_0">
<name>Feedback (%)</name>
<p>The amount of the delays output that is mixed back into the delay.</p>
<range min="-100" max="100"/>
</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="buffer" type="LADSPA_Data *" />
<instance-data label="buffer_pos" type="unsigned int" />
<instance-data label="buffer_mask" type="unsigned int" />
<instance-data label="fs" type="float" />
<instance-data label="x" type="float" />
<instance-data label="y" type="float" />
<instance-data label="last_sync" type="unsigned int" />
</plugin>
</ladspa>