[SCM] calf/master: + Small modules: new Sample&Hold and Edge Detector modules
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:36 UTC 2013
The following commit has been merged in the master branch:
commit 75597b2b367549dedd3de0b782e3cb4903afbcfc
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Thu Sep 25 20:04:25 2008 +0000
+ Small modules: new Sample&Hold and Edge Detector modules
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@296 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index f8c2998..34c5389 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -19,6 +19,7 @@
PER_SMALL_MODULE_ITEM(minus, "minus")
PER_SMALL_MODULE_ITEM(mul, "mul")
PER_SMALL_MODULE_ITEM(neg, "neg")
+ PER_SMALL_MODULE_ITEM(level2edge_c, "level2edge_c")
PER_SMALL_MODULE_ITEM(map_lin2exp, "lin2exp")
PER_SMALL_MODULE_ITEM(square_osc, "square_osc")
PER_SMALL_MODULE_ITEM(saw_osc, "saw_osc")
@@ -30,6 +31,8 @@
PER_SMALL_MODULE_ITEM(quadpower_c, "quadpower_c")
PER_SMALL_MODULE_ITEM(linear_inertia_c, "linear_inertia_c")
PER_SMALL_MODULE_ITEM(exp_inertia_c, "exp_inertia_c")
+ PER_SMALL_MODULE_ITEM(sample_hold_edge_c, "sample_hold_edge_c")
+ PER_SMALL_MODULE_ITEM(sample_hold_level_c, "sample_hold_level_c")
#endif
#undef PER_MODULE_ITEM
#undef PER_SMALL_MODULE_ITEM
diff --git a/src/modules_small.cpp b/src/modules_small.cpp
index 67aace9..123ab60 100644
--- a/src/modules_small.cpp
+++ b/src/modules_small.cpp
@@ -292,6 +292,45 @@ public:
}
};
+/// This works for 1 or 2 operands only...
+template<int Inputs>
+class control_operator_audio_module: public small_audio_module_base<Inputs, 1>
+{
+public:
+ static void port_info(plugin_info_iface *pii, control_port_info_iface *cports[Inputs + 1], float in1 = 0, float in2 = 0)
+ {
+ int idx = 0;
+ if (Inputs == 1)
+ cports[idx++] = &pii->control_port("in", "In", in1).input();
+ else
+ {
+ cports[idx++] = &pii->control_port("in_1", "In 1", in1).input();
+ cports[idx++] = &pii->control_port("in_2", "In 2", in2).input();
+ }
+ cports[idx++] = &pii->control_port("out", "Out", 0).output();
+ }
+};
+
+class level2edge_c_audio_module: public control_operator_audio_module<1>
+{
+public:
+ bool last_value;
+ void activate() {
+ last_value = false;
+ }
+ void process(uint32_t count) {
+ *outs[0] = (*ins[0] > 0 && !last_value) ? 1.f : 0.f;
+ last_value = *ins[0] > 0;
+ }
+ static void plugin_info(plugin_info_iface *pii)
+ {
+ pii->names("level2edge_c", "Level to edge (C)", "lv2:UtilityPlugin");
+ control_port_info_iface *cports[2];
+ port_info(pii, cports);
+ cports[0]->toggle().trigger();
+ }
+};
+
class map_lin2exp_audio_module: public null_small_audio_module
{
public:
@@ -570,13 +609,13 @@ public:
{
pii->control_port("in", "In", 0).input();
pii->control_port("time", "Inertia time", 100).input();
- pii->control_port("reset", "Reset", 0).input().toggle();
+ pii->control_port("reset", "Reset", 0).input().toggle().trigger();
pii->control_port("out", "Out", 0).output();
}
void process(uint32_t count)
{
float value = *ins[in_value];
- if (reset || *ins[in_immediate] != 0)
+ if (reset || *ins[in_immediate] > 0)
{
*outs[0] = value;
state.set_now(value);
@@ -616,6 +655,63 @@ public:
}
};
+class sample_hold_base: public small_audio_module_base<2, 1>
+{
+public:
+ enum { in_value, in_gate };
+ static void port_info(plugin_info_iface *pii, const char *clock_symbol, const char *clock_name)
+ {
+ pii->control_port("in", "In", 0).input();
+ pii->control_port(clock_symbol, clock_name, 0).input().toggle().trigger();
+ pii->control_port("out", "Out", 0).output();
+ }
+};
+
+class sample_hold_edge_c_audio_module: public sample_hold_base
+{
+public:
+ bool prev_clock;
+ float value;
+ void activate()
+ {
+ prev_clock = false;
+ value = 0;
+ }
+ void process(uint32_t count)
+ {
+ if (!prev_clock && *ins[in_gate] > 0)
+ value = *ins[in_value];
+ prev_clock = *ins[in_gate] > 0;
+ *outs[0] = value;
+ }
+ static void plugin_info(plugin_info_iface *pii)
+ {
+ pii->names("sample_hold_edge", "Sample&Hold (Edge, C)", "lv2:FilterPlugin");
+ port_info(pii, "clock", "Clock");
+ }
+};
+
+class sample_hold_level_c_audio_module: public sample_hold_base
+{
+public:
+ float value;
+ void activate()
+ {
+ value = 0;
+ }
+ void process(uint32_t count)
+ {
+ if (*ins[in_gate] > 0)
+ value = *ins[in_value];
+ *outs[0] = value;
+ }
+ static void plugin_info(plugin_info_iface *pii)
+ {
+ pii->names("sample_hold_level", "Sample&Hold (Level, C)", "lv2:FilterPlugin");
+ port_info(pii, "gate", "Gate");
+ }
+};
+
};
#define PER_MODULE_ITEM(...)
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list