Mercurial > audlegacy-plugins
annotate src/voice_removal/voice_removal.c @ 3162:e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
This driver uses the "safe" ALSA API subset, including use of blocking I/O.
Right now, it is hardcoded to use "default".
Do not complain about bugs in this plugin.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 14 May 2009 21:05:11 -0500 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 * libxmmsstandard - XMMS plugin. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 * Copyright (C) 2000-2001 Konstantin Laevsky <debleek63@yahoo.com> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * audacious port of the voice removal code from libxmmsstandard |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * by Thomas Cort <linuxgeek@gmail.com> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * as published by the Free Software Foundation; either version 2 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * of the License, or (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 */ |
1954
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1897
diff
changeset
|
23 #include "config.h" |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include <gtk/gtk.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2575
diff
changeset
|
26 #include <audlegacy/plugin.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 static int apply_effect (gpointer *d, gint length, AFormat afmt, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 gint srate, gint nch); |
2575
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
31 static void query_format (AFormat *fmt, gint *rate, gint *nch); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 static EffectPlugin xmms_plugin = { |
1897
65717457fcab
More descriptive plugin name for voice_removal.
William Pitcock <nenolod@atheme.org>
parents:
1638
diff
changeset
|
34 .description = "Voice Removal Plugin", |
1638
e85bb4872787
voice_removal: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
35 .mod_samples = apply_effect, |
2575
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
36 .query_format = query_format |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 |
1109 | 39 EffectPlugin *voice_eplist[] = { &xmms_plugin, NULL }; |
40 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1109
diff
changeset
|
41 DECLARE_PLUGIN(voice_removal, NULL, NULL, NULL, NULL, voice_eplist, NULL, NULL, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 |
2575
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
43 static void query_format (AFormat *fmt, gint *rate, gint *nch) |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
44 { |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
45 if (!((*fmt == FMT_S16_NE) || |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
46 (*fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
47 (*fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN))) |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
48 *fmt = FMT_S16_NE; |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
49 |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
50 if (*nch != 2) |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
51 *nch = 2; |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
52 } |
1e67df1a1edc
Implemented query_format() callback in all effect plugins
Stefano D'Angelo <zanga.mail@gmail.com>
parents:
1954
diff
changeset
|
53 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
54 static int apply_effect (gpointer *d, gint length, AFormat afmt, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 gint srate, gint nch) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 int x; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 int left, right; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 gint16 *dataptr = (gint16 *) * d; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 if (!((afmt == FMT_S16_NE) || |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 (afmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 (afmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) || |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 (nch != 2)) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 return length; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
65 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
66 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
67 for (x = 0; x < length; x += 4) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
68 left = CLAMP(dataptr[1] - dataptr[0], -32768, 32767); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 right = CLAMP(dataptr[0] - dataptr[1], -32768, 32767); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
70 dataptr[0] = left; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
71 dataptr[1] = right; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
72 dataptr += 2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
73 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
74 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
75 return (length); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 } |