Mercurial > audlegacy
comparison src/audacious/iir.c @ 3560:154f21dcd61e trunk
equalizer -> flow API
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 18 Sep 2007 13:39:21 -0500 |
parents | 3b6d316f8b09 |
children | d1cacc65f091 |
comparison
equal
deleted
inserted
replaced
3559:0898b8139af8 | 3560:154f21dcd61e |
---|---|
18 * | 18 * |
19 * $Id: iir.c,v 1.15 2005/10/17 01:57:59 liebremx Exp $ | 19 * $Id: iir.c,v 1.15 2005/10/17 01:57:59 liebremx Exp $ |
20 */ | 20 */ |
21 | 21 |
22 #include <math.h> | 22 #include <math.h> |
23 | |
24 #include "main.h" | |
23 #include "iir.h" | 25 #include "iir.h" |
24 | 26 |
25 /* Coefficients */ | 27 /* Coefficients */ |
26 sIIRCoefficients *iir_cf; | 28 sIIRCoefficients *iir_cf; |
27 | 29 |
80 if ( rounded_value != (short) rounded_value ) | 82 if ( rounded_value != (short) rounded_value ) |
81 rounded_value = ( rounded_value >> 31 ) ^ 0x7FFF; | 83 rounded_value = ( rounded_value >> 31 ) ^ 0x7FFF; |
82 return rounded_value; | 84 return rounded_value; |
83 } | 85 } |
84 #endif | 86 #endif |
87 | |
88 static void | |
89 byteswap(size_t size, | |
90 gint16 * buf) | |
91 { | |
92 gint16 *it; | |
93 size &= ~1; /* must be multiple of 2 */ | |
94 for (it = buf; it < buf + size / 2; ++it) | |
95 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); | |
96 } | |
97 | |
98 void | |
99 iir_flow(FlowContext *context) | |
100 { | |
101 static int init = 0; | |
102 int swapped = 0; | |
103 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; | |
104 int caneq = (fmt == FMT_S16_NE || fmt == myorder); | |
105 | |
106 if (!caneq && cfg.equalizer_active) { /* wrong byte order */ | |
107 byteswap(context->len, context->data); /* so convert */ | |
108 ++swapped; | |
109 ++caneq; | |
110 } /* can eq now, mark swapd */ | |
111 else if (caneq && !cfg.equalizer_active) /* right order but no eq */ | |
112 caneq = 0; /* so don't eq */ | |
113 | |
114 if (caneq) { /* if eq enab */ | |
115 if (!init) { /* if first run */ | |
116 init_iir(); /* then init eq */ | |
117 ++init; | |
118 } | |
119 | |
120 iir(&context->data, context->len, context->channels); | |
121 | |
122 if (swapped) /* if was swapped */ | |
123 byteswap(context->len, context->data); /* swap back for output */ | |
124 } | |
125 } |