[SCM] calf/master: + Compressor: add line graph with dot
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:25 UTC 2013
The following commit has been merged in the master branch:
commit 2913753432d14fd76191c57c1c7c8606ae321617
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Fri Nov 7 22:19:09 2008 +0000
+ Compressor: add line graph with dot
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 5331649..fd9af85 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -142,7 +142,7 @@ struct parameter_properties
/// 'provides live line graph values' interface
struct line_graph_iface
{
- /// Obtain subindex'th graph of parameter index
+ /// Obtain subindex'th graph of parameter 'index'
/// @param index parameter/graph number (usually tied to particular plugin control port)
/// @param subindex graph number (there may be multiple overlaid graphs for one parameter, eg. for monosynth 2x12dB filters)
/// @param data buffer for normalized output values
@@ -151,6 +151,11 @@ struct line_graph_iface
/// @retval true graph data was returned; subindex+1 graph may or may not be available
/// @retval false graph data was not returned; subindex+1 graph does not exist either
virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) { return false; }
+
+ /// Obtain subindex'th dot of parameter 'index'
+ /// @param index parameter/dot number (usually tied to particular plugin control port)
+ /// @param subindex dot number (there may be multiple dots graphs for one parameter)
+ virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_t *context) { return false; }
/// Obtain subindex'th static graph of parameter index (static graphs are only dependent on parameter value, not plugin state)
/// @param index parameter/graph number (usually tied to particular plugin control port)
@@ -162,6 +167,7 @@ struct line_graph_iface
/// @retval true graph data was returned; subindex+1 graph may or may not be available
/// @retval false graph data was not returned; subindex+1 graph does not exist either
virtual bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context) { return false; }
+
/// Standard destructor to make compiler happy
virtual ~line_graph_iface() {}
};
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index 2c6a3ea..f9a08a2 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -27,7 +27,7 @@ namespace calf_plugins {
#if ENABLE_EXPERIMENTAL
-class compressor_audio_module: public audio_module<compressor_metadata> {
+class compressor_audio_module: public audio_module<compressor_metadata>, public line_graph_iface {
private:
float linslope, clip, peak;
bool aweighting;
@@ -150,6 +150,52 @@ public:
awL.set(sr);
awR.set(sr);
}
+ inline float output_level(float slope)
+ {
+ float threshold = *params[param_threshold];
+ float ratio = *params[param_ratio];
+ float makeup = *params[param_makeup];
+ float knee = *params[param_knee];
+
+ if(slope > 0.f && (slope > threshold || knee < 1.f)) {
+ float gain = 0.f;
+ if(IS_FAKE_INFINITY(ratio)) {
+ gain = threshold;
+ } else {
+ gain = (slope - threshold) / ratio + threshold;
+ }
+
+ if(knee < 1.f) {
+ float t = std::min(1.f, std::max(0.f, slope / threshold - knee) / (1.f - knee));
+ gain = (gain - slope) * t + slope;
+ }
+ return gain * makeup;
+ }
+ return slope * makeup;
+ }
+ virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) {
+ if (subindex > 0) // 1
+ return false;
+ for (int i = 0; i < points; i++)
+ {
+ float input = pow(65536.0, i * 1.0 / (points - 1) - 1);
+ float output = output_level(input);
+ //if (subindex == 0)
+ // data[i] = 1 + 2 * log(input) / log(65536);
+ //else
+ data[i] = 1 + 2 * log(output) / log(65536);
+ }
+ return true;
+ }
+ virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_t *context) {
+ if (!subindex)
+ {
+ x = 1 + 2 * log(peak) / log(65536);
+ y = 1 + 2 * log(output_level(peak)) / log(65536);
+ return true;
+ }
+ return false;
+ }
};
#endif
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index b06dc60..331bacf 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -80,6 +80,16 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
}
cairo_stroke(c);
}
+ float x, y;
+ int size = 0;
+ GdkColor sc3 = { 0, 32767, 65535, 0 };
+ gdk_cairo_set_source_color(c, &sc3);
+ for(int gn = 0; lg->source->get_dot(lg->source_id, gn, x, y, size = 3, c); gn++)
+ {
+ int yv = (int)(oy + sy / 2 - (sy / 2 - 1) * y);
+ cairo_arc(c, ox + (x + 1) * sx / 2, yv, size, 0, 2 * M_PI);
+ cairo_fill(c);
+ }
delete []data;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index acf1374..5f68f3e 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -187,7 +187,7 @@ CALF_PORT_PROPS(compressor) = {
{ 0, 0, 1, 0, PF_ENUM | PF_CTL_COMBO, compressor_detection_names, "detection", "Detection" },
{ 0, 0, 1, 0, PF_ENUM | PF_CTL_COMBO, compressor_stereo_link_names, "stereo_link", "Stereo Link" },
{ 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "aweighting", "A-weighting" },
- { 0, 0.03125, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_CTLO_REVERSE | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "compression", "Compression" },
+ { 0, 0.03125, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_CTLO_REVERSE | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL| PF_PROP_GRAPH, NULL, "compression", "Compression" },
{ 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "peak", "Peak" },
{ 0, 1, 0, 0, PF_BOOL | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip", "Clip" },
{ 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list