-
Notifications
You must be signed in to change notification settings - Fork 52
/
divider_1186.xml
96 lines (81 loc) · 2.52 KB
/
divider_1186.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
<?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"/>
</global>
<plugin label="divider" id="1186" class="GeneratorPlugin">
<name>Audio Divider (Suboctave Generator)</name>
<p>Reduces the period of the signal by the factor given, and makes it a square wave in the process. Has some amplitude tracking capability, but not really useful on complex signals.</p>
<callback event="instantiate"><![CDATA[
out = 1.0f;
amp = 0.0f;
count = 0.0f;
lamp = 0.0f;
last = 0.0f;
zeroxs = 0;
]]></callback>
<callback event="run"><![CDATA[
/* Integer version of denominator */
int den = (int)denominator;
unsigned long pos;
for (pos = 0; pos < sample_count; pos++) {
count += 1.0f;
if ((input[pos] > 0.0f && last <= 0.0f) ||
(input[pos] < 0.0f && last >= 0.0)) {
zeroxs++;
if (den == 1) {
out = out > 0.0f ? -1.0f : 1.0f;
lamp = amp / count;
zeroxs = 0;
count = 0;
amp = 0;
}
}
amp += fabs(input[pos]);
if (den > 1 && (zeroxs % den) == den-1) {
out = out > 0.0f ? -1.0f : 1.0f;
lamp = amp / count;
zeroxs = 0;
count = 0;
amp = 0;
}
last = input[pos];
buffer_write(output[pos], out * lamp);
}
plugin_data->last = last;
plugin_data->amp = amp;
plugin_data->lamp = lamp;
plugin_data->zeroxs = zeroxs;
plugin_data->count = count;
plugin_data->out = out;
]]></callback>
<port label="denominator" dir="input" type="control" hint="integer,default_1">
<name>Denominator</name>
<range min="1" max="8"/>
<p>The factor the incoming frequency will be divided by.</p>
</port>
<port label="input" dir="input" type="audio">
<name>Input</name>
</port>
<port label="output" dir="output" type="audio">
<name>Output</name>
<range min="-1" max="+1"/>
</port>
<!-- Last input value, to find 0 crossings -->
<instance-data label="last" type="LADSPA_Data"/>
<!-- Current amplitude sum (well, amp of last half cycle) -->
<instance-data label="amp" type="LADSPA_Data"/>
<!-- Average last amplitude (well, amp of last half cycle) -->
<instance-data label="lamp" type="LADSPA_Data"/>
<!-- Count of zero xings to make divider -->
<instance-data label="zeroxs" type="int"/>
<!-- Count of number of samples since x -->
<instance-data label="count" type="float"/>
<!-- Current output value -->
<instance-data label="out" type="LADSPA_Data"/>
</plugin>
</ladspa>