[SCM] calf/master: + Phaser: add live frequency response graph
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:53 UTC 2013
The following commit has been merged in the master branch:
commit 2d013c76c2fa31f986ef72b0f52baf2aa3ce5461
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Mon Jan 19 21:21:49 2009 +0000
+ Phaser: add live frequency response graph
diff --git a/gui/gui-phaser.xml b/gui/gui-phaser.xml
index 01772f2..019e71c 100644
--- a/gui/gui-phaser.xml
+++ b/gui/gui-phaser.xml
@@ -50,4 +50,11 @@
</vbox>
</hbox>
</frame>
+ <if cond="directlink">
+ <frame label="Freq. response" attach-x="0" attach-y="2" >
+ <vbox expand-x="1" fill-x="1" >
+ <line-graph refresh="1" width="160" height="160" param="base_freq"/>
+ </vbox>
+ </frame>
+ </if>
</table>
diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index fd9399c..a76ae0b 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -194,6 +194,21 @@ public:
*buf_out++ = sdry + swet;
}
}
+ 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
+
+ cfloat p = cfloat(1.0);
+ cfloat stg = stage1.h_z(z);
+
+ for (int i = 0; i < stages; i++)
+ p = p * stg;
+
+ p = p / (cfloat(1.0) - cfloat(fb) * p);
+ return std::abs(cfloat(gs_dry.get_last()) + cfloat(gs_wet.get_last()) * p);
+ }
};
/**
diff --git a/src/calf/biquad.h b/src/calf/biquad.h
index aa81c8a..2e6b4f2 100644
--- a/src/calf/biquad.h
+++ b/src/calf/biquad.h
@@ -315,8 +315,7 @@ public:
}
/// Return H(z) the filter's gain at frequency freq
- /// @param freq Frequency to look up
- /// @param sr Filter sample rate (used to convert frequency to angular frequency)
+ /// @param z Z variable (e^jw)
cfloat h_z(const cfloat &z)
{
diff --git a/src/calf/modules.h b/src/calf/modules.h
index d60b40f..fc9369c 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -123,7 +123,7 @@ public:
float freq_gain(int subindex, float freq, float srate);
};
-class phaser_audio_module: public audio_module<phaser_metadata>
+class phaser_audio_module: public audio_module<phaser_metadata>, public line_graph_iface
{
public:
float *ins[in_count];
@@ -182,6 +182,9 @@ 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_iface *context);
+ bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
+ float freq_gain(int subindex, float freq, float srate);
};
class reverb_audio_module: public audio_module<reverb_metadata>
diff --git a/src/calf/onepole.h b/src/calf/onepole.h
index 9e9dc1a..c9d2e9f 100644
--- a/src/calf/onepole.h
+++ b/src/calf/onepole.h
@@ -34,6 +34,8 @@ template<class T = float, class Coeff = float>
class onepole
{
public:
+ typedef std::complex<double> cfloat;
+
T x1, y1;
Coeff a0, a1, b1;
@@ -165,6 +167,24 @@ public:
a1 = src.a1;
b1 = src.b1;
}
+
+ /// Return the filter's gain at frequency freq
+ /// @param freq Frequency to look up
+ /// @param sr Filter sample rate (used to convert frequency to angular frequency)
+ float freq_gain(float freq, float sr)
+ {
+ freq *= 2.0 * M_PI / sr;
+ cfloat z = 1.0 / exp(cfloat(0.0, freq));
+
+ return std::abs(h_z(z));
+ }
+
+ /// Return H(z) the filter's gain at frequency freq
+ /// @param z Z variable (e^jw)
+ cfloat h_z(const cfloat &z)
+ {
+ return (cfloat(a0) + double(a1) * z) / (cfloat(1.0) + double(b1) * z);
+ }
};
};
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 3242bed..d5a81f0 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -173,6 +173,28 @@ void phaser_audio_module::deactivate()
is_active = false;
}
+bool phaser_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+{
+ if (!is_active)
+ return false;
+ if (subindex < 2)
+ {
+ set_channel_color(context, subindex);
+ return ::get_graph(*this, subindex, data, points);
+ }
+ return false;
+}
+
+float phaser_audio_module::freq_gain(int subindex, float freq, float srate)
+{
+ return (subindex ? right : left).freq_gain(freq, srate);
+}
+
+bool phaser_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+{
+ return get_freq_gridline(subindex, pos, vertical, legend, context);
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
void reverb_audio_module::activate()
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list