File: plugin.xml

package info (click to toggle)
swh-lv2 1.0.16%2Bgit20160519~repack0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 1,004 kB
  • ctags: 440
  • sloc: xml: 11,889; ansic: 2,120; makefile: 120
file content (215 lines) | stat: -rw-r--r-- 6,564 bytes parent folder | download | duplicates (4)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?xml version="1.0"?>
<!DOCTYPE ladspa SYSTEM "ladspa-swh.dtd">
<?xml-stylesheet href="ladspa.css" type="text/css"?>

<!-- Copyright (C) 2000 Nedko Arnaudov <nedko@arnaudov.name> -->

<ladspa>
  <global>
    <meta name="maker" value="Steve Harris &lt;steve@plugin.org.uk&gt;"/>
    <meta name="copyright" value="GPL"/>
    <meta name="properties" value="HARD_RT_CAPABLE"/>
    <code><![CDATA[
      #include "ladspa-util.h"
      #include "util/biquad.h"

      #define ENV_TR 0.0001f

      #define CLOSED  1
      #define OPENING 2
      #define OPEN    3
      #define HOLD    4
      #define CLOSING 5
    ]]></code>
  </global>

  <plugin label="gate" id="1410" class="GatePlugin">
    <name>Gate</name>
    <p>The parameters are copied from the Drawmer DS-201, but I've never used one, so if someone out there has one, please tell me if it behaves differently.</p>

    <callback event="instantiate"><![CDATA[
      fs = s_rate;
      env = 0.0f;
      gate = 0.0f;
      state = CLOSED;
      hold_count = 0;

      lf = malloc(sizeof(biquad));
      hf = malloc(sizeof(biquad));
      biquad_init(lf);
      biquad_init(hf);
    ]]></callback>

    <callback event="activate"><![CDATA[
      env = 0.0f;
      gate = 0.0f;
      state = CLOSED;
      biquad_init(lf);
      biquad_init(hf);
    ]]></callback>

    <callback event="cleanup"><![CDATA[
      free(plugin_data->lf);
      free(plugin_data->hf);
    ]]></callback>


    <callback event="run"><![CDATA[
      unsigned long pos;
      float cut = DB_CO(range);
      float t_level = DB_CO(threshold);
      float a_rate = 1000.0f / (attack * fs);
      float d_rate = 1000.0f / (decay * fs);
      float post_filter, apost_filter;
      int op = f_round(select);

      ls_set_params(lf, lf_fc, -40.0f, 0.6f, fs);
      hs_set_params(hf, hf_fc, -50.0f, 0.6f, fs);

      for (pos = 0; pos < sample_count; pos++) {
	post_filter = biquad_run(lf, input[pos]);
	post_filter = biquad_run(hf, post_filter);
	apost_filter = fabs(post_filter);

        if (apost_filter > env) {
          env = apost_filter;
        } else {
          env = apost_filter * ENV_TR + env * (1.0f - ENV_TR);
        }

	if (state == CLOSED) {
	  if (env >= t_level) {
	    state = OPENING;
	  }
        } else if (state == OPENING) {
	  gate += a_rate;
	  if (gate >= 1.0f) {
	    gate = 1.0f;
	    state = OPEN;
	  }
        } else if (state == OPEN) {
          if (env < t_level) {
            state = HOLD;
            hold_count = f_round(hold * fs * 0.001f);
          }
        } else if (state == HOLD) {
	  if (env >= t_level) {
	    state = OPEN;
          } else if (hold_count <= 0) {
            state = CLOSING;
          } else {
            hold_count--;
          }
	} else if (state == CLOSING) {
	  gate -= d_rate;
	  if (env >= t_level) {
	    state = OPENING;
	  } else if (gate <= 0.0f) {
	    gate = 0.0f;
	    state = CLOSED;
	  }
	}

	if (op == 0) {
          buffer_write(output[pos], input[pos] * (cut * (1.0f - gate) + gate));
	} else if (op == -1) {
          buffer_write(output[pos], post_filter);
	} else {
	  buffer_write(output[pos], input[pos]);
	}
      }

      *(plugin_data->level) = CO_DB(env);
      switch (state) {
      case OPEN:
        *(plugin_data->gate_state) = 1.0;
        break;
      case HOLD:
        *(plugin_data->gate_state) = 0.5;
        break;
      default:
        *(plugin_data->gate_state) = 0.0;
      }

      plugin_data->env = env;
      plugin_data->gate = gate;
      plugin_data->state = state;
      plugin_data->hold_count = hold_count;
    ]]></callback>

    <port label="lf_fc" dir="input" type="control" hint="logarithmic">
      <name>LF key filter (Hz)</name>
      <p>Controls the cutoff of the low frequency filter (highpass).</p>
      <range min="25.0" max="4000.0" default="500.0"/>
    </port>

    <port label="hf_fc" dir="input" type="control" hint="logarithmic">
      <name>HF key filter (Hz)</name>
      <p>Controls the cutoff of the high frequency filter (lowpass).</p>
      <range min="250.0" max="20000.0" default="2000.0"/>
    </port>

    <port label="threshold" dir="input" type="control">
      <name>Threshold (dB)</name>
      <p>Controls the level at which the gate will open.</p>
      <range min="-70.0" max="+20.0" default="-40.0"/>
    </port>

    <port label="attack" dir="input" type="control" hint="logarithmic">
      <name>Attack (ms)</name>
      <p>Controls the time the gate will take to open fully.</p>
      <range min="0.01" max="1000.0" default="0.1"/>
    </port>

    <port label="hold" dir="input" type="control" hint="logarithmic">
      <name>Hold (ms)</name>
      <p>Controls the amount of time the gate will stay open after the signal falls below Threshold.</p>
      <range min="2.0" max="2000.0" default="50.0"/>
    </port>

    <port label="decay" dir="input" type="control" hint="logarithmic">
      <name>Decay (ms)</name>
      <p>Controls the time the gate will take to close fully, once the signal has fallen below the Threshold and the Hold time has expired.</p>
      <range min="2.0" max="4000.0" default="50.0"/>
    </port>

    <port label="range" dir="input" type="control">
      <name>Range (dB)</name>
      <p>Controls the difference between the gate's open and closed state.</p>
      <range min="-90.0" max="0.0" default="-20.0"/>
    </port>

    <port label="select" dir="input" type="control" hint="integer">
      <name>Output select (-1 = key listen, 0 = gate, 1 = bypass)</name>
      <p>Controls output monitor. -1 is the output of the key filters (so you can check what is being gated on). 0 is the normal, gated output. 1 is bypass mode.</p>
      <range min="-1" max="1" default="0"/>
    </port>

    <port label="level" dir="output" type="control">
      <name>Key level (dB)</name>
      <p>Shows the current level of the key.</p>
      <range min="-90.0" max="0.0"/>
    </port>

    <port label="gate_state" dir="output" type="control">
      <name>Gate state</name>
      <range min="0.0" max="1.0"/>
    </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="fs" type="float" />
    <instance-data label="env" type="float" />
    <instance-data label="gate" type="float" />
    <instance-data label="state" type="int" />
    <instance-data label="hold_count" type="int" />
    <instance-data label="lf" type="biquad *" />
    <instance-data label="hf" type="biquad *" />
  </plugin>
</ladspa>