annotate libaf/af_sinesuppress.c @ 33928:27b1c4df84bd

Remove pointless pointer indirection for shader program strings.
author reimar
date Fri, 26 Aug 2011 19:35:46 +0000
parents 8fa2f43cb760
children a93891202051
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28229
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
1 /*
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
2 * Copyright (C) 2006 Michael Niedermayer
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
3 * Copyright (C) 2004 Alex Beregszaszi
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
4 * based upon af_extrastereo.c by Pierre Lombard
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
5 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
6 * This file is part of MPlayer.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
7 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
9 * it under the terms of the GNU General Public License as published by
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
11 * (at your option) any later version.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
12 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
16 * GNU General Public License for more details.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
17 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
18 * You should have received a copy of the GNU General Public License along
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 24888
diff changeset
21 */
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
22
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
23 #include <stdio.h>
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
24 #include <stdlib.h>
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
25 #include <string.h>
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
26
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
27 #include <inttypes.h>
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
28 #include <math.h>
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
29 #include <limits.h>
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
30
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
31 #include "af.h"
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
32
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
33 // Data for specific instances of this filter
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
34 typedef struct af_sinesuppress_s
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
35 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
36 double freq;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
37 double decay;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
38 double real;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
39 double imag;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
40 double ref;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
41 double pos;
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
42 }af_sinesuppress_t;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
43
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
44 static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data);
24171
6dcbc0080be8 Fix warning:
diego
parents: 22748
diff changeset
45 //static af_data_t* play_float(struct af_instance_s* af, af_data_t* data);
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
46
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
47 // Initialization and runtime control
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
48 static int control(struct af_instance_s* af, int cmd, void* arg)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
49 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
50 af_sinesuppress_t* s = (af_sinesuppress_t*)af->setup;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
51
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
52 switch(cmd){
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
53 case AF_CONTROL_REINIT:{
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
54 // Sanity check
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
55 if(!arg) return AF_ERROR;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
56
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
57 af->data->rate = ((af_data_t*)arg)->rate;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
58 af->data->nch = 1;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
59 #if 0
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
60 if (((af_data_t*)arg)->format == AF_FORMAT_FLOAT_NE)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
61 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
62 af->data->format = AF_FORMAT_FLOAT_NE;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
63 af->data->bps = 4;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
64 af->play = play_float;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
65 }// else
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
66 #endif
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
67 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
68 af->data->format = AF_FORMAT_S16_NE;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
69 af->data->bps = 2;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
70 af->play = play_s16;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
71 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
72
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
73 return af_test_output(af,(af_data_t*)arg);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
74 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
75 case AF_CONTROL_COMMAND_LINE:{
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
76 float f1,f2;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
77 sscanf((char*)arg,"%f:%f", &f1,&f2);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
78 s->freq = f1;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
79 s->decay = f2;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
80 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
81 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
82 case AF_CONTROL_SS_FREQ | AF_CONTROL_SET:
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
83 s->freq = *(float*)arg;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
84 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
85 case AF_CONTROL_SS_FREQ | AF_CONTROL_GET:
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
86 *(float*)arg = s->freq;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
87 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
88 case AF_CONTROL_SS_DECAY | AF_CONTROL_SET:
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
89 s->decay = *(float*)arg;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
90 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
91 case AF_CONTROL_SS_DECAY | AF_CONTROL_GET:
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
92 *(float*)arg = s->decay;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
93 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
94 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
95 return AF_UNKNOWN;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
96 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
97
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
98 // Deallocate memory
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
99 static void uninit(struct af_instance_s* af)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
100 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
101 free(af->data);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
102 free(af->setup);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
103 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
104
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
105 // Filter data through filter
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
106 static af_data_t* play_s16(struct af_instance_s* af, af_data_t* data)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
107 {
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
108 af_sinesuppress_t *s = af->setup;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
109 register int i = 0;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
110 int16_t *a = (int16_t*)data->audio; // Audio data
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
111 int len = data->len/2; // Number of samples
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
112
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
113 for (i = 0; i < len; i++)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
114 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
115 double co= cos(s->pos);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
116 double si= sin(s->pos);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
117
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
118 s->real += co * a[i];
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
119 s->imag += si * a[i];
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
120 s->ref += co * co;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
121
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
122 a[i] -= (s->real * co + s->imag * si) / s->ref;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
123
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
124 s->real -= s->real * s->decay;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
125 s->imag -= s->imag * s->decay;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
126 s->ref -= s->ref * s->decay;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
127
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
128 s->pos += 2 * M_PI * s->freq / data->rate;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
129 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
130
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28229
diff changeset
131 mp_msg(MSGT_AFILTER, MSGL_V, "[sinesuppress] f:%8.2f: amp:%8.2f\n", s->freq, sqrt(s->real*s->real + s->imag*s->imag) / s->ref);
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
132
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
133 return data;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
134 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
135
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
136 #if 0
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
137 static af_data_t* play_float(struct af_instance_s* af, af_data_t* data)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
138 {
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
139 af_sinesuppress_t *s = af->setup;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
140 register int i = 0;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
141 float *a = (float*)data->audio; // Audio data
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
142 int len = data->len/4; // Number of samples
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
143 float avg, l, r;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
144
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
145 for (i = 0; i < len; i+=2)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
146 {
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
147 avg = (a[i] + a[i + 1]) / 2;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
148
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
149 /* l = avg + (s->mul * (a[i] - avg));
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
150 r = avg + (s->mul * (a[i + 1] - avg));*/
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
151
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
152 a[i] = af_softclip(l);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
153 a[i + 1] = af_softclip(r);
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
154 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
155
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
156 return data;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
157 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
158 #endif
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
159
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
160 // Allocate memory and set function pointers
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 18905
diff changeset
161 static int af_open(af_instance_t* af){
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
162 af->control=control;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
163 af->uninit=uninit;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
164 af->play=play_s16;
24888
b2402b4f0afa libaf: change filter input/output ratio calculations
uau
parents: 24171
diff changeset
165 af->mul=1;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
166 af->data=calloc(1,sizeof(af_data_t));
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
167 af->setup=calloc(1,sizeof(af_sinesuppress_t));
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
168 if(af->data == NULL || af->setup == NULL)
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
169 return AF_ERROR;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
170
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
171 ((af_sinesuppress_t*)af->setup)->freq = 50.0;
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
172 ((af_sinesuppress_t*)af->setup)->decay = 0.0001;
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
173 return AF_OK;
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
174 }
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
175
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
176 // Description of this filter
18611
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
177 af_info_t af_info_sinesuppress = {
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
178 "Sine Suppress",
1c2f694d5232 Rename sinesupress to sinesuppress, including af_sinesupress.c file rename.
corey
parents: 18082
diff changeset
179 "sinesuppress",
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
180 "Michael Niedermayer",
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
181 "",
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
182 0,
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 18905
diff changeset
183 af_open
18082
0aa3fef68422 very simple filter which can remove a sine at a specified frequency, usefull to get rid of the 50/60hz noise on ultra crappy equipment
michael
parents:
diff changeset
184 };