[SCM] calf/master: all windowing functions implemented
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:41:10 UTC 2013
The following commit has been merged in the master branch:
commit 77373549467070c9327e1e5fe637e6850995e543
Author: Markus Schmidt <schmidt at boomshop.net>
Date: Fri Sep 14 02:44:32 2012 +0200
all windowing functions implemented
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index d80e100..feacbc9 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -127,7 +127,7 @@ calf_line_graph_draw_graph( cairo_t *c, float *data, int sx, int sy, int mode =
case 4:
// this mode draws pixels at the bottom of the surface
if (i and ((data[i] < INFINITY) or i == sx - 1)) {
- cairo_set_source_rgba(c, 0.35, 0.4, 0.2, data[i] + 1 / 2.f);
+ cairo_set_source_rgba(c, 0.35, 0.4, 0.2, (data[i] + 1) / 2.f);
cairo_rectangle(c, ox + _last, oy + sy - 1, i - _last, 1);
cairo_fill(c);
_last = i;
diff --git a/src/metadata.cpp b/src/metadata.cpp
index b92fefe..c28a12b 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -990,7 +990,7 @@ const char *analyzer_smooth_names[] = { "Off", "Falling", "Transition" };
const char *analyzer_post_names[] = { "Normalized", "Average", "Additive", "Denoised Peaks" };
const char *analyzer_view_names[] = { "Bars", "Lines", "Cubic Splines" };
const char *analyzer_scale_names[] = { "Logarithmic", "Linear" };
-const char *analyzer_windowing_names[] = { "Linear", "Hamming", "von Hann", "Blackman", "Blackman-Harris", "Blackman-Nuttall", "Bartlett", "Bartlett-Hann", "Sine", "Tukey", "Lanczos", "Kaiser", "Gauß" };
+const char *analyzer_windowing_names[] = { "Linear", "Hamming", "von Hann", "Blackman", "Blackman-Harris", "Blackman-Nuttall", "Bartlett", "Triangular", "Bartlett-Hann", "Sine", "Lanczos", "Gauß" };
CALF_PORT_PROPS(analyzer) = {
{ 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, "meter_L", "Level L" },
{ 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, "meter_R", "Level R" },
@@ -1003,7 +1003,7 @@ CALF_PORT_PROPS(analyzer) = {
{ 2, 0, 3, 0, PF_ENUM | PF_CTL_COMBO, analyzer_post_names, "analyzer_post", "Analyzer Post FFT" },
{ 1, 0, 1, 2, PF_ENUM | PF_CTL_COMBO , analyzer_view_names, "analyzer_view", "Analyzer View" },
{ 1, 0, 2, 0, PF_ENUM | PF_CTL_COMBO, analyzer_smooth_names, "analyzer_smoothing", "Analyzer Smoothing" },
- { 3, 0, 12, 2, PF_ENUM | PF_CTL_COMBO, analyzer_windowing_names, "analyzer_windowing", "Analyzer Windowing" },
+ { 8, 0, 11, 2, PF_ENUM | PF_CTL_COMBO, analyzer_windowing_names, "analyzer_windowing", "Analyzer Windowing" },
{ 6, 2, 8, 0, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "analyzer_accuracy", "Analyzer Accuracy" },
{ 13, 1, 15, 0, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "analyzer_speed", "Analyzer Speed" },
{ 1, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "analyzer_display", "Analyzer Display" },
diff --git a/src/modules.cpp b/src/modules.cpp
index dd2b6fa..8254b52 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -1157,21 +1157,15 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
case 0:
default:
// Linear
- L = L;
- if(_param_mode > _m)
- R = R;
+ _f = 1.f;
break;
case 1:
// Hamming
- L = L;
- if(_param_mode > _m)
- R = R;
+ _f = 0.54 + 0.46 * cos(2 * M_PI * (i - 2 / points));
break;
case 2:
// von Hann
- L = L;
- if(_param_mode > _m)
- R = R;
+ _f = 0.5 * (1 + cos(2 * M_PI * (i - 2 / points)));
break;
case 3:
// Blackman
@@ -1181,9 +1175,6 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
a2 = _a / 2.f;
_f = a0 + a1 * cos((2.f * M_PI * i) / points - 1) + \
a2 * cos((4.f * M_PI * i) / points - 1);
- L = L;
- if(_param_mode > _m)
- R = R;
break;
case 4:
// Blackman-Harris
@@ -1194,9 +1185,6 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
_f = a0 - a1 * cos((2.f * M_PI * i) / points - 1) + \
a2 * cos((4.f * M_PI * i) / points - 1) - \
a3 * cos((6.f * M_PI * i) / points - 1);
- L *= _f;
- if(_param_mode > _m)
- R *= _f;
break;
case 5:
// Blackman-Nuttall
@@ -1207,57 +1195,41 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
_f = a0 - a1 * cos((2.f * M_PI * i) / points - 1) + \
a2 * cos((4.f * M_PI * i) / points - 1) - \
a3 * cos((6.f * M_PI * i) / points - 1);
- L *= _f;
- if(_param_mode > _m)
- R *= _f;
break;
case 6:
// Bartlett
- //_f = (2.f / (sx - 1)) * ((sx - 1) / 2.f
- L = L;
- if(_param_mode > _m)
- R = R;
+ _f = (2.f / (points - 1)) * (((points - 1) / 2.f) - \
+ fabs(i - ((points - 1) / 2.f)));
break;
case 7:
- // Bartlett-Hann
- L = L;
- if(_param_mode > _m)
- R = R;
+ // Triangular
+ _f = (2.f / points) * ((2.f / points) - fabs(i - ((points - 1) / 2.f)));
break;
case 8:
- // Sine
- _f = sin((M_PI * i) / (points - 1));
- L *= _f;
- if(_param_mode > _m)
- R *= _f;
+ // Bartlett-Hann
+ a0 = 0.62;
+ a1 = 0.48;
+ a2 = 0.38;
+ _f = a0 - a1 * fabs((i / (points - 1)) - 0.5) - \
+ a2 * cos((2 * M_PI * i) / (points - 1));
break;
case 9:
- // Tukey
- L = L;
- if(_param_mode > _m)
- R = R;
+ // Sine
+ _f = sin((M_PI * i) / (points - 1));
break;
case 10:
// Lanczos
_f = sinc((2.f * i) / (points - 1) - 1);
- L *= _f;
- if(_param_mode > _m)
- R *= _f;
break;
case 11:
- // Kaiser
- L = L;
- if(_param_mode > _m)
- R = R;
- break;
- case 12:
// Gauß
- L = L;
- if(_param_mode > _m)
- R = R;
+ _a = 2.718281828459045;
+ _f = pow(_a, -0.5f * pow((i - (points - 1) / 2) / (0.4 * (points - 1) / 2.f), 2));
break;
}
-
+ L *= _f;
+ if(_param_mode > _m)
+ R *= _f;
// perhaps we need to compute two FFT's, so store left and right
// channel in case we need only one FFT, the left channel is
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list