ref: 92b54bdc3b83e139f2f38ebfc977b1d203bf159a
parent: 55c0aa70d90735f744edddd0647a8e648db9bf06
author: Rob Sykes <robs@users.sourceforge.net>
date: Fri Jun 22 04:29:42 EDT 2012
deemph now additionally works at 48k
--- a/src/biquads.c
+++ b/src/biquads.c
@@ -131,10 +131,6 @@
static int deemph_getopts(sox_effect_t * effp, int argc, char **argv) {
- priv_t * p = (priv_t *)effp->priv;
- p->fc = 5283;
- p->width = 0.4845;
- p->gain = -9.477;
return lsx_biquad_getopts(effp, argc, argv, 0, 0, 0, 1, 2, "s", filter_deemph);
}
@@ -162,10 +158,29 @@
static int start(sox_effect_t * effp)
{
priv_t * p = (priv_t *)effp->priv;
- double w0 = 2 * M_PI * p->fc / effp->in_signal.rate;
- double A = exp(p->gain / 40 * log(10.));
- double alpha = 0, mult = dB_to_linear(max(p->gain, 0));
+ double w0, A, alpha, mult;
+ if (p->filter_type == filter_deemph) { /* See deemph.plt for documentation */
+ if (effp->in_signal.rate == 44100) {
+ p->fc = 5283;
+ p->width = 0.4845;
+ p->gain = -9.477;
+ }
+ else if (effp->in_signal.rate == 48000) {
+ p->fc = 5356;
+ p->width = 0.479;
+ p->gain = -9.62;
+ }
+ else {
+ lsx_fail("sample rate must be 44100 (audio-CD) or 48000 (DAT)");
+ return SOX_EOF;
+ }
+ }
+
+ w0 = 2 * M_PI * p->fc / effp->in_signal.rate;
+ A = exp(p->gain / 40 * log(10.));
+ alpha = 0, mult = dB_to_linear(max(p->gain, 0));
+
if (w0 > M_PI) {
lsx_fail("frequency must be less than half the sample-rate (Nyquist rate)");
return SOX_EOF;
@@ -275,12 +290,7 @@
p->a2 = (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha;
break;
- case filter_deemph: /* See deemph.plt for documentation */
- if (effp->in_signal.rate != 44100) {
- lsx_fail("Sample rate must be 44100 (audio-CD)");
- return SOX_EOF;
- }
- /* Falls through... */
+ case filter_deemph: /* Falls through to high-shelf... */
case filter_highShelf: /* H(s) = A * (A*s^2 + (sqrt(A)/Q)*s + 1)/(s^2 + (sqrt(A)/Q)*s + A) */
if (!A)