2 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 typedef struct af_sweep_s
{
36 // Initialization and runtime control
37 static int control(struct af_instance_s
* af
, int cmd
, void* arg
)
39 af_sweept
* s
= (af_sweept
*)af
->setup
;
40 af_data_t
*data
= (af_data_t
*)arg
;
43 case AF_CONTROL_REINIT
:
44 af
->data
->nch
= data
->nch
;
45 af
->data
->format
= AF_FORMAT_S16_NE
;
47 af
->data
->rate
= data
->rate
;
50 case AF_CONTROL_COMMAND_LINE
:
51 sscanf((char*)arg
,"%lf", &s
->delta
);
53 /* case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:
54 af->data->rate = *(int*)arg;
61 static void uninit(struct af_instance_s
* af
)
66 af_sweept
*s
= af
->setup
;
71 // Filter data through filter
72 static af_data_t
* play(struct af_instance_s
* af
, af_data_t
* data
)
74 af_sweept
*s
= af
->setup
;
76 int16_t *in
= (int16_t*)data
->audio
;
77 int chans
= data
->nch
;
78 int in_len
= data
->len
/(2*chans
);
80 for(i
=0; i
<in_len
; i
++){
81 for(j
=0; j
<chans
; j
++)
82 in
[i
*chans
+j
]= 32000*sin(s
->x
*s
->x
);
84 if(2*s
->x
*s
->delta
>= 3.141592) s
->x
=0;
90 static int af_open(af_instance_t
* af
){
95 af
->data
=calloc(1,sizeof(af_data_t
));
96 af
->setup
=calloc(1,sizeof(af_sweept
));
100 af_info_t af_info_sweep
= {
103 "Michael Niedermayer",