[SCM] calf/master: + Flanger: add frequency response graph
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 cf36adc67a7de173fbd48db783e6e8fc417678d5
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Fri Nov 7 19:42:39 2008 +0000
+ Flanger: add frequency response graph
diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index 1bcf4ae..def9ea6 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -21,6 +21,8 @@
#ifndef __CALF_AUDIOFX_H
#define __CALF_AUDIOFX_H
+#include <complex>
+#include <iostream>
#include "primitives.h"
#include "delay.h"
#include "fixed_point.h"
@@ -367,6 +369,22 @@ public:
}
last_delay_pos = delay_pos;
}
+ float freq_gain(float freq, float sr)
+ {
+ typedef std::complex<double> cfloat;
+ freq *= 2.0 * M_PI / sr;
+ cfloat z = 1.0 / exp(cfloat(0.0, freq)); // z^-1
+
+ float ldp = last_delay_pos / 65536.0;
+ float fldp = floor(ldp);
+ cfloat zn = std::pow(z, fldp); // z^-N
+ cfloat zn1 = zn * z; // z^-(N+1)
+ // simulate a lerped comb filter - H(z) = 1 / (1 + fb * (lerp(z^-N, z^-(N+1), fracpos))), N = int(pos), fracpos = pos - int(pos)
+ cfloat h = cfloat(1.0) / (cfloat(1.0) + cfloat(fb) * (zn + (zn1 - zn) * cfloat(ldp - fldp)));
+ // mix with dry signal
+ float v = std::abs(cfloat(gs_dry.get_last()) + cfloat(gs_wet.get_last()) * h);
+ return v;
+ }
};
/**
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 67ff820..4769e1c 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -59,7 +59,19 @@ public:
};
#endif
-class flanger_audio_module: public audio_module<flanger_metadata>
+template<class Fx>
+bool get_graph(Fx &fx, int subindex, float *data, int points)
+{
+ for (int i = 0; i < points; i++)
+ {
+ typedef std::complex<double> cfloat;
+ double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
+ data[i] = log(fx.freq_gain(subindex, freq, fx.srate)) / log(1024.0) + 0.5;
+ }
+ return true;
+}
+
+class flanger_audio_module: public audio_module<flanger_metadata>, public line_graph_iface
{
public:
dsp::simple_flanger<float, 2048> left, right;
@@ -122,6 +134,16 @@ public:
right.process(outs[1] + offset, ins[1] + offset, nsamples);
return outputs_mask; // XXXKF allow some delay after input going blank
}
+ bool get_graph(int index, int subindex, float *data, int points, cairo_t *context)
+ {
+ if (index == par_delay && subindex < 2)
+ return calf_plugins::get_graph(*this, subindex, data, points);
+ return false;
+ }
+ float freq_gain(int subindex, float freq, float srate)
+ {
+ return (subindex ? right : left).freq_gain(freq, srate);
+ }
};
class phaser_audio_module: public audio_module<phaser_metadata>
@@ -379,20 +401,17 @@ public:
}
bool get_graph(int index, int subindex, float *data, int points, cairo_t *context)
{
- if (index == par_cutoff && !subindex) {
- for (int i = 0; i < points; i++)
- {
- typedef std::complex<double> cfloat;
- double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
- float level = 1.0;
- for (int j = 0; j < order; j++)
- level *= left[j].freq_gain(freq, srate);
- data[i] = log(level) / log(1024.0) + 0.5;
- }
- return true;
- }
+ if (index == par_cutoff && !subindex)
+ return calf_plugins::get_graph(*this, subindex, data, points);
return false;
}
+ float freq_gain(int subindex, float freq, float srate)
+ {
+ float level = 1.0;
+ for (int j = 0; j < order; j++)
+ level *= left[j].freq_gain(freq, srate);
+ return level;
+ }
};
class vintage_delay_audio_module: public audio_module<vintage_delay_metadata>
diff --git a/src/modules.cpp b/src/modules.cpp
index 28c62ee..7d84f50 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -37,7 +37,7 @@ const char *calf_plugins::calf_copyright_info = "(C) 2001-2008 Krzysztof Foltman
CALF_PORT_NAMES(flanger) = {"In L", "In R", "Out L", "Out R"};
CALF_PORT_PROPS(flanger) = {
- { 0.1, 0.1, 10, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "min_delay", "Minimum delay" },
+ { 0.1, 0.1, 10, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC | PF_PROP_GRAPH, NULL, "min_delay", "Minimum delay" },
{ 0.5, 0.1, 10, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "mod_depth", "Modulation depth" },
{ 0.25, 0.01, 20, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "mod_rate", "Modulation rate" },
{ 0.90, -0.99, 0.99, 0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "feedback", "Feedback" },
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list