加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
divider_1186.xml 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
swh 提交于 2007-02-27 11:45 . Initial import
<?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"/>
</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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化