File: pointer_cast_1910.xml

package info (click to toggle)
swh-plugins 0.4.17-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,264 kB
  • sloc: ansic: 23,551; xml: 12,633; perl: 1,114; sh: 964; makefile: 218
file content (85 lines) | stat: -rw-r--r-- 2,573 bytes parent folder | download | duplicates (2)
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
<?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 &lt;steve@plugin.org.uk&gt;"/>
    <meta name="copyright" value="GPL"/>
    <meta name="properties" value="HARD_RT_CAPABLE"/>
    <code><![CDATA[
      #include <limits.h>

      #include "ladspa-util.h"
      #include "util/biquad.h"

      typedef union {
	LADSPA_Data fp;
	int         in;
      } pcast;
    ]]></code>
  </global>

  <plugin label="pointerCastDistortion" id="1910" class="DistortionPlugin">
    <name>Pointer cast distortion</name>
    <p>This distortion is created by treating the floating point representation
of the input signal as a 0.32 1's complement fixedpoint integer. Its very
unmusical but supprisingly recognisable. I'm not sure that its useful for
anything, but it can make interesting noises.</p>

    <callback event="instantiate"><![CDATA[
      filt = malloc(sizeof(biquad));
      fs = s_rate;
    ]]></callback>

    <callback event="activate"><![CDATA[
      biquad_init(filt);
    ]]></callback>

    <callback event="run"><![CDATA[
      unsigned long pos;
      const float filt_scale = cutoff < 50.0f ? cutoff / 50.0f : 1.0f;

      lp_set_params(filt, cutoff, 1.0f, fs);

      for (pos = 0; pos < sample_count; pos++) {
	pcast val;
	float sign, filt_val, dist_val;

	filt_val = biquad_run(filt, input[pos]) * filt_scale;
	sign = filt_val < 0.0f ? -1.0f : 1.0f;
	val.fp = fabs(filt_val);
	dist_val = sign * (LADSPA_Data)val.in / (LADSPA_Data)INT_MAX +
		   (input[pos] - filt_val);
        buffer_write(output[pos], LIN_INTERP(wet, input[pos], dist_val));
      }
    ]]></callback>

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

    <port label="cutoff" dir="input" type="control" hint="logarithmic,sample_rate,default_low">
      <name>Effect cutoff freq (Hz)</name>
      <p>Controls the frequencies that will be passed to the effect.</p>
      <range min="0.0001" max="0.3"/>
    </port>

    <port label="wet" dir="input" type="control" hint="default_0">
      <name>Dry/wet mix</name>
      <p>Controls the ammunt of distorting mixed into the output.</p>
      <range min="0" max="1"/>
    </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="filt" type="biquad *" />
  </plugin>
</ladspa>