+WARNING: THINGS DESCRIBED BELOW ARE NOT YET IN THE REPOS. THEY WILL BE,
+VERY SOON.
+
The TLV320AIC3X is a powerful four channel low power audio codec family.
More information is available at:
http://focus.ti.com/docs/prod/folders/print/tlv320aic34.html
/ \ / \
| (N0 + 2*N1*z^-1 + N2*z^-2) || (N3 + 2*N4*z^-1 + N5*z^-2) |
| ------------------------------ || ------------------------------ |
- \ (32768 - 2*D1*z^-1 - D2*z^-2) / \ (32768 - 2*D4*z^-1 - D5*z^-2) /
+| (32768 - 2*D1*z^-1 - D2*z^-2) || (32768 - 2*D4*z^-1 - D5*z^-2) |
+\ / \ /
The filter can be controlled through an alsa hwdep device, via
-libalsa. A short example follows, note that the data struct must be
-passed *EXACTLY* as shown:
+libasound. A short example follows, note that the data struct must be
+passed *EXACTLY* as shown. Remember to link against libasound:
+gcc myapp.c -lasound -o myapp
+-------------------------------EXAMPLE----------------------------------
#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <alsa/asoundlib.h>
#include <alsa/hwdep.h>
-struct _iirfilter_data {
+struct iirfilter_data {
int16_t N0, N1, N2, D1, D2;
int16_t N3, N4, N5, D4, D5;
-} iirfilter_data;
+};
-/* Initialize */
-snd_hwdep *hwdep;
+int main() {
+ int ret;
+ snd_hwdep_t *hwdep;
+ struct iirfilter_data data = {
+ .N0 = 27619, .N1 = -27034, .N2 = 26461, .D1 = 32131, .D2 = -31506,
+ .N3 = 27619, .N4 = -27034, .N5 = 26461, .D4 = 32131, .D5 = -31506
+ };
-snd_hwdep_open(&hwdep, "IIR Filter", "w");
+/* Initialize */
+ ret = snd_hwdep_open(&hwdep, "hw:0,0", SND_HWDEP_OPEN_DUPLEX);
+ if(ret != 0) exit(1);
/* To write: */
-iirfilter_data = {
- .N0 = 27619, .N1 = -27034, .N2 = 26461, .D1 = 32131, .D2 = -31506,
- .N3 = 27619, .N4 = -27034, .N5 = 26461, .D4 = 32131, .D5 = -31506
-};
-
-snd_hwdep_write(hwdep, (void*)iirfilter_data, sizeof(iirfilter_data));
+ snd_hwdep_write(hwdep, (void*)&data, sizeof(data));
/* To read: */
-snd_hwdep_read(hwdep, (void*)iirfilter_data, sizeof(iirfilter_data));
+ snd_hwdep_read(hwdep, (void*)&data, sizeof(data));
/* To enable/disable filtering: */
-int arg = 1; /* 1 = enable, 0 = disable */
-snd_hwdep_ioctl(hwdep, 1, &arg);
+ int arg = 1; /* 1 = enable, 0 = disable */
+ snd_hwdep_ioctl(hwdep, 1, &arg);
+ return 0;
+}
+------------------------------------------------------------------------
+