forked from swh/ladspa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgong_beater_1439.xml
109 lines (95 loc) · 3.67 KB
/
gong_beater_1439.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
<?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 <[email protected]>"/>
<meta name="copyright" value="GPL"/>
<meta name="properties" value="HARD_RT_CAPABLE"/>
<code>
#include "ladspa-util.h"
</code>
</global>
<plugin label="gongBeater" id="1439" class="GeneratorPlugin">
<name>Gong beater</name>
<p>A plugin to simulator the action of a beator on a gong surface, used to trigger the gong physical model.</p>
<p>It is triggered by an impulse on the input, eg. from a mic or piezo placed near a solid surface, for an event sequencer.</p>
<callback event="instantiate"><![CDATA[
running = 0;
x = 0.5f;
y = 0.0f;
xm = 0.5f;
ym = 0.0f;
fs = (float)s_rate;
imp_level = 0.0f;
]]></callback>
<callback event="activate"><![CDATA[
running = 0;
x = 0.5f;
y = 0.0f;
xm = 0.5f;
ym = 0.0f;
]]></callback>
<callback event="run"><![CDATA[
unsigned long pos;
const float imp_amp = DB_CO(imp_gain);
const float strike_amp = DB_CO(strike_gain);
const float omega = 6.2831852f / (strike_duration * fs);
pos = 0;
while (pos < sample_count) {
for (; !running && pos < sample_count; pos++) {
if (fabs(input[pos]) > 0.05f) {
running = strike_duration * fs;
imp_level = fabs(input[pos]);
}
buffer_write(output[pos], input[pos] * imp_amp);
}
for (; running && pos < sample_count; pos++, running--) {
if (fabs(input[pos]) > imp_level) {
imp_level = fabs(input[pos]);
}
x -= omega * y;
y += omega * x;
xm -= omega * 0.5f * ym;
ym += omega * 0.5f * xm;
buffer_write(output[pos], input[pos] * imp_amp + y * strike_amp *
imp_level * 4.0f * ym);
}
}
plugin_data->x = x;
plugin_data->y = y;
plugin_data->xm = xm;
plugin_data->ym = ym;
plugin_data->running = running;
plugin_data->imp_level = imp_level;
]]></callback>
<port label="imp_gain" dir="input" type="control" hint="default_minimum">
<name>Impulse gain (dB)</name>
<p>The gain of the input impulse mixed into the output, bringing this up allows you to make the outputted strike more impulsive, but may reduce the gongyness of the resulting output sound.</p>
<range min="-70" max="0"/>
</port>
<port label="strike_gain" dir="input" type="control" hint="default_maximum">
<name>Strike gain (dB)</name>
<p>The gain of the simulated pressure wave mixed into the output, bringing this up allows you to make the outputted strike more pure. The final output level is also proprtional to the amplitude of the trigger.</p>
<range min="-70" max="0"/>
</port>
<port label="strike_duration" dir="input" type="control" hint="default_middle">
<name>Strike duration (s)</name>
<p>The duration of the pressure wave used to simulate the action of the beater on the gong surface. The logner the duration the more sonorus the resulting gong sound.</p>
<range min="0.001" max="0.2"/>
</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="x" type="float" />
<instance-data label="y" type="float" />
<instance-data label="xm" type="float" />
<instance-data label="ym" type="float" />
<instance-data label="running" type="unsigned int" />
<instance-data label="fs" type="float" />
<instance-data label="imp_level" type="float" />
</plugin>
</ladspa>