2 * simple voice removal filter
4 * copyright (c) 2006 Reynaldo H. Verdejo Pinochet
5 * Based on code by Alex Beregszaszi for his 'center' filter.
7 * This file is part of MPlayer.
9 * MPlayer is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * MPlayer is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 // Data for specific instances of this filter
32 // Initialization and runtime control
33 static int control(struct af_instance_s
* af
, int cmd
, void* arg
)
36 case AF_CONTROL_REINIT
:
37 af
->data
->rate
= ((af_data_t
*)arg
)->rate
;
38 af
->data
->nch
= ((af_data_t
*)arg
)->nch
;
39 af
->data
->format
= AF_FORMAT_FLOAT_NE
;
41 return af_test_output(af
,(af_data_t
*)arg
);
47 static void uninit(struct af_instance_s
* af
)
53 // Filter data through filter
54 static af_data_t
* play(struct af_instance_s
* af
, af_data_t
* data
)
56 af_data_t
* c
= data
; // Current working data
57 float* a
= c
->audio
; // Audio data
58 int len
= c
->len
/4; // Number of samples in current audio block
59 int nch
= c
->nch
; // Number of channels
63 FIXME1 add a low band pass filter to avoid suppressing
65 FIXME2 better calculated* attenuation factor
70 a
[i
] = (a
[i
] - a
[i
+1]) * 0.7;
77 // Allocate memory and set function pointers
78 static int af_open(af_instance_t
* af
){
79 af
->control
= control
;
83 af
->data
= calloc(1,sizeof(af_data_t
));
91 // Description of this filter
92 af_info_t af_info_karaoke
= {
93 "Simple karaoke/voice-removal audio filter",
95 "Reynaldo H. Verdejo Pinochet",
97 AF_FLAGS_NOT_REENTRANT
,