1 // Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
13 typedef struct af_sweep_s
{
19 // Initialization and runtime control
20 static int control(struct af_instance_s
* af
, int cmd
, void* arg
)
22 af_sweept
* s
= (af_sweept
*)af
->setup
;
23 af_data_t
*data
= (af_data_t
*)arg
;
26 case AF_CONTROL_REINIT
:
27 af
->data
->nch
= data
->nch
;
28 af
->data
->format
= AF_FORMAT_S16_NE
;
30 af
->data
->rate
= data
->rate
;
33 case AF_CONTROL_COMMAND_LINE
:
34 sscanf((char*)arg
,"%lf", &s
->delta
);
36 /* case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:
37 af->data->rate = *(int*)arg;
44 static void uninit(struct af_instance_s
* af
)
49 af_sweept
*s
= af
->setup
;
54 // Filter data through filter
55 static af_data_t
* play(struct af_instance_s
* af
, af_data_t
* data
)
57 af_sweept
*s
= af
->setup
;
59 int16_t *in
= (int16_t*)data
->audio
;
60 int chans
= data
->nch
;
61 int in_len
= data
->len
/(2*chans
);
63 for(i
=0; i
<in_len
; i
++){
64 for(j
=0; j
<chans
; j
++)
65 in
[i
*chans
+j
]= 32000*sin(s
->x
*s
->x
);
67 if(2*s
->x
*s
->delta
>= 3.141592) s
->x
=0;
73 static int open(af_instance_t
* af
){
79 af
->data
=calloc(1,sizeof(af_data_t
));
80 af
->setup
=calloc(1,sizeof(af_sweept
));
84 af_info_t af_info_sweep
= {
87 "Michael Niedermayer",