ref: eaab3cc8bab082dd7f9f28255f713a6a674041a4
parent: 6a2432280dba6df6d13afe5850b1499062c43be5
author: robs <robs>
date: Tue Nov 14 10:03:46 EST 2006
Octave plotting for the equalizer effect
--- a/sox.1
+++ b/sox.1
@@ -880,6 +880,8 @@
.TP 10
equalizer \fIcentral-frequency\fR \fIQ\fR \fIgain\fR
Apply an equalizer effect. \fIcentral-frequency\fR gives the central frequency in Hz, \fIQ\fR is the Q-factor (see http://en.wikipedia.org/wiki/Q_factor), and \fIgain\fR is the gain or attenuation in dB.
+
+This effect supports the \fI-o\fR option (see above).
.TP 10
fade [ \fItype\fR ] \fIfade-in-length\fR [ \fIstop-time\fR [ \fIfade-out-length\fR ] ]
Add a fade effect to the beginning, end, or both of the audio data.
--- a/src/equalizer.c
+++ b/src/equalizer.c
@@ -124,6 +124,26 @@
eq->y[1] = 0; // y[n-1]
eq->y[2] = 0; // y[n-2]
+ if (effp->globalinfo.octave_plot_effect)
+ {
+ printf(
+ "title('SoX effect: %s gain=%g centre=%g Q=%g (rate=%u)')\n"
+ "xlabel('Frequency (Hz)')\n"
+ "ylabel('Amplitude Response (dB)')\n"
+ "Fs=%u;minF=10;maxF=Fs/2;\n"
+ "axis([minF maxF -25 25])\n"
+ "sweepF=logspace(log10(minF),log10(maxF),200);\n"
+ "grid on\n"
+ "[h,w]=freqz([%f %f %f],[%f %f %f],sweepF,Fs);\n"
+ "semilogx(w,20*log10(h),'b')\n"
+ "pause\n"
+ , effp->name, eq->gain, eq->cfreq, eq->Q
+ , effp->ininfo.rate, effp->ininfo.rate
+ , eq->b[0], eq->b[1], eq->b[2], eq->a[0], eq->a[1], eq->a[2]
+ );
+ exit(0);
+ }
+
return (ST_SUCCESS);
}